Search in sources :

Example 1 with EntityTNTPrimedCQR

use of team.cqr.cqrepoured.entity.misc.EntityTNTPrimedCQR in project ChocolateQuestRepoured by TeamChocoQuest.

the class ProtectedRegionHelper method removeExplosionPreventedPositions.

public static void removeExplosionPreventedPositions(World world, Explosion explosion, boolean checkForOrigin) {
    IProtectedRegionManager manager = ProtectedRegionManager.getInstance(world);
    if (manager == null) {
        return;
    }
    List<BlockPos> affectedBlockPositions = explosion.getToBlow();
    if (affectedBlockPositions.isEmpty()) {
        return;
    }
    // If the exploder is our own custom tnt => let it blow!
    if (explosion.source instanceof EntityTNTPrimedCQR) {
        return;
    }
    boolean flag = explosion.source instanceof TNTEntity;
    boolean flag1 = (flag && CQRConfig.dungeonProtection.enablePreventExplosionTNT) || (!flag && CQRConfig.dungeonProtection.enablePreventExplosionOther);
    boolean flag2 = CQRConfig.dungeonProtection.protectionSystemEnabled && flag1;
    if (flag2) {
        BlockPos pos = new BlockPos(explosion.getPosition());
        for (ProtectedRegion protectedRegion : manager.getProtectedRegions()) {
            if ((flag && protectedRegion.preventExplosionsTNT()) || (!flag && protectedRegion.preventExplosionsOther())) {
                if (checkForOrigin && protectedRegion.isInsideProtectedRegion(pos)) {
                    affectedBlockPositions.clear();
                } else {
                    for (int i = 0; i < affectedBlockPositions.size(); i++) {
                        BlockPos pos1 = affectedBlockPositions.get(i);
                        if (protectedRegion.isInsideProtectedRegion(pos1)) {
                            affectedBlockPositions.remove(i--);
                        }
                    }
                }
            }
            if (affectedBlockPositions.isEmpty()) {
                return;
            }
        }
    }
    for (ProtectedRegion protectedRegion : manager.getProtectedRegions()) {
        for (BlockPos pos1 : affectedBlockPositions) {
            protectedRegion.setProtectionState(pos1, 0);
        }
    }
}
Also used : EntityTNTPrimedCQR(team.cqr.cqrepoured.entity.misc.EntityTNTPrimedCQR) TNTEntity(net.minecraft.entity.item.TNTEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with EntityTNTPrimedCQR

use of team.cqr.cqrepoured.entity.misc.EntityTNTPrimedCQR in project ChocolateQuestRepoured by TeamChocoQuest.

the class BlockTNTCQR method onExplosionDestroy.

@Override
public void onExplosionDestroy(World worldIn, BlockPos pos, Explosion explosionIn) {
    // Copied from vanilla
    if (!worldIn.isRemote) {
        EntityTNTPrimedCQR entitytntprimed = new EntityTNTPrimedCQR(worldIn, pos.getX() + 0.5F, pos.getY(), pos.getZ() + 0.5F, explosionIn.getExplosivePlacedBy());
        entitytntprimed.setFuse((short) (worldIn.rand.nextInt(entitytntprimed.getFuse() / 4) + entitytntprimed.getFuse() / 8));
        worldIn.spawnEntity(entitytntprimed);
    }
}
Also used : EntityTNTPrimedCQR(team.cqr.cqrepoured.entity.misc.EntityTNTPrimedCQR)

Example 3 with EntityTNTPrimedCQR

use of team.cqr.cqrepoured.entity.misc.EntityTNTPrimedCQR in project ChocolateQuestRepoured by TeamChocoQuest.

the class BlockTNTCQR method explode.

@Override
public void explode(World worldIn, BlockPos pos, BlockState state, LivingEntity igniter) {
    if (worldIn.isRemote) {
        return;
    }
    if (!state.getValue(EXPLODE)) {
        return;
    }
    EntityTNTPrimedCQR entitytntprimed = new EntityTNTPrimedCQR(worldIn, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, igniter);
    worldIn.spawnEntity(entitytntprimed);
    worldIn.playSound(null, entitytntprimed.posX, entitytntprimed.posY, entitytntprimed.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
Also used : EntityTNTPrimedCQR(team.cqr.cqrepoured.entity.misc.EntityTNTPrimedCQR)

Aggregations

EntityTNTPrimedCQR (team.cqr.cqrepoured.entity.misc.EntityTNTPrimedCQR)3 TNTEntity (net.minecraft.entity.item.TNTEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1