Block protection compat overhaul
- Unifies all block protection checks into helper methods in BlockUtils which trigger all the necessary forge events and vanilla methods - Implements these checks in all the appropriate places and removes calls to EntityUtils#canDamageBlocks(...) where they are no longer needed - Changes the mine spell to respect the config settings in line with the rest of the spells - Fixes earthquake not respecting the settings at all - Adds a separate config option for dispenser block damage and updates the description for the existing settings to reflect the changes
This commit is contained in:
@@ -109,7 +109,7 @@ public class EntityBlackHole extends EntityScaledConstruct {
|
||||
if(rand.nextInt(Math.max(1, (int)this.getDistanceSq(pos) * 3)) == 0){
|
||||
|
||||
if(!BlockUtils.isBlockUnbreakable(world, pos) && !world.isAirBlock(pos)
|
||||
&& world.isBlockNormalCube(pos, false)){
|
||||
&& world.isBlockNormalCube(pos, false) && BlockUtils.canBreakBlock(getCaster(), world, pos)){
|
||||
// Checks that the block above is not solid, since this causes the falling block to vanish.
|
||||
// && !world.isBlockNormalCube(pos.up(), false)){
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import electroblob.wizardry.registry.Spells;
|
||||
import electroblob.wizardry.registry.WizardrySounds;
|
||||
import electroblob.wizardry.spell.Boulder;
|
||||
import electroblob.wizardry.spell.Spell;
|
||||
import electroblob.wizardry.util.BlockUtils;
|
||||
import electroblob.wizardry.util.EntityUtils;
|
||||
import electroblob.wizardry.util.MagicDamage;
|
||||
import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
@@ -119,7 +120,8 @@ public class EntityBoulder extends EntityScaledConstruct {
|
||||
*/
|
||||
private boolean smashBlocks(List<BlockPos> blocks, boolean breakIfTooHard){
|
||||
|
||||
if(blocks.removeIf(p -> world.getBlockState(p).getBlock().getExplosionResistance(world, p, this, null) > 3)){
|
||||
if(blocks.removeIf(p -> world.getBlockState(p).getBlock().getExplosionResistance(world, p, this, null) > 3
|
||||
|| (!world.isRemote && !BlockUtils.canBreakBlock(getCaster(), world, p)))){
|
||||
// If any of the blocks were not breakable, the boulder is smashed
|
||||
if(breakIfTooHard){
|
||||
this.despawn();
|
||||
|
||||
@@ -43,7 +43,7 @@ public class EntityCombustionRune extends EntityScaledConstruct {
|
||||
float strength = Spells.combustion_rune.getProperty(Spell.BLAST_RADIUS).floatValue() * sizeMultiplier;
|
||||
|
||||
world.newExplosion(this.getCaster(), this.posX, this.posY, this.posZ, strength, true,
|
||||
getCaster() != null && EntityUtils.canDamageBlocks(getCaster(), world));
|
||||
EntityUtils.canDamageBlocks(getCaster(), world));
|
||||
|
||||
// The trap is destroyed once triggered.
|
||||
this.setDead();
|
||||
|
||||
@@ -31,7 +31,7 @@ public class EntityEarthquake extends EntityMagicConstruct { // NOT a scaled con
|
||||
|
||||
double speed = Spells.earthquake.getProperty(Earthquake.SPREAD_SPEED).doubleValue();
|
||||
|
||||
if(!world.isRemote){
|
||||
if(!world.isRemote && EntityUtils.canDamageBlocks(getCaster(), world)){
|
||||
|
||||
// The further the earthquake is going to spread, the finer the angle increments.
|
||||
for(float angle = 0; angle < 2 * Math.PI; angle += Math.PI / (lifetime * 1.5)){
|
||||
@@ -46,10 +46,9 @@ public class EntityEarthquake extends EntityMagicConstruct { // NOT a scaled con
|
||||
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
if(!BlockUtils.isBlockUnbreakable(world, pos) && !world.isAirBlock(pos)
|
||||
&& world.isBlockNormalCube(pos, false)
|
||||
if(!BlockUtils.isBlockUnbreakable(world, pos) && !world.isAirBlock(pos) && world.isBlockNormalCube(pos, false)
|
||||
// Checks that the block above is not solid, since this causes the falling sand to vanish.
|
||||
&& !world.isBlockNormalCube(pos.up(), false)){
|
||||
&& !world.isBlockNormalCube(pos.up(), false) && BlockUtils.canBreakBlock(getCaster(), world, pos)){
|
||||
|
||||
// Falling blocks do the setting block to air themselves.
|
||||
EntityFallingBlock fallingblock = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5,
|
||||
|
||||
Reference in New Issue
Block a user