Item and NBT patches, IShearable blocks are responsible for setting themselves to air, to allow for setting other states.

This commit is contained in:
LexManos committed 2018-12-03 18:04:37 -08:00
1 parent bf9158172f
commit a3c8e04ee6
92 files changed
+1008 -2205

No files matched your search

@@ -44,6 +44,7 @@ import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.MobSpawnerBaseLogic;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
@@ -347,22 +348,22 @@ public class ForgeEventFactory
return MinecraftForge.EVENT_BUS.post(event) ? "" : event.getMessage();
}
public static int onHoeUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos)
public static int onHoeUse(ItemUseContext context)
{
UseHoeEvent event = new UseHoeEvent(player, stack, worldIn, pos);
UseHoeEvent event = new UseHoeEvent(context);
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
if (event.getResult() == Result.ALLOW)
{
stack.damageItem(1, player);
context.getItem().damageItem(1, context.getPlayer());
return 1;
}
return 0;
}
public static int onApplyBonemeal(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull ItemStack stack, @Nullable EnumHand hand)
public static int onApplyBonemeal(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull ItemStack stack)
{
BonemealEvent event = new BonemealEvent(player, world, pos, state, hand, stack);
BonemealEvent event = new BonemealEvent(player, world, pos, state, stack);
if (MinecraftForge.EVENT_BUS.post(event)) return -1;
if (event.getResult() == Result.ALLOW)
{
@@ -20,16 +20,13 @@
package net.minecraftforge.event.entity.player;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* This event is called when a player attempts to use Bonemeal on a block.
@@ -48,17 +45,14 @@ public class BonemealEvent extends PlayerEvent
private final World world;
private final BlockPos pos;
private final IBlockState block;
private final EnumHand hand;
private final ItemStack stack;
public BonemealEvent(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState block, @Nullable EnumHand hand,
@Nonnull ItemStack stack)
public BonemealEvent(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState block, @Nonnull ItemStack stack)
{
super(player);
this.world = world;
this.pos = pos;
this.block = block;
this.hand = hand;
this.stack = stack;
}
@@ -77,12 +71,6 @@ public class BonemealEvent extends PlayerEvent
return block;
}
@Nullable
public EnumHand getHand()
{
return hand;
}
@Nonnull
public ItemStack getStack()
{
@@ -19,10 +19,7 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.item.ItemUseContext;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event.HasResult;
@@ -41,32 +38,17 @@ import javax.annotation.Nonnull;
@HasResult
public class UseHoeEvent extends PlayerEvent
{
private final ItemUseContext context;;
private final ItemStack current;
private final World world;
private final BlockPos pos;
public UseHoeEvent(EntityPlayer player, @Nonnull ItemStack current, World world, BlockPos pos)
public UseHoeEvent(ItemUseContext context)
{
super(player);
this.current = current;
this.world = world;
this.pos = pos;
super(context.getPlayer());
this.context = context;
}
@Nonnull
public ItemStack getCurrent()
public ItemUseContext getContext()
{
return current;
}
public World getWorld()
{
return world;
}
public BlockPos getPos()
{
return pos;
return context;
}
}