Add target world to PlayerInteractEvent for potential 'cross dimension' interaction such as LittleBlocks. Closes #1071
This commit is contained in:
parent
eb1ddab278
commit
b301b1f70c
5 changed files with 24 additions and 9 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue