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);
}
}
}
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);
}
}
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);
}
Aggregations