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 2018-12-03 18:04:37 -08:00
parent bf9158172f
commit a3c8e04ee6
92 changed files with 1008 additions and 2205 deletions

View File

@ -9,13 +9,14 @@
protected static final VoxelShape field_196397_a = Block.func_208617_a(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D);
protected BlockDeadBush(Block.Builder p_i48418_1_) {
@@ -46,4 +46,9 @@
@@ -46,4 +46,10 @@
super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, flag ? Blocks.field_150350_a.func_176223_P() : p_180657_4_, p_180657_5_, p_180657_6_);
}
+
+ @Override
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorldReader world, BlockPos pos, int fortune) {
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorld world, BlockPos pos, int fortune) {
+ world.func_180501_a(pos, Blocks.field_150350_a.func_176223_P(), 11);
+ return java.util.Arrays.asList(new ItemStack(Blocks.field_196555_aI));
+ }
}

View File

@ -70,13 +70,14 @@
}
protected void func_206840_a(StateContainer.Builder<Block, IBlockState> p_206840_1_) {
@@ -189,4 +192,9 @@
@@ -189,4 +192,10 @@
public IBlockState func_196258_a(BlockItemUseContext p_196258_1_) {
return func_208493_b((IBlockState)this.func_176223_P().func_206870_a(field_208495_b, Boolean.valueOf(true)), p_196258_1_.func_195991_k(), p_196258_1_.func_195995_a());
}
+
+ @Override
+ public java.util.List<ItemStack> onSheared(@javax.annotation.Nonnull ItemStack item, net.minecraft.world.IWorldReader world, BlockPos pos, int fortune) {
+ public java.util.List<ItemStack> onSheared(@javax.annotation.Nonnull ItemStack item, net.minecraft.world.IWorld world, BlockPos pos, int fortune) {
+ world.func_180501_a(pos, Blocks.field_150350_a.func_176223_P(), 11);
+ return java.util.Arrays.asList(new ItemStack(this));
+ }
}

View File

@ -20,7 +20,7 @@
super.func_196391_a(p_196391_1_, p_196391_2_, p_196391_3_, p_196391_4_);
}
@@ -37,4 +35,14 @@
@@ -37,4 +35,15 @@
public IItemProvider func_199769_a(IBlockState p_199769_1_, World p_199769_2_, BlockPos p_199769_3_, int p_199769_4_) {
return p_199769_1_.func_177229_b(field_208063_b) == DoubleBlockHalf.LOWER && this == Blocks.field_196804_gh && p_199769_2_.field_73012_v.nextInt(8) == 0 ? Items.field_151014_N : Items.field_190931_a;
}
@ -31,7 +31,8 @@
+ }
+
+ @Override
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorldReader world, BlockPos pos, int fortune) {
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorld world, BlockPos pos, int fortune) {
+ world.func_180501_a(pos, Blocks.field_150350_a.func_176223_P(), 11);
+ return java.util.Arrays.asList(new ItemStack(this.field_196392_b, 2));
+ }
}

View File

@ -18,13 +18,14 @@
}
public int func_196251_a(IBlockState p_196251_1_, int p_196251_2_, World p_196251_3_, BlockPos p_196251_4_, Random p_196251_5_) {
@@ -64,4 +64,17 @@
@@ -64,4 +64,18 @@
public Block.EnumOffsetType func_176218_Q() {
return Block.EnumOffsetType.XYZ;
}
+
+ @Override
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorldReader world, BlockPos pos, int fortune) {
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorld world, BlockPos pos, int fortune) {
+ world.func_180501_a(pos, Blocks.field_150350_a.func_176223_P(), 11);
+ return java.util.Arrays.asList(new ItemStack(this));
+ }
+

View File

@ -18,7 +18,7 @@
EnumFacing enumfacing = EnumFacing.func_176741_a(p_196267_4_);
BlockPos blockpos = p_196267_3_.func_177984_a();
if (enumfacing.func_176740_k().func_176722_c() && !p_196267_1_.func_177229_b(func_176267_a(enumfacing))) {
@@ -365,4 +365,14 @@
@@ -365,4 +365,15 @@
public BlockFaceShape func_193383_a(IBlockReader p_193383_1_, IBlockState p_193383_2_, BlockPos p_193383_3_, EnumFacing p_193383_4_) {
return BlockFaceShape.UNDEFINED;
}
@ -29,7 +29,8 @@
+ }
+
+ @Override
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorldReader world, BlockPos pos, int fortune) {
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorld world, BlockPos pos, int fortune) {
+ world.func_180501_a(pos, Blocks.field_150350_a.func_176223_P(), 11);
+ return java.util.Arrays.asList(new ItemStack(this));
+ }
}

View File

@ -1,6 +1,14 @@
--- a/net/minecraft/block/BlockWeb.java
+++ b/net/minecraft/block/BlockWeb.java
@@ -16,7 +16,7 @@
@@ -5,6 +5,7 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
@@ -16,7 +17,7 @@
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
@ -9,13 +17,14 @@
public BlockWeb(Block.Builder p_i48296_1_) {
super(p_i48296_1_);
}
@@ -54,4 +54,9 @@
@@ -54,4 +55,10 @@
public BlockFaceShape func_193383_a(IBlockReader p_193383_1_, IBlockState p_193383_2_, BlockPos p_193383_3_, EnumFacing p_193383_4_) {
return BlockFaceShape.UNDEFINED;
}
+
+ @Override
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorldReader world, BlockPos pos, int fortune) {
+ public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorld world, BlockPos pos, int fortune) {
+ world.func_180501_a(pos, Blocks.field_150350_a.func_176223_P(), 11);
+ return java.util.Arrays.asList(new ItemStack(this));
+ }
}

View File

@ -1,11 +1,47 @@
--- a/net/minecraft/enchantment/Enchantment.java
+++ b/net/minecraft/enchantment/Enchantment.java
@@ -18,7 +18,7 @@
@@ -18,8 +18,8 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
-public abstract class Enchantment {
- public static final RegistryNamespaced<ResourceLocation, Enchantment> field_185264_b = new RegistryNamespaced<ResourceLocation, Enchantment>();
+public abstract class Enchantment extends net.minecraftforge.registries.ForgeRegistryEntry<Enchantment> {
public static final RegistryNamespaced<ResourceLocation, Enchantment> field_185264_b = new RegistryNamespaced<ResourceLocation, Enchantment>();
+ public static final RegistryNamespaced<ResourceLocation, Enchantment> field_185264_b = net.minecraftforge.registries.GameData.getWrapper(Enchantment.class);
private final EntityEquipmentSlot[] field_185263_a;
private final Enchantment.Rarity field_77333_a;
@Nullable
@@ -114,7 +114,7 @@
}
public boolean func_92089_a(ItemStack p_92089_1_) {
- return this.field_77351_y.func_77557_a(p_92089_1_.func_77973_b());
+ return canApplyAtEnchantingTable(p_92089_1_);
}
public void func_151368_a(EntityLivingBase p_151368_1_, Entity p_151368_2_, int p_151368_3_) {
@@ -131,6 +131,24 @@
return false;
}
+ /**
+ * This applies specifically to applying at the enchanting table. The other method {@link #canApply(ItemStack)}
+ * applies for <i>all possible</i> enchantments.
+ * @param stack
+ * @return
+ */
+ public boolean canApplyAtEnchantingTable(ItemStack stack) {
+ return stack.canApplyAtEnchantingTable(this);
+ }
+
+ /**
+ * Is this enchantment allowed to be enchanted on books via Enchantment Table
+ * @return false to disable the vanilla feature
+ */
+ public boolean isAllowedOnBooks() {
+ return true;
+ }
+
public static void func_185257_f() {
EntityEquipmentSlot[] aentityequipmentslot = new EntityEquipmentSlot[]{EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET};
func_210770_a("protection", new EnchantmentProtection(Enchantment.Rarity.COMMON, EnchantmentProtection.Type.ALL, aentityequipmentslot));

View File

@ -0,0 +1,12 @@
--- a/net/minecraft/enchantment/EnchantmentFrostWalker.java
+++ b/net/minecraft/enchantment/EnchantmentFrostWalker.java
@@ -44,7 +44,8 @@
IBlockState iblockstate1 = p_185266_1_.func_180495_p(blockpos$mutableblockpos);
if (iblockstate1.func_196958_f()) {
IBlockState iblockstate2 = p_185266_1_.func_180495_p(blockpos$mutableblockpos1);
- if (iblockstate2.func_185904_a() == Material.field_151586_h && iblockstate2.func_177229_b(BlockFlowingFluid.field_176367_b) == 0 && iblockstate.func_196955_c(p_185266_1_, blockpos$mutableblockpos1) && p_185266_1_.func_195584_a(iblockstate, blockpos$mutableblockpos1)) {
+ boolean isFull = iblockstate2.func_177230_c() == Blocks.field_150355_j && iblockstate2.func_177229_b(BlockFlowingFluid.field_176367_b) == 0; //TODO: Forge, modded waters?
+ if (iblockstate2.func_185904_a() == Material.field_151586_h && isFull && iblockstate.func_196955_c(p_185266_1_, blockpos$mutableblockpos1) && p_185266_1_.func_195584_a(iblockstate, blockpos$mutableblockpos1)) {
p_185266_1_.func_175656_a(blockpos$mutableblockpos1, iblockstate);
p_185266_1_.func_205220_G_().func_205360_a(blockpos$mutableblockpos1.func_185334_h(), Blocks.field_185778_de, MathHelper.func_76136_a(p_185266_0_.func_70681_au(), 60, 120));
}

View File

@ -0,0 +1,29 @@
--- a/net/minecraft/enchantment/EnchantmentHelper.java
+++ b/net/minecraft/enchantment/EnchantmentHelper.java
@@ -262,7 +262,7 @@
public static int func_77514_a(Random p_77514_0_, int p_77514_1_, int p_77514_2_, ItemStack p_77514_3_) {
Item item = p_77514_3_.func_77973_b();
- int i = item.func_77619_b();
+ int i = p_77514_3_.getItemEnchantability();
if (i <= 0) {
return 0;
} else {
@@ -300,7 +300,7 @@
public static List<EnchantmentData> func_77513_b(Random p_77513_0_, ItemStack p_77513_1_, int p_77513_2_, boolean p_77513_3_) {
List<EnchantmentData> list = Lists.<EnchantmentData>newArrayList();
Item item = p_77513_1_.func_77973_b();
- int i = item.func_77619_b();
+ int i = p_77513_1_.getItemEnchantability();
if (i <= 0) {
return list;
} else {
@@ -353,7 +353,7 @@
boolean flag = p_185291_1_.func_77973_b() == Items.field_151122_aG;
for(Enchantment enchantment : Enchantment.field_185264_b) {
- if ((!enchantment.func_185261_e() || p_185291_2_) && (enchantment.field_77351_y.func_77557_a(item) || flag)) {
+ if ((!enchantment.func_185261_e() || p_185291_2_) && (enchantment.canApplyAtEnchantingTable(p_185291_1_) || (flag && enchantment.isAllowedOnBooks()))) {
for(int i = enchantment.func_77325_b(); i > enchantment.func_77319_d() - 1; --i) {
if (p_185291_0_ >= enchantment.func_77321_a(i) && p_185291_0_ <= enchantment.func_77317_b(i)) {
list.add(new EnchantmentData(enchantment, i));

View File

@ -0,0 +1,20 @@
--- a/net/minecraft/enchantment/EnumEnchantmentType.java
+++ b/net/minecraft/enchantment/EnumEnchantmentType.java
@@ -90,5 +90,16 @@
private EnumEnchantmentType() {
}
- public abstract boolean func_77557_a(Item p_77557_1_);
+ private java.util.function.Predicate<Item> delegate;
+ private EnumEnchantmentType(java.util.function.Predicate<Item> delegate) {
+ this.delegate = delegate;
+ }
+
+ public static EnumEnchantmentType create(String name, java.util.function.Predicate<Item> delegate) {
+ return null;
+ }
+
+ public boolean func_77557_a(Item p_77557_1_) {
+ return this.delegate == null ? false : this.delegate.test(p_77557_1_);
+ }
}

View File

@ -0,0 +1,30 @@
--- a/net/minecraft/entity/EntityLivingBase.java
+++ b/net/minecraft/entity/EntityLivingBase.java
@@ -622,6 +622,27 @@
}
}
+ /***
+ * Removes all potion effects that have curativeItem as a curative item for its effect
+ * @param curativeItem The itemstack we are using to cure potion effects
+ */
+ public boolean curePotionEffects(ItemStack curativeItem) {
+ if (this.field_70170_p.field_72995_K)
+ return false;
+ boolean ret = false;
+ Iterator<PotionEffect> itr = this.field_70713_bf.values().iterator();
+ while (itr.hasNext()) {
+ PotionEffect effect = itr.next();
+ if (effect.isCurativeItem(curativeItem)) {
+ this.func_70688_c(effect);
+ itr.remove();
+ ret = true;
+ this.field_70752_e = true;
+ }
+ }
+ return ret;
+ }
+
public Collection<PotionEffect> func_70651_bq() {
return this.field_70713_bf.values();
}

View File

@ -4,7 +4,7 @@
public int func_200881_e() {
return this.field_77879_b;
}
+
+
+ public float getToughness() {
+ return this.field_189415_e;
+ }

View File

@ -0,0 +1,12 @@
--- a/net/minecraft/item/ItemArrow.java
+++ b/net/minecraft/item/ItemArrow.java
@@ -15,4 +15,9 @@
entitytippedarrow.func_184555_a(p_200887_2_);
return entitytippedarrow;
}
+
+ public boolean isInfinite(ItemStack stack, ItemStack bow, net.minecraft.entity.player.EntityPlayer player) {
+ int enchant = net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.init.Enchantments.field_185312_x, bow);
+ return enchant <= 0 ? false : this.getClass() == ItemArrow.class;
+ }
}

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/item/ItemAxe.java
+++ b/net/minecraft/item/ItemAxe.java
@@ -21,7 +21,7 @@
protected static final Map<Block, Block> field_203176_a = (new ImmutableMap.Builder<Block, Block>()).put(Blocks.field_196626_Q, Blocks.field_209389_ab).put(Blocks.field_196617_K, Blocks.field_203204_R).put(Blocks.field_196639_V, Blocks.field_209394_ag).put(Blocks.field_196623_P, Blocks.field_203209_W).put(Blocks.field_196637_U, Blocks.field_209393_af).put(Blocks.field_196621_O, Blocks.field_203208_V).put(Blocks.field_196631_S, Blocks.field_209391_ad).put(Blocks.field_196619_M, Blocks.field_203206_T).put(Blocks.field_196634_T, Blocks.field_209392_ae).put(Blocks.field_196620_N, Blocks.field_203207_U).put(Blocks.field_196629_R, Blocks.field_209390_ac).put(Blocks.field_196618_L, Blocks.field_203205_S).build();
protected ItemAxe(IItemTier p_i48530_1_, float p_i48530_2_, float p_i48530_3_, Item.Builder p_i48530_4_) {
- super(p_i48530_2_, p_i48530_3_, p_i48530_1_, field_150917_c, p_i48530_4_);
+ super(p_i48530_2_, p_i48530_3_, p_i48530_1_, field_150917_c, p_i48530_4_.addToolType(net.minecraftforge.common.ToolType.AXE, p_i48530_1_.func_200925_d()));
}
public float func_150893_a(ItemStack p_150893_1_, IBlockState p_150893_2_) {

View File

@ -0,0 +1,22 @@
--- a/net/minecraft/item/ItemBlock.java
+++ b/net/minecraft/item/ItemBlock.java
@@ -59,7 +59,7 @@
}
}
- SoundType soundtype = block.func_185467_w();
+ SoundType soundtype = iblockstate1.getSoundType(world, blockpos, p_195942_1_.func_195999_j());
world.func_184133_a(entityplayer, blockpos, soundtype.func_185841_e(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F);
itemstack.func_190918_g(1);
return EnumActionResult.SUCCESS;
@@ -134,6 +134,10 @@
}
public Block func_179223_d() {
+ return this.getBlockRaw() == null ? null : this.getBlockRaw().delegate.get();
+ }
+
+ private Block getBlockRaw() {
return this.field_150939_a;
}

View File

@ -0,0 +1,46 @@
--- a/net/minecraft/item/ItemBoneMeal.java
+++ b/net/minecraft/item/ItemBoneMeal.java
@@ -20,7 +20,7 @@
public EnumActionResult func_195939_a(ItemUseContext p_195939_1_) {
World world = p_195939_1_.func_195991_k();
BlockPos blockpos = p_195939_1_.func_195995_a();
- if (func_195966_a(p_195939_1_.func_195996_i(), world, blockpos)) {
+ if (applyBonemeal(p_195939_1_.func_195996_i(), world, blockpos, p_195939_1_.func_195999_j())) {
if (!world.field_72995_K) {
world.func_175718_b(2005, blockpos, 0);
}
@@ -40,8 +40,19 @@
}
}
+ @Deprecated //Forge: Use Player/Hand version
public static boolean func_195966_a(ItemStack p_195966_0_, World p_195966_1_, BlockPos p_195966_2_) {
+ if (p_195966_1_ instanceof net.minecraft.world.WorldServer)
+ return applyBonemeal(p_195966_0_, p_195966_1_, p_195966_2_, net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.world.WorldServer)p_195966_1_));
+ return false;
+ }
+
+ public static boolean applyBonemeal(ItemStack p_195966_0_, World p_195966_1_, BlockPos p_195966_2_, net.minecraft.entity.player.EntityPlayer player) {
IBlockState iblockstate = p_195966_1_.func_180495_p(p_195966_2_);
+
+ int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, p_195966_1_, p_195966_2_, iblockstate, p_195966_0_);
+ if (hook != 0) return hook > 0;
+
if (iblockstate.func_177230_c() instanceof IGrowable) {
IGrowable igrowable = (IGrowable)iblockstate.func_177230_c();
if (igrowable.func_176473_a(p_195966_1_, p_195966_2_, iblockstate, p_195966_1_.field_72995_K)) {
@@ -101,12 +112,13 @@
}
IBlockState iblockstate = p_195965_0_.func_180495_p(p_195965_1_);
+ double height = iblockstate.isAir(p_195965_0_, p_195965_1_) ? 1.0f : iblockstate.func_196954_c(p_195965_0_, p_195965_1_).func_197758_c(EnumFacing.Axis.Y);
if (!iblockstate.func_196958_f()) {
for(int i = 0; i < p_195965_2_; ++i) {
double d0 = field_77697_d.nextGaussian() * 0.02D;
double d1 = field_77697_d.nextGaussian() * 0.02D;
double d2 = field_77697_d.nextGaussian() * 0.02D;
- p_195965_0_.func_195594_a(Particles.field_197632_y, (double)((float)p_195965_1_.func_177958_n() + field_77697_d.nextFloat()), (double)p_195965_1_.func_177956_o() + (double)field_77697_d.nextFloat() * iblockstate.func_196954_c(p_195965_0_, p_195965_1_).func_197758_c(EnumFacing.Axis.Y), (double)((float)p_195965_1_.func_177952_p() + field_77697_d.nextFloat()), d0, d1, d2);
+ p_195965_0_.func_195594_a(Particles.field_197632_y, (double)((float)p_195965_1_.func_177958_n() + field_77697_d.nextFloat()), (double)p_195965_1_.func_177956_o() + (double)field_77697_d.nextFloat() * height, (double)((float)p_195965_1_.func_177952_p() + field_77697_d.nextFloat()), d0, d1, d2);
}
}

View File

@ -0,0 +1,35 @@
--- a/net/minecraft/item/ItemBow.java
+++ b/net/minecraft/item/ItemBow.java
@@ -56,15 +56,19 @@
EntityPlayer entityplayer = (EntityPlayer)p_77615_3_;
boolean flag = entityplayer.field_71075_bZ.field_75098_d || EnchantmentHelper.func_77506_a(Enchantments.field_185312_x, p_77615_1_) > 0;
ItemStack itemstack = this.func_185060_a(entityplayer);
+
+ int i = this.func_77626_a(p_77615_1_) - p_77615_4_;
+ i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(p_77615_1_, p_77615_2_, entityplayer, i, !itemstack.func_190926_b() || flag);
+ if (i < 0) return;
+
if (!itemstack.func_190926_b() || flag) {
if (itemstack.func_190926_b()) {
itemstack = new ItemStack(Items.field_151032_g);
}
- int i = this.func_77626_a(p_77615_1_) - p_77615_4_;
float f = func_185059_b(i);
if (!((double)f < 0.1D)) {
- boolean flag1 = flag && itemstack.func_77973_b() == Items.field_151032_g;
+ boolean flag1 = entityplayer.field_71075_bZ.field_75098_d || (itemstack.func_77973_b() instanceof ItemArrow && ((ItemArrow) itemstack.func_77973_b()).isInfinite(itemstack, p_77615_1_, entityplayer));
if (!p_77615_2_.field_72995_K) {
ItemArrow itemarrow = (ItemArrow)(itemstack.func_77973_b() instanceof ItemArrow ? itemstack.func_77973_b() : Items.field_151032_g);
EntityArrow entityarrow = itemarrow.func_200887_a(p_77615_2_, itemstack, entityplayer);
@@ -130,6 +134,10 @@
public ActionResult<ItemStack> func_77659_a(World p_77659_1_, EntityPlayer p_77659_2_, EnumHand p_77659_3_) {
ItemStack itemstack = p_77659_2_.func_184586_b(p_77659_3_);
boolean flag = !this.func_185060_a(p_77659_2_).func_190926_b();
+
+ ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, p_77659_1_, p_77659_2_, p_77659_3_, flag);
+ if (ret != null) return ret;
+
if (!p_77659_2_.field_71075_bZ.field_75098_d && !flag) {
return flag ? new ActionResult(EnumActionResult.PASS, itemstack) : new ActionResult(EnumActionResult.FAIL, itemstack);
} else {

View File

@ -0,0 +1,26 @@
--- a/net/minecraft/item/ItemBucket.java
+++ b/net/minecraft/item/ItemBucket.java
@@ -37,6 +37,10 @@
public ActionResult<ItemStack> func_77659_a(World p_77659_1_, EntityPlayer p_77659_2_, EnumHand p_77659_3_) {
ItemStack itemstack = p_77659_2_.func_184586_b(p_77659_3_);
RayTraceResult raytraceresult = this.func_77621_a(p_77659_1_, p_77659_2_, this.field_77876_a == Fluids.field_204541_a);
+
+ ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(p_77659_2_, p_77659_1_, itemstack, raytraceresult);
+ if (ret != null) return ret;
+
if (raytraceresult == null) {
return new ActionResult<ItemStack>(EnumActionResult.PASS, itemstack);
} else if (raytraceresult.field_72313_a == RayTraceResult.Type.BLOCK) {
@@ -150,4 +154,12 @@
SoundEvent soundevent = this.field_77876_a.func_207185_a(FluidTags.field_206960_b) ? SoundEvents.field_187627_L : SoundEvents.field_187624_K;
p_203791_2_.func_184133_a(p_203791_1_, p_203791_3_, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
+
+ @Override
+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable net.minecraft.nbt.NBTTagCompound nbt) {
+ if (this.getClass() == ItemBucket.class)
+ return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack);
+ else
+ return super.initCapabilities(stack, nbt);
+ }
}

View File

@ -0,0 +1,29 @@
--- a/net/minecraft/item/ItemBucketMilk.java
+++ b/net/minecraft/item/ItemBucketMilk.java
@@ -1,5 +1,7 @@
package net.minecraft.item;
+import javax.annotation.Nullable;
+
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -17,6 +19,8 @@
}
public ItemStack func_77654_b(ItemStack p_77654_1_, World p_77654_2_, EntityLivingBase p_77654_3_) {
+ if (!p_77654_2_.field_72995_K) p_77654_3_.curePotionEffects(p_77654_1_); // FORGE - move up so stack.shrink does not turn stack into air
+
if (p_77654_3_ instanceof EntityPlayerMP) {
EntityPlayerMP entityplayermp = (EntityPlayerMP)p_77654_3_;
CriteriaTriggers.field_193138_y.func_193148_a(entityplayermp, p_77654_1_);
@@ -46,4 +50,9 @@
p_77659_2_.func_184598_c(p_77659_3_);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, p_77659_2_.func_184586_b(p_77659_3_));
}
+
+ @Override
+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable net.minecraft.nbt.NBTTagCompound nbt) {
+ return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack);
+ }
}

View File

@ -0,0 +1,13 @@
--- a/net/minecraft/item/ItemHoe.java
+++ b/net/minecraft/item/ItemHoe.java
@@ -31,7 +31,9 @@
public EnumActionResult func_195939_a(ItemUseContext p_195939_1_) {
World world = p_195939_1_.func_195991_k();
BlockPos blockpos = p_195939_1_.func_195995_a();
- if (p_195939_1_.func_196000_l() != EnumFacing.DOWN && world.func_180495_p(blockpos.func_177984_a()).func_196958_f()) {
+ int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(p_195939_1_);
+ if (hook != 0) return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
+ if (p_195939_1_.func_196000_l() != EnumFacing.DOWN && world.func_175623_d(blockpos.func_177984_a())) {
IBlockState iblockstate = field_195973_b.get(world.func_180495_p(blockpos).func_177230_c());
if (iblockstate != null) {
EntityPlayer entityplayer = p_195939_1_.func_195999_j();

View File

@ -0,0 +1,18 @@
--- a/net/minecraft/item/ItemLilyPad.java
+++ b/net/minecraft/item/ItemLilyPad.java
@@ -45,7 +45,15 @@
Material material = iblockstate.func_185904_a();
IFluidState ifluidstate = p_77659_1_.func_204610_c(blockpos);
if ((ifluidstate.func_206886_c() == Fluids.field_204546_a || material == Material.field_151588_w) && p_77659_1_.func_175623_d(blockpos1)) {
+
+ // special case for handling block placement with water lilies
+ net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(p_77659_1_, blockpos1);
p_77659_1_.func_180501_a(blockpos1, Blocks.field_196651_dG.func_176223_P(), 11);
+ if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(p_77659_2_, blocksnapshot, net.minecraft.util.EnumFacing.UP, p_77659_3_).isCanceled()) {
+ blocksnapshot.restore(true, false);
+ return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack);
+ }
+
if (p_77659_2_ instanceof EntityPlayerMP) {
CriteriaTriggers.field_193137_x.func_193173_a((EntityPlayerMP)p_77659_2_, blockpos1, itemstack);
}

View File

@ -0,0 +1,38 @@
--- a/net/minecraft/item/ItemMap.java
+++ b/net/minecraft/item/ItemMap.java
@@ -41,7 +41,7 @@
public static ItemStack func_195952_a(World p_195952_0_, int p_195952_1_, int p_195952_2_, byte p_195952_3_, boolean p_195952_4_, boolean p_195952_5_) {
ItemStack itemstack = new ItemStack(Items.field_151098_aY);
- func_195951_a(itemstack, p_195952_0_, p_195952_1_, p_195952_2_, p_195952_3_, p_195952_4_, p_195952_5_, p_195952_0_.field_73011_w.func_186058_p().func_186068_a());
+ func_195951_a(itemstack, p_195952_0_, p_195952_1_, p_195952_2_, p_195952_3_, p_195952_4_, p_195952_5_, p_195952_0_.field_73011_w.getId());
return itemstack;
}
@@ -49,7 +49,7 @@
public static MapData func_195950_a(ItemStack p_195950_0_, World p_195950_1_) {
MapData mapdata = func_195953_a(p_195950_1_, "map_" + func_195949_f(p_195950_0_));
if (mapdata == null && !p_195950_1_.field_72995_K) {
- mapdata = func_195951_a(p_195950_0_, p_195950_1_, p_195950_1_.func_72912_H().func_76079_c(), p_195950_1_.func_72912_H().func_76074_e(), 3, false, false, p_195950_1_.field_73011_w.func_186058_p().func_186068_a());
+ mapdata = func_195951_a(p_195950_0_, p_195950_1_, p_195950_1_.func_72912_H().func_76079_c(), p_195950_1_.func_72912_H().func_76074_e(), 3, false, false, p_195950_1_.field_73011_w.getId());
}
return mapdata;
@@ -75,7 +75,7 @@
}
public void func_77872_a(World p_77872_1_, Entity p_77872_2_, MapData p_77872_3_) {
- if (p_77872_1_.field_73011_w.func_186058_p().func_186068_a() == p_77872_3_.field_76200_c && p_77872_2_ instanceof EntityPlayer) {
+ if (p_77872_1_.field_73011_w.getId() == p_77872_3_.field_76200_c && p_77872_2_ instanceof EntityPlayer) {
int i = 1 << p_77872_3_.field_76197_d;
int j = p_77872_3_.field_76201_a;
int k = p_77872_3_.field_76199_b;
@@ -215,7 +215,7 @@
public static void func_190905_a(World p_190905_0_, ItemStack p_190905_1_) {
MapData mapdata = func_195950_a(p_190905_1_, p_190905_0_);
if (mapdata != null) {
- if (p_190905_0_.field_73011_w.func_186058_p().func_186068_a() == mapdata.field_76200_c) {
+ if (p_190905_0_.field_73011_w.getId() == mapdata.field_76200_c) {
int i = 1 << mapdata.field_76197_d;
int j = mapdata.field_76201_a;
int k = mapdata.field_76199_b;

View File

@ -0,0 +1,29 @@
--- a/net/minecraft/item/ItemMinecart.java
+++ b/net/minecraft/item/ItemMinecart.java
@@ -26,7 +26,7 @@
double d2 = p_82487_1_.func_82616_c() + (double)enumfacing.func_82599_e() * 1.125D;
BlockPos blockpos = p_82487_1_.func_180699_d().func_177972_a(enumfacing);
IBlockState iblockstate = world.func_180495_p(blockpos);
- RailShape railshape = iblockstate.func_177230_c() instanceof BlockRailBase ? (RailShape)iblockstate.func_177229_b(((BlockRailBase)iblockstate.func_177230_c()).func_176560_l()) : RailShape.NORTH_SOUTH;
+ RailShape railshape = iblockstate.func_177230_c() instanceof BlockRailBase ? ((BlockRailBase)iblockstate.func_177230_c()).getRailDirection(iblockstate, world, blockpos, null) : RailShape.NORTH_SOUTH;
double d3;
if (iblockstate.func_203425_a(BlockTags.field_203437_y)) {
if (railshape.func_208092_c()) {
@@ -40,7 +40,7 @@
}
IBlockState iblockstate1 = world.func_180495_p(blockpos.func_177977_b());
- RailShape railshape1 = iblockstate1.func_177230_c() instanceof BlockRailBase ? (RailShape)iblockstate1.func_177229_b(((BlockRailBase)iblockstate1.func_177230_c()).func_176560_l()) : RailShape.NORTH_SOUTH;
+ RailShape railshape1 = iblockstate1.func_177230_c() instanceof BlockRailBase ? ((BlockRailBase)iblockstate1.func_177230_c()).getRailDirection(iblockstate1, world, blockpos, null) : RailShape.NORTH_SOUTH;
if (enumfacing != EnumFacing.DOWN && railshape1.func_208092_c()) {
d3 = -0.4D;
} else {
@@ -79,7 +79,7 @@
} else {
ItemStack itemstack = p_195939_1_.func_195996_i();
if (!world.field_72995_K) {
- RailShape railshape = iblockstate.func_177230_c() instanceof BlockRailBase ? (RailShape)iblockstate.func_177229_b(((BlockRailBase)iblockstate.func_177230_c()).func_176560_l()) : RailShape.NORTH_SOUTH;
+ RailShape railshape = iblockstate.func_177230_c() instanceof BlockRailBase ? ((BlockRailBase)iblockstate.func_177230_c()).getRailDirection(iblockstate, world, blockpos, null) : RailShape.NORTH_SOUTH;
double d0 = 0.0D;
if (railshape.func_208092_c()) {
d0 = 0.5D;

View File

@ -1,6 +1,13 @@
--- a/net/minecraft/item/ItemPickaxe.java
+++ b/net/minecraft/item/ItemPickaxe.java
@@ -17,18 +17,11 @@
@@ -11,24 +11,17 @@
private static final Set<Block> field_150915_c = Sets.newHashSet(Blocks.field_150408_cc, Blocks.field_150365_q, Blocks.field_150347_e, Blocks.field_150319_E, Blocks.field_150484_ah, Blocks.field_150482_ag, Blocks.field_196552_aC, Blocks.field_150340_R, Blocks.field_150352_o, Blocks.field_150432_aD, Blocks.field_150339_S, Blocks.field_150366_p, Blocks.field_150368_y, Blocks.field_150369_x, Blocks.field_150341_Y, Blocks.field_150424_aL, Blocks.field_150403_cj, Blocks.field_205164_gk, Blocks.field_150448_aq, Blocks.field_150450_ax, Blocks.field_150322_A, Blocks.field_196583_aj, Blocks.field_196585_ak, Blocks.field_196798_hA, Blocks.field_196799_hB, Blocks.field_180395_cM, Blocks.field_150348_b, Blocks.field_196650_c, Blocks.field_196652_d, Blocks.field_196654_e, Blocks.field_196655_f, Blocks.field_196656_g, Blocks.field_196657_h, Blocks.field_150333_U, Blocks.field_196640_bx, Blocks.field_196643_by, Blocks.field_196646_bz, Blocks.field_196571_bA, Blocks.field_196573_bB, Blocks.field_196575_bC, Blocks.field_196576_bD, Blocks.field_196578_bE, Blocks.field_185771_cX, Blocks.field_196581_bI, Blocks.field_196582_bJ, Blocks.field_196580_bH, Blocks.field_196579_bG, Blocks.field_150430_aB, Blocks.field_150456_au);
protected ItemPickaxe(IItemTier p_i48478_1_, int p_i48478_2_, float p_i48478_3_, Item.Builder p_i48478_4_) {
- super((float)p_i48478_2_, p_i48478_3_, p_i48478_1_, field_150915_c, p_i48478_4_);
+ super((float)p_i48478_2_, p_i48478_3_, p_i48478_1_, field_150915_c, p_i48478_4_.addToolType(net.minecraftforge.common.ToolType.PICKAXE, p_i48478_1_.func_200925_d()));
}
public boolean func_150897_b(IBlockState p_150897_1_) {
Block block = p_150897_1_.func_177230_c();
int i = this.func_200891_e().func_200925_d();

View File

@ -0,0 +1,35 @@
--- a/net/minecraft/item/ItemSeedFood.java
+++ b/net/minecraft/item/ItemSeedFood.java
@@ -10,7 +10,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
-public class ItemSeedFood extends ItemFood {
+public class ItemSeedFood extends ItemFood implements net.minecraftforge.common.IPlantable {
private final IBlockState field_195972_b;
public ItemSeedFood(int p_i48473_1_, float p_i48473_2_, Block p_i48473_3_, Item.Builder p_i48473_4_) {
@@ -21,7 +21,7 @@
public EnumActionResult func_195939_a(ItemUseContext p_195939_1_) {
IWorld iworld = p_195939_1_.func_195991_k();
BlockPos blockpos = p_195939_1_.func_195995_a().func_177984_a();
- if (p_195939_1_.func_196000_l() == EnumFacing.UP && iworld.func_175623_d(blockpos) && this.field_195972_b.func_196955_c(iworld, blockpos)) {
+ if (p_195939_1_.func_196000_l() == EnumFacing.UP && iworld.func_175623_d(blockpos) && this.field_195972_b.func_196955_c(iworld, blockpos) && iworld.func_180495_p(p_195939_1_.func_195995_a()).canSustainPlant(iworld, p_195939_1_.func_195995_a(), EnumFacing.UP, this)) {
iworld.func_180501_a(blockpos, this.field_195972_b, 11);
EntityPlayer entityplayer = p_195939_1_.func_195999_j();
ItemStack itemstack = p_195939_1_.func_195996_i();
@@ -35,4 +35,14 @@
return EnumActionResult.PASS;
}
}
+
+ @Override
+ public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockReader world, BlockPos pos) {
+ return net.minecraftforge.common.EnumPlantType.Crop;
+ }
+
+ @Override
+ public IBlockState getPlant(net.minecraft.world.IBlockReader world, BlockPos pos) {
+ return this.field_195972_b;
+ }
}

View File

@ -0,0 +1,35 @@
--- a/net/minecraft/item/ItemSeeds.java
+++ b/net/minecraft/item/ItemSeeds.java
@@ -10,7 +10,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
-public class ItemSeeds extends Item {
+public class ItemSeeds extends Item implements net.minecraftforge.common.IPlantable {
private final IBlockState field_195978_a;
public ItemSeeds(Block p_i48472_1_, Item.Builder p_i48472_2_) {
@@ -21,7 +21,7 @@
public EnumActionResult func_195939_a(ItemUseContext p_195939_1_) {
IWorld iworld = p_195939_1_.func_195991_k();
BlockPos blockpos = p_195939_1_.func_195995_a().func_177984_a();
- if (p_195939_1_.func_196000_l() == EnumFacing.UP && iworld.func_175623_d(blockpos) && this.field_195978_a.func_196955_c(iworld, blockpos)) {
+ if (p_195939_1_.func_196000_l() == EnumFacing.UP && iworld.func_175623_d(blockpos) && this.field_195978_a.func_196955_c(iworld, blockpos) && iworld.func_180495_p(p_195939_1_.func_195995_a()).canSustainPlant(iworld, p_195939_1_.func_195995_a(), EnumFacing.UP, this)) {
iworld.func_180501_a(blockpos, this.field_195978_a, 11);
ItemStack itemstack = p_195939_1_.func_195996_i();
EntityPlayer entityplayer = p_195939_1_.func_195999_j();
@@ -35,4 +35,14 @@
return EnumActionResult.FAIL;
}
}
+
+ @Override
+ public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockReader world, BlockPos pos) {
+ return net.minecraftforge.common.EnumPlantType.Crop;
+ }
+
+ @Override
+ public IBlockState getPlant(net.minecraft.world.IBlockReader world, BlockPos pos) {
+ return this.field_195978_a;
+ }
}

View File

@ -0,0 +1,68 @@
--- a/net/minecraft/item/ItemShears.java
+++ b/net/minecraft/item/ItemShears.java
@@ -19,6 +19,7 @@
}
Block block = p_179218_3_.func_177230_c();
+ if (block instanceof net.minecraftforge.common.IShearable) return true;
return !p_179218_3_.func_203425_a(BlockTags.field_206952_E) && block != Blocks.field_196553_aF && block != Blocks.field_150349_c && block != Blocks.field_196554_aH && block != Blocks.field_196555_aI && block != Blocks.field_150395_bd && block != Blocks.field_150473_bD && !block.func_203417_a(BlockTags.field_199897_a) ? super.func_179218_a(p_179218_1_, p_179218_2_, p_179218_3_, p_179218_4_, p_179218_5_) : true;
}
@@ -35,4 +36,57 @@
return 15.0F;
}
}
+
+
+ @Override
+ public boolean func_111207_a(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity, net.minecraft.util.EnumHand hand) {
+ if (entity.field_70170_p.field_72995_K)
+ return false;
+ if (entity instanceof net.minecraftforge.common.IShearable) {
+ net.minecraftforge.common.IShearable target = (net.minecraftforge.common.IShearable)entity;
+ BlockPos pos = new BlockPos(entity.field_70165_t, entity.field_70163_u, entity.field_70161_v);
+ if (target.isShearable(itemstack, entity.field_70170_p, pos)) {
+ java.util.List<ItemStack> drops = target.onSheared(itemstack, entity.field_70170_p, pos,
+ net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.init.Enchantments.field_185308_t, itemstack));
+ java.util.Random rand = new java.util.Random();
+ for (ItemStack stack : drops) {
+ net.minecraft.entity.item.EntityItem ent = entity.func_70099_a(stack, 1.0F);
+ ent.field_70181_x += rand.nextFloat() * 0.05F;
+ ent.field_70159_w += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
+ ent.field_70179_y += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
+ }
+ itemstack.func_77972_a(1, entity);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, net.minecraft.entity.player.EntityPlayer player) {
+ if (player.field_70170_p.field_72995_K || player.field_71075_bZ.field_75098_d)
+ return false;
+ Block block = player.field_70170_p.func_180495_p(pos).func_177230_c();
+ if (block instanceof net.minecraftforge.common.IShearable) {
+ net.minecraftforge.common.IShearable target = (net.minecraftforge.common.IShearable)block;
+ if (target.isShearable(itemstack, player.field_70170_p, pos)) {
+ java.util.List<ItemStack> drops = target.onSheared(itemstack, player.field_70170_p, pos,
+ net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.init.Enchantments.field_185308_t, itemstack));
+ java.util.Random rand = new java.util.Random();
+ for (ItemStack stack : drops) {
+ float f = 0.7F;
+ double d = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
+ double d1 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
+ double d2 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
+ net.minecraft.entity.item.EntityItem entityitem = new net.minecraft.entity.item.EntityItem(player.field_70170_p, (double)pos.func_177958_n() + d, (double)pos.func_177956_o() + d1, (double)pos.func_177952_p() + d2, stack);
+ entityitem.func_174869_p();
+ player.field_70170_p.func_72838_d(entityitem);
+ }
+ itemstack.func_77972_a(1, player);
+ player.func_71029_a(net.minecraft.stats.StatList.field_188065_ae.func_199076_b(block));
+ return true;
+ }
+ }
+ return false;
+ }
}

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/item/ItemSpade.java
+++ b/net/minecraft/item/ItemSpade.java
@@ -21,7 +21,7 @@
protected static final Map<Block, IBlockState> field_195955_e = Maps.<Block, IBlockState>newHashMap(ImmutableMap.of(Blocks.field_196658_i, Blocks.field_185774_da.func_176223_P()));
public ItemSpade(IItemTier p_i48469_1_, float p_i48469_2_, float p_i48469_3_, Item.Builder p_i48469_4_) {
- super(p_i48469_2_, p_i48469_3_, p_i48469_1_, field_150916_c, p_i48469_4_);
+ super(p_i48469_2_, p_i48469_3_, p_i48469_1_, field_150916_c, p_i48469_4_.addToolType(net.minecraftforge.common.ToolType.SHOVEL, p_i48469_1_.func_200925_d()));
}
public boolean func_150897_b(IBlockState p_150897_1_) {

View File

@ -0,0 +1,10 @@
--- a/net/minecraft/item/ItemTool.java
+++ b/net/minecraft/item/ItemTool.java
@@ -26,6 +26,7 @@
}
public float func_150893_a(ItemStack p_150893_1_, IBlockState p_150893_2_) {
+ if (getToolTypes(p_150893_1_).stream().anyMatch(e -> p_150893_2_.isToolEffective(e))) return field_77864_a;
return this.field_150914_c.contains(p_150893_2_.func_177230_c()) ? this.field_77864_a : 1.0F;
}

View File

@ -0,0 +1,49 @@
--- a/net/minecraft/nbt/CompressedStreamTools.java
+++ b/net/minecraft/nbt/CompressedStreamTools.java
@@ -18,8 +18,6 @@
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.crash.ReportedException;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class CompressedStreamTools {
public static NBTTagCompound func_74796_a(InputStream p_74796_0_) throws IOException {
@@ -46,7 +44,6 @@
}
- @OnlyIn(Dist.CLIENT)
public static void func_74793_a(NBTTagCompound p_74793_0_, File p_74793_1_) throws IOException {
File file1 = new File(p_74793_1_.getAbsolutePath() + "_tmp");
if (file1.exists()) {
@@ -65,7 +62,6 @@
}
}
- @OnlyIn(Dist.CLIENT)
public static void func_74795_b(NBTTagCompound p_74795_0_, File p_74795_1_) throws IOException {
DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(p_74795_1_));
@@ -78,7 +74,6 @@
}
@Nullable
- @OnlyIn(Dist.CLIENT)
public static NBTTagCompound func_74797_a(File p_74797_0_) throws IOException {
if (!p_74797_0_.exists()) {
return null;
@@ -123,10 +118,12 @@
private static INBTBase func_152455_a(DataInput p_152455_0_, int p_152455_1_, NBTSizeTracker p_152455_2_) throws IOException {
byte b0 = p_152455_0_.readByte();
+ p_152455_2_.func_152450_a(8); // Forge: Count everything!
if (b0 == 0) {
return new NBTTagEnd();
} else {
- p_152455_0_.readUTF();
+ NBTSizeTracker.readUTF(p_152455_2_, p_152455_0_.readUTF()); //Forge: Count this string.
+ p_152455_2_.func_152450_a(32); //Forge: 4 extra bytes for the object allocation.
INBTBase inbtbase = INBTBase.func_150284_a(b0);
try {

View File

@ -0,0 +1,35 @@
--- a/net/minecraft/nbt/NBTSizeTracker.java
+++ b/net/minecraft/nbt/NBTSizeTracker.java
@@ -18,4 +18,32 @@
throw new RuntimeException("Tried to read NBT tag that was too big; tried to allocate: " + this.field_152453_c + "bytes where max allowed: " + this.field_152452_b);
}
}
+
+ /*
+ * UTF8 is not a simple encoding system, each character can be either
+ * 1, 2, or 3 bytes. Depending on where it's numerical value falls.
+ * We have to count up each character individually to see the true
+ * length of the data.
+ *
+ * Basic concept is that it uses the MSB of each byte as a 'read more' signal.
+ * So it has to shift each 7-bit segment.
+ *
+ * This will accurately count the correct byte length to encode this string, plus the 2 bytes for it's length prefix.
+ */
+ public static void readUTF(NBTSizeTracker tracker, String data) {
+ tracker.func_152450_a(16); //Header length
+ if (data == null)
+ return;
+
+ int len = data.length();
+ int utflen = 0;
+
+ for (int i = 0; i < len; i++) {
+ int c = data.charAt(i);
+ if ((c >= 0x0001) && (c <= 0x007F)) utflen += 1;
+ else if (c > 0x07FF) utflen += 3;
+ else utflen += 2;
+ }
+ tracker.func_152450_a(8 * utflen);
+ }
}

View File

@ -0,0 +1,18 @@
--- a/net/minecraft/nbt/NBTTagCompound.java
+++ b/net/minecraft/nbt/NBTTagCompound.java
@@ -389,6 +389,7 @@
}
private static byte func_152447_a(DataInput p_152447_0_, NBTSizeTracker p_152447_1_) throws IOException {
+ p_152447_1_.func_152450_a(8);
return p_152447_0_.readByte();
}
@@ -397,6 +398,7 @@
}
static INBTBase func_152449_a(byte p_152449_0_, String p_152449_1_, DataInput p_152449_2_, int p_152449_3_, NBTSizeTracker p_152449_4_) throws IOException {
+ p_152449_4_.func_152450_a(32); //Forge: 4 extra bytes for the object allocation.
INBTBase inbtbase = INBTBase.func_150284_a(p_152449_0_);
try {

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/nbt/NBTTagString.java
+++ b/net/minecraft/nbt/NBTTagString.java
@@ -26,7 +26,7 @@
public void func_152446_a(DataInput p_152446_1_, int p_152446_2_, NBTSizeTracker p_152446_3_) throws IOException {
p_152446_3_.func_152450_a(288L);
this.field_74751_a = p_152446_1_.readUTF();
- p_152446_3_.func_152450_a((long)(16 * this.field_74751_a.length()));
+ NBTSizeTracker.readUTF(p_152446_3_, this.field_74751_a); // Forge: Correctly read String length including header.
}
public byte func_74732_a() {

View File

@ -0,0 +1,29 @@
--- a/net/minecraft/pathfinding/WalkNodeProcessor.java
+++ b/net/minecraft/pathfinding/WalkNodeProcessor.java
@@ -343,10 +343,11 @@
for(int i = -1; i <= 1; ++i) {
for(int j = -1; j <= 1; ++j) {
if (i != 0 || j != 0) {
- Block block = p_193578_1_.func_180495_p(blockpos$pooledmutableblockpos.func_181079_c(i + p_193578_2_, p_193578_3_, j + p_193578_4_)).func_177230_c();
+ IBlockState state = p_193578_1_.func_180495_p(blockpos$pooledmutableblockpos.func_181079_c(i + p_193578_2_, p_193578_3_, j + p_193578_4_));
+ Block block = state.func_177230_c();
if (block == Blocks.field_150434_aF) {
p_193578_5_ = PathNodeType.DANGER_CACTUS;
- } else if (block == Blocks.field_150480_ab) {
+ } else if (block == Blocks.field_150480_ab || state.isBurning(p_193578_1_, blockpos$pooledmutableblockpos)) {
p_193578_5_ = PathNodeType.DANGER_FIRE;
}
}
@@ -361,9 +362,11 @@
protected PathNodeType func_189553_b(IBlockReader p_189553_1_, int p_189553_2_, int p_189553_3_, int p_189553_4_) {
BlockPos blockpos = new BlockPos(p_189553_2_, p_189553_3_, p_189553_4_);
IBlockState iblockstate = p_189553_1_.func_180495_p(blockpos);
+ PathNodeType type = iblockstate.getAiPathNodeType(p_189553_1_, blockpos);
+ if (type != null) return type;
Block block = iblockstate.func_177230_c();
Material material = iblockstate.func_185904_a();
- if (iblockstate.func_196958_f()) {
+ if (iblockstate.isAir(p_189553_1_, blockpos)) {
return PathNodeType.OPEN;
} else if (!block.func_203417_a(BlockTags.field_212185_E) && block != Blocks.field_196651_dG) {
if (block == Blocks.field_150480_ab) {

View File

@ -0,0 +1,111 @@
--- a/net/minecraft/potion/PotionEffect.java
+++ b/net/minecraft/potion/PotionEffect.java
@@ -19,6 +19,8 @@
private boolean field_100013_f;
private boolean field_188421_h;
private boolean field_205349_i;
+ /** List of ItemStack that can cure the potion effect **/
+ private java.util.List<net.minecraft.item.ItemStack> curativeItems;
public PotionEffect(Potion p_i46811_1_) {
this(p_i46811_1_, 0, 0);
@@ -52,6 +54,7 @@
this.field_82724_e = p_i1577_1_.field_82724_e;
this.field_188421_h = p_i1577_1_.field_188421_h;
this.field_205349_i = p_i1577_1_.field_205349_i;
+ this.curativeItems = p_i1577_1_.curativeItems == null ? null : new java.util.ArrayList<net.minecraft.item.ItemStack>(p_i1577_1_.curativeItems);
}
public boolean func_199308_a(PotionEffect p_199308_1_) {
@@ -188,11 +191,12 @@
p_82719_1_.func_74757_a("Ambient", this.func_82720_e());
p_82719_1_.func_74757_a("ShowParticles", this.func_188418_e());
p_82719_1_.func_74757_a("ShowIcon", this.func_205348_f());
+ writeCurativeItems(p_82719_1_);
return p_82719_1_;
}
public static PotionEffect func_82722_b(NBTTagCompound p_82722_0_) {
- int i = p_82722_0_.func_74771_c("Id");
+ int i = p_82722_0_.func_74771_c("Id") & 0xFF;
Potion potion = Potion.func_188412_a(i);
if (potion == null) {
return null;
@@ -210,7 +214,7 @@
flag2 = p_82722_0_.func_74767_n("ShowIcon");
}
- return new PotionEffect(potion, k, j < 0 ? 0 : j, flag, flag1, flag2);
+ return readCurativeItems(new PotionEffect(potion, k, j < 0 ? 0 : j, flag, flag1, flag2), p_82722_0_);
}
}
@@ -226,6 +230,67 @@
public int compareTo(PotionEffect p_compareTo_1_) {
int i = 32147;
- return (this.func_76459_b() <= 32147 || p_compareTo_1_.func_76459_b() <= 32147) && (!this.func_82720_e() || !p_compareTo_1_.func_82720_e()) ? ComparisonChain.start().compare(this.func_82720_e(), p_compareTo_1_.func_82720_e()).compare(this.func_76459_b(), p_compareTo_1_.func_76459_b()).compare(this.func_188419_a().func_76401_j(), p_compareTo_1_.func_188419_a().func_76401_j()).result() : ComparisonChain.start().compare(this.func_82720_e(), p_compareTo_1_.func_82720_e()).compare(this.func_188419_a().func_76401_j(), p_compareTo_1_.func_188419_a().func_76401_j()).result();
+ return (this.func_76459_b() <= 32147 || p_compareTo_1_.func_76459_b() <= 32147) && (!this.func_82720_e() || !p_compareTo_1_.func_82720_e()) ? ComparisonChain.start().compare(this.func_82720_e(), p_compareTo_1_.func_82720_e()).compare(this.func_76459_b(), p_compareTo_1_.func_76459_b()).compare(this.func_188419_a().getGuiSortColor(this), p_compareTo_1_.func_188419_a().getGuiSortColor(this)).result() : ComparisonChain.start().compare(this.func_82720_e(), p_compareTo_1_.func_82720_e()).compare(this.func_188419_a().getGuiSortColor(this), p_compareTo_1_.func_188419_a().getGuiSortColor(this)).result();
}
+
+ /***
+ * Returns a list of curative items for the potion effect
+ * By default, this list is initialized using {@link Potion#getCurativeItems}
+ *
+ * @return The list (ItemStack) of curative items for the potion effect
+ */
+ public java.util.List<net.minecraft.item.ItemStack> getCurativeItems() {
+ if (this.curativeItems == null) { //Lazy load this so that we don't create a circular dep on Items.
+ this.curativeItems = func_188419_a().getCurativeItems();
+ }
+ return this.curativeItems;
+ }
+
+ /***
+ * Checks the given ItemStack to see if it is in the list of curative items for the potion effect
+ * @param stack The ItemStack being checked against the list of curative items for this PotionEffect
+ * @return true if the given ItemStack is in the list of curative items for this PotionEffect, false otherwise
+ */
+ public boolean isCurativeItem(net.minecraft.item.ItemStack stack) {
+ return this.getCurativeItems().stream().anyMatch(e -> e.func_77969_a(stack));
+ }
+
+ /***
+ * Sets the list of curative items for this potion effect, overwriting any already present
+ * @param curativeItems The list of ItemStacks being set to the potion effect
+ */
+ public void setCurativeItems(java.util.List<net.minecraft.item.ItemStack> curativeItems) {
+ this.curativeItems = curativeItems;
+ }
+
+ /***
+ * Adds the given stack to the list of curative items for this PotionEffect
+ * @param stack The ItemStack being added to the curative item list
+ */
+ public void addCurativeItem(net.minecraft.item.ItemStack stack) {
+ if (!this.isCurativeItem(stack)) {
+ this.getCurativeItems().add(stack);
+ }
+ }
+
+ private void writeCurativeItems(NBTTagCompound nbt) {
+ net.minecraft.nbt.NBTTagList list = new net.minecraft.nbt.NBTTagList();
+ for (net.minecraft.item.ItemStack stack : getCurativeItems()) {
+ list.add(stack.func_77955_b(new NBTTagCompound()));
+ }
+ nbt.func_74782_a("CurativeItems", list);
+ }
+
+ private static PotionEffect readCurativeItems(PotionEffect effect, NBTTagCompound nbt) {
+ if (nbt.func_150297_b("CurativeItems", net.minecraftforge.common.util.Constants.NBT.TAG_LIST)) {
+ java.util.List<net.minecraft.item.ItemStack> items = new java.util.ArrayList<net.minecraft.item.ItemStack>();
+ net.minecraft.nbt.NBTTagList list = nbt.func_150295_c("CurativeItems", net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND);
+ for (int i = 0; i < list.size(); i++) {
+ items.add(net.minecraft.item.ItemStack.func_199557_a(list.func_150305_b(i)));
+ }
+ effect.setCurativeItems(items);
+ }
+
+ return effect;
+ }
}

View File

@ -1,11 +1,14 @@
--- a/net/minecraft/potion/PotionType.java
+++ b/net/minecraft/potion/PotionType.java
@@ -7,7 +7,7 @@
@@ -7,9 +7,8 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
-public class PotionType {
- private static final ResourceLocation field_185177_b = new ResourceLocation("empty");
- public static final RegistryNamespacedDefaultedByKey<ResourceLocation, PotionType> field_185176_a = new RegistryNamespacedDefaultedByKey<ResourceLocation, PotionType>(field_185177_b);
+public class PotionType extends net.minecraftforge.registries.ForgeRegistryEntry<PotionType> {
private static final ResourceLocation field_185177_b = new ResourceLocation("empty");
public static final RegistryNamespacedDefaultedByKey<ResourceLocation, PotionType> field_185176_a = new RegistryNamespacedDefaultedByKey<ResourceLocation, PotionType>(field_185177_b);
+ public static final RegistryNamespacedDefaultedByKey<ResourceLocation, PotionType> field_185176_a = net.minecraftforge.registries.GameData.getWrapperDefaulted(PotionType.class);
private final String field_185179_d;
private final ImmutableList<PotionEffect> field_185180_e;

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/world/ChunkCache.java
+++ b/net/minecraft/world/ChunkCache.java
@@ -239,7 +239,7 @@
}
public boolean func_175623_d(BlockPos p_175623_1_) {
- return this.func_180495_p(p_175623_1_).func_196958_f();
+ return this.func_180495_p(p_175623_1_).isAir(this, p_175623_1_);
}
public int func_175642_b(EnumLightType p_175642_1_, BlockPos p_175642_2_) {

View File

@ -26,6 +26,15 @@
}
public IWorld func_175643_b() {
@@ -184,7 +187,7 @@
}
public boolean func_175623_d(BlockPos p_175623_1_) {
- return this.func_180495_p(p_175623_1_).func_196958_f();
+ return this.func_180495_p(p_175623_1_).isAir(this, p_175623_1_);
}
public Chunk func_175726_f(BlockPos p_175726_1_) {
@@ -2397,4 +2400,31 @@
public abstract RecipeManager func_199532_z();

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/world/gen/WorldGenRegion.java
+++ b/net/minecraft/world/gen/WorldGenRegion.java
@@ -128,7 +128,7 @@
}
public boolean func_175623_d(BlockPos p_175623_1_) {
- return this.func_180495_p(p_175623_1_).func_196958_f();
+ return this.func_180495_p(p_175623_1_).isAir(this, p_175623_1_);
}
public Biome func_180494_b(BlockPos p_180494_1_) {

View File

@ -0,0 +1,38 @@
--- a/net/minecraft/world/storage/MapData.java
+++ b/net/minecraft/world/storage/MapData.java
@@ -24,7 +24,7 @@
public class MapData extends WorldSavedData {
public int field_76201_a;
public int field_76199_b;
- public byte field_76200_c;
+ public int field_76200_c; //Forge: byte->int
public boolean field_186210_e;
public boolean field_191096_f;
public byte field_76197_d;
@@ -41,7 +41,7 @@
public void func_195926_a(int p_195926_1_, int p_195926_2_, int p_195926_3_, boolean p_195926_4_, boolean p_195926_5_, int p_195926_6_) {
this.field_76197_d = (byte)p_195926_3_;
this.func_176054_a((double)p_195926_1_, (double)p_195926_2_, this.field_76197_d);
- this.field_76200_c = (byte)p_195926_6_;
+ this.field_76200_c = p_195926_6_;
this.field_186210_e = p_195926_4_;
this.field_191096_f = p_195926_5_;
this.func_76188_b();
@@ -56,7 +56,7 @@
}
public void func_76184_a(NBTTagCompound p_76184_1_) {
- this.field_76200_c = p_76184_1_.func_74771_c("dimension");
+ this.field_76200_c = p_76184_1_.func_74762_e("dimension");
this.field_76201_a = p_76184_1_.func_74762_e("xCenter");
this.field_76199_b = p_76184_1_.func_74762_e("zCenter");
this.field_76197_d = (byte)MathHelper.func_76125_a(p_76184_1_.func_74771_c("scale"), 0, 4);
@@ -78,7 +78,7 @@
}
public NBTTagCompound func_189551_b(NBTTagCompound p_189551_1_) {
- p_189551_1_.func_74774_a("dimension", this.field_76200_c);
+ p_189551_1_.func_74768_a("dimension", this.field_76200_c);
p_189551_1_.func_74768_a("xCenter", this.field_76201_a);
p_189551_1_.func_74768_a("zCenter", this.field_76199_b);
p_189551_1_.func_74774_a("scale", this.field_76197_d);

View File

@ -1,50 +0,0 @@
--- ../src-base/minecraft/net/minecraft/enchantment/Enchantment.java
+++ ../src-work/minecraft/net/minecraft/enchantment/Enchantment.java
@@ -14,9 +14,9 @@
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
-public abstract class Enchantment
+public abstract class Enchantment extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<Enchantment>
{
- public static final RegistryNamespaced<ResourceLocation, Enchantment> field_185264_b = new RegistryNamespaced<ResourceLocation, Enchantment>();
+ public static final RegistryNamespaced<ResourceLocation, Enchantment> field_185264_b = net.minecraftforge.registries.GameData.getWrapper(Enchantment.class);
private final EntityEquipmentSlot[] field_185263_a;
private final Enchantment.Rarity field_77333_a;
@Nullable
@@ -134,7 +134,7 @@
public boolean func_92089_a(ItemStack p_92089_1_)
{
- return this.field_77351_y.func_77557_a(p_92089_1_.func_77973_b());
+ return canApplyAtEnchantingTable(p_92089_1_);
}
public void func_151368_a(EntityLivingBase p_151368_1_, Entity p_151368_2_, int p_151368_3_)
@@ -155,6 +155,26 @@
return false;
}
+ /**
+ * This applies specifically to applying at the enchanting table. The other method {@link #canApply(ItemStack)}
+ * applies for <i>all possible</i> enchantments.
+ * @param stack
+ * @return
+ */
+ public boolean canApplyAtEnchantingTable(ItemStack stack)
+ {
+ return stack.func_77973_b().canApplyAtEnchantingTable(stack, this);
+ }
+
+ /**
+ * Is this enchantment allowed to be enchanted on books via Enchantment Table
+ * @return false to disable the vanilla feature
+ */
+ public boolean isAllowedOnBooks()
+ {
+ return true;
+ }
+
public static void func_185257_f()
{
EntityEquipmentSlot[] aentityequipmentslot = new EntityEquipmentSlot[] {EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET};

View File

@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/enchantment/EnchantmentFrostWalker.java
+++ ../src-work/minecraft/net/minecraft/enchantment/EnchantmentFrostWalker.java
@@ -59,7 +59,7 @@
{
IBlockState iblockstate1 = p_185266_1_.func_180495_p(blockpos$mutableblockpos1);
- if (iblockstate1.func_185904_a() == Material.field_151586_h && ((Integer)iblockstate1.func_177229_b(BlockLiquid.field_176367_b)).intValue() == 0 && p_185266_1_.func_190527_a(Blocks.field_185778_de, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null))
+ if (iblockstate1.func_185904_a() == Material.field_151586_h && (iblockstate1.func_177230_c() == net.minecraft.init.Blocks.field_150355_j || iblockstate1.func_177230_c() == net.minecraft.init.Blocks.field_150358_i) && ((Integer)iblockstate1.func_177229_b(BlockLiquid.field_176367_b)).intValue() == 0 && p_185266_1_.func_190527_a(Blocks.field_185778_de, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null))
{
p_185266_1_.func_175656_a(blockpos$mutableblockpos1, Blocks.field_185778_de.func_176223_P());
p_185266_1_.func_175684_a(blockpos$mutableblockpos1.func_185334_h(), Blocks.field_185778_de, MathHelper.func_76136_a(p_185266_0_.func_70681_au(), 60, 120));

View File

@ -1,57 +0,0 @@
--- ../src-base/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
+++ ../src-work/minecraft/net/minecraft/enchantment/EnchantmentHelper.java
@@ -140,6 +140,7 @@
field_77520_b.field_77497_a = 0;
field_77520_b.field_77496_b = p_77508_1_;
func_77516_a(field_77520_b, p_77508_0_);
+ field_77520_b.field_77496_b = null; //Forge Fix memory leaks: https://bugs.mojang.com/browse/MC-128547
return field_77520_b.field_77497_a;
}
@@ -171,6 +172,9 @@
{
func_77518_a(field_151388_d, p_151384_0_.func_184614_ca());
}
+
+ field_151388_d.field_151363_b = null; //Forge Fix memory leaks: https://bugs.mojang.com/browse/MC-128547
+ field_151388_d.field_151364_a = null;
}
public static void func_151385_b(EntityLivingBase p_151385_0_, Entity p_151385_1_)
@@ -187,6 +191,9 @@
{
func_77518_a(field_151389_e, p_151385_0_.func_184614_ca());
}
+
+ field_151389_e.field_151366_a = null; //Forge Fix memory leaks: https://bugs.mojang.com/browse/MC-128547
+ field_151389_e.field_151365_b = null;
}
public static int func_185284_a(Enchantment p_185284_0_, EntityLivingBase p_185284_1_)
@@ -302,7 +309,7 @@
public static int func_77514_a(Random p_77514_0_, int p_77514_1_, int p_77514_2_, ItemStack p_77514_3_)
{
Item item = p_77514_3_.func_77973_b();
- int i = item.func_77619_b();
+ int i = item.getItemEnchantability(p_77514_3_);
if (i <= 0)
{
@@ -357,7 +364,7 @@
{
List<EnchantmentData> list = Lists.<EnchantmentData>newArrayList();
Item item = p_77513_1_.func_77973_b();
- int i = item.func_77619_b();
+ int i = item.getItemEnchantability(p_77513_1_);
if (i <= 0)
{
@@ -413,7 +420,7 @@
for (Enchantment enchantment : Enchantment.field_185264_b)
{
- if ((!enchantment.func_185261_e() || p_185291_2_) && (enchantment.field_77351_y.func_77557_a(item) || flag))
+ if ((!enchantment.func_185261_e() || p_185291_2_) && (enchantment.canApplyAtEnchantingTable(p_185291_1_) || (flag && enchantment.isAllowedOnBooks())))
{
for (int i = enchantment.func_77325_b(); i > enchantment.func_77319_d() - 1; --i)
{

View File

@ -1,17 +0,0 @@
--- ../src-base/minecraft/net/minecraft/enchantment/EnumEnchantmentType.java
+++ ../src-work/minecraft/net/minecraft/enchantment/EnumEnchantmentType.java
@@ -100,5 +100,13 @@
{
}
- public abstract boolean func_77557_a(Item p_77557_1_);
+ private com.google.common.base.Predicate<Item> delegate = null;
+ private EnumEnchantmentType(com.google.common.base.Predicate<Item> delegate)
+ {
+ this.delegate = delegate;
+ }
+ public boolean func_77557_a(Item p_77557_1_)
+ {
+ return this.delegate == null ? false : this.delegate.apply(p_77557_1_);
+ }
}

View File

@ -325,27 +325,6 @@
this.field_70752_e = true;
}
+ /***
+ * Removes all potion effects that have curativeItem as a curative item for its effect
+ * @param curativeItem The itemstack we are using to cure potion effects
+ */
+ public void curePotionEffects(ItemStack curativeItem)
+ {
+ if (field_70170_p.field_72995_K) return;
+ Iterator<PotionEffect> iterator = this.field_70713_bf.values().iterator();
+
+ while (iterator.hasNext())
+ {
+ PotionEffect effect = iterator.next();
+
+ if (effect.isCurativeItem(curativeItem))
+ {
+ func_70688_c(effect);
+ iterator.remove();
+ this.field_70752_e = true;
+ }
+ }
+ }
+
+ /**
+ * Returns true if the entity's rider (EntityPlayer) should face forward when mounted.

View File

@ -1,867 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/Item.java
+++ ../src-work/minecraft/net/minecraft/item/Item.java
@@ -58,10 +58,10 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
-public class Item
+public class Item extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<Item>
{
- public static final RegistryNamespaced<ResourceLocation, Item> field_150901_e = new RegistryNamespaced<ResourceLocation, Item>();
- private static final Map<Block, Item> field_179220_a = Maps.<Block, Item>newHashMap();
+ public static final RegistryNamespaced<ResourceLocation, Item> field_150901_e = net.minecraftforge.registries.GameData.getWrapper(Item.class);
+ private static final Map<Block, Item> field_179220_a = net.minecraftforge.registries.GameData.getBlockItemMap();
private static final IItemPropertyGetter field_185046_b = new IItemPropertyGetter()
{
@SideOnly(Side.CLIENT)
@@ -197,6 +197,7 @@
return p_77654_1_;
}
+ @Deprecated // Use ItemStack sensitive version below.
public int func_77639_j()
{
return this.field_77777_bU;
@@ -218,6 +219,7 @@
return this;
}
+ @Deprecated
public int func_77612_l()
{
return this.field_77699_b;
@@ -317,6 +319,7 @@
return this.field_77700_c;
}
+ @Deprecated // Use ItemStack sensitive version below.
public boolean func_77634_r()
{
return this.field_77700_c != null;
@@ -372,7 +375,7 @@
public boolean func_77616_k(ItemStack p_77616_1_)
{
- return this.func_77639_j() == 1 && this.func_77645_m();
+ return this.getItemStackLimit(p_77616_1_) == 1 && this.func_77645_m();
}
protected RayTraceResult func_77621_a(World p_77621_1_, EntityPlayer p_77621_2_, boolean p_77621_3_)
@@ -389,8 +392,8 @@
float f5 = MathHelper.func_76126_a(-f * 0.017453292F);
float f6 = f3 * f4;
float f7 = f2 * f4;
- double d3 = 5.0D;
- Vec3d vec3d1 = vec3d.func_72441_c((double)f6 * 5.0D, (double)f5 * 5.0D, (double)f7 * 5.0D);
+ double d3 = p_77621_2_.func_110148_a(EntityPlayer.REACH_DISTANCE).func_111126_e();
+ Vec3d vec3d1 = vec3d.func_72441_c((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
return p_77621_1_.func_147447_a(vec3d, vec3d1, p_77621_3_, !p_77621_3_, false);
}
@@ -409,6 +412,9 @@
protected boolean func_194125_a(CreativeTabs p_194125_1_)
{
+ for (CreativeTabs tab : this.getCreativeTabs())
+ if (tab == p_194125_1_)
+ return true;
CreativeTabs creativetabs = this.func_77640_w();
return creativetabs != null && (p_194125_1_ == CreativeTabs.field_78027_g || p_194125_1_ == creativetabs);
}
@@ -435,11 +441,757 @@
return false;
}
+ @Deprecated // Use ItemStack sensitive version below.
public Multimap<String, AttributeModifier> func_111205_h(EntityEquipmentSlot p_111205_1_)
{
return HashMultimap.<String, AttributeModifier>create();
}
+ /* ======================================== FORGE START =====================================*/
+ /**
+ * ItemStack sensitive version of getItemAttributeModifiers
+ */
+ public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
+ {
+ return this.func_111205_h(slot);
+ }
+
+ /**
+ * Called when a player drops the item into the world,
+ * returning false from this will prevent the item from
+ * being removed from the players inventory and spawning
+ * in the world
+ *
+ * @param player The player that dropped the item
+ * @param item The item stack, before the item is removed.
+ */
+ public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player)
+ {
+ return true;
+ }
+
+ /**
+ * Allow the item one last chance to modify its name used for the
+ * tool highlight useful for adding something extra that can't be removed
+ * by a user in the displayed name, such as a mode of operation.
+ *
+ * @param item the ItemStack for the item.
+ * @param displayName the name that will be displayed unless it is changed in this method.
+ */
+ public String getHighlightTip( ItemStack item, String displayName )
+ {
+ return displayName;
+ }
+
+ /**
+ * This is called when the item is used, before the block is activated.
+ * @param stack The Item Stack
+ * @param player The Player that used the item
+ * @param world The Current World
+ * @param pos Target position
+ * @param side The side of the target hit
+ * @param hand Which hand the item is being held in.
+ * @return Return PASS to allow vanilla handling, any other to skip normal code.
+ */
+ public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
+ {
+ return EnumActionResult.PASS;
+ }
+
+ protected boolean canRepair = true;
+ /**
+ * Called by CraftingManager to determine if an item is reparable.
+ * @return True if reparable
+ */
+ public boolean isRepairable()
+ {
+ return canRepair && func_77645_m();
+ }
+
+ /**
+ * Call to disable repair recipes.
+ * @return The current Item instance
+ */
+ public Item setNoRepair()
+ {
+ canRepair = false;
+ return this;
+ }
+
+ /**
+ * Override this method to change the NBT data being sent to the client.
+ * You should ONLY override this when you have no other choice, as this might change behavior client side!
+ *
+ * Note that this will sometimes be applied multiple times, the following MUST be supported:
+ * Item item = stack.getItem();
+ * NBTTagCompound nbtShare1 = item.getNBTShareTag(stack);
+ * stack.setTagCompound(nbtShare1);
+ * NBTTagCompound nbtShare2 = item.getNBTShareTag(stack);
+ * assert nbtShare1.equals(nbtShare2);
+ *
+ * @param stack The stack to send the NBT tag for
+ * @return The NBT tag
+ */
+ @Nullable
+ public NBTTagCompound getNBTShareTag(ItemStack stack)
+ {
+ return stack.func_77978_p();
+ }
+
+ /**
+ * Override this method to decide what to do with the NBT data received from getNBTShareTag().
+ *
+ * @param stack The stack that received NBT
+ * @param nbt Received NBT, can be null
+ */
+ public void readNBTShareTag(ItemStack stack, @Nullable NBTTagCompound nbt)
+ {
+ stack.func_77982_d(nbt);
+ }
+
+ /**
+ * Called before a block is broken. Return true to prevent default block harvesting.
+ *
+ * Note: In SMP, this is called on both client and server sides!
+ *
+ * @param itemstack The current ItemStack
+ * @param pos Block's position in world
+ * @param player The Player that is wielding the item
+ * @return True to prevent harvesting, false to continue as normal
+ */
+ public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player)
+ {
+ return false;
+ }
+
+ /**
+ * Called each tick while using an item.
+ * @param stack The Item being used
+ * @param player The Player using the item
+ * @param count The amount of time in tick the item has been used for continuously
+ */
+ public void onUsingTick(ItemStack stack, EntityLivingBase player, int count)
+ {
+ }
+
+ /**
+ * Called when the player Left Clicks (attacks) an entity.
+ * Processed before damage is done, if return value is true further processing is canceled
+ * and the entity is not attacked.
+ *
+ * @param stack The Item being used
+ * @param player The player that is attacking
+ * @param entity The entity being attacked
+ * @return True to cancel the rest of the interaction.
+ */
+ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
+ {
+ return false;
+ }
+
+ /**
+ * ItemStack sensitive version of getContainerItem.
+ * Returns a full ItemStack instance of the result.
+ *
+ * @param itemStack The current ItemStack
+ * @return The resulting ItemStack
+ */
+ public ItemStack getContainerItem(ItemStack itemStack)
+ {
+ if (!hasContainerItem(itemStack))
+ {
+ return ItemStack.field_190927_a;
+ }
+ return new ItemStack(func_77668_q());
+ }
+
+ /**
+ * ItemStack sensitive version of hasContainerItem
+ * @param stack The current item stack
+ * @return True if this item has a 'container'
+ */
+ public boolean hasContainerItem(ItemStack stack)
+ {
+ return func_77634_r();
+ }
+
+ /**
+ * Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem.
+ * This is in ticks, standard result is 6000, or 5 mins.
+ *
+ * @param itemStack The current ItemStack
+ * @param world The world the entity is in
+ * @return The normal lifespan in ticks.
+ */
+ public int getEntityLifespan(ItemStack itemStack, World world)
+ {
+ return 6000;
+ }
+
+ /**
+ * Determines if this Item has a special entity for when they are in the world.
+ * Is called when a EntityItem is spawned in the world, if true and Item#createCustomEntity
+ * returns non null, the EntityItem will be destroyed and the new Entity will be added to the world.
+ *
+ * @param stack The current item stack
+ * @return True of the item has a custom entity, If true, Item#createCustomEntity will be called
+ */
+ public boolean hasCustomEntity(ItemStack stack)
+ {
+ return false;
+ }
+
+ /**
+ * This function should return a new entity to replace the dropped item.
+ * Returning null here will not kill the EntityItem and will leave it to function normally.
+ * Called when the item it placed in a world.
+ *
+ * @param world The world object
+ * @param location The EntityItem object, useful for getting the position of the entity
+ * @param itemstack The current item stack
+ * @return A new Entity object to spawn or null
+ */
+ @Nullable
+ public Entity createEntity(World world, Entity location, ItemStack itemstack)
+ {
+ return null;
+ }
+
+ /**
+ * Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner
+ * control over the update of the item without having to write a subclass.
+ *
+ * @param entityItem The entity Item
+ * @return Return true to skip any further update code.
+ */
+ public boolean onEntityItemUpdate(net.minecraft.entity.item.EntityItem entityItem)
+ {
+ return false;
+ }
+
+ /**
+ * Gets a list of tabs that items belonging to this class can display on,
+ * combined properly with getSubItems allows for a single item to span
+ * many sub-items across many tabs.
+ *
+ * @return A list of all tabs that this item could possibly be one.
+ */
+ public CreativeTabs[] getCreativeTabs()
+ {
+ return new CreativeTabs[]{ func_77640_w() };
+ }
+
+ /**
+ * Determines the base experience for a player when they remove this item from a furnace slot.
+ * This number must be between 0 and 1 for it to be valid.
+ * This number will be multiplied by the stack size to get the total experience.
+ *
+ * @param item The item stack the player is picking up.
+ * @return The amount to award for each item.
+ */
+ public float getSmeltingExperience(ItemStack item)
+ {
+ return -1; //-1 will default to the old lookups.
+ }
+
+ /**
+ *
+ * Should this item, when held, allow sneak-clicks to pass through to the underlying block?
+ *
+ * @param world The world
+ * @param pos Block position in world
+ * @param player The Player that is wielding the item
+ * @return
+ */
+ public boolean doesSneakBypassUse(ItemStack stack, net.minecraft.world.IBlockAccess world, BlockPos pos, EntityPlayer player)
+ {
+ return false;
+ }
+
+ /**
+ * Called to tick armor in the armor slot. Override to do something
+ */
+ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack){}
+
+ /**
+ * Determines if the specific ItemStack can be placed in the specified armor slot, for the entity.
+ *
+ * TODO: Change name to canEquip in 1.13?
+ *
+ * @param stack The ItemStack
+ * @param armorType Armor slot to be verified.
+ * @param entity The entity trying to equip the armor
+ * @return True if the given ItemStack can be inserted in the slot
+ */
+ public boolean isValidArmor(ItemStack stack, EntityEquipmentSlot armorType, Entity entity)
+ {
+ return net.minecraft.entity.EntityLiving.func_184640_d(stack) == armorType;
+ }
+
+ /**
+ * Override this to set a non-default armor slot for an ItemStack, but
+ * <em>do not use this to get the armor slot of said stack; for that, use
+ * {@link net.minecraft.entity.EntityLiving#getSlotForItemStack(ItemStack)}.</em>
+ *
+ * @param stack the ItemStack
+ * @return the armor slot of the ItemStack, or {@code null} to let the default
+ * vanilla logic as per {@code EntityLiving.getSlotForItemStack(stack)} decide
+ */
+ @Nullable
+ public EntityEquipmentSlot getEquipmentSlot(ItemStack stack)
+ {
+ return null;
+ }
+
+ /**
+ * Allow or forbid the specific book/item combination as an anvil enchant
+ *
+ * @param stack The item
+ * @param book The book
+ * @return if the enchantment is allowed
+ */
+ public boolean isBookEnchantable(ItemStack stack, ItemStack book)
+ {
+ return true;
+ }
+
+ /**
+ * Called by RenderBiped and RenderPlayer to determine the armor texture that
+ * should be use for the currently equipped item.
+ * This will only be called on instances of ItemArmor.
+ *
+ * Returning null from this function will use the default value.
+ *
+ * @param stack ItemStack for the equipped armor
+ * @param entity The entity wearing the armor
+ * @param slot The slot the armor is in
+ * @param type The subtype, can be null or "overlay"
+ * @return Path of texture to bind, or null to use default
+ */
+ @Nullable
+ public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the font renderer used to render tooltips and overlays for this item.
+ * Returning null will use the standard font renderer.
+ *
+ * @param stack The current item stack
+ * @return A instance of FontRenderer or null to use default
+ */
+ @SideOnly(Side.CLIENT)
+ @Nullable
+ public net.minecraft.client.gui.FontRenderer getFontRenderer(ItemStack stack)
+ {
+ return null;
+ }
+
+ /**
+ * Override this method to have an item handle its own armor rendering.
+ *
+ * @param entityLiving The entity wearing the armor
+ * @param itemStack The itemStack to render the model of
+ * @param armorSlot The slot the armor is in
+ * @param _default Original armor model. Will have attributes set.
+ * @return A ModelBiped to render instead of the default
+ */
+ @SideOnly(Side.CLIENT)
+ @Nullable
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, net.minecraft.client.model.ModelBiped _default)
+ {
+ return null;
+ }
+
+ /**
+ * Called when a entity tries to play the 'swing' animation.
+ *
+ * @param entityLiving The entity swinging the item.
+ * @param stack The Item stack
+ * @return True to cancel any further processing by EntityLiving
+ */
+ public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
+ {
+ return false;
+ }
+
+ /**
+ * Called when the client starts rendering the HUD, for whatever item the player currently has as a helmet.
+ * This is where pumpkins would render there overlay.
+ *
+ * @param stack The ItemStack that is equipped
+ * @param player Reference to the current client entity
+ * @param resolution Resolution information about the current viewport and configured GUI Scale
+ * @param partialTicks Partial ticks for the renderer, useful for interpolation
+ */
+ @SideOnly(Side.CLIENT)
+ public void renderHelmetOverlay(ItemStack stack, EntityPlayer player, net.minecraft.client.gui.ScaledResolution resolution, float partialTicks){}
+
+ /**
+ * Return the itemDamage represented by this ItemStack. Defaults to the itemDamage field on ItemStack, but can be overridden here for other sources such as NBT.
+ *
+ * @param stack The itemstack that is damaged
+ * @return the damage value
+ */
+ public int getDamage(ItemStack stack)
+ {
+ return stack.field_77991_e;
+ }
+
+ /**
+ * This used to be 'display damage' but its really just 'aux' data in the ItemStack, usually shares the same variable as damage.
+ * @param stack
+ * @return
+ */
+ public int getMetadata(ItemStack stack)
+ {
+ return stack.field_77991_e;
+ }
+
+ /**
+ * Determines if the durability bar should be rendered for this item.
+ * Defaults to vanilla stack.isDamaged behavior.
+ * But modders can use this for any data they wish.
+ *
+ * @param stack The current Item Stack
+ * @return True if it should render the 'durability' bar.
+ */
+ public boolean showDurabilityBar(ItemStack stack)
+ {
+ return stack.func_77951_h();
+ }
+
+ /**
+ * Queries the percentage of the 'Durability' bar that should be drawn.
+ *
+ * @param stack The current ItemStack
+ * @return 0.0 for 100% (no damage / full bar), 1.0 for 0% (fully damaged / empty bar)
+ */
+ public double getDurabilityForDisplay(ItemStack stack)
+ {
+ return (double)stack.func_77952_i() / (double)stack.func_77958_k();
+ }
+
+ /**
+ * Returns the packed int RGB value used to render the durability bar in the GUI.
+ * Defaults to a value based on the hue scaled based on {@link #getDurabilityForDisplay}, but can be overriden.
+ *
+ * @param stack Stack to get durability from
+ * @return A packed RGB value for the durability colour (0x00RRGGBB)
+ */
+ public int getRGBDurabilityForDisplay(ItemStack stack)
+ {
+ return MathHelper.func_181758_c(Math.max(0.0F, (float) (1.0F - getDurabilityForDisplay(stack))) / 3.0F, 1.0F, 1.0F);
+ }
+ /**
+ * Return the maxDamage for this ItemStack. Defaults to the maxDamage field in this item,
+ * but can be overridden here for other sources such as NBT.
+ *
+ * @param stack The itemstack that is damaged
+ * @return the damage value
+ */
+ public int getMaxDamage(ItemStack stack)
+ {
+ return func_77612_l();
+ }
+
+ /**
+ * Return if this itemstack is damaged. Note only called if {@link #isDamageable()} is true.
+ * @param stack the stack
+ * @return if the stack is damaged
+ */
+ public boolean isDamaged(ItemStack stack)
+ {
+ return stack.field_77991_e > 0;
+ }
+
+ /**
+ * Set the damage for this itemstack. Note, this method is responsible for zero checking.
+ * @param stack the stack
+ * @param damage the new damage value
+ */
+ public void setDamage(ItemStack stack, int damage)
+ {
+ stack.field_77991_e = damage;
+
+ if (stack.field_77991_e < 0)
+ {
+ stack.field_77991_e = 0;
+ }
+ }
+
+ /**
+ * Checked from {@link net.minecraft.client.multiplayer.PlayerControllerMP#onPlayerDestroyBlock(BlockPos pos) PlayerControllerMP.onPlayerDestroyBlock()}
+ * when a creative player left-clicks a block with this item.
+ * Also checked from {@link net.minecraftforge.common.ForgeHooks#onBlockBreakEvent(World, GameType, EntityPlayerMP, BlockPos) ForgeHooks.onBlockBreakEvent()}
+ * to prevent sending an event.
+ * @return true if the given player can destroy specified block in creative mode with this item
+ */
+ public boolean canDestroyBlockInCreative(World world, BlockPos pos, ItemStack stack, EntityPlayer player)
+ {
+ return !(this instanceof ItemSword);
+ }
+
+ /**
+ * ItemStack sensitive version of {@link #canHarvestBlock(IBlockState)}
+ * @param state The block trying to harvest
+ * @param stack The itemstack used to harvest the block
+ * @return true if can harvest the block
+ */
+ public boolean canHarvestBlock(IBlockState state, ItemStack stack)
+ {
+ return func_150897_b(state);
+ }
+
+ /**
+ * Gets the maximum number of items that this stack should be able to hold.
+ * This is a ItemStack (and thus NBT) sensitive version of Item.getItemStackLimit()
+ *
+ * @param stack The ItemStack
+ * @return The maximum number this item can be stacked to
+ */
+ public int getItemStackLimit(ItemStack stack)
+ {
+ return this.func_77639_j();
+ }
+
+ private java.util.Map<String, Integer> toolClasses = new java.util.HashMap<String, Integer>();
+ /**
+ * Sets or removes the harvest level for the specified tool class.
+ *
+ * @param toolClass Class
+ * @param level Harvest level:
+ * Wood: 0
+ * Stone: 1
+ * Iron: 2
+ * Diamond: 3
+ * Gold: 0
+ */
+ public void setHarvestLevel(String toolClass, int level)
+ {
+ if (level < 0)
+ toolClasses.remove(toolClass);
+ else
+ toolClasses.put(toolClass, level);
+ }
+
+ public java.util.Set<String> getToolClasses(ItemStack stack)
+ {
+ return toolClasses.keySet();
+ }
+
+ /**
+ * Queries the harvest level of this item stack for the specified tool class,
+ * Returns -1 if this tool is not of the specified type
+ *
+ * @param stack This item stack instance
+ * @param toolClass Tool Class
+ * @param player The player trying to harvest the given blockstate
+ * @param blockState The block to harvest
+ * @return Harvest level, or -1 if not the specified tool type.
+ */
+ public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState)
+ {
+ Integer ret = toolClasses.get(toolClass);
+ return ret == null ? -1 : ret;
+ }
+
+ /**
+ * ItemStack sensitive version of getItemEnchantability
+ *
+ * @param stack The ItemStack
+ * @return the item echantability value
+ */
+ public int getItemEnchantability(ItemStack stack)
+ {
+ return func_77619_b();
+ }
+
+ /**
+ * Checks whether an item can be enchanted with a certain enchantment. This applies specifically to enchanting an item in the enchanting table and is called when retrieving the list of possible enchantments for an item.
+ * Enchantments may additionally (or exclusively) be doing their own checks in {@link net.minecraft.enchantment.Enchantment#canApplyAtEnchantingTable(ItemStack)}; check the individual implementation for reference.
+ * By default this will check if the enchantment type is valid for this item type.
+ * @param stack the item stack to be enchanted
+ * @param enchantment the enchantment to be applied
+ * @return true if the enchantment can be applied to this item
+ */
+ public boolean canApplyAtEnchantingTable(ItemStack stack, net.minecraft.enchantment.Enchantment enchantment)
+ {
+ return enchantment.field_77351_y.func_77557_a(stack.func_77973_b());
+ }
+
+ /**
+ * Whether this Item can be used as a payment to activate the vanilla beacon.
+ * @param stack the ItemStack
+ * @return true if this Item can be used
+ */
+ public boolean isBeaconPayment(ItemStack stack)
+ {
+ return this == Items.field_151166_bC || this == Items.field_151045_i || this == Items.field_151043_k || this == Items.field_151042_j;
+ }
+
+ /**
+ * Determine if the player switching between these two item stacks
+ * @param oldStack The old stack that was equipped
+ * @param newStack The new stack
+ * @param slotChanged If the current equipped slot was changed,
+ * Vanilla does not play the animation if you switch between two
+ * slots that hold the exact same item.
+ * @return True to play the item change animation
+ */
+ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
+ {
+ return !oldStack.equals(newStack); //!ItemStack.areItemStacksEqual(oldStack, newStack);
+ }
+
+ /**
+ * Called when the player is mining a block and the item in his hand changes.
+ * Allows to not reset blockbreaking if only NBT or similar changes.
+ * @param oldStack The old stack that was used for mining. Item in players main hand
+ * @param newStack The new stack
+ * @return True to reset block break progress
+ */
+ public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack)
+ {
+ return !(newStack.func_77973_b() == oldStack.func_77973_b() && ItemStack.func_77970_a(newStack, oldStack) && (newStack.func_77984_f() || newStack.func_77960_j() == oldStack.func_77960_j()));
+ }
+
+ /**
+ * Called to get the Mod ID of the mod that *created* the ItemStack,
+ * instead of the real Mod ID that *registered* it.
+ *
+ * For example the Forge Universal Bucket creates a subitem for each modded fluid,
+ * and it returns the modded fluid's Mod ID here.
+ *
+ * Mods that register subitems for other mods can override this.
+ * Informational mods can call it to show the mod that created the item.
+ *
+ * @param itemStack the ItemStack to check
+ * @return the Mod ID for the ItemStack, or
+ * null when there is no specially associated mod and {@link #getRegistryName()} would return null.
+ */
+ @Nullable
+ public String getCreatorModId(ItemStack itemStack)
+ {
+ return net.minecraftforge.common.ForgeHooks.getDefaultCreatorModId(itemStack);
+ }
+
+ /**
+ * Called from ItemStack.setItem, will hold extra data for the life of this ItemStack.
+ * Can be retrieved from stack.getCapabilities()
+ * The NBT can be null if this is not called from readNBT or if the item the stack is
+ * changing FROM is different then this item, or the previous item had no capabilities.
+ *
+ * This is called BEFORE the stacks item is set so you can use stack.getItem() to see the OLD item.
+ * Remember that getItem CAN return null.
+ *
+ * @param stack The ItemStack
+ * @param nbt NBT of this item serialized, or null.
+ * @return A holder instance associated with this ItemStack where you can hold capabilities for the life of this item.
+ */
+ @Nullable
+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt)
+ {
+ return null;
+ }
+
+ public com.google.common.collect.ImmutableMap<String, net.minecraftforge.common.animation.ITimeValue> getAnimationParameters(final ItemStack stack, final World world, final EntityLivingBase entity)
+ {
+ com.google.common.collect.ImmutableMap.Builder<String, net.minecraftforge.common.animation.ITimeValue> builder = com.google.common.collect.ImmutableMap.builder();
+ for(ResourceLocation location : field_185051_m.func_148742_b())
+ {
+ final IItemPropertyGetter parameter = field_185051_m.func_82594_a(location);
+ builder.put(location.toString(), new net.minecraftforge.common.animation.ITimeValue()
+ {
+ public float apply(float input)
+ {
+ return parameter.func_185085_a(stack, world, entity);
+ }
+ });
+ }
+ return builder.build();
+ }
+
+ /**
+ * Can this Item disable a shield
+ * @param stack The ItemStack
+ * @param shield The shield in question
+ * @param entity The EntityLivingBase holding the shield
+ * @param attacker The EntityLivingBase holding the ItemStack
+ * @retrun True if this ItemStack can disable the shield in question.
+ */
+ public boolean canDisableShield(ItemStack stack, ItemStack shield, EntityLivingBase entity, EntityLivingBase attacker)
+ {
+ return this instanceof ItemAxe;
+ }
+
+ /**
+ * Is this Item a shield
+ * @param stack The ItemStack
+ * @param entity The Entity holding the ItemStack
+ * @return True if the ItemStack is considered a shield
+ */
+ public boolean isShield(ItemStack stack, @Nullable EntityLivingBase entity)
+ {
+ return stack.func_77973_b() == Items.field_185159_cQ;
+ }
+
+ /**
+ * @return the fuel burn time for this itemStack in a furnace.
+ * Return 0 to make it not act as a fuel.
+ * Return -1 to let the default vanilla logic decide.
+ */
+ public int getItemBurnTime(ItemStack itemStack)
+ {
+ return -1;
+ }
+
+ /**
+ * Returns an enum constant of type {@code HorseArmorType}.
+ * The returned enum constant will be used to determine the armor value and texture of this item when equipped.
+ * @param stack the armor stack
+ * @return an enum constant of type {@code HorseArmorType}. Return HorseArmorType.NONE if this is not horse armor
+ */
+ public net.minecraft.entity.passive.HorseArmorType getHorseArmorType(ItemStack stack)
+ {
+ return net.minecraft.entity.passive.HorseArmorType.func_188576_a(stack.func_77973_b());
+ }
+
+ public String getHorseArmorTexture(net.minecraft.entity.EntityLiving wearer, ItemStack stack)
+ {
+ return getHorseArmorType(stack).func_188574_d();
+ }
+
+ /**
+ * Called every tick from {@link EntityHorse#onUpdate()} on the item in the armor slot.
+ * @param world the world the horse is in
+ * @param horse the horse wearing this armor
+ * @param armor the armor itemstack
+ */
+ public void onHorseArmorTick(World world, net.minecraft.entity.EntityLiving horse, ItemStack armor) {}
+
+ @SideOnly(Side.CLIENT)
+ @Nullable
+ private net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer teisr;
+
+ /**
+ * @return This Item's renderer, or the default instance if it does not have one.
+ */
+ @SideOnly(Side.CLIENT)
+ public final net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer getTileEntityItemStackRenderer()
+ {
+ return teisr != null ? teisr : net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer.field_147719_a;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void setTileEntityItemStackRenderer(@Nullable net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer teisr)
+ {
+ this.teisr = teisr;
+ }
+
+ /* ======================================== FORGE END =====================================*/
+
public static void func_150900_l()
{
func_179214_a(Blocks.field_150350_a, new ItemAir(Blocks.field_150350_a));
@@ -999,6 +1751,8 @@
private final float field_78010_h;
private final float field_78011_i;
private final int field_78008_j;
+ //Added by forge for custom Tool materials.
+ private ItemStack repairMaterial = ItemStack.field_190927_a;
private ToolMaterial(int p_i1874_3_, int p_i1874_4_, float p_i1874_5_, float p_i1874_6_, int p_i1874_7_)
{
@@ -1034,6 +1788,7 @@
return this.field_78008_j;
}
+ @Deprecated // Use getRepairItemStack below
public Item func_150995_f()
{
if (this == WOOD)
@@ -1057,5 +1812,21 @@
return this == DIAMOND ? Items.field_151045_i : null;
}
}
+
+ public ToolMaterial setRepairItem(ItemStack stack)
+ {
+ if (!this.repairMaterial.func_190926_b()) throw new RuntimeException("Repair material has already been set");
+ if (this == WOOD || this == STONE || this == GOLD || this == IRON || this == DIAMOND) throw new RuntimeException("Can not change vanilla tool repair materials");
+ this.repairMaterial = stack;
+ return this;
+ }
+
+ public ItemStack getRepairItemStack()
+ {
+ if (!repairMaterial.func_190926_b()) return repairMaterial;
+ Item ret = this.func_150995_f();
+ if (ret != null) repairMaterial = new ItemStack(ret, 1, net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE);
+ return repairMaterial;
+ }
}
}

View File

@ -1,72 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemArmor.java
+++ ../src-work/minecraft/net/minecraft/item/ItemArmor.java
@@ -187,7 +187,9 @@
public boolean func_82789_a(ItemStack p_82789_1_, ItemStack p_82789_2_)
{
- return this.field_77878_bZ.func_151685_b() == p_82789_2_.func_77973_b() ? true : super.func_82789_a(p_82789_1_, p_82789_2_);
+ ItemStack mat = this.field_77878_bZ.getRepairItemStack();
+ if (!mat.func_190926_b() && net.minecraftforge.oredict.OreDictionary.itemMatches(mat,p_82789_2_,false)) return true;
+ return super.func_82789_a(p_82789_1_, p_82789_2_);
}
public ActionResult<ItemStack> func_77659_a(World p_77659_1_, EntityPlayer p_77659_2_, EnumHand p_77659_3_)
@@ -221,6 +223,19 @@
return multimap;
}
+ /**
+ * Determines if this armor will be rendered with the secondary 'overlay' texture.
+ * If this is true, the first texture will be rendered using a tint of the color
+ * specified by getColor(ItemStack)
+ *
+ * @param stack The stack
+ * @return true/false
+ */
+ public boolean hasOverlay(ItemStack stack)
+ {
+ return this.field_77878_bZ == ItemArmor.ArmorMaterial.LEATHER || func_82814_b(stack) != 0x00FFFFFF;
+ }
+
public static enum ArmorMaterial
{
LEATHER("leather", 5, new int[]{1, 2, 3, 1}, 15, SoundEvents.field_187728_s, 0.0F),
@@ -235,6 +250,8 @@
private final int field_78055_h;
private final SoundEvent field_185020_j;
private final float field_189417_k;
+ //Added by forge for custom Armor materials.
+ public ItemStack repairMaterial = ItemStack.field_190927_a;
private ArmorMaterial(String p_i47117_3_, int p_i47117_4_, int[] p_i47117_5_, int p_i47117_6_, SoundEvent p_i47117_7_, float p_i47117_8_)
{
@@ -266,6 +283,7 @@
return this.field_185020_j;
}
+ @Deprecated // Use getRepairItemStack below
public Item func_151685_b()
{
if (this == LEATHER)
@@ -300,5 +318,21 @@
{
return this.field_189417_k;
}
+
+ public ArmorMaterial setRepairItem(ItemStack stack)
+ {
+ if (!this.repairMaterial.func_190926_b()) throw new RuntimeException("Repair material has already been set");
+ if (this == LEATHER || this == CHAIN || this == GOLD || this == IRON || this == DIAMOND) throw new RuntimeException("Can not change vanilla armor repair materials");
+ this.repairMaterial = stack;
+ return this;
+ }
+
+ public ItemStack getRepairItemStack()
+ {
+ if (!repairMaterial.func_190926_b()) return repairMaterial;
+ Item ret = this.func_151685_b();
+ if (ret != null) repairMaterial = new ItemStack(ret,1,net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE);
+ return repairMaterial;
+ }
}
}

View File

@ -1,13 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemArrow.java
+++ ../src-work/minecraft/net/minecraft/item/ItemArrow.java
@@ -19,4 +19,10 @@
entitytippedarrow.func_184555_a(p_185052_2_);
return entitytippedarrow;
}
+
+ public boolean isInfinite(ItemStack stack, ItemStack bow, net.minecraft.entity.player.EntityPlayer player)
+ {
+ int enchant = net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.init.Enchantments.field_185312_x, bow);
+ return enchant <= 0 ? false : this.getClass() == ItemArrow.class;
+ }
}

View File

@ -1,16 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemAxe.java
+++ ../src-work/minecraft/net/minecraft/item/ItemAxe.java
@@ -20,6 +20,13 @@
this.field_185065_c = field_185067_n[p_i45327_1_.ordinal()];
}
+ protected ItemAxe(Item.ToolMaterial material, float damage, float speed)
+ {
+ super(material, field_150917_c);
+ this.field_77865_bY = damage;
+ this.field_185065_c = speed;
+ }
+
public float func_150893_a(ItemStack p_150893_1_, IBlockState p_150893_2_)
{
Material material = p_150893_2_.func_185904_a();

View File

@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemBed.java
+++ ../src-work/minecraft/net/minecraft/item/ItemBed.java
@@ -67,7 +67,7 @@
IBlockState iblockstate2 = Blocks.field_150324_C.func_176223_P().func_177226_a(BlockBed.field_176471_b, Boolean.valueOf(false)).func_177226_a(BlockBed.field_185512_D, enumfacing).func_177226_a(BlockBed.field_176472_a, BlockBed.EnumPartType.FOOT);
p_180614_2_.func_180501_a(p_180614_3_, iblockstate2, 10);
p_180614_2_.func_180501_a(blockpos, iblockstate2.func_177226_a(BlockBed.field_176472_a, BlockBed.EnumPartType.HEAD), 10);
- SoundType soundtype = iblockstate2.func_177230_c().func_185467_w();
+ SoundType soundtype = iblockstate2.func_177230_c().getSoundType(iblockstate2, p_180614_2_, p_180614_3_, p_180614_1_);
p_180614_2_.func_184133_a((EntityPlayer)null, p_180614_3_, soundtype.func_185841_e(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F);
TileEntity tileentity = p_180614_2_.func_175625_s(blockpos);

View File

@ -1,35 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemBlockSpecial.java
+++ ../src-work/minecraft/net/minecraft/item/ItemBlockSpecial.java
@@ -43,7 +43,7 @@
if (!itemstack.func_190926_b() && p_180614_1_.func_175151_a(p_180614_3_, p_180614_5_, itemstack) && p_180614_2_.func_190527_a(this.field_150935_a, p_180614_3_, false, p_180614_5_, (Entity)null))
{
- IBlockState iblockstate1 = this.field_150935_a.func_180642_a(p_180614_2_, p_180614_3_, p_180614_5_, p_180614_6_, p_180614_7_, p_180614_8_, 0, p_180614_1_);
+ IBlockState iblockstate1 = this.field_150935_a.getStateForPlacement(p_180614_2_, p_180614_3_, p_180614_5_, p_180614_6_, p_180614_7_, p_180614_8_, 0, p_180614_1_, p_180614_4_);
if (!p_180614_2_.func_180501_a(p_180614_3_, iblockstate1, 11))
{
@@ -64,7 +64,7 @@
}
}
- SoundType soundtype = this.field_150935_a.func_185467_w();
+ SoundType soundtype = iblockstate1.func_177230_c().getSoundType(iblockstate1, p_180614_2_, p_180614_3_, p_180614_1_);
p_180614_2_.func_184133_a(p_180614_1_, p_180614_3_, soundtype.func_185841_e(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F);
itemstack.func_190918_g(1);
return EnumActionResult.SUCCESS;
@@ -75,4 +75,14 @@
return EnumActionResult.FAIL;
}
}
+
+ public Block getBlock()
+ {
+ return this.getBlockRaw() == null ? null : this.getBlockRaw().delegate.get();
+ }
+
+ private Block getBlockRaw()
+ {
+ return this.field_150935_a;
+ }
}

View File

@ -1,37 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemBow.java
+++ ../src-work/minecraft/net/minecraft/item/ItemBow.java
@@ -90,6 +90,10 @@
boolean flag = entityplayer.field_71075_bZ.field_75098_d || EnchantmentHelper.func_77506_a(Enchantments.field_185312_x, p_77615_1_) > 0;
ItemStack itemstack = this.func_185060_a(entityplayer);
+ int i = this.func_77626_a(p_77615_1_) - p_77615_4_;
+ i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(p_77615_1_, p_77615_2_, entityplayer, i, !itemstack.func_190926_b() || flag);
+ if (i < 0) return;
+
if (!itemstack.func_190926_b() || flag)
{
if (itemstack.func_190926_b())
@@ -97,12 +101,11 @@
itemstack = new ItemStack(Items.field_151032_g);
}
- int i = this.func_77626_a(p_77615_1_) - p_77615_4_;
float f = func_185059_b(i);
if ((double)f >= 0.1D)
{
- boolean flag1 = flag && itemstack.func_77973_b() == Items.field_151032_g;
+ boolean flag1 = entityplayer.field_71075_bZ.field_75098_d || (itemstack.func_77973_b() instanceof ItemArrow && ((ItemArrow) itemstack.func_77973_b()).isInfinite(itemstack, p_77615_1_, entityplayer));
if (!p_77615_2_.field_72995_K)
{
@@ -190,6 +193,9 @@
ItemStack itemstack = p_77659_2_.func_184586_b(p_77659_3_);
boolean flag = !this.func_185060_a(p_77659_2_).func_190926_b();
+ ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, p_77659_1_, p_77659_2_, p_77659_3_, flag);
+ if (ret != null) return ret;
+
if (!p_77659_2_.field_71075_bZ.field_75098_d && !flag)
{
return flag ? new ActionResult(EnumActionResult.PASS, itemstack) : new ActionResult(EnumActionResult.FAIL, itemstack);

View File

@ -1,28 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemBucket.java
+++ ../src-work/minecraft/net/minecraft/item/ItemBucket.java
@@ -40,6 +40,8 @@
boolean flag = this.field_77876_a == Blocks.field_150350_a;
ItemStack itemstack = p_77659_2_.func_184586_b(p_77659_3_);
RayTraceResult raytraceresult = this.func_77621_a(p_77659_1_, p_77659_2_, flag);
+ ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(p_77659_2_, p_77659_1_, itemstack, raytraceresult);
+ if (ret != null) return ret;
if (raytraceresult == null)
{
@@ -188,4 +190,16 @@
}
}
}
+
+ @Override
+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable net.minecraft.nbt.NBTTagCompound nbt) {
+ if (this.getClass() == ItemBucket.class)
+ {
+ return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack);
+ }
+ else
+ {
+ return super.initCapabilities(stack, nbt);
+ }
+ }
}

View File

@ -1,34 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemBucketMilk.java
+++ ../src-work/minecraft/net/minecraft/item/ItemBucketMilk.java
@@ -22,6 +22,7 @@
public ItemStack func_77654_b(ItemStack p_77654_1_, World p_77654_2_, EntityLivingBase p_77654_3_)
{
+ if (!p_77654_2_.field_72995_K) p_77654_3_.curePotionEffects(p_77654_1_); // FORGE - move up so stack.shrink does not turn stack into air
if (p_77654_3_ instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)p_77654_3_;
@@ -34,11 +35,6 @@
p_77654_1_.func_190918_g(1);
}
- if (!p_77654_2_.field_72995_K)
- {
- p_77654_3_.func_70674_bp();
- }
-
return p_77654_1_.func_190926_b() ? new ItemStack(Items.field_151133_ar) : p_77654_1_;
}
@@ -52,6 +48,11 @@
return EnumAction.DRINK;
}
+ @Override
+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, net.minecraft.nbt.NBTTagCompound nbt) {
+ return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack);
+ }
+
public ActionResult<ItemStack> func_77659_a(World p_77659_1_, EntityPlayer p_77659_2_, EnumHand p_77659_3_)
{
p_77659_2_.func_184598_c(p_77659_3_);

View File

@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemDoor.java
+++ ../src-work/minecraft/net/minecraft/item/ItemDoor.java
@@ -48,7 +48,7 @@
int j = enumfacing.func_82599_e();
boolean flag = i < 0 && p_180614_8_ < 0.5F || i > 0 && p_180614_8_ > 0.5F || j < 0 && p_180614_6_ > 0.5F || j > 0 && p_180614_6_ < 0.5F;
func_179235_a(p_180614_2_, p_180614_3_, enumfacing, this.field_179236_a, flag);
- SoundType soundtype = this.field_179236_a.func_185467_w();
+ SoundType soundtype = p_180614_2_.func_180495_p(p_180614_3_).func_177230_c().getSoundType(p_180614_2_.func_180495_p(p_180614_3_), p_180614_2_, p_180614_3_, p_180614_1_);
p_180614_2_.func_184133_a(p_180614_1_, p_180614_3_, soundtype.func_185841_e(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F);
itemstack.func_190918_g(1);
return EnumActionResult.SUCCESS;

View File

@ -1,56 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemDye.java
+++ ../src-work/minecraft/net/minecraft/item/ItemDye.java
@@ -52,7 +52,7 @@
if (enumdyecolor == EnumDyeColor.WHITE)
{
- if (func_179234_a(itemstack, p_180614_2_, p_180614_3_))
+ if (applyBonemeal(itemstack, p_180614_2_, p_180614_3_, p_180614_1_, p_180614_4_))
{
if (!p_180614_2_.field_72995_K)
{
@@ -78,7 +78,7 @@
if (p_180614_2_.func_175623_d(p_180614_3_))
{
- IBlockState iblockstate1 = Blocks.field_150375_by.func_180642_a(p_180614_2_, p_180614_3_, p_180614_5_, p_180614_6_, p_180614_7_, p_180614_8_, 0, p_180614_1_);
+ IBlockState iblockstate1 = Blocks.field_150375_by.getStateForPlacement(p_180614_2_, p_180614_3_, p_180614_5_, p_180614_6_, p_180614_7_, p_180614_8_, 0, p_180614_1_, p_180614_4_);
p_180614_2_.func_180501_a(p_180614_3_, iblockstate1, 10);
if (!p_180614_1_.field_71075_bZ.field_75098_d)
@@ -99,8 +99,18 @@
public static boolean func_179234_a(ItemStack p_179234_0_, World p_179234_1_, BlockPos p_179234_2_)
{
+ if (p_179234_1_ instanceof net.minecraft.world.WorldServer)
+ return applyBonemeal(p_179234_0_, p_179234_1_, p_179234_2_, net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.world.WorldServer)p_179234_1_), null);
+ return false;
+ }
+
+ public static boolean applyBonemeal(ItemStack p_179234_0_, World p_179234_1_, BlockPos p_179234_2_, EntityPlayer player, @javax.annotation.Nullable EnumHand hand)
+ {
IBlockState iblockstate = p_179234_1_.func_180495_p(p_179234_2_);
+ int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, p_179234_1_, p_179234_2_, iblockstate, p_179234_0_, hand);
+ if (hook != 0) return hook > 0;
+
if (iblockstate.func_177230_c() instanceof IGrowable)
{
IGrowable igrowable = (IGrowable)iblockstate.func_177230_c();
@@ -144,6 +154,16 @@
p_180617_0_.func_175688_a(EnumParticleTypes.VILLAGER_HAPPY, (double)((float)p_180617_1_.func_177958_n() + field_77697_d.nextFloat()), (double)p_180617_1_.func_177956_o() + (double)field_77697_d.nextFloat() * iblockstate.func_185900_c(p_180617_0_, p_180617_1_).field_72337_e, (double)((float)p_180617_1_.func_177952_p() + field_77697_d.nextFloat()), d0, d1, d2);
}
}
+ else
+ {
+ for (int i1 = 0; i1 < p_180617_2_; ++i1)
+ {
+ double d0 = field_77697_d.nextGaussian() * 0.02D;
+ double d1 = field_77697_d.nextGaussian() * 0.02D;
+ double d2 = field_77697_d.nextGaussian() * 0.02D;
+ p_180617_0_.func_175688_a(EnumParticleTypes.VILLAGER_HAPPY, (double)((float)p_180617_1_.func_177958_n() + field_77697_d.nextFloat()), (double)p_180617_1_.func_177956_o() + (double)field_77697_d.nextFloat() * 1.0f, (double)((float)p_180617_1_.func_177952_p() + field_77697_d.nextFloat()), d0, d1, d2, new int[0]);
+ }
+ }
}
public boolean func_111207_a(ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_, EnumHand p_111207_4_)

View File

@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemFlintAndSteel.java
+++ ../src-work/minecraft/net/minecraft/item/ItemFlintAndSteel.java
@@ -34,7 +34,7 @@
}
else
{
- if (p_180614_2_.func_180495_p(p_180614_3_).func_185904_a() == Material.field_151579_a)
+ if (p_180614_2_.func_175623_d(p_180614_3_))
{
p_180614_2_.func_184133_a(p_180614_1_, p_180614_3_, SoundEvents.field_187649_bu, SoundCategory.BLOCKS, 1.0F, field_77697_d.nextFloat() * 0.4F + 0.8F);
p_180614_2_.func_180501_a(p_180614_3_, Blocks.field_150480_ab.func_176223_P(), 11);

View File

@ -1,17 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemHoe.java
+++ ../src-work/minecraft/net/minecraft/item/ItemHoe.java
@@ -47,10 +47,13 @@
}
else
{
+ int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(itemstack, p_180614_1_, p_180614_2_, p_180614_3_);
+ if (hook != 0) return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
+
IBlockState iblockstate = p_180614_2_.func_180495_p(p_180614_3_);
Block block = iblockstate.func_177230_c();
- if (p_180614_5_ != EnumFacing.DOWN && p_180614_2_.func_180495_p(p_180614_3_.func_177984_a()).func_185904_a() == Material.field_151579_a)
+ if (p_180614_5_ != EnumFacing.DOWN && p_180614_2_.func_175623_d(p_180614_3_.func_177984_a()))
{
if (block == Blocks.field_150349_c || block == Blocks.field_185774_da)
{

View File

@ -1,18 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemLilyPad.java
+++ ../src-work/minecraft/net/minecraft/item/ItemLilyPad.java
@@ -50,6 +50,15 @@
if (iblockstate.func_185904_a() == Material.field_151586_h && ((Integer)iblockstate.func_177229_b(BlockLiquid.field_176367_b)).intValue() == 0 && p_77659_1_.func_175623_d(blockpos1))
{
+ // special case for handling block placement with water lilies
+ net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(p_77659_1_, blockpos1);
+ p_77659_1_.func_175656_a(blockpos1, Blocks.field_150392_bi.func_176223_P());
+ if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(p_77659_2_, blocksnapshot, net.minecraft.util.EnumFacing.UP, p_77659_3_).isCanceled())
+ {
+ blocksnapshot.restore(true, false);
+ return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack);
+ }
+
p_77659_1_.func_180501_a(blockpos1, Blocks.field_150392_bi.func_176223_P(), 11);
if (p_77659_2_ instanceof EntityPlayerMP)

View File

@ -1,46 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemMap.java
+++ ../src-work/minecraft/net/minecraft/item/ItemMap.java
@@ -42,7 +42,7 @@
p_190906_0_.func_72823_a(s, mapdata);
mapdata.field_76197_d = p_190906_5_;
mapdata.func_176054_a(p_190906_1_, p_190906_3_, mapdata.field_76197_d);
- mapdata.field_76200_c = (byte)p_190906_0_.field_73011_w.func_186058_p().func_186068_a();
+ mapdata.field_76200_c = p_190906_0_.field_73011_w.getDimension();
mapdata.field_186210_e = p_190906_6_;
mapdata.field_191096_f = p_190906_7_;
mapdata.func_76185_a();
@@ -70,7 +70,7 @@
mapdata = new MapData(s);
mapdata.field_76197_d = 3;
mapdata.func_176054_a((double)p_77873_2_.func_72912_H().func_76079_c(), (double)p_77873_2_.func_72912_H().func_76074_e(), mapdata.field_76197_d);
- mapdata.field_76200_c = (byte)p_77873_2_.field_73011_w.func_186058_p().func_186068_a();
+ mapdata.field_76200_c = p_77873_2_.field_73011_w.getDimension();
mapdata.func_76185_a();
p_77873_2_.func_72823_a(s, mapdata);
}
@@ -80,7 +80,7 @@
public void func_77872_a(World p_77872_1_, Entity p_77872_2_, MapData p_77872_3_)
{
- if (p_77872_1_.field_73011_w.func_186058_p().func_186068_a() == p_77872_3_.field_76200_c && p_77872_2_ instanceof EntityPlayer)
+ if (p_77872_1_.field_73011_w.getDimension() == p_77872_3_.field_76200_c && p_77872_2_ instanceof EntityPlayer)
{
int i = 1 << p_77872_3_.field_76197_d;
int j = p_77872_3_.field_76201_a;
@@ -251,13 +251,13 @@
public static void func_190905_a(World p_190905_0_, ItemStack p_190905_1_)
{
- if (p_190905_1_.func_77973_b() == Items.field_151098_aY)
+ if (p_190905_1_.func_77973_b() instanceof ItemMap)
{
- MapData mapdata = Items.field_151098_aY.func_77873_a(p_190905_1_, p_190905_0_);
+ MapData mapdata = ((ItemMap) p_190905_1_.func_77973_b()).func_77873_a(p_190905_1_, p_190905_0_);
if (mapdata != null)
{
- if (p_190905_0_.field_73011_w.func_186058_p().func_186068_a() == mapdata.field_76200_c)
+ if (p_190905_0_.field_73011_w.getDimension() == mapdata.field_76200_c)
{
int i = 1 << mapdata.field_76197_d;
int j = mapdata.field_76201_a;

View File

@ -1,29 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemMinecart.java
+++ ../src-work/minecraft/net/minecraft/item/ItemMinecart.java
@@ -30,7 +30,7 @@
double d2 = p_82487_1_.func_82616_c() + (double)enumfacing.func_82599_e() * 1.125D;
BlockPos blockpos = p_82487_1_.func_180699_d().func_177972_a(enumfacing);
IBlockState iblockstate = world.func_180495_p(blockpos);
- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.func_177230_c() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.func_177229_b(((BlockRailBase)iblockstate.func_177230_c()).func_176560_l()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.func_177230_c() instanceof BlockRailBase ? ((BlockRailBase)iblockstate.func_177230_c()).getRailDirection(world, blockpos, iblockstate, null) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d3;
if (BlockRailBase.func_176563_d(iblockstate))
@@ -52,7 +52,7 @@
}
IBlockState iblockstate1 = world.func_180495_p(blockpos.func_177977_b());
- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection1 = iblockstate1.func_177230_c() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate1.func_177229_b(((BlockRailBase)iblockstate1.func_177230_c()).func_176560_l()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection1 = iblockstate1.func_177230_c() instanceof BlockRailBase ? ((BlockRailBase)iblockstate1.func_177230_c()).getRailDirection(world, blockpos.func_177977_b(), iblockstate1, null) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
if (enumfacing != EnumFacing.DOWN && blockrailbase$enumraildirection1.func_177018_c())
{
@@ -104,7 +104,7 @@
if (!p_180614_2_.field_72995_K)
{
- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.func_177230_c() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.func_177229_b(((BlockRailBase)iblockstate.func_177230_c()).func_176560_l()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.func_177230_c() instanceof BlockRailBase ? ((BlockRailBase)iblockstate.func_177230_c()).getRailDirection(p_180614_2_, p_180614_3_, iblockstate, null) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if (blockrailbase$enumraildirection.func_177018_c())

View File

@ -1,39 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemSeedFood.java
+++ ../src-work/minecraft/net/minecraft/item/ItemSeedFood.java
@@ -8,7 +8,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
-public class ItemSeedFood extends ItemFood
+public class ItemSeedFood extends ItemFood implements net.minecraftforge.common.IPlantable
{
private final Block field_150908_b;
private final Block field_82809_c;
@@ -23,8 +23,8 @@
public EnumActionResult func_180614_a(EntityPlayer p_180614_1_, World p_180614_2_, BlockPos p_180614_3_, EnumHand p_180614_4_, EnumFacing p_180614_5_, float p_180614_6_, float p_180614_7_, float p_180614_8_)
{
ItemStack itemstack = p_180614_1_.func_184586_b(p_180614_4_);
-
- if (p_180614_5_ == EnumFacing.UP && p_180614_1_.func_175151_a(p_180614_3_.func_177972_a(p_180614_5_), p_180614_5_, itemstack) && p_180614_2_.func_180495_p(p_180614_3_).func_177230_c() == this.field_82809_c && p_180614_2_.func_175623_d(p_180614_3_.func_177984_a()))
+ net.minecraft.block.state.IBlockState state = p_180614_2_.func_180495_p(p_180614_3_);
+ if (p_180614_5_ == EnumFacing.UP && p_180614_1_.func_175151_a(p_180614_3_.func_177972_a(p_180614_5_), p_180614_5_, itemstack) && state.func_177230_c().canSustainPlant(state, p_180614_2_, p_180614_3_, EnumFacing.UP, this) && p_180614_2_.func_175623_d(p_180614_3_.func_177984_a()))
{
p_180614_2_.func_180501_a(p_180614_3_.func_177984_a(), this.field_150908_b.func_176223_P(), 11);
itemstack.func_190918_g(1);
@@ -35,4 +35,16 @@
return EnumActionResult.FAIL;
}
}
+
+ @Override
+ public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos)
+ {
+ return net.minecraftforge.common.EnumPlantType.Crop;
+ }
+
+ @Override
+ public net.minecraft.block.state.IBlockState getPlant(net.minecraft.world.IBlockAccess world, BlockPos pos)
+ {
+ return this.field_150908_b.func_176223_P();
+ }
}

View File

@ -1,39 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemSeeds.java
+++ ../src-work/minecraft/net/minecraft/item/ItemSeeds.java
@@ -11,7 +11,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
-public class ItemSeeds extends Item
+public class ItemSeeds extends Item implements net.minecraftforge.common.IPlantable
{
private final Block field_150925_a;
private final Block field_77838_b;
@@ -26,8 +26,8 @@
public EnumActionResult func_180614_a(EntityPlayer p_180614_1_, World p_180614_2_, BlockPos p_180614_3_, EnumHand p_180614_4_, EnumFacing p_180614_5_, float p_180614_6_, float p_180614_7_, float p_180614_8_)
{
ItemStack itemstack = p_180614_1_.func_184586_b(p_180614_4_);
-
- if (p_180614_5_ == EnumFacing.UP && p_180614_1_.func_175151_a(p_180614_3_.func_177972_a(p_180614_5_), p_180614_5_, itemstack) && p_180614_2_.func_180495_p(p_180614_3_).func_177230_c() == this.field_77838_b && p_180614_2_.func_175623_d(p_180614_3_.func_177984_a()))
+ net.minecraft.block.state.IBlockState state = p_180614_2_.func_180495_p(p_180614_3_);
+ if (p_180614_5_ == EnumFacing.UP && p_180614_1_.func_175151_a(p_180614_3_.func_177972_a(p_180614_5_), p_180614_5_, itemstack) && state.func_177230_c().canSustainPlant(state, p_180614_2_, p_180614_3_, EnumFacing.UP, this) && p_180614_2_.func_175623_d(p_180614_3_.func_177984_a()))
{
p_180614_2_.func_175656_a(p_180614_3_.func_177984_a(), this.field_150925_a.func_176223_P());
@@ -44,4 +44,16 @@
return EnumActionResult.FAIL;
}
}
+
+ @Override
+ public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos)
+ {
+ return this.field_150925_a == net.minecraft.init.Blocks.field_150388_bm ? net.minecraftforge.common.EnumPlantType.Nether : net.minecraftforge.common.EnumPlantType.Crop;
+ }
+
+ @Override
+ public net.minecraft.block.state.IBlockState getPlant(net.minecraft.world.IBlockAccess world, BlockPos pos)
+ {
+ return this.field_150925_a.func_176223_P();
+ }
}

View File

@ -1,86 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemShears.java
+++ ../src-work/minecraft/net/minecraft/item/ItemShears.java
@@ -26,6 +26,7 @@
}
Block block = p_179218_3_.func_177230_c();
+ if (block instanceof net.minecraftforge.common.IShearable) return true;
return p_179218_3_.func_185904_a() != Material.field_151584_j && block != Blocks.field_150321_G && block != Blocks.field_150329_H && block != Blocks.field_150395_bd && block != Blocks.field_150473_bD && block != Blocks.field_150325_L ? super.func_179218_a(p_179218_1_, p_179218_2_, p_179218_3_, p_179218_4_, p_179218_5_) : true;
}
@@ -35,6 +36,75 @@
return block == Blocks.field_150321_G || block == Blocks.field_150488_af || block == Blocks.field_150473_bD;
}
+
+ @Override
+ public boolean func_111207_a(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity, net.minecraft.util.EnumHand hand)
+ {
+ if (entity.field_70170_p.field_72995_K)
+ {
+ return false;
+ }
+ if (entity instanceof net.minecraftforge.common.IShearable)
+ {
+ net.minecraftforge.common.IShearable target = (net.minecraftforge.common.IShearable)entity;
+ BlockPos pos = new BlockPos(entity.field_70165_t, entity.field_70163_u, entity.field_70161_v);
+ if (target.isShearable(itemstack, entity.field_70170_p, pos))
+ {
+ java.util.List<ItemStack> drops = target.onSheared(itemstack, entity.field_70170_p, pos,
+ net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.init.Enchantments.field_185308_t, itemstack));
+
+ java.util.Random rand = new java.util.Random();
+ for(ItemStack stack : drops)
+ {
+ net.minecraft.entity.item.EntityItem ent = entity.func_70099_a(stack, 1.0F);
+ ent.field_70181_x += rand.nextFloat() * 0.05F;
+ ent.field_70159_w += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
+ ent.field_70179_y += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
+ }
+ itemstack.func_77972_a(1, entity);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, net.minecraft.entity.player.EntityPlayer player)
+ {
+ if (player.field_70170_p.field_72995_K || player.field_71075_bZ.field_75098_d)
+ {
+ return false;
+ }
+ Block block = player.field_70170_p.func_180495_p(pos).func_177230_c();
+ if (block instanceof net.minecraftforge.common.IShearable)
+ {
+ net.minecraftforge.common.IShearable target = (net.minecraftforge.common.IShearable)block;
+ if (target.isShearable(itemstack, player.field_70170_p, pos))
+ {
+ java.util.List<ItemStack> drops = target.onSheared(itemstack, player.field_70170_p, pos,
+ net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.init.Enchantments.field_185308_t, itemstack));
+ java.util.Random rand = new java.util.Random();
+
+ for (ItemStack stack : drops)
+ {
+ float f = 0.7F;
+ double d = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
+ double d1 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
+ double d2 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
+ net.minecraft.entity.item.EntityItem entityitem = new net.minecraft.entity.item.EntityItem(player.field_70170_p, (double)pos.func_177958_n() + d, (double)pos.func_177956_o() + d1, (double)pos.func_177952_p() + d2, stack);
+ entityitem.func_174869_p();
+ player.field_70170_p.func_72838_d(entityitem);
+ }
+
+ itemstack.func_77972_a(1, player);
+ player.func_71029_a(net.minecraft.stats.StatList.func_188055_a(block));
+ player.field_70170_p.func_180501_a(pos, Blocks.field_150350_a.func_176223_P(), 11); //TODO: Move to IShearable implementors in 1.12+
+ return true;
+ }
+ }
+ return false;
+ }
+
public float func_150893_a(ItemStack p_150893_1_, IBlockState p_150893_2_)
{
Block block = p_150893_2_.func_177230_c();

View File

@ -1,20 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemSlab.java
+++ ../src-work/minecraft/net/minecraft/item/ItemSlab.java
@@ -64,7 +64,7 @@
if (axisalignedbb != Block.field_185506_k && p_180614_2_.func_72855_b(axisalignedbb.func_186670_a(p_180614_3_)) && p_180614_2_.func_180501_a(p_180614_3_, iblockstate1, 11))
{
- SoundType soundtype = this.field_179226_c.func_185467_w();
+ SoundType soundtype = this.field_179226_c.getSoundType(iblockstate1, p_180614_2_, p_180614_3_, p_180614_1_);
p_180614_2_.func_184133_a(p_180614_1_, p_180614_3_, soundtype.func_185841_e(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F);
itemstack.func_190918_g(1);
@@ -124,7 +124,7 @@
if (axisalignedbb != Block.field_185506_k && p_180615_3_.func_72855_b(axisalignedbb.func_186670_a(p_180615_4_)) && p_180615_3_.func_180501_a(p_180615_4_, iblockstate1, 11))
{
- SoundType soundtype = this.field_179226_c.func_185467_w();
+ SoundType soundtype = this.field_179226_c.getSoundType(iblockstate1, p_180615_3_, p_180615_4_, p_180615_1_);
p_180615_3_.func_184133_a(p_180615_1_, p_180615_4_, soundtype.func_185841_e(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F);
p_180615_2_.func_190918_g(1);
}

View File

@ -1,22 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemSnow.java
+++ ../src-work/minecraft/net/minecraft/item/ItemSnow.java
@@ -51,7 +51,7 @@
if (axisalignedbb != Block.field_185506_k && p_180614_2_.func_72855_b(axisalignedbb.func_186670_a(blockpos)) && p_180614_2_.func_180501_a(blockpos, iblockstate1, 10))
{
- SoundType soundtype = this.field_150939_a.func_185467_w();
+ SoundType soundtype = this.field_150939_a.getSoundType(iblockstate1, p_180614_2_, p_180614_3_, p_180614_1_);
p_180614_2_.func_184133_a(p_180614_1_, blockpos, soundtype.func_185841_e(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F);
if (p_180614_1_ instanceof EntityPlayerMP)
@@ -77,4 +77,10 @@
{
return p_77647_1_;
}
+
+ public boolean func_179222_a(World world, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
+ {
+ IBlockState state = world.func_180495_p(pos);
+ return (state.func_177230_c() != net.minecraft.init.Blocks.field_150431_aC || ((Integer)state.func_177229_b(BlockSnow.field_176315_a)) > 7) ? super.func_179222_a(world, pos, side, player, stack) : true;
+ }
}

View File

@ -1,13 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemSword.java
+++ ../src-work/minecraft/net/minecraft/item/ItemSword.java
@@ -88,7 +88,9 @@
public boolean func_82789_a(ItemStack p_82789_1_, ItemStack p_82789_2_)
{
- return this.field_150933_b.func_150995_f() == p_82789_2_.func_77973_b() ? true : super.func_82789_a(p_82789_1_, p_82789_2_);
+ ItemStack mat = this.field_150933_b.getRepairItemStack();
+ if (!mat.func_190926_b() && net.minecraftforge.oredict.OreDictionary.itemMatches(mat, p_82789_2_, false)) return true;
+ return super.func_82789_a(p_82789_1_, p_82789_2_);
}
public Multimap<String, AttributeModifier> func_111205_h(EntityEquipmentSlot p_111205_1_)

View File

@ -1,73 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/ItemTool.java
+++ ../src-work/minecraft/net/minecraft/item/ItemTool.java
@@ -33,6 +33,18 @@
this.field_77865_bY = p_i46745_1_ + p_i46745_3_.func_78000_c();
this.field_185065_c = p_i46745_2_;
this.func_77637_a(CreativeTabs.field_78040_i);
+ if (this instanceof ItemPickaxe)
+ {
+ toolClass = "pickaxe";
+ }
+ else if (this instanceof ItemAxe)
+ {
+ toolClass = "axe";
+ }
+ else if (this instanceof ItemSpade)
+ {
+ toolClass = "shovel";
+ }
}
protected ItemTool(Item.ToolMaterial p_i46746_1_, Set<Block> p_i46746_2_)
@@ -42,6 +54,11 @@
public float func_150893_a(ItemStack p_150893_1_, IBlockState p_150893_2_)
{
+ for (String type : getToolClasses(p_150893_1_))
+ {
+ if (p_150893_2_.func_177230_c().isToolEffective(type, p_150893_2_))
+ return field_77864_a;
+ }
return this.field_150914_c.contains(p_150893_2_.func_177230_c()) ? this.field_77864_a : 1.0F;
}
@@ -79,7 +96,9 @@
public boolean func_82789_a(ItemStack p_82789_1_, ItemStack p_82789_2_)
{
- return this.field_77862_b.func_150995_f() == p_82789_2_.func_77973_b() ? true : super.func_82789_a(p_82789_1_, p_82789_2_);
+ ItemStack mat = this.field_77862_b.getRepairItemStack();
+ if (!mat.func_190926_b() && net.minecraftforge.oredict.OreDictionary.itemMatches(mat, p_82789_2_, false)) return true;
+ return super.func_82789_a(p_82789_1_, p_82789_2_);
}
public Multimap<String, AttributeModifier> func_111205_h(EntityEquipmentSlot p_111205_1_)
@@ -94,4 +113,28 @@
return multimap;
}
+
+ /*===================================== FORGE START =================================*/
+ @javax.annotation.Nullable
+ private String toolClass;
+ @Override
+ public int getHarvestLevel(ItemStack stack, String toolClass, @javax.annotation.Nullable net.minecraft.entity.player.EntityPlayer player, @javax.annotation.Nullable IBlockState blockState)
+ {
+ int level = super.getHarvestLevel(stack, toolClass, player, blockState);
+ if (level == -1 && toolClass.equals(this.toolClass))
+ {
+ return this.field_77862_b.func_77996_d();
+ }
+ else
+ {
+ return level;
+ }
+ }
+
+ @Override
+ public Set<String> getToolClasses(ItemStack stack)
+ {
+ return toolClass != null ? com.google.common.collect.ImmutableSet.of(toolClass) : super.getToolClasses(stack);
+ }
+ /*===================================== FORGE END =================================*/
}

View File

@ -1,21 +0,0 @@
--- ../src-base/minecraft/net/minecraft/item/crafting/Ingredient.java
+++ ../src-work/minecraft/net/minecraft/item/crafting/Ingredient.java
@@ -108,4 +142,22 @@
return field_193370_a;
}
+
+ // Merges several vanilla Ingredients together. As a qwerk of how the json is structured, we can't tell if its a single Ingredient type or multiple so we split per item and remerge here.
+ //Only public for internal use, so we can access a private field in here.
+ public static Ingredient merge(java.util.Collection<Ingredient> parts)
+ {
+ net.minecraft.util.NonNullList<ItemStack> lst = net.minecraft.util.NonNullList.func_191196_a();
+ for (Ingredient part : parts)
+ {
+ for (ItemStack stack : part.field_193371_b)
+ lst.add(stack);
+ }
+ return new Ingredient(lst.toArray(new ItemStack[lst.size()]));
+ }
+
}

View File

@ -1,53 +0,0 @@
--- ../src-base/minecraft/net/minecraft/nbt/CompressedStreamTools.java
+++ ../src-work/minecraft/net/minecraft/nbt/CompressedStreamTools.java
@@ -18,8 +18,6 @@
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.util.ReportedException;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
public class CompressedStreamTools
{
@@ -54,7 +52,6 @@
}
}
- @SideOnly(Side.CLIENT)
public static void func_74793_a(NBTTagCompound p_74793_0_, File p_74793_1_) throws IOException
{
File file1 = new File(p_74793_1_.getAbsolutePath() + "_tmp");
@@ -119,6 +116,7 @@
private static NBTBase func_152455_a(DataInput p_152455_0_, int p_152455_1_, NBTSizeTracker p_152455_2_) throws IOException
{
byte b0 = p_152455_0_.readByte();
+ p_152455_2_.func_152450_a(8); // Forge: Count everything!
if (b0 == 0)
{
@@ -126,7 +124,8 @@
}
else
{
- p_152455_0_.readUTF();
+ NBTSizeTracker.readUTF(p_152455_2_, p_152455_0_.readUTF()); //Forge: Count this string.
+ p_152455_2_.func_152450_a(32); //Forge: 4 extra bytes for the object allocation.
NBTBase nbtbase = NBTBase.func_150284_a(b0);
try
@@ -144,7 +143,6 @@
}
}
- @SideOnly(Side.CLIENT)
public static void func_74795_b(NBTTagCompound p_74795_0_, File p_74795_1_) throws IOException
{
DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(p_74795_1_));
@@ -160,7 +158,6 @@
}
@Nullable
- @SideOnly(Side.CLIENT)
public static NBTTagCompound func_74797_a(File p_74797_0_) throws IOException
{
if (!p_74797_0_.exists())

View File

@ -1,37 +0,0 @@
--- ../src-base/minecraft/net/minecraft/nbt/NBTSizeTracker.java
+++ ../src-work/minecraft/net/minecraft/nbt/NBTSizeTracker.java
@@ -25,4 +25,34 @@
throw new RuntimeException("Tried to read NBT tag that was too big; tried to allocate: " + this.field_152453_c + "bytes where max allowed: " + this.field_152452_b);
}
}
+
+ /*
+ * UTF8 is not a simple encoding system, each character can be either
+ * 1, 2, or 3 bytes. Depending on where it's numerical value falls.
+ * We have to count up each character individually to see the true
+ * length of the data.
+ *
+ * Basic concept is that it uses the MSB of each byte as a 'read more' signal.
+ * So it has to shift each 7-bit segment.
+ *
+ * This will accurately count the correct byte length to encode this string, plus the 2 bytes for it's length prefix.
+ */
+ public static void readUTF(NBTSizeTracker tracker, String data)
+ {
+ tracker.func_152450_a(16); //Header length
+ if (data == null)
+ return;
+
+ int len = data.length();
+ int utflen = 0;
+
+ for (int i = 0; i < len; i++)
+ {
+ int c = data.charAt(i);
+ if ((c >= 0x0001) && (c <= 0x007F)) utflen += 1;
+ else if (c > 0x07FF) utflen += 3;
+ else utflen += 2;
+ }
+ tracker.func_152450_a(8 * utflen);
+ }
}

View File

@ -1,18 +0,0 @@
--- ../src-base/minecraft/net/minecraft/nbt/NBTTagCompound.java
+++ ../src-work/minecraft/net/minecraft/nbt/NBTTagCompound.java
@@ -477,6 +477,7 @@
private static byte func_152447_a(DataInput p_152447_0_, NBTSizeTracker p_152447_1_) throws IOException
{
+ p_152447_1_.func_152450_a(8);
return p_152447_0_.readByte();
}
@@ -487,6 +488,7 @@
static NBTBase func_152449_a(byte p_152449_0_, String p_152449_1_, DataInput p_152449_2_, int p_152449_3_, NBTSizeTracker p_152449_4_) throws IOException
{
+ p_152449_4_.func_152450_a(32); //Forge: 4 extra bytes for the object allocation.
NBTBase nbtbase = NBTBase.func_150284_a(p_152449_0_);
try

View File

@ -1,17 +0,0 @@
--- ../src-base/minecraft/net/minecraft/nbt/NBTTagList.java
+++ ../src-work/minecraft/net/minecraft/nbt/NBTTagList.java
@@ -9,7 +9,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-public class NBTTagList extends NBTBase
+public class NBTTagList extends NBTBase implements java.lang.Iterable<NBTBase>
{
private static final Logger field_179239_b = LogManager.getLogger();
private List<NBTBase> field_74747_a = Lists.<NBTBase>newArrayList();
@@ -281,4 +281,5 @@
{
return this.field_74746_b;
}
+ @Override public java.util.Iterator<NBTBase> iterator() {return field_74747_a.iterator();}
}

View File

@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/nbt/NBTTagString.java
+++ ../src-work/minecraft/net/minecraft/nbt/NBTTagString.java
@@ -29,7 +29,7 @@
{
p_152446_3_.func_152450_a(288L);
this.field_74751_a = p_152446_1_.readUTF();
- p_152446_3_.func_152450_a((long)(16 * this.field_74751_a.length()));
+ NBTSizeTracker.readUTF(p_152446_3_, field_74751_a); // Forge: Correctly read String length including header.
}
public byte func_74732_a()

View File

@ -1,20 +0,0 @@
--- ../src-base/minecraft/net/minecraft/pathfinding/WalkNodeProcessor.java
+++ ../src-work/minecraft/net/minecraft/pathfinding/WalkNodeProcessor.java
@@ -427,6 +427,7 @@
{
p_193578_5_ = PathNodeType.DANGER_FIRE;
}
+ else if(block.isBurning(p_193578_1_,blockpos$pooledmutableblockpos)) p_193578_5_ = PathNodeType.DAMAGE_FIRE;
}
}
}
@@ -443,6 +444,9 @@
Block block = iblockstate.func_177230_c();
Material material = iblockstate.func_185904_a();
+ PathNodeType type = block.getAiPathNodeType(iblockstate, p_189553_1_, blockpos);
+ if (type != null) return type;
+
if (material == Material.field_151579_a)
{
return PathNodeType.OPEN;

View File

@ -1,138 +0,0 @@
--- ../src-base/minecraft/net/minecraft/potion/PotionEffect.java
+++ ../src-work/minecraft/net/minecraft/potion/PotionEffect.java
@@ -19,6 +19,8 @@
@SideOnly(Side.CLIENT)
private boolean field_100013_f;
private boolean field_188421_h;
+ /** List of ItemStack that can cure the potion effect **/
+ private java.util.List<net.minecraft.item.ItemStack> curativeItems;
public PotionEffect(Potion p_i46811_1_)
{
@@ -51,6 +53,7 @@
this.field_76461_c = p_i1577_1_.field_76461_c;
this.field_82724_e = p_i1577_1_.field_82724_e;
this.field_188421_h = p_i1577_1_.field_188421_h;
+ this.curativeItems = p_i1577_1_.curativeItems == null ? null : new java.util.ArrayList<net.minecraft.item.ItemStack>(p_i1577_1_.curativeItems);
}
public void func_76452_a(PotionEffect p_76452_1_)
@@ -195,12 +198,13 @@
p_82719_1_.func_74768_a("Duration", this.func_76459_b());
p_82719_1_.func_74757_a("Ambient", this.func_82720_e());
p_82719_1_.func_74757_a("ShowParticles", this.func_188418_e());
+ writeCurativeItems(p_82719_1_);
return p_82719_1_;
}
public static PotionEffect func_82722_b(NBTTagCompound p_82722_0_)
{
- int i = p_82722_0_.func_74771_c("Id");
+ int i = p_82722_0_.func_74771_c("Id") & 0xFF;
Potion potion = Potion.func_188412_a(i);
if (potion == null)
@@ -219,7 +223,7 @@
flag1 = p_82722_0_.func_74767_n("ShowParticles");
}
- return new PotionEffect(potion, k, j < 0 ? 0 : j, flag, flag1);
+ return readCurativeItems(new PotionEffect(potion, k, j < 0 ? 0 : j, flag, flag1), p_82722_0_);
}
}
@@ -232,7 +236,7 @@
public int compareTo(PotionEffect p_compareTo_1_)
{
int i = 32147;
- return (this.func_76459_b() <= 32147 || p_compareTo_1_.func_76459_b() <= 32147) && (!this.func_82720_e() || !p_compareTo_1_.func_82720_e()) ? ComparisonChain.start().compare(Boolean.valueOf(this.func_82720_e()), Boolean.valueOf(p_compareTo_1_.func_82720_e())).compare(this.func_76459_b(), p_compareTo_1_.func_76459_b()).compare(this.func_188419_a().func_76401_j(), p_compareTo_1_.func_188419_a().func_76401_j()).result() : ComparisonChain.start().compare(Boolean.valueOf(this.func_82720_e()), Boolean.valueOf(p_compareTo_1_.func_82720_e())).compare(this.func_188419_a().func_76401_j(), p_compareTo_1_.func_188419_a().func_76401_j()).result();
+ return (this.func_76459_b() <= 32147 || p_compareTo_1_.func_76459_b() <= 32147) && (!this.func_82720_e() || !p_compareTo_1_.func_82720_e()) ? ComparisonChain.start().compare(Boolean.valueOf(this.func_82720_e()), Boolean.valueOf(p_compareTo_1_.func_82720_e())).compare(this.func_76459_b(), p_compareTo_1_.func_76459_b()).compare(this.func_188419_a().getGuiSortColor(this), p_compareTo_1_.func_188419_a().getGuiSortColor(p_compareTo_1_)).result() : ComparisonChain.start().compare(Boolean.valueOf(this.func_82720_e()), Boolean.valueOf(p_compareTo_1_.func_82720_e())).compare(this.func_188419_a().getGuiSortColor(this), p_compareTo_1_.func_188419_a().getGuiSortColor(p_compareTo_1_)).result();
}
@SideOnly(Side.CLIENT)
@@ -240,4 +244,85 @@
{
return this.field_100013_f;
}
+
+ /* ======================================== FORGE START =====================================*/
+ /***
+ * Returns a list of curative items for the potion effect
+ * By default, this list is initialized using {@link Potion#getCurativeItems}
+ *
+ * @return The list (ItemStack) of curative items for the potion effect
+ */
+ public java.util.List<net.minecraft.item.ItemStack> getCurativeItems()
+ {
+ if (this.curativeItems == null) //Lazy load this so that we don't create a circular dep on Items.
+ {
+ this.curativeItems = func_188419_a().getCurativeItems();
+ }
+ return this.curativeItems;
+ }
+
+ /***
+ * Checks the given ItemStack to see if it is in the list of curative items for the potion effect
+ * @param stack The ItemStack being checked against the list of curative items for this PotionEffect
+ * @return true if the given ItemStack is in the list of curative items for this PotionEffect, false otherwise
+ */
+ public boolean isCurativeItem(net.minecraft.item.ItemStack stack)
+ {
+ for (net.minecraft.item.ItemStack curativeItem : this.getCurativeItems())
+ {
+ if (curativeItem.func_77969_a(stack))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /***
+ * Sets the list of curative items for this potion effect, overwriting any already present
+ * @param curativeItems The list of ItemStacks being set to the potion effect
+ */
+ public void setCurativeItems(java.util.List<net.minecraft.item.ItemStack> curativeItems)
+ {
+ this.curativeItems = curativeItems;
+ }
+
+ /***
+ * Adds the given stack to the list of curative items for this PotionEffect
+ * @param stack The ItemStack being added to the curative item list
+ */
+ public void addCurativeItem(net.minecraft.item.ItemStack stack)
+ {
+ if (!this.isCurativeItem(stack))
+ {
+ this.getCurativeItems().add(stack);
+ }
+ }
+
+ private void writeCurativeItems(NBTTagCompound nbt)
+ {
+ net.minecraft.nbt.NBTTagList list = new net.minecraft.nbt.NBTTagList();
+ for (net.minecraft.item.ItemStack stack : getCurativeItems())
+ {
+ list.func_74742_a(stack.func_77955_b(new NBTTagCompound()));
+ }
+ nbt.func_74782_a("CurativeItems", list);
+ }
+
+ private static PotionEffect readCurativeItems(PotionEffect effect, NBTTagCompound nbt)
+ {
+ if (nbt.func_150297_b("CurativeItems", net.minecraftforge.common.util.Constants.NBT.TAG_LIST))
+ {
+ java.util.List<net.minecraft.item.ItemStack> items = new java.util.ArrayList<net.minecraft.item.ItemStack>();
+ net.minecraft.nbt.NBTTagList list = nbt.func_150295_c("CurativeItems", net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND);
+ for (int i = 0; i < list.func_74745_c(); i++)
+ {
+ items.add(new net.minecraft.item.ItemStack(list.func_150305_b(i)));
+ }
+ effect.setCurativeItems(items);
+ }
+
+ return effect;
+ }
}

View File

@ -1,16 +0,0 @@
--- ../src-base/minecraft/net/minecraft/potion/PotionType.java
+++ ../src-work/minecraft/net/minecraft/potion/PotionType.java
@@ -8,10 +8,11 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
-public class PotionType
+public class PotionType extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<PotionType>
{
+ @Deprecated // unused
private static final ResourceLocation field_185177_b = new ResourceLocation("empty");
- public static final RegistryNamespacedDefaultedByKey<ResourceLocation, PotionType> field_185176_a = new RegistryNamespacedDefaultedByKey<ResourceLocation, PotionType>(field_185177_b);
+ public static final RegistryNamespacedDefaultedByKey<ResourceLocation, PotionType> field_185176_a = net.minecraftforge.registries.GameData.getWrapperDefaulted(PotionType.class);
private static int field_185178_c;
private final String field_185179_d;
private final ImmutableList<PotionEffect> field_185180_e;

View File

@ -1,19 +0,0 @@
--- ../src-base/minecraft/net/minecraft/profiler/Profiler.java
+++ ../src-work/minecraft/net/minecraft/profiler/Profiler.java
@@ -193,4 +193,16 @@
return (this.field_76331_c.hashCode() & 11184810) + 4473924;
}
}
+
+ /**
+ * Forge: Fix for MC-117087, World.updateEntities is wasting time calling Class.getSimpleName() when the profiler is not active
+ */
+ @Deprecated // TODO: remove (1.13)
+ public void startSection(Class<?> profiledClass)
+ {
+ if (this.field_76327_a)
+ {
+ func_76320_a(profiledClass.getSimpleName());
+ }
+ }
}

View File

@ -1,19 +0,0 @@
--- ../src-base/minecraft/net/minecraft/realms/RealmsConnect.java
+++ ../src-work/minecraft/net/minecraft/realms/RealmsConnect.java
@@ -38,6 +38,7 @@
try
{
+ net.minecraftforge.fml.client.FMLClientHandler.instance().connectToRealmsServer(p_connect_1_, p_connect_2_);
inetaddress = InetAddress.getByName(p_connect_1_);
if (RealmsConnect.this.aborted)
@@ -59,7 +60,7 @@
return;
}
- RealmsConnect.this.connection.func_179290_a(new C00Handshake(p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN));
+ RealmsConnect.this.connection.func_179290_a(new C00Handshake(p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN, true));
if (RealmsConnect.this.aborted)
{

View File

@ -38,17 +38,6 @@
p_179222_3_ = EnumFacing.UP;
}
@@ -171,6 +159,36 @@
public Block func_179223_d()
{
+ return this.getBlockRaw() == null ? null : this.getBlockRaw().delegate.get();
+ }
+
+ private Block getBlockRaw()
+ {
return this.field_150939_a;
}
+
+ /**
+ * Called to actually place the block, after the location is determined
+ * and all permission checks have been made.

View File

@ -23,6 +23,7 @@ import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import javax.annotation.Nonnull;
@ -71,5 +72,5 @@ public interface IShearable
* @return A List containing all items from this shearing. May be empty.
*/
@Nonnull
List<ItemStack> onSheared(@Nonnull ItemStack item, IWorldReader world, BlockPos pos, int fortune);
List<ItemStack> onSheared(@Nonnull ItemStack item, IWorld world, BlockPos pos, int fortune);
}

View File

@ -26,12 +26,13 @@ import com.google.common.collect.Maps;
public final class ToolType
{
private static final Pattern VALID_NAME = Pattern.compile("[^a-z_]"); //Only a-z and _ are allowed, meaning names must be lower case. And use _ to separate words.
private static final Map<String, ToolType> values = Maps.newHashMap();
public static final ToolType AXE = get("axe");
public static final ToolType PICKAXE = get("pickaxe");
public static final ToolType SHOVEL = get("shovel");
private static final Map<String, ToolType> values = Maps.newHashMap();
private static final Pattern VALID_NAME = Pattern.compile("[^a-z_]"); //Only a-z and _ are allowed, meaning names must be lower case. And use _ to separate words.
public static ToolType get(String name)
{

View File

@ -160,7 +160,7 @@ public interface IForgeBlock
* @param pos Block position in world
* @return True if the block should deal damage
*/
default boolean isBurning(IWorldReader world, BlockPos pos)
default boolean isBurning(IBlockState state, IBlockReader world, BlockPos pos)
{
return false;
}
@ -361,7 +361,7 @@ public interface IForgeBlock
* @param pos Block position in world
* @return True if the block considered air
*/
default boolean isAir(IBlockState state, IWorldReader world, BlockPos pos)
default boolean isAir(IBlockState state, IBlockReader world, BlockPos pos)
{
return state.getMaterial() == Material.AIR;
}
@ -903,9 +903,9 @@ public interface IForgeBlock
* @return the PathNodeType
*/
@Nullable
default PathNodeType getAiPathNodeType(IBlockState state, IWorldReader world, BlockPos pos)
default PathNodeType getAiPathNodeType(IBlockState state, IBlockReader world, BlockPos pos)
{
return isBurning(world, pos) ? PathNodeType.DAMAGE_FIRE : null;
return state.isBurning(world, pos) ? PathNodeType.DAMAGE_FIRE : null;
}
/**

View File

@ -310,7 +310,7 @@ public interface IForgeBlockState
* @param pos Block position in world
* @return True if the block considered air
*/
default boolean isAir(IWorldReader world, BlockPos pos)
default boolean isAir(IBlockReader world, BlockPos pos)
{
return getBlockState().getBlock().isAir(getBlockState(), world, pos);
}
@ -898,4 +898,28 @@ public interface IForgeBlockState
{
return getBlockState().getBlock().getValidRotations(getBlockState(), world, pos);
}
/**
* Determines if this block should set fire and deal fire damage
* to entities coming into contact with it.
*
* @param world The current world
* @param pos Block position in world
* @return True if the block should deal damage
*/
default boolean isBurning(IBlockReader world, BlockPos pos)
{
return getBlockState().getBlock().isBurning(getBlockState(), world, pos);
}
/**
* Get the {@code PathNodeType} for this block. Return {@code null} for vanilla behavior.
*
* @return the PathNodeType
*/
@Nullable
default PathNodeType getAiPathNodeType(IBlockReader world, BlockPos pos)
{
return getBlockState().getBlock().getAiPathNodeType(getBlockState(), world, pos);
}
}

View File

@ -162,7 +162,6 @@ public interface IForgeEntity extends ICapabilitySerializable<NBTTagCompound>
/**
* Checks if this {@link Entity} can trample a {@link Block}.
*
* @param block The block being tested
* @param pos The block pos
* @param fallDistance The fall distance
* @return {@code true} if this entity can trample, {@code false} otherwise

View File

@ -25,6 +25,7 @@ import javax.annotation.Nullable;
import net.minecraft.block.state.BlockWorldState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -149,4 +150,32 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
{
return getStack().getItem().shouldCauseBlockBreakReset(getStack(), newStack);
}
/**
* Checks whether an item can be enchanted with a certain enchantment. This
* applies specifically to enchanting an item in the enchanting table and is
* called when retrieving the list of possible enchantments for an item.
* Enchantments may additionally (or exclusively) be doing their own checks in
* {@link net.minecraft.enchantment.Enchantment#canApplyAtEnchantingTable(ItemStack)};
* check the individual implementation for reference. By default this will check
* if the enchantment type is valid for this item type.
*
* @param stack the item stack to be enchanted
* @param enchantment the enchantment to be applied
* @return true if the enchantment can be applied to this item
*/
default boolean canApplyAtEnchantingTable(Enchantment enchantment)
{
return getStack().getItem().canApplyAtEnchantingTable(getStack(), enchantment);
}
/**
* ItemStack sensitive version of getItemEnchantability
*
* @return the item echantability value
*/
default int getItemEnchantability()
{
return getStack().getItem().getItemEnchantability(getStack());
}
}

View File

@ -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)
{

View File

@ -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()
{

View File

@ -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;
}
}

View File

@ -19,13 +19,9 @@
package net.minecraftforge.resource;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
* Represents a generic type of reloadable resource. Used for resource reload filtering.
*/
@OnlyIn(Dist.CLIENT)
public interface IResourceType
{
}