This commit is contained in:
modmuss50 2016-04-23 13:32:03 +01:00
parent b2d5ee7b3d
commit a2d626bc61
No known key found for this signature in database
GPG key ID: 1838986A0F12E8EE
3 changed files with 7 additions and 100 deletions

View file

@ -69,45 +69,6 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
return new BlockStateContainer(this, FACING);
}
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
super.onBlockAdded(worldIn, pos, state);
this.setDefaultFacing(worldIn, pos, state);
}
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
{
if (!worldIn.isRemote)
{
IBlockState sate = worldIn.getBlockState(pos.north());
Block block = sate.getBlock();
IBlockState state1 = worldIn.getBlockState(pos.south());
Block block1 = state1.getBlock();
IBlockState state2 = worldIn.getBlockState(pos.west());
Block block2 = state2.getBlock();
IBlockState state3 = worldIn.getBlockState(pos.east());
Block block3 = state3.getBlock();
EnumFacing enumfacing = state.getValue(FACING);
if (enumfacing == EnumFacing.NORTH && block.isFullBlock(state) && !block1.isFullBlock(state1))
{
enumfacing = EnumFacing.SOUTH;
} else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock(state1) && !block.isFullBlock(state))
{
enumfacing = EnumFacing.NORTH;
} else if (enumfacing == EnumFacing.WEST && block2.isFullBlock(state2) && !block3.isFullBlock(state2))
{
enumfacing = EnumFacing.EAST;
} else if (enumfacing == EnumFacing.EAST && block3.isFullBlock(state3) && !block2.isFullBlock(state2))
{
enumfacing = EnumFacing.WEST;
}
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
}
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer,
ItemStack stack)
@ -124,53 +85,6 @@ public abstract class BlockEnergyStorage extends BaseTileBlock implements IRotat
setFacing(facing, worldIn, pos);
}
protected List<ItemStack> dropInventory(IBlockAccess world, BlockPos pos, ItemStack itemToDrop)
{
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity == null)
{
return Collections.emptyList();
}
if (!(tileEntity instanceof IInventory))
{
return Collections.emptyList();
}
IInventory inventory = (IInventory) tileEntity;
List<ItemStack> items = new ArrayList<>();
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack itemStack = inventory.getStackInSlot(i);
if (itemStack == null)
{
continue;
}
if (itemStack != null && itemStack.stackSize > 0)
{
if (itemStack.getItem() instanceof ItemBlock)
{
if (((ItemBlock) itemStack.getItem()).block instanceof BlockFluidBase
|| ((ItemBlock) itemStack.getItem()).block instanceof BlockStaticLiquid
|| ((ItemBlock) itemStack.getItem()).block instanceof BlockDynamicLiquid)
{
continue;
}
}
}
items.add(itemStack.copy());
}
items.add(itemToDrop.copy());
return items;
}
@Override
public int getMetaFromState(IBlockState state)
{

View file

@ -58,21 +58,9 @@ public class ItemWrench extends ItemTR implements ITexturedItem
return EnumActionResult.FAIL;
}
if (!player.isSneaking())
if (!player.isSneaking() && !player.worldObj.isRemote)
{
if (tile instanceof TileEnergyStorage || tile instanceof IWrenchable)
{
if(((IWrenchable)tile).wrenchCanSetFacing(player, side.getOpposite())){
tile.getWorld().setBlockState(tile.getPos(),
tile.getWorld().getBlockState(pos).withProperty(BlockBatBox.FACING, side.getOpposite()));
return EnumActionResult.SUCCESS;
}else{
return EnumActionResult.FAIL;
}
} else if (tile instanceof TileMachineBase)
if (tile instanceof TileMachineBase)
{
if (side != EnumFacing.DOWN && side != EnumFacing.UP)
{

View file

@ -90,6 +90,11 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
}
}
@Override
public void setFacing(EnumFacing enumFacing) {
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockEnergyStorage.FACING, enumFacing));
}
@Override public float getWrenchDropRate()
{
return 1.0F;