From be5eb87a0cb46f9cb4e134ff3da24eaa10ac7d22 Mon Sep 17 00:00:00 2001 From: KRP-byte <85948056+KRP-byte@users.noreply.github.com> Date: Mon, 28 Jun 2021 11:40:19 +0300 Subject: [PATCH 1/3] API for creation of explosion-proof and wither-proof machines --- .../gregtech/api/block/machines/BlockMachine.java | 15 +++++++++++++++ .../api/metatileentity/MetaTileEntity.java | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/gregtech/api/block/machines/BlockMachine.java b/src/main/java/gregtech/api/block/machines/BlockMachine.java index dfd3e44891d..dc096d422d4 100755 --- a/src/main/java/gregtech/api/block/machines/BlockMachine.java +++ b/src/main/java/gregtech/api/block/machines/BlockMachine.java @@ -481,4 +481,19 @@ public boolean supportsVisualConnections() { protected Pair getParticleTexture(World world, BlockPos blockPos) { return MetaTileEntityRenderer.INSTANCE.getParticleTexture(world, blockPos); } + + @Override + public void onBlockExploded(World world, BlockPos pos, Explosion explosion) { + MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos); + if(!metaTileEntity.getExplosionProof()) { + world.setBlockToAir(pos); + this.onExplosionDestroy(world, pos, explosion); + } + } + + @Override + public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) { + MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos); + return !(entity instanceof EntityWither && metaTileEntity.getWitherProof()); + } } diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index aec1bc3113f..7d10da15e70 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -1229,4 +1229,12 @@ public float getBlockHardness() { public float getBlockResistance() { return 6.0f; } + + public boolean getExplosionProof(){ + return false; + } + + public boolean getWitherProof(){ + return false; + } } From 5add2660125b3ff8352847146bf39341257bddc3 Mon Sep 17 00:00:00 2001 From: KRP-byte <85948056+KRP-byte@users.noreply.github.com> Date: Mon, 28 Jun 2021 12:08:28 +0300 Subject: [PATCH 2/3] removed redundant code --- src/main/java/gregtech/api/metatileentity/MetaTileEntity.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 7d10da15e70..7180423ed2a 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -1230,10 +1230,6 @@ public float getBlockResistance() { return 6.0f; } - public boolean getExplosionProof(){ - return false; - } - public boolean getWitherProof(){ return false; } From 7a18ba2796b315fb7faa313b69ba995eeb8b21eb Mon Sep 17 00:00:00 2001 From: KRP-byte <85948056+KRP-byte@users.noreply.github.com> Date: Mon, 28 Jun 2021 12:10:42 +0300 Subject: [PATCH 3/3] Removed redundant code --- .../gregtech/api/block/machines/BlockMachine.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/gregtech/api/block/machines/BlockMachine.java b/src/main/java/gregtech/api/block/machines/BlockMachine.java index dc096d422d4..27ff822c1bc 100755 --- a/src/main/java/gregtech/api/block/machines/BlockMachine.java +++ b/src/main/java/gregtech/api/block/machines/BlockMachine.java @@ -482,18 +482,9 @@ protected Pair getParticleTexture(World world, Bloc return MetaTileEntityRenderer.INSTANCE.getParticleTexture(world, blockPos); } - @Override - public void onBlockExploded(World world, BlockPos pos, Explosion explosion) { - MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos); - if(!metaTileEntity.getExplosionProof()) { - world.setBlockToAir(pos); - this.onExplosionDestroy(world, pos, explosion); - } - } - @Override public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) { MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos); - return !(entity instanceof EntityWither && metaTileEntity.getWitherProof()); + return !((entity instanceof EntityWither || entity instanceof EntityWitherSkull) && metaTileEntity.getWitherProof()); } }