net.minecraft.world.Explosion Java Examples

The following examples show how to use net.minecraft.world.Explosion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CrystalAuraModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
private float calculateExplosionDamage(EntityLivingBase entity, float size, float x, float y, float z) {
    final Minecraft mc = Minecraft.getMinecraft();
    final float scale = size * 2.0F;
    final Vec3d pos = MathUtil.interpolateEntity(entity, mc.getRenderPartialTicks());
    final double dist = MathUtil.getDistance(pos, x, y, z) / (double) scale;
    //final double dist = entity.getDistance(x, y, z) / (double) scale;
    final Vec3d vec3d = new Vec3d(x, y, z);
    final double density = (double) entity.world.getBlockDensity(vec3d, entity.getEntityBoundingBox());
    final double densityScale = (1.0D - dist) * density;

    float unscaledDamage = (float) ((int) ((densityScale * densityScale + densityScale) / 2.0d * 7.0d * (double) scale + 1.0d));

    unscaledDamage *= 0.5f * mc.world.getDifficulty().getId();

    return scaleExplosionDamage(entity, new Explosion(mc.world, null, x, y, z, size, false, true), unscaledDamage);
}
 
Example #2
Source File: FWBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) {
	// TODO: Maybe do something withPriority these parameters.

	// This number was calculated from the blast resistance of Stone,
	// which requires exactly one cubic meter of TNT to get blown up.
	//
	//   1. During construction, the setResistance method is called
	//     on minecraft:stone with a value of 10.
	//
	//   2. The setResistance method multiplies that by 3 and assigns
	//      the result to the blockResistance instance variable.
	//
	//   3. Finally, the getExplosionResistance method divides the
	//      blockResistance instance variable by 5 and returns the result.
	//
	// From this we see that minecraft:stone’s final blast resistance is 6.

	return (float) getBlockInstance(world, pos).getResistance() * 6;
}
 
Example #3
Source File: FWBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) {
	// TODO: Maybe do something withPriority these parameters.

	// This number was calculated from the blast resistance of Stone,
	// which requires exactly one cubic meter of TNT to get blown up.
	//
	//   1. During construction, the setResistance method is called
	//     on minecraft:stone with a value of 10.
	//
	//   2. The setResistance method multiplies that by 3 and assigns
	//      the result to the blockResistance instance variable.
	//
	//   3. Finally, the getExplosionResistance method divides the
	//      blockResistance instance variable by 5 and returns the result.
	//
	// From this we see that minecraft:stone’s final blast resistance is 6.

	return (float) getBlockInstance(world, VectorConverter.instance().toNova(pos)).getResistance() * 6;
}
 
Example #4
Source File: CrystalAuraModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private float scaleExplosionDamage(EntityLivingBase entity, Explosion explosion, float damage) {
    damage = CombatRules.getDamageAfterAbsorb(damage, (float) entity.getTotalArmorValue(), (float) entity.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).getAttributeValue());

    damage *= (1.0F - MathHelper.clamp(EnchantmentHelper.getEnchantmentModifierDamage(entity.getArmorInventoryList(), DamageSource.causeExplosionDamage(explosion)), 0.0F, 20.0F) / 25.0F);

    damage = Math.max(damage - entity.getAbsorptionAmount(), 0.0F);
    return damage;
}
 
Example #5
Source File: EntitySpecialArrow.java    From Artifacts with MIT License 5 votes vote down vote up
public void missEffect(int x, int y, int z) {
	switch (this.effect.ID) {
		case 1:
			Explosion explosion = new Explosion(this.worldObj, this, this.posX, this.posY, this.posZ, 2F);
			explosion.doExplosionA();
			explosion.doExplosionB(true);
			setDead();
			break;
	}
}
 
Example #6
Source File: EntitySpecialArrow.java    From Artifacts with MIT License 5 votes vote down vote up
public void hitEffect(Entity entityHit) {
	switch (this.effect.ID) {
		case 1:
			Explosion explosion = new Explosion(this.worldObj, this, this.posX, this.posY, this.posZ, 2F);
			explosion.doExplosionA();
			explosion.doExplosionB(true);
			break;
	}
}
 
Example #7
Source File: BlockChestBase.java    From BetterChests with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) {
	TileEntity te = world.getTileEntity(pos);
	if (te != null && te instanceof IUpgradableBlock && UpgradeHelper.INSTANCE.booleanSum((IUpgradableBlock) te, ChestModifier.HARDNESS, false)) {
		return Float.POSITIVE_INFINITY;
	}
	return super.getExplosionResistance(world, pos, exploder, explosion);
}
 
Example #8
Source File: BlockConfusingCharge.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
  if (!world.isRemote) {
    EntityLivingBase placedBy = explosion.getExplosivePlacedBy();
    onIgnitedByNeighbour(world, pos.getX(), pos.getY(), pos.getZ(), placedBy);
  }
}
 
Example #9
Source File: BlockLaser.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos,
		Explosion explosionIn) {
	// TODO Auto-generated method stub
	super.onBlockDestroyedByExplosion(worldIn, pos, explosionIn);
	((TileSpaceLaser)worldIn.getTileEntity(pos)).onDestroy();
}
 
Example #10
Source File: BlockSeat.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void onBlockDestroyedByExplosion(World world, BlockPos pos,
		Explosion explosionIn) {
	// TODO Auto-generated method stub
	super.onBlockDestroyedByExplosion(world, pos, explosionIn);
	
	List<EntityDummy> list = world.getEntitiesWithinAABB(EntityDummy.class, new AxisAlignedBB(pos, pos.add(1,1,1)));

	//We only expect one but just be sure
	for(EntityDummy e : list) {
		if(e instanceof EntityDummy) {
			e.setDead();
		}
	}
}
 
Example #11
Source File: EventHandlerWorld.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGH)
public void on(ExplosionEvent.Start e) {
    Explosion expl = e.explosion;
    if(expl.isSmoking
            && (expl.exploder != null ? TileBlockProtector.isSpotProtected(e.world, expl.exploder) :
                TileBlockProtector.isSpotProtected(e.world, expl.explosionX, expl.explosionY, expl.explosionZ))) {
        //why?
        //expl.isSmoking = false;
        e.setCanceled(true);
        e.world.newExplosion(expl.exploder, expl.explosionX, expl.explosionY, expl.explosionZ, expl.explosionSize, expl.isFlaming, false);
    }
}
 
Example #12
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Explosion explosion) {
    org.bukkit.World bukkitWorld = world.getWorld();
    org.bukkit.entity.Entity igniter = explosion.exploder == null ? null : explosion.exploder.getBukkitEntity();

    BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), IgniteCause.EXPLOSION, igniter);
    world.getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #13
Source File: Entity.java    From TickDynamic with MIT License 4 votes vote down vote up
public float func_145772_a(Explosion p_145772_1_, World p_145772_2_, int p_145772_3_, int p_145772_4_, int p_145772_5_, Block p_145772_6_)
{
    return p_145772_6_.getExplosionResistance(this, p_145772_2_, p_145772_3_, p_145772_4_, p_145772_5_, posX, posY + getEyeHeight(), posZ);
}
 
Example #14
Source File: Entity.java    From TickDynamic with MIT License 4 votes vote down vote up
public boolean func_145774_a(Explosion p_145774_1_, World p_145774_2_, int p_145774_3_, int p_145774_4_, int p_145774_5_, Block p_145774_6_, float p_145774_7_)
{
    return true;
}
 
Example #15
Source File: BlockFakeAir.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean canDropFromExplosion(Explosion explosionIn) {
	return false;
}
 
Example #16
Source File: BlockMoving.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canDropFromExplosion(Explosion p_149659_1_) {

    return false;
}
 
Example #17
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn)
{
	this.modelBlock.onBlockDestroyedByExplosion(worldIn, pos, explosionIn);
}
 
Example #18
Source File: BlockPortableNode.java    From Electro-Magic-Tools with GNU General Public License v3.0 4 votes vote down vote up
public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {
}
 
Example #19
Source File: BlockShield.java    From Electro-Magic-Tools with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {
}
 
Example #20
Source File: BlockBackpack.java    From WearableBackpacks with MIT License 4 votes vote down vote up
public void onBlockExploded(World world, BlockPos pos, Explosion explosion) {
	// Only destroy the backpack block if its age isn't negative.
	if (preventExplosionDestroy(world, pos)) return;
	super.onBlockExploded(world, pos, explosion);
}
 
Example #21
Source File: BlockMixin.java    From customstuff4 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion)
{
    IBlockState blockState = world.getBlockState(pos);
    return getContent().resistance.get(getSubtype(blockState)).orElse(0f) / 5f;
}
 
Example #22
Source File: BlockOre.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public float getExplosionResistance(World world, BlockPos pos, @Nullable Entity exploder, Explosion explosion) {
    return world.getBlockState(pos).getValue(STONE_TYPE).unbreakable ? 1200000.0F : getExplosionResistance(exploder);
}
 
Example #23
Source File: BlockMachine.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public float getExplosionResistance(World world, BlockPos pos, @Nullable Entity exploder, Explosion explosion) {
    MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos);
    return metaTileEntity == null ? 1.0f : metaTileEntity.getBlockResistance();
}
 
Example #24
Source File: EventsCommon.java    From Valkyrien-Skies with Apache License 2.0 3 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onExplosionStart(ExplosionEvent.Start event) {
    // Only run on server side
    if (!event.getWorld().isRemote) {
        Explosion explosion = event.getExplosion();
        Vector center = new Vector(explosion.x, explosion.y, explosion.z);
        Optional<PhysicsObject> optionalPhysicsObject = ValkyrienUtils
            .getPhysicsObject(event.getWorld(),
                new BlockPos(event.getExplosion().getPosition()), true);
        if (optionalPhysicsObject.isPresent()) {
            return;
        }
        // Explosion radius
        float radius = explosion.size;
        AxisAlignedBB toCheck = new AxisAlignedBB(center.X - radius, center.Y - radius,
            center.Z - radius,
            center.X + radius, center.Y + radius, center.Z + radius);
        // Find nearby ships, we will check if the explosion effects them
        List<PhysicsWrapperEntity> shipsNear = ValkyrienSkiesMod.VS_PHYSICS_MANAGER
            .getManagerForWorld(event.getWorld())
            .getNearbyPhysObjects(toCheck);
        // Process the explosion on the nearby ships
        for (PhysicsWrapperEntity ship : shipsNear) {
            Vector inLocal = new Vector(center);

            ship.getPhysicsObject().getShipTransformationManager().getCurrentTickTransform()
                .transform(inLocal, TransformType.GLOBAL_TO_SUBSPACE);

            Explosion expl = new Explosion(event.getWorld(), null, inLocal.X, inLocal.Y,
                inLocal.Z, radius, explosion.causesFire, true);

            double waterRange = .6D;

            for (int x = (int) Math.floor(expl.x - waterRange);
                x <= Math.ceil(expl.x + waterRange); x++) {
                for (int y = (int) Math.floor(expl.y - waterRange);
                    y <= Math.ceil(expl.y + waterRange); y++) {
                    for (int z = (int) Math.floor(expl.z - waterRange);
                        z <= Math.ceil(expl.z + waterRange); z++) {
                        IBlockState state = event.getWorld()
                            .getBlockState(new BlockPos(x, y, z));
                        if (state.getBlock() instanceof BlockLiquid) {
                            return;
                        }
                    }
                }
            }

            expl.doExplosionA();
            event.getExplosion().affectedBlockPositions.addAll(expl.affectedBlockPositions);
        }
    }
}
 
Example #25
Source File: BlockMoving.java    From Framez with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {

}