Seperated block placmenet logic in ItemBlock as immibis requested: https://github.com/MinecraftForge/MinecraftForge/pull/110
This commit is contained in:
parent
57441b8678
commit
60a9655602
1 changed files with 56 additions and 0 deletions
|
@ -10,3 +10,59 @@
|
|||
{
|
||||
if (par7 == 0)
|
||||
{
|
||||
@@ -81,14 +82,8 @@
|
||||
{
|
||||
Block var12 = Block.blocksList[this.blockID];
|
||||
|
||||
- if (par3World.setBlockAndMetadataWithNotify(par4, par5, par6, this.blockID, this.getMetadata(par1ItemStack.getItemDamage())))
|
||||
- {
|
||||
- if (par3World.getBlockId(par4, par5, par6) == this.blockID)
|
||||
- {
|
||||
- Block.blocksList[this.blockID].updateBlockMetadata(par3World, par4, par5, par6, par7, par8, par9, par10);
|
||||
- Block.blocksList[this.blockID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer);
|
||||
- }
|
||||
-
|
||||
+ if (placeBlockAt(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10))
|
||||
+ {
|
||||
par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), var12.stepSound.getStepSound(), (var12.stepSound.getVolume() + 1.0F) / 2.0F, var12.stepSound.getPitch() * 0.8F);
|
||||
--par1ItemStack.stackSize;
|
||||
}
|
||||
@@ -114,7 +109,8 @@
|
||||
{
|
||||
par5 = 1;
|
||||
}
|
||||
- else if (var8 != Block.vine.blockID && var8 != Block.tallGrass.blockID && var8 != Block.deadBush.blockID)
|
||||
+ else if (var8 != Block.vine.blockID && var8 != Block.tallGrass.blockID && var8 != Block.deadBush.blockID
|
||||
+ && (Block.blocksList[var8] == null || !Block.blocksList[var8].isBlockReplaceable(par1World, par2, par3, par4)))
|
||||
{
|
||||
if (par5 == 0)
|
||||
{
|
||||
@@ -179,4 +175,28 @@
|
||||
{
|
||||
Block.blocksList[this.blockID].getSubBlocks(par1, par2CreativeTabs, par3List);
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Called to actually place the block, after the location is determined
|
||||
+ * and all permission checks have been made.
|
||||
+ *
|
||||
+ * @param stack The item stack that was used to place the block. This can be changed inside the method.
|
||||
+ * @param player The player who is placing the block. Can be null if the block is not being placed by a player.
|
||||
+ * @param side The side the player (or machine) right-clicked on.
|
||||
+ */
|
||||
+ public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
+ {
|
||||
+ if (!world.setBlockAndMetadataWithNotify(x, y, z, this.blockID, this.getMetadata(stack.getItemDamage())))
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (world.getBlockId(x, y, z) == this.blockID)
|
||||
+ {
|
||||
+ Block.blocksList[this.blockID].updateBlockMetadata(world, x, y, z, side, hitX, hitY, hitZ);
|
||||
+ Block.blocksList[this.blockID].onBlockPlacedBy(world, x, y, z, player);
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue