Java Code Examples for net.minecraft.world.World#createExplosion()

The following examples show how to use net.minecraft.world.World#createExplosion() . These examples are extracted from open source projects. 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
public static boolean tryExplodeOtherAbsorbers(World world, BlockPos checkPos) {
	Iterable<BlockPos> surroundingPos = BlockPos.getAllInBox(checkPos.offset(EnumFacing.SOUTH, 4).offset(EnumFacing.WEST, 4), checkPos.offset(EnumFacing.NORTH, 4).offset(EnumFacing.EAST, 4));
	for (BlockPos absorberPos : surroundingPos) {
		if (absorberPos.equals(checkPos)) {
			continue;
		}
		TileEntity tile = world.getTileEntity(absorberPos);
		if (tile instanceof GTTileMagicEnergyAbsorber) {
			GTTileMagicEnergyAbsorber absorber = (GTTileMagicEnergyAbsorber) tile;
			if (absorber.portalMode && absorber.isAbovePortal) {
				world.setBlockToAir(absorberPos);
				world.removeTileEntity(absorberPos);
				world.createExplosion(null, absorberPos.getX(), absorberPos.getY(), absorberPos.getZ(), 8.0F, true);
				return true;
			}
		}
	}
	return false;
}
 
Example 2
public static void taintplosion(World world, int x, int y, int z, boolean taintBiome, int chanceToTaint, float str, int size, int blocksAffected) {
    if(chanceToTaint < 1) chanceToTaint = 1;
    world.createExplosion(null, x + 0.5D, y + 0.5D, z + 0.5D, str, false);
    for (int a = 0; a < blocksAffected; a++) {
        int xx = x + world.rand.nextInt(size) - world.rand.nextInt(size);
        int yy = y + world.rand.nextInt(size) - world.rand.nextInt(size);
        int zz = z + world.rand.nextInt(size) - world.rand.nextInt(size);
        if (world.isAirBlock(xx, yy, zz)) {
            if (yy < y) {
                world.setBlock(xx, yy, zz, ConfigBlocks.blockFluxGoo, 8, 3);
            } else {
                world.setBlock(xx, yy, zz, ConfigBlocks.blockFluxGas, 8, 3);
            }
        }
        if(!Config.genTaint) continue;

        if(taintBiome && world.rand.nextInt(chanceToTaint) == 0) {
            Utils.setBiomeAt(world, xx, zz, ThaumcraftWorldGenerator.biomeTaint);
        }
    }
}
 
Example 3
@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand){
    if(world.getBlockMetadata(x, y, z) == 14) {
        if(!world.isRemote) {
            world.createExplosion(null, x + 0.5D, y + 0.5D, z + 0.5D, 0.5F, false);
            EntityItem item = new EntityItem(world, x + 0.5D, y + 0.5D, z + 0.5D, new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.CREEPER_PLANT_DAMAGE));
            item.motionX = (rand.nextGaussian() - 0.5D) / 2;
            item.motionY = rand.nextDouble();
            item.motionZ = (rand.nextGaussian() - 0.5D) / 2;
            item.lifespan = 300;
            ItemPlasticPlants.markInactive(item);
            world.spawnEntityInWorld(item);
            world.setBlock(x, y, z, this, world.getBlockMetadata(x, y, z) - 2, 3);
        }
    } else {
        world.setBlockMetadataWithNotify(x, y, z, 14, 3);
        NetworkHandler.sendToAllAround(new PacketPlaySound("creeper.primed", x + 0.5D, y + 0.5D, z + 0.5D, 1.0F, 1.0F, true), world);
        world.scheduleBlockUpdate(x, y, z, this, 60);
    }
}
 
Example 4
public void destroyNetwork(boolean isLeaking, boolean isBurning) {
    World world = worldData.getWorld();
    ((WorldFluidPipeNet) (Object) worldData).removePipeNet(this);
    for (BlockPos nodePos : getAllNodes().keySet()) {
        TileEntity tileEntity = world.getTileEntity(nodePos);
        if (tileEntity instanceof TileEntityFluidPipe) {
            if (isBurning) {
                world.setBlockState(nodePos, Blocks.FIRE.getDefaultState());
            } else {
                world.setBlockToAir(nodePos);
            }
        } else if (GTValues.isModLoaded(GTValues.MODID_FMP)) {
            removeMultipartPipePartFromTile(tileEntity);
        }
        Random random = world.rand;
        if (isBurning) {
            TileEntityFluidPipe.spawnParticles(world, nodePos, EnumFacing.UP,
                EnumParticleTypes.FLAME, 3 + random.nextInt(2), random);
            if (random.nextInt(4) == 0) {
                TileEntityFluidPipe.setNeighboursToFire(world, nodePos);
            }
        }
        if (isLeaking) {
            if (world.rand.nextInt(isBurning ? 3 : 7) == 0) {
                world.createExplosion(null,
                    nodePos.getX() + 0.5, nodePos.getY() + 0.5, nodePos.getZ() + 0.5,
                    1.0f + world.rand.nextFloat(), false);
            }
        }
    }
}
 
Example 5
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
    //world.playSoundEffect(x, y, z, "advancedmod:flagFlap", 1.0F, player.getRNG().nextFloat() + 0.5F);

    if(!world.isRemote) {
        world.createExplosion(player, x, y, z, 3, true);
    }
    return true;
}
 
Example 6
private static void tryAuraCoreCreation(ItemStack i, EntityPlayer entityPlayer, World world, int x, int y, int z) {
    if(world.isRemote) return;

    List items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1)
            .expand(EntityAuraCore.CLUSTER_RANGE, EntityAuraCore.CLUSTER_RANGE, EntityAuraCore.CLUSTER_RANGE));
    Iterator it = items.iterator();
    EntityItem itemAuraCore = null;
    while(itemAuraCore == null && it.hasNext()) {
        Object item = it.next();
        if(item != null && item instanceof EntityItem && !((EntityItem) item).isDead) {
            EntityItem entityItem = (EntityItem) item;
            if(entityItem.getEntityItem() != null && entityItem.getEntityItem().getItem() != null
                    && entityItem.getEntityItem().getItem() instanceof ItemAuraCore && !(item instanceof EntityAuraCore)) {
                if(((ItemAuraCore) entityItem.getEntityItem().getItem()).isBlank(entityItem.getEntityItem())) itemAuraCore = entityItem;
            }
        }
    }

    if(itemAuraCore == null) return;

    int meta = world.getBlockMetadata(x, y, z);
    if(meta <= 6) {
        Aspect[] aspects;
        switch (meta) {
            case 0:
                aspects = new Aspect[]{Aspect.AIR};
                break;
            case 1:
                aspects = new Aspect[]{Aspect.FIRE};
                break;
            case 2:
                aspects = new Aspect[]{Aspect.WATER};
                break;
            case 3:
                aspects = new Aspect[]{Aspect.EARTH};
                break;
            case 4:
                aspects = new Aspect[]{Aspect.ORDER};
                break;
            case 5:
                aspects = new Aspect[]{Aspect.ENTROPY};
                break;
            case 6:
                aspects = new Aspect[]{Aspect.AIR, Aspect.FIRE, Aspect.EARTH, Aspect.WATER, Aspect.ORDER, Aspect.ENTROPY};
                break;
            default:
                return;
        }

        if(!ThaumcraftApiHelper.consumeVisFromWandCrafting(i, entityPlayer, (AspectList)RegisteredRecipes.auraCoreRecipes[meta].get(0), true))
            return;


        PacketStartAnimation packet = new PacketStartAnimation(PacketStartAnimation.ID_BURST, x, y, z);
        PacketHandler.INSTANCE.sendToAllAround(packet, new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32.0D));
        world.createExplosion(null, x + 0.5D, y + 0.5D, z + 0.5D, 1.5F, false);
        world.setBlockToAir(x, y, z);

        EntityAuraCore ea =
                new EntityAuraCore(itemAuraCore.worldObj, itemAuraCore.posX, itemAuraCore.posY, itemAuraCore.posZ,
                        itemAuraCore.getEntityItem(), new ChunkCoordinates(x, y, z), aspects);
        ea.age = itemAuraCore.age;
        ea.hoverStart = itemAuraCore.hoverStart;
        ea.motionX = itemAuraCore.motionX;
        ea.motionY = itemAuraCore.motionY;
        ea.motionZ = itemAuraCore.motionZ;
        itemAuraCore.worldObj.spawnEntityInWorld(ea);
        itemAuraCore.setDead();
    }
}