mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 19:59:42 +00:00
Add position to BreakSpeed event. Closes #621
This commit is contained in:
1 parent
f436b3e62d
commit
d9a1c718bf
4 files changed
+55
-31
No files matched your search
@@ -114,11 +114,11 @@ public class ForgeHooks
|
||||
|
||||
if (!canHarvestBlock(block, player, metadata))
|
||||
{
|
||||
return player.getBreakSpeed(block, true, metadata) / hardness / 100F;
|
||||
return player.getBreakSpeed(block, true, metadata, x, y, z) / hardness / 100F;
|
||||
}
|
||||
else
|
||||
{
|
||||
return player.getBreakSpeed(block, false, metadata) / hardness / 30F;
|
||||
return player.getBreakSpeed(block, false, metadata, x, y, z) / hardness / 30F;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,15 @@ public class ForgeEventFactory
|
||||
return event.success;
|
||||
}
|
||||
|
||||
@Deprecated // Location version below
|
||||
public static float getBreakSpeed(EntityPlayer player, Block block, int metadata, float original)
|
||||
{
|
||||
PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, block, metadata, original);
|
||||
return getBreakSpeed(player, block, metadata, original, 0, -1, 0);
|
||||
}
|
||||
|
||||
public static float getBreakSpeed(EntityPlayer player, Block block, int metadata, float original, int x, int y, int z)
|
||||
{
|
||||
PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, block, metadata, original, x, y, z);
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.newSpeed);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,14 +34,26 @@ public class PlayerEvent extends LivingEvent
|
||||
public final int metadata;
|
||||
public final float originalSpeed;
|
||||
public float newSpeed = 0.0f;
|
||||
public final int x;
|
||||
public final int y; // -1 notes unknown location
|
||||
public final int z;
|
||||
|
||||
@Deprecated
|
||||
public BreakSpeed(EntityPlayer player, Block block, int metadata, float original)
|
||||
{
|
||||
this(player, block, metadata, original, 0, -1, 0);
|
||||
}
|
||||
|
||||
public BreakSpeed(EntityPlayer player, Block block, int metadata, float original, int x, int y, int z)
|
||||
{
|
||||
super(player);
|
||||
this.block = block;
|
||||
this.metadata = metadata;
|
||||
this.originalSpeed = original;
|
||||
this.newSpeed = original;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user