From 5a3b3751475268ccb8c4a8da875c76cba6473f95 Mon Sep 17 00:00:00 2001 From: tterrag Date: Fri, 21 Jun 2019 21:15:56 -0400 Subject: [PATCH] Fix #5612 add entity to ISelectionContext --- .../shapes/EntitySelectionContext.java.patch | 35 +++++++++++++++++++ .../math/shapes/ISelectionContext.java.patch | 11 ++++++ .../extensions/IForgeSelectionContext.java | 13 +++++++ src/main/resources/forge.exc | 2 ++ 4 files changed, 61 insertions(+) create mode 100644 patches/minecraft/net/minecraft/util/math/shapes/EntitySelectionContext.java.patch create mode 100644 patches/minecraft/net/minecraft/util/math/shapes/ISelectionContext.java.patch create mode 100644 src/main/java/net/minecraftforge/common/extensions/IForgeSelectionContext.java diff --git a/patches/minecraft/net/minecraft/util/math/shapes/EntitySelectionContext.java.patch b/patches/minecraft/net/minecraft/util/math/shapes/EntitySelectionContext.java.patch new file mode 100644 index 000000000..6984ae786 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/math/shapes/EntitySelectionContext.java.patch @@ -0,0 +1,35 @@ +--- a/net/minecraft/util/math/shapes/EntitySelectionContext.java ++++ b/net/minecraft/util/math/shapes/EntitySelectionContext.java +@@ -18,6 +18,11 @@ + private final Item field_216382_d; + + protected EntitySelectionContext(boolean p_i51181_1_, double p_i51181_2_, Item p_i51181_4_) { ++ this(null, p_i51181_1_, p_i51181_2_, p_i51181_4_); ++ } ++ ++ protected EntitySelectionContext(@javax.annotation.Nullable Entity entityIn, boolean p_i51181_1_, double p_i51181_2_, Item p_i51181_4_) { ++ this.entity = entityIn; + this.field_216380_b = p_i51181_1_; + this.field_216381_c = p_i51181_2_; + this.field_216382_d = p_i51181_4_; +@@ -25,7 +30,7 @@ + + @Deprecated + protected EntitySelectionContext(Entity p_i51182_1_) { +- this(p_i51182_1_.func_70093_af(), p_i51182_1_.func_174813_aQ().field_72338_b, p_i51182_1_ instanceof LivingEntity ? ((LivingEntity)p_i51182_1_).func_184614_ca().func_77973_b() : Items.field_190931_a); ++ this(p_i51182_1_, p_i51182_1_.func_70093_af(), p_i51182_1_.func_174813_aQ().field_72338_b, p_i51182_1_ instanceof LivingEntity ? ((LivingEntity)p_i51182_1_).func_184614_ca().func_77973_b() : Items.field_190931_a); + } + + public boolean func_216375_a(Item p_216375_1_) { +@@ -39,4 +44,11 @@ + public boolean func_216378_a(VoxelShape p_216378_1_, BlockPos p_216378_2_, boolean p_216378_3_) { + return this.field_216381_c > (double)p_216378_2_.func_177956_o() + p_216378_1_.func_197758_c(Direction.Axis.Y) - (double)1.0E-5F; + } ++ ++ private final @javax.annotation.Nullable Entity entity; ++ ++ @Override ++ public @javax.annotation.Nullable Entity getEntity() { ++ return entity; ++ } + } diff --git a/patches/minecraft/net/minecraft/util/math/shapes/ISelectionContext.java.patch b/patches/minecraft/net/minecraft/util/math/shapes/ISelectionContext.java.patch new file mode 100644 index 000000000..13cd00bf6 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/math/shapes/ISelectionContext.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/util/math/shapes/ISelectionContext.java ++++ b/net/minecraft/util/math/shapes/ISelectionContext.java +@@ -4,7 +4,7 @@ + import net.minecraft.item.Item; + import net.minecraft.util.math.BlockPos; + +-public interface ISelectionContext { ++public interface ISelectionContext extends net.minecraftforge.common.extensions.IForgeSelectionContext { + static ISelectionContext func_216377_a() { + return EntitySelectionContext.field_216379_a; + } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeSelectionContext.java b/src/main/java/net/minecraftforge/common/extensions/IForgeSelectionContext.java new file mode 100644 index 000000000..61e539df9 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeSelectionContext.java @@ -0,0 +1,13 @@ +package net.minecraftforge.common.extensions; + +import javax.annotation.Nullable; + +import net.minecraft.entity.Entity; + +public interface IForgeSelectionContext +{ + default @Nullable Entity getEntity() + { + return null; + } +} diff --git a/src/main/resources/forge.exc b/src/main/resources/forge.exc index 80fcb5fc3..aa22b54e7 100644 --- a/src/main/resources/forge.exc +++ b/src/main/resources/forge.exc @@ -75,3 +75,5 @@ net/minecraft/world/storage/loot/LootEntryEmpty.(II[Lnet/minecraft/world/s net/minecraft/world/storage/loot/LootEntryItem.(Lnet/minecraft/item/Item;II[Lnet/minecraft/world/storage/loot/functions/LootFunction;[Lnet/minecraft/world/storage/loot/conditions/LootCondition;Ljava/lang/String;)V=|p_i46644_1_,p_i46644_2_,p_i46644_3_,p_i46644_4_,p_i46644_5_,entryName net/minecraft/world/storage/loot/LootEntryTable.(Lnet/minecraft/util/ResourceLocation;II[Lnet/minecraft/world/storage/loot/conditions/LootCondition;Ljava/lang/String;)V=|p_i46639_1_,p_i46639_2_,p_i46639_3_,p_i46639_4_,entryName net/minecraft/world/storage/loot/LootPool.([Lnet/minecraft/world/storage/loot/LootEntry;[Lnet/minecraft/world/storage/loot/conditions/LootCondition;Lnet/minecraft/world/storage/loot/RandomValueRange;Lnet/minecraft/world/storage/loot/RandomValueRange;Ljava/lang/String;)V=|p_i46643_1_,p_i46643_2_,p_i46643_3_,p_i46643_4_ + +net/minecraft/util/shapes/EntitySelectionContext.(Lnet/minecraft/entity/Entity;ZDLnet/minecraft/item/Item;)V=|entity,p_i51181_1_,p_i51181_2_,p_i51181_4_ \ No newline at end of file