Fixes #416
This commit is contained in:
parent
aceceb7d2d
commit
aeb567deb7
1 changed files with 93 additions and 55 deletions
|
@ -24,10 +24,13 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fluids.BlockFluidBase;
|
import net.minecraftforge.fluids.BlockFluidBase;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import reborncore.common.tile.TileMachineBase;
|
||||||
|
import techreborn.blocks.storage.BlockBatBox;
|
||||||
import techreborn.client.TechRebornCreativeTabMisc;
|
import techreborn.client.TechRebornCreativeTabMisc;
|
||||||
import techreborn.items.ItemTR;
|
import techreborn.items.ItemTR;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
import ic2.api.tile.IWrenchable;
|
import ic2.api.tile.IWrenchable;
|
||||||
|
import techreborn.tiles.storage.TileBatBox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 26/02/2016.
|
* Created by modmuss50 on 26/02/2016.
|
||||||
|
@ -43,10 +46,8 @@ public class ItemWrench extends ItemTR implements ITexturedItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand,
|
public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
|
||||||
EnumFacing facing, float hitX, float hitY, float hitZ)
|
if (world.isAirBlock(pos))
|
||||||
{
|
|
||||||
if (world.isAirBlock(pos) || !player.isSneaking())
|
|
||||||
{
|
{
|
||||||
return EnumActionResult.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
@ -55,12 +56,41 @@ public class ItemWrench extends ItemTR implements ITexturedItem
|
||||||
{
|
{
|
||||||
return EnumActionResult.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
if (!(tile instanceof IInventory))
|
|
||||||
|
if(!player.isSneaking()){
|
||||||
|
if(tile instanceof TileBatBox){
|
||||||
|
tile.getWorld().setBlockState(tile.getPos(), tile.getWorld().getBlockState(pos).withProperty(BlockBatBox.FACING, side.getOpposite()));
|
||||||
|
return EnumActionResult.SUCCESS;
|
||||||
|
} else
|
||||||
|
if(tile instanceof TileMachineBase){
|
||||||
|
if(side != EnumFacing.DOWN && side != EnumFacing.UP){
|
||||||
|
((TileMachineBase) tile).setFacing(side);
|
||||||
|
return EnumActionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onItemUseFirst(stack, player, world, pos, side, hitX, hitY, hitZ, hand);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand,
|
||||||
|
EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (world.isAirBlock(pos))
|
||||||
|
{
|
||||||
|
return EnumActionResult.FAIL;
|
||||||
|
}
|
||||||
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
|
if (tile == null)
|
||||||
{
|
{
|
||||||
return EnumActionResult.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.isSneaking())
|
||||||
|
{
|
||||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||||
|
if (tile instanceof IInventory)
|
||||||
|
{
|
||||||
IInventory inventory = (IInventory) tile;
|
IInventory inventory = (IInventory) tile;
|
||||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||||
{
|
{
|
||||||
|
@ -84,6 +114,7 @@ public class ItemWrench extends ItemTR implements ITexturedItem
|
||||||
}
|
}
|
||||||
items.add(itemStack.copy());
|
items.add(itemStack.copy());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tile instanceof IWrenchable)
|
if (tile instanceof IWrenchable)
|
||||||
{
|
{
|
||||||
|
@ -96,6 +127,8 @@ public class ItemWrench extends ItemTR implements ITexturedItem
|
||||||
}
|
}
|
||||||
items.add(itemStack);
|
items.add(itemStack);
|
||||||
}
|
}
|
||||||
|
if (!items.isEmpty())
|
||||||
|
{
|
||||||
for (ItemStack itemStack : items)
|
for (ItemStack itemStack : items)
|
||||||
{
|
{
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
|
@ -109,7 +142,8 @@ public class ItemWrench extends ItemTR implements ITexturedItem
|
||||||
|
|
||||||
if (itemStack.hasTagCompound())
|
if (itemStack.hasTagCompound())
|
||||||
{
|
{
|
||||||
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
|
entityItem.getEntityItem()
|
||||||
|
.setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
float factor = 0.05F;
|
float factor = 0.05F;
|
||||||
|
@ -121,6 +155,8 @@ public class ItemWrench extends ItemTR implements ITexturedItem
|
||||||
world.spawnEntityInWorld(entityItem);
|
world.spawnEntityInWorld(entityItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO 1.9 sounds
|
// TODO 1.9 sounds
|
||||||
// world.playSoundAtEntity(player, "techreborn:block_dismantle",
|
// world.playSoundAtEntity(player, "techreborn:block_dismantle",
|
||||||
// 0.8F, 1F);
|
// 0.8F, 1F);
|
||||||
|
@ -130,6 +166,8 @@ public class ItemWrench extends ItemTR implements ITexturedItem
|
||||||
}
|
}
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return EnumActionResult.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue