diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 738665cae..b1a048508 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -91,7 +91,7 @@ int l = itemstack != null ? itemstack.field_77994_a : 0; - if (this.field_71442_b.func_78760_a(this.field_71439_g, this.field_71441_e, itemstack, i, j, k, this.field_71476_x.field_72310_e, this.field_71476_x.field_72307_f)) -+ boolean result = !ForgeEventFactory.onPlayerInteract(field_71439_g, Action.RIGHT_CLICK_BLOCK, i, j, k, this.field_71476_x.field_72310_e).isCanceled(); ++ boolean result = !ForgeEventFactory.onPlayerInteract(field_71439_g, Action.RIGHT_CLICK_BLOCK, i, j, k, this.field_71476_x.field_72310_e, this.field_71441_e).isCanceled(); + if (result && this.field_71442_b.func_78760_a(this.field_71439_g, this.field_71441_e, itemstack, i, j, k, this.field_71476_x.field_72310_e, this.field_71476_x.field_72307_f)) { flag = false; @@ -101,7 +101,7 @@ ItemStack itemstack1 = this.field_71439_g.field_71071_by.func_70448_g(); - if (itemstack1 != null && this.field_71442_b.func_78769_a(this.field_71439_g, this.field_71441_e, itemstack1)) -+ boolean result = !ForgeEventFactory.onPlayerInteract(field_71439_g, Action.RIGHT_CLICK_AIR, 0, 0, 0, -1).isCanceled(); ++ boolean result = !ForgeEventFactory.onPlayerInteract(field_71439_g, Action.RIGHT_CLICK_AIR, 0, 0, 0, -1, this.field_71441_e).isCanceled(); + if (result && itemstack1 != null && this.field_71442_b.func_78769_a(this.field_71439_g, this.field_71441_e, itemstack1)) { this.field_71460_t.field_78516_c.func_78445_c(); diff --git a/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch b/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch index 6d8ca05a9..86b999477 100644 --- a/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch +++ b/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch @@ -108,7 +108,7 @@ } - this.field_147369_b.field_71134_c.func_73085_a(this.field_147369_b, worldserver, itemstack); -+ PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(field_147369_b, PlayerInteractEvent.Action.RIGHT_CLICK_AIR, 0, 0, 0, -1); ++ PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(field_147369_b, PlayerInteractEvent.Action.RIGHT_CLICK_AIR, 0, 0, 0, -1, worldserver); + if (event.useItem != Event.Result.DENY) + { + this.field_147369_b.field_71134_c.func_73085_a(this.field_147369_b, worldserver, itemstack); diff --git a/patches/minecraft/net/minecraft/server/management/ItemInWorldManager.java.patch b/patches/minecraft/net/minecraft/server/management/ItemInWorldManager.java.patch index 727519aa4..f4f971dad 100644 --- a/patches/minecraft/net/minecraft/server/management/ItemInWorldManager.java.patch +++ b/patches/minecraft/net/minecraft/server/management/ItemInWorldManager.java.patch @@ -28,7 +28,7 @@ { if (!this.field_73091_c.func_82752_c() || this.field_73090_b.func_82246_f(p_73074_1_, p_73074_2_, p_73074_3_)) { -+ PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(field_73090_b, Action.LEFT_CLICK_BLOCK, p_73074_1_, p_73074_2_, p_73074_3_, p_73074_4_); ++ PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(field_73090_b, Action.LEFT_CLICK_BLOCK, p_73074_1_, p_73074_2_, p_73074_3_, p_73074_4_, field_73092_a); + if (event.isCanceled()) + { + field_73090_b.field_71135_a.func_147359_a(new S23PacketBlockChange(p_73074_1_, p_73074_2_, p_73074_3_, field_73092_a)); @@ -170,7 +170,7 @@ public boolean func_73078_a(EntityPlayer p_73078_1_, World p_73078_2_, ItemStack p_73078_3_, int p_73078_4_, int p_73078_5_, int p_73078_6_, int p_73078_7_, float p_73078_8_, float p_73078_9_, float p_73078_10_) { - if ((!p_73078_1_.func_70093_af() || p_73078_1_.func_70694_bm() == null) && p_73078_2_.func_147439_a(p_73078_4_, p_73078_5_, p_73078_6_).func_149727_a(p_73078_2_, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_1_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_)) -+ PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(p_73078_1_, Action.RIGHT_CLICK_BLOCK, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_); ++ PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(p_73078_1_, Action.RIGHT_CLICK_BLOCK, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_2_); + if (event.isCanceled()) { - return true; diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 1110d00cf..c19f4a92c 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -51,9 +51,14 @@ public class ForgeEventFactory return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.newSpeed); } + @Deprecated public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face) { - PlayerInteractEvent event = new PlayerInteractEvent(player, action, x, y, z, face); + return onPlayerInteract(player, action, x, y, z, face, null); + } + public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face, World world) + { + PlayerInteractEvent event = new PlayerInteractEvent(player, action, x, y, z, face, world); MinecraftForge.EVENT_BUS.post(event); return event; } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java index 4269edc6b..41ac206d6 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java @@ -1,8 +1,10 @@ package net.minecraftforge.event.entity.player; -import cpw.mods.fml.common.eventhandler.Cancelable; +import static cpw.mods.fml.common.eventhandler.Event.Result.DEFAULT; +import static cpw.mods.fml.common.eventhandler.Event.Result.DENY; import net.minecraft.entity.player.EntityPlayer; -import static cpw.mods.fml.common.eventhandler.Event.Result.*; +import net.minecraft.world.World; +import cpw.mods.fml.common.eventhandler.Cancelable; @Cancelable public class PlayerInteractEvent extends PlayerEvent @@ -19,11 +21,18 @@ public class PlayerInteractEvent extends PlayerEvent public final int y; public final int z; public final int face; + public final World world; public Result useBlock = DEFAULT; public Result useItem = DEFAULT; - + + @Deprecated public PlayerInteractEvent(EntityPlayer player, Action action, int x, int y, int z, int face) + { + this(player, action, x, y, z, face, player.worldObj); + } + + public PlayerInteractEvent(EntityPlayer player, Action action, int x, int y, int z, int face, World world) { super(player); this.action = action; @@ -32,6 +41,7 @@ public class PlayerInteractEvent extends PlayerEvent this.z = z; this.face = face; if (face == -1) useBlock = DENY; + this.world = world; } @Override