Add position to BreakSpeed event. Closes #621
This commit is contained in:
parent
f436b3e62d
commit
d9a1c718bf
4 changed files with 55 additions and 31 deletions
|
@ -188,7 +188,7 @@
|
|||
}
|
||||
|
||||
public EntityItem func_146097_a(ItemStack p_146097_1_, boolean p_146097_2_, boolean p_146097_3_)
|
||||
@@ -723,13 +786,25 @@
|
||||
@@ -723,13 +786,31 @@
|
||||
|
||||
public void func_71012_a(EntityItem p_71012_1_)
|
||||
{
|
||||
|
@ -204,18 +204,24 @@
|
|||
public float func_146096_a(Block p_146096_1_, boolean p_146096_2_)
|
||||
{
|
||||
- float f = this.field_71071_by.func_146023_a(p_146096_1_);
|
||||
+ return getBreakSpeed(p_146096_1_, p_146096_2_, 0);
|
||||
+ return getBreakSpeed(p_146096_1_, p_146096_2_, 0, 0, -1, 0);
|
||||
+ }
|
||||
|
||||
+ @Deprecated //Location Specifc, one below, remove in 1.8
|
||||
+ public float getBreakSpeed(Block p_146096_1_, boolean p_146096_2_, int meta)
|
||||
+ {
|
||||
+ return getBreakSpeed(p_146096_1_, p_146096_2_, meta, 0, -1, 0);
|
||||
+ }
|
||||
+
|
||||
+ public float getBreakSpeed(Block p_146096_1_, boolean p_146096_2_, int meta, int x, int y, int z)
|
||||
+ {
|
||||
+ ItemStack stack = field_71071_by.func_70448_g();
|
||||
+ float f = (stack == null ? 1.0F : stack.func_77973_b().getDigSpeed(stack, p_146096_1_, meta));
|
||||
+
|
||||
if (f > 1.0F)
|
||||
{
|
||||
int i = EnchantmentHelper.func_77509_b(this);
|
||||
@@ -739,7 +814,9 @@
|
||||
@@ -739,7 +820,9 @@
|
||||
{
|
||||
float f1 = (float)(i * i + 1);
|
||||
|
||||
|
@ -226,12 +232,12 @@
|
|||
{
|
||||
f += f1 * 0.08F;
|
||||
}
|
||||
@@ -770,12 +847,13 @@
|
||||
@@ -770,12 +853,13 @@
|
||||
f /= 5.0F;
|
||||
}
|
||||
|
||||
- return f;
|
||||
+ f = ForgeEventFactory.getBreakSpeed(this, p_146096_1_, meta, f);
|
||||
+ f = ForgeEventFactory.getBreakSpeed(this, p_146096_1_, meta, f, x, y, z);
|
||||
+ return (f < 0 ? 0 : f);
|
||||
}
|
||||
|
||||
|
@ -242,7 +248,7 @@
|
|||
}
|
||||
|
||||
public void func_70037_a(NBTTagCompound p_70037_1_)
|
||||
@@ -804,6 +882,16 @@
|
||||
@@ -804,6 +888,16 @@
|
||||
this.field_82248_d = p_70037_1_.func_74767_n("SpawnForced");
|
||||
}
|
||||
|
||||
|
@ -259,7 +265,7 @@
|
|||
this.field_71100_bB.func_75112_a(p_70037_1_);
|
||||
this.field_71075_bZ.func_75095_b(p_70037_1_);
|
||||
|
||||
@@ -834,6 +922,23 @@
|
||||
@@ -834,6 +928,23 @@
|
||||
p_70014_1_.func_74757_a("SpawnForced", this.field_82248_d);
|
||||
}
|
||||
|
||||
|
@ -283,7 +289,7 @@
|
|||
this.field_71100_bB.func_75117_b(p_70014_1_);
|
||||
this.field_71075_bZ.func_75091_a(p_70014_1_);
|
||||
p_70014_1_.func_74782_a("EnderItems", this.field_71078_a.func_70487_g());
|
||||
@@ -855,7 +960,7 @@
|
||||
@@ -855,7 +966,7 @@
|
||||
|
||||
public float func_70047_e()
|
||||
{
|
||||
|
@ -292,7 +298,7 @@
|
|||
}
|
||||
|
||||
protected void func_71061_d_()
|
||||
@@ -865,6 +970,7 @@
|
||||
@@ -865,6 +976,7 @@
|
||||
|
||||
public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_)
|
||||
{
|
||||
|
@ -300,7 +306,7 @@
|
|||
if (this.func_85032_ar())
|
||||
{
|
||||
return false;
|
||||
@@ -966,12 +1072,15 @@
|
||||
@@ -966,12 +1078,15 @@
|
||||
{
|
||||
if (!this.func_85032_ar())
|
||||
{
|
||||
|
@ -317,7 +323,7 @@
|
|||
p_70665_2_ = this.func_70672_c(p_70665_1_, p_70665_2_);
|
||||
float f1 = p_70665_2_;
|
||||
p_70665_2_ = Math.max(p_70665_2_ - this.func_110139_bj(), 0.0F);
|
||||
@@ -1005,6 +1114,7 @@
|
||||
@@ -1005,6 +1120,7 @@
|
||||
|
||||
public boolean func_70998_m(Entity p_70998_1_)
|
||||
{
|
||||
|
@ -325,7 +331,7 @@
|
|||
ItemStack itemstack = this.func_71045_bC();
|
||||
ItemStack itemstack1 = itemstack != null ? itemstack.func_77946_l() : null;
|
||||
|
||||
@@ -1055,7 +1165,9 @@
|
||||
@@ -1055,7 +1171,9 @@
|
||||
|
||||
public void func_71028_bD()
|
||||
{
|
||||
|
@ -335,7 +341,7 @@
|
|||
}
|
||||
|
||||
public double func_70033_W()
|
||||
@@ -1065,6 +1177,15 @@
|
||||
@@ -1065,6 +1183,15 @@
|
||||
|
||||
public void func_71059_n(Entity p_71059_1_)
|
||||
{
|
||||
|
@ -351,7 +357,7 @@
|
|||
if (p_71059_1_.func_70075_an())
|
||||
{
|
||||
if (!p_71059_1_.func_85031_j(this))
|
||||
@@ -1212,6 +1333,12 @@
|
||||
@@ -1212,6 +1339,12 @@
|
||||
|
||||
public EntityPlayer.EnumStatus func_71018_a(int p_71018_1_, int p_71018_2_, int p_71018_3_)
|
||||
{
|
||||
|
@ -364,7 +370,7 @@
|
|||
if (!this.field_70170_p.field_72995_K)
|
||||
{
|
||||
if (this.func_70608_bn() || !this.func_70089_S())
|
||||
@@ -1254,8 +1381,7 @@
|
||||
@@ -1254,8 +1387,7 @@
|
||||
|
||||
if (this.field_70170_p.func_72899_e(p_71018_1_, p_71018_2_, p_71018_3_))
|
||||
{
|
||||
|
@ -374,7 +380,7 @@
|
|||
float f1 = 0.5F;
|
||||
float f = 0.5F;
|
||||
|
||||
@@ -1322,11 +1448,12 @@
|
||||
@@ -1322,11 +1454,12 @@
|
||||
this.func_71061_d_();
|
||||
ChunkCoordinates chunkcoordinates = this.field_71081_bT;
|
||||
ChunkCoordinates chunkcoordinates1 = this.field_71081_bT;
|
||||
|
@ -390,7 +396,7 @@
|
|||
|
||||
if (chunkcoordinates1 == null)
|
||||
{
|
||||
@@ -1360,7 +1487,7 @@
|
||||
@@ -1360,7 +1493,7 @@
|
||||
|
||||
private boolean func_71065_l()
|
||||
{
|
||||
|
@ -399,7 +405,7 @@
|
|||
}
|
||||
|
||||
public static ChunkCoordinates func_71056_a(World p_71056_0_, ChunkCoordinates p_71056_1_, boolean p_71056_2_)
|
||||
@@ -1371,9 +1498,9 @@
|
||||
@@ -1371,9 +1504,9 @@
|
||||
ichunkprovider.func_73158_c(p_71056_1_.field_71574_a - 3 >> 4, p_71056_1_.field_71573_c + 3 >> 4);
|
||||
ichunkprovider.func_73158_c(p_71056_1_.field_71574_a + 3 >> 4, p_71056_1_.field_71573_c + 3 >> 4);
|
||||
|
||||
|
@ -411,7 +417,7 @@
|
|||
return chunkcoordinates1;
|
||||
}
|
||||
else
|
||||
@@ -1391,8 +1518,10 @@
|
||||
@@ -1391,8 +1524,10 @@
|
||||
{
|
||||
if (this.field_71081_bT != null)
|
||||
{
|
||||
|
@ -424,7 +430,7 @@
|
|||
|
||||
switch (j)
|
||||
{
|
||||
@@ -1448,18 +1577,25 @@
|
||||
@@ -1448,18 +1583,25 @@
|
||||
|
||||
public void func_146105_b(IChatComponent p_146105_1_) {}
|
||||
|
||||
|
@ -452,7 +458,7 @@
|
|||
if (p_71063_1_ != null)
|
||||
{
|
||||
this.field_71077_c = new ChunkCoordinates(p_71063_1_);
|
||||
@@ -1633,6 +1769,10 @@
|
||||
@@ -1633,6 +1775,10 @@
|
||||
|
||||
super.func_70069_a(p_70069_1_);
|
||||
}
|
||||
|
@ -463,7 +469,7 @@
|
|||
}
|
||||
|
||||
protected String func_146067_o(int p_146067_1_)
|
||||
@@ -1675,11 +1815,6 @@
|
||||
@@ -1675,11 +1821,6 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -475,7 +481,7 @@
|
|||
if (this.field_71074_e != null && p_70620_1_.func_77973_b() == Items.field_151031_f)
|
||||
{
|
||||
int j = p_70620_1_.func_77988_m() - this.field_71072_f;
|
||||
@@ -1699,6 +1834,7 @@
|
||||
@@ -1699,6 +1840,7 @@
|
||||
return Items.field_151031_f.func_94599_c(0);
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +489,7 @@
|
|||
}
|
||||
|
||||
return iicon;
|
||||
@@ -1782,6 +1918,8 @@
|
||||
@@ -1782,6 +1924,8 @@
|
||||
{
|
||||
if (p_71008_1_ != this.field_71074_e)
|
||||
{
|
||||
|
@ -492,7 +498,7 @@
|
|||
this.field_71074_e = p_71008_1_;
|
||||
this.field_71072_f = p_71008_2_;
|
||||
|
||||
@@ -1876,6 +2014,17 @@
|
||||
@@ -1876,6 +2020,17 @@
|
||||
}
|
||||
|
||||
this.field_71078_a = p_71049_1_.field_71078_a;
|
||||
|
@ -510,7 +516,7 @@
|
|||
}
|
||||
|
||||
protected boolean func_70041_e_()
|
||||
@@ -1914,7 +2063,14 @@
|
||||
@@ -1914,7 +2069,14 @@
|
||||
|
||||
public void func_70062_b(int p_70062_1_, ItemStack p_70062_2_)
|
||||
{
|
||||
|
@ -526,7 +532,7 @@
|
|||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -1959,7 +2115,7 @@
|
||||
@@ -1959,7 +2121,7 @@
|
||||
|
||||
public IChatComponent func_145748_c_()
|
||||
{
|
||||
|
@ -535,7 +541,7 @@
|
|||
chatcomponenttext.func_150256_b().func_150241_a(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.func_70005_c_() + " "));
|
||||
return chatcomponenttext;
|
||||
}
|
||||
@@ -2042,6 +2198,118 @@
|
||||
@@ -2042,6 +2204,118 @@
|
||||
FMLNetworkHandler.openGui(this, mod, modGuiId, world, x, y, z);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue