|
24 | 24 | import net.minecraft.item.Item;
|
25 | 25 | import net.minecraft.item.ItemStack;
|
26 | 26 | import net.minecraft.nbt.NBTTagCompound;
|
27 |
| -import net.minecraft.util.*; |
| 27 | +import net.minecraft.util.ActionResult; |
| 28 | +import net.minecraft.util.EnumActionResult; |
| 29 | +import net.minecraft.util.EnumFacing; |
| 30 | +import net.minecraft.util.EnumHand; |
| 31 | +import net.minecraft.util.NonNullList; |
| 32 | +import net.minecraft.util.ResourceLocation; |
| 33 | +import net.minecraft.util.SoundCategory; |
28 | 34 | import net.minecraft.util.math.BlockPos;
|
29 | 35 | import net.minecraft.world.World;
|
30 | 36 | import net.minecraftforge.fluids.FluidStack;
|
@@ -89,20 +95,27 @@ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity en
|
89 | 95 | }
|
90 | 96 |
|
91 | 97 | @Override
|
92 |
| - public EnumActionResult onItemUseFirst(@NotNull EntityPlayer player, @NotNull World world, BlockPos pos, |
93 |
| - EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { |
| 98 | + public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { |
94 | 99 | ItemStack stack = player.getHeldItem(hand);
|
95 | 100 | NBTTagCompound compound = GTUtility.getOrCreateNbtCompound(stack);
|
96 | 101 |
|
97 | 102 | if (canOpen && player.isSneaking()) {
|
98 | 103 | compound.setBoolean(LIGHTER_OPEN, !compound.getBoolean(LIGHTER_OPEN));
|
99 | 104 | stack.setTagCompound(compound);
|
100 |
| - return EnumActionResult.PASS; |
101 | 105 | }
|
| 106 | + return ActionResult.newResult(EnumActionResult.PASS, stack); |
| 107 | + } |
| 108 | + |
| 109 | + @Override |
| 110 | + public EnumActionResult onItemUseFirst(@NotNull EntityPlayer player, @NotNull World world, BlockPos pos, |
| 111 | + EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { |
| 112 | + ItemStack stack = player.getHeldItem(hand); |
| 113 | + NBTTagCompound compound = GTUtility.getOrCreateNbtCompound(stack); |
102 | 114 |
|
103 | 115 | if (!player.canPlayerEdit(pos, side, player.getHeldItem(hand))) return EnumActionResult.FAIL;
|
104 | 116 | // If this item does not have opening mechanics, or if it does and is currently open
|
105 |
| - if ((!canOpen || compound.getBoolean(LIGHTER_OPEN)) && consumeFuel(player, stack)) { |
| 117 | + // If the item has opening mechanics, and the player is sneaking, close the item instead |
| 118 | + if ((!canOpen || (compound.getBoolean(LIGHTER_OPEN)) && !player.isSneaking()) && consumeFuel(player, stack)) { |
106 | 119 | player.getEntityWorld().playSound(null, player.getPosition(), SoundEvents.ITEM_FLINTANDSTEEL_USE,
|
107 | 120 | SoundCategory.PLAYERS, 1.0F, GTValues.RNG.nextFloat() * 0.4F + 0.8F);
|
108 | 121 | IBlockState blockState = world.getBlockState(pos);
|
|
0 commit comments