New block destruction hook. Deprecated IOverrideReplace.
This commit is contained in:
parent
8acaaa0e53
commit
f1a6f45353
5 changed files with 62 additions and 7 deletions
|
@ -13,6 +13,7 @@ import net.minecraft.src.World;
|
|||
* to control how it can be replaced
|
||||
*
|
||||
* @see Block
|
||||
* @deprecated. This functionality will be removed soon.
|
||||
*/
|
||||
public interface IOverrideReplace {
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
}
|
||||
|
||||
protected void dropBlockAsItem_do(World world, int i, int j, int k, ItemStack itemstack)
|
||||
@@ -618,6 +629,86 @@
|
||||
@@ -618,6 +629,96 @@
|
||||
return iblockaccess.isBlockNormalCube(i, j, k) ? 0.2F : 1.0F;
|
||||
}
|
||||
|
||||
|
@ -184,6 +184,16 @@
|
|||
+ public boolean canHarvestBlock(EntityPlayer player, int md) {
|
||||
+ return ForgeHooks.canHarvestBlock(this,player,md);
|
||||
+ }
|
||||
+
|
||||
+ /* FORGE: Called when a player removes a block. This is responsible for
|
||||
+ * actually destroying the block, and the block is intact at time of call.
|
||||
+ * This is called regardless of whether the player can harvest the block or
|
||||
+ * not. Return true if the block is actually destroyed.
|
||||
+ */
|
||||
+ public boolean removeBlockByPlayer(World world, EntityPlayer player,
|
||||
+ int i, int j, int k) {
|
||||
+ return world.setBlockWithNotify(i, j, k, 0);
|
||||
+ }
|
||||
+
|
||||
static Class _mthclass$(String s)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,25 @@
|
|||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -64,6 +65,7 @@
|
||||
@@ -36,12 +37,11 @@
|
||||
}
|
||||
world.playAuxSFX(2001, i, j, k, block.blockID + world.getBlockMetadata(i, j, k) * 256);
|
||||
int i1 = world.getBlockMetadata(i, j, k);
|
||||
- boolean flag = world.setBlockWithNotify(i, j, k, 0);
|
||||
- if(block != null && flag)
|
||||
- {
|
||||
- block.onBlockDestroyedByPlayer(world, i, j, k, i1);
|
||||
- }
|
||||
- return flag;
|
||||
+
|
||||
+ if(block==null) return false;
|
||||
+ boolean flag = block.removeBlockByPlayer(world,mc.thePlayer,i,j,k);
|
||||
+ if(flag) block.onBlockDestroyedByPlayer(world, i, j, k, i1);
|
||||
+ return flag;
|
||||
}
|
||||
|
||||
public abstract void sendBlockRemoving(int i, int j, int k, int l);
|
||||
@@ -64,6 +64,7 @@
|
||||
if(itemstack1.stackSize == 0)
|
||||
{
|
||||
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = null;
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
}
|
||||
|
||||
protected void dropBlockAsItem_do(World world, int i, int j, int k, ItemStack itemstack)
|
||||
@@ -529,6 +538,86 @@
|
||||
@@ -529,6 +538,96 @@
|
||||
return blockMaterial.getMaterialMobility();
|
||||
}
|
||||
|
||||
|
@ -167,6 +167,16 @@
|
|||
+ public boolean canHarvestBlock(EntityPlayer player, int md) {
|
||||
+ return ForgeHooks.canHarvestBlock(this,player,md);
|
||||
+ }
|
||||
+
|
||||
+ /* FORGE: Called when a player removes a block. This is responsible for
|
||||
+ * actually destroying the block, and the block is intact at time of call.
|
||||
+ * This is called regardless of whether the player can harvest the block or
|
||||
+ * not. Return true if the block is actually destroyed.
|
||||
+ */
|
||||
+ public boolean removeBlockByPlayer(World world, EntityPlayer player,
|
||||
+ int i, int j, int k) {
|
||||
+ return world.setBlockWithNotify(i, j, k, 0);
|
||||
+ }
|
||||
+
|
||||
static Class _mthclass$(String s)
|
||||
{
|
||||
|
|
|
@ -38,7 +38,23 @@
|
|||
if(f >= 0.7F)
|
||||
{
|
||||
blockHarvessted(i, j, k);
|
||||
@@ -164,7 +166,7 @@
|
||||
@@ -135,11 +137,10 @@
|
||||
{
|
||||
Block block = Block.blocksList[thisWorld.getBlockId(i, j, k)];
|
||||
int l = thisWorld.getBlockMetadata(i, j, k);
|
||||
- boolean flag = thisWorld.setBlockWithNotify(i, j, k, 0);
|
||||
- if(block != null && flag)
|
||||
- {
|
||||
- block.onBlockDestroyedByPlayer(thisWorld, i, j, k, l);
|
||||
- }
|
||||
+
|
||||
+ if(block==null) return false;
|
||||
+ boolean flag = block.removeBlockByPlayer(thisWorld,thisPlayer,i,j,k);
|
||||
+ if(flag) block.onBlockDestroyedByPlayer(thisWorld, i, j, k, l);
|
||||
return flag;
|
||||
}
|
||||
|
||||
@@ -164,7 +165,7 @@
|
||||
thisPlayer.destroyCurrentEquippedItem();
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +63,7 @@
|
|||
{
|
||||
Block.blocksList[l].harvestBlock(thisWorld, thisPlayer, i, j, k, i1);
|
||||
}
|
||||
@@ -188,6 +190,7 @@
|
||||
@@ -188,6 +189,7 @@
|
||||
if(itemstack1.stackSize == 0)
|
||||
{
|
||||
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = null;
|
||||
|
@ -55,7 +71,7 @@
|
|||
}
|
||||
return true;
|
||||
} else
|
||||
@@ -198,6 +201,11 @@
|
||||
@@ -198,6 +200,11 @@
|
||||
|
||||
public boolean activeBlockOrUseItem(EntityPlayer entityplayer, World world, ItemStack itemstack, int i, int j, int k, int l)
|
||||
{
|
||||
|
@ -67,7 +83,7 @@
|
|||
int i1 = world.getBlockId(i, j, k);
|
||||
if(i1 > 0 && Block.blocksList[i1].blockActivated(world, i, j, k, entityplayer))
|
||||
{
|
||||
@@ -217,7 +225,11 @@
|
||||
@@ -217,7 +224,11 @@
|
||||
return flag;
|
||||
} else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue