Player sensitive version of Block.getPickBlock Closes #1348

This commit is contained in:
Lex Manos 2014-11-04 18:27:02 -08:00
parent ef0e0d7393
commit 47305ff691
2 changed files with 22 additions and 17 deletions

View File

@ -205,14 +205,14 @@
}
protected ItemStack func_149644_j(int p_149644_1_)
@@ -1116,6 +1155,1099 @@
@@ -1116,6 +1155,1104 @@
return null;
}
+ /* ======================================== FORGE START =====================================*/
+ //For ForgeInternal use Only!
+ protected ThreadLocal<EntityPlayer> harvesters = new ThreadLocal();
+ private ThreadLocal<Integer> silk_check_meta = new ThreadLocal();
+ private ThreadLocal<Integer> silk_check_meta = new ThreadLocal();
+ /**
+ * Get a light value for the block at the specified coordinates, normal ranges are between 0 and 15
+ *
@ -380,7 +380,7 @@
+ * @param x X Position
+ * @param y Y position
+ * @param z Z position
+ * @param willHarvest True if Block.harvestBlock will be called after this, if the return in true.
+ * @param willHarvest True if Block.harvestBlock will be called after this, if the return in true.
+ * Can be useful to delay the destruction of tile entities till after harvestBlock
+ * @return True if the block is actually destroyed.
+ */
@ -845,6 +845,11 @@
+ * @param target The full target the player is looking at
+ * @return A ItemStack to add to the player's inventory, Null if nothing should be added.
+ */
+ public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player)
+ {
+ return getPickBlock(target, world, x, y, z);
+ }
+ @Deprecated
+ public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
+ {
+ Item item = func_149694_d(world, x, y, z);
@ -1047,7 +1052,7 @@
+ }
+ else if (entity instanceof EntityDragon)
+ {
+ return this != Blocks.field_150343_Z && this != Blocks.field_150377_bs && this != Blocks.field_150357_h;
+ return this != Blocks.field_150343_Z && this != Blocks.field_150377_bs && this != Blocks.field_150357_h;
+ }
+
+ return true;
@ -1141,7 +1146,7 @@
+
+ /**
+ * Gathers how much experience this block drops when broken.
+ *
+ *
+ * @param world The world
+ * @param metadata
+ * @param fortune
@ -1184,7 +1189,7 @@
+ * If this block should be notified of weak changes.
+ * Weak changes are changes 1 block away through a solid block.
+ * Similar to comparators.
+ *
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y position
@ -1201,7 +1206,7 @@
+ private int[] harvestLevel = new int[]{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
+ /**
+ * Sets or removes the tool and level required to harvest this block.
+ *
+ *
+ * @param toolClass Class
+ * @param level Harvest level:
+ * Wood: 0
@ -1220,7 +1225,7 @@
+
+ /**
+ * Sets or removes the tool and level required to harvest this block.
+ *
+ *
+ * @param toolClass Class
+ * @param level Harvest level:
+ * Wood: 0
@ -1237,9 +1242,9 @@
+ }
+
+ /**
+ * Queries the class of tool required to harvest this block, if null is returned
+ * Queries the class of tool required to harvest this block, if null is returned
+ * we assume that anything can harvest this block.
+ *
+ *
+ * @param metadata
+ * @return
+ */
@ -1251,7 +1256,7 @@
+ /**
+ * Queries the harvest level of this item stack for the specifred tool class,
+ * Returns -1 if this tool is not of the specified type
+ *
+ *
+ * @param stack This item stack instance
+ * @return Harvest level, or -1 if not the specified tool type.
+ */
@ -1261,9 +1266,9 @@
+ }
+
+ /**
+ * Checks if the specified tool type is efficient on this block,
+ * Checks if the specified tool type is efficient on this block,
+ * meaning that it digs at full speed.
+ *
+ *
+ * @param type
+ * @param metadata
+ * @return

View File

@ -224,7 +224,7 @@ public class ForgeHooks
return false;
}
result = block.getPickBlock(target, world, x, y, z);
result = block.getPickBlock(target, world, x, y, z, player);
}
else
{
@ -475,10 +475,10 @@ public class ForgeHooks
{
itemstack.setTagCompound(nbt);
}
if (blockSnapshots.size() > 1)
if (blockSnapshots.size() > 1)
{
placeEvent = ForgeEventFactory.onPlayerMultiBlockPlace(player, blockSnapshots, net.minecraftforge.common.util.ForgeDirection.getOrientation(side));
}
}
else if (blockSnapshots.size() == 1)
{
placeEvent = ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshots.get(0), net.minecraftforge.common.util.ForgeDirection.getOrientation(side));
@ -540,7 +540,7 @@ public class ForgeHooks
container.stackSizeToBeUsedInRepair = e.materialCost;
return false;
}
public static float onAnvilRepair(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
{
AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);