Re-implement state.onBlockExploded() Closes #5914

This commit is contained in:
LexManos 2019-07-09 17:07:09 -07:00
parent d88e4fbf36
commit 983e0a93db
3 changed files with 40 additions and 2 deletions

View file

@ -48,7 +48,16 @@
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld)this.field_77287_j)).func_216023_a(this.field_77287_j.field_73012_v).func_216015_a(LootParameters.field_216286_f, blockpos).func_216015_a(LootParameters.field_216289_i, ItemStack.field_190927_a).func_216021_b(LootParameters.field_216288_h, tileentity);
if (this.field_222260_b == Explosion.Mode.DESTROY) {
lootcontext$builder.func_216015_a(LootParameters.field_216290_j, this.field_77280_f);
@@ -248,7 +251,7 @@
@@ -240,15 +243,14 @@
Block.func_220078_b(blockstate, lootcontext$builder);
}
- this.field_77287_j.func_180501_a(blockpos, Blocks.field_150350_a.func_176223_P(), 3);
- block.func_180652_a(this.field_77287_j, blockpos, this);
+ blockstate.onBlockExploded(this.field_77287_j, blockpos, this);
}
}
}
if (this.field_77286_a) {
for(BlockPos blockpos1 : this.field_77281_g) {
@ -57,7 +66,7 @@
this.field_77287_j.func_175656_a(blockpos1, Blocks.field_150480_ab.func_176223_P());
}
}
@@ -287,6 +290,10 @@
@@ -287,6 +289,10 @@
return this.field_77281_g;
}

View file

@ -1009,4 +1009,19 @@ public interface IForgeBlock
* This should be used in favor of TagCollection.getOwningTags, as this caches the result and automatically updates when the TagCollection changes.
*/
Set<ResourceLocation> getTags();
/**
* Called when the block is destroyed by an explosion.
* Useful for allowing the block to take into account tile entities,
* state, etc. when exploded, before it is removed.
*
* @param world The current world
* @param pos Block position in world
* @param explosion The explosion instance affecting the block
*/
default void onBlockExploded(BlockState state, World world, BlockPos pos, Explosion explosion)
{
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
getBlock().onExplosionDestroy(world, pos, explosion);
}
}

View file

@ -853,4 +853,18 @@ public interface IForgeBlockState
{
return getBlockState().getBlock().canDropFromExplosion(getBlockState(), world, pos, explosion);
}
/**
* Called when the block is destroyed by an explosion.
* Useful for allowing the block to take into account tile entities,
* state, etc. when exploded, before it is removed.
*
* @param world The current world
* @param pos Block position in world
* @param explosion The explosion instance affecting the block
*/
default void onBlockExploded(World world, BlockPos pos, Explosion explosion)
{
getBlockState().getBlock().onBlockExploded(getBlockState(), world, pos, explosion);
}
}