diff --git a/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java b/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java index bce273610..e6d0b3103 100644 --- a/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java +++ b/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java @@ -42,6 +42,7 @@ import prospector.shootingstar.model.ModelCompound; import reborncore.common.BaseTileBlock; import techreborn.Core; import techreborn.client.TechRebornCreativeTab; +import techreborn.items.tools.ItemWrench; import techreborn.lib.ModInfo; import java.util.Iterator; @@ -68,6 +69,20 @@ public abstract class BlockEnergyStorage extends BaseTileBlock { @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + ItemStack heldStack = player.getHeldItem(hand); + if(heldStack.getItem() instanceof ItemWrench){ + if (state.getBlock() instanceof BlockEnergyStorage) { + EnumFacing facing2 = state.getValue(BlockEnergyStorage.FACING); + if (facing2.getOpposite() == side) { + facing2 = side; + } else { + facing2 = side.getOpposite(); + } + world.setBlockState(pos, state.withProperty(BlockEnergyStorage.FACING, facing2)); + return true; + } + } + if (!player.isSneaking()) player.openGui(Core.INSTANCE, guiID, world, pos.getX(), pos.getY(), pos.getZ()); return true; diff --git a/src/main/java/techreborn/items/tools/ItemWrench.java b/src/main/java/techreborn/items/tools/ItemWrench.java index 19a38be4b..f12694d5b 100644 --- a/src/main/java/techreborn/items/tools/ItemWrench.java +++ b/src/main/java/techreborn/items/tools/ItemWrench.java @@ -26,7 +26,6 @@ package techreborn.items.tools; import net.minecraft.block.BlockDynamicLiquid; import net.minecraft.block.BlockStaticLiquid; -import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -46,10 +45,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.server.permission.PermissionAPI; import net.minecraftforge.server.permission.context.BlockPosContext; import reborncore.common.IWrenchable; -import reborncore.common.tile.TileMachineBase; import reborncore.common.util.RebornPermissions; import techreborn.blocks.fluid.BlockFluidBase; -import techreborn.blocks.storage.BlockEnergyStorage; import techreborn.client.TechRebornCreativeTabMisc; import techreborn.compat.CompatManager; import techreborn.init.ModSounds; @@ -71,48 +68,6 @@ public class ItemWrench extends ItemTR { setMaxStackSize(1); } - @Override - public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, - EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { - if (!PermissionAPI.hasPermission(player.getGameProfile(), RebornPermissions.WRENCH_BLOCK, new BlockPosContext(player, pos, world.getBlockState(pos), side))) { - return EnumActionResult.FAIL; - } - if (CompatManager.isIC2Loaded) { - EnumActionResult result = IC2WrenchHelper.onItemUseFirst(player.getHeldItem(hand), player, world, pos, side, hitX, hitY, hitZ, hand); - if (result == EnumActionResult.SUCCESS) { - return result; - } - } - if (world.isAirBlock(pos)) { - return EnumActionResult.FAIL; - } - TileEntity tile = world.getTileEntity(pos); - if (tile == null) { - return EnumActionResult.FAIL; - } - - if (!player.isSneaking()) { - if (tile instanceof TileMachineBase) { - if (side != EnumFacing.DOWN && side != EnumFacing.UP) { - ((TileMachineBase) tile).setFacing(side); - return EnumActionResult.SUCCESS; - } - } - IBlockState state = world.getBlockState(pos); - if (state.getBlock() instanceof BlockEnergyStorage) { - EnumFacing facing = state.getValue(BlockEnergyStorage.FACING); - if (facing.getOpposite() == side) { - facing = side; - } else { - facing = side.getOpposite(); - } - world.setBlockState(pos, state.withProperty(BlockEnergyStorage.FACING, facing)); - return EnumActionResult.SUCCESS; - } - } - return super.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand); - } - @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { diff --git a/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java b/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java index 40680dd2b..3be1d8a94 100644 --- a/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java +++ b/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java @@ -79,6 +79,7 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable, @Override public void updateEntity() { + super.updateEntity(); if (inventory.getStackInSlot(0) != ItemStack.EMPTY) { ItemStack stack = inventory.getStackInSlot(0); if (!(stack.getItem() instanceof IEnergyItemInfo)) {