Search in sources :

Example 1 with TileEntityCrashedAlienProbe

use of stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityCrashedAlienProbe in project MorePlanets by SteveKunG.

the class WorldGenCrashedAlienProbe method generate.

@Override
public boolean generate(World world, Random rand, BlockPos pos) {
    for (pos = pos.add(-8, 0, -8); pos.getY() > 3 && world.isAirBlock(pos); pos = pos.down()) {
    }
    if (pos.getY() <= 2) {
        return false;
    }
    int radius = 1 + rand.nextInt(4);
    int radiusSq = radius * radius;
    for (int poolX = -radius - 1; poolX <= radius + 1; poolX++) {
        for (int poolY = -radius - 1; poolY <= 256 - pos.getY(); poolY++) {
            for (int poolZ = -radius - 1; poolZ <= radius + 1; poolZ++) {
                int distance = poolX * poolX + Math.min(0, poolY) * Math.min(0, poolY) + poolZ * poolZ;
                BlockPos posnew = new BlockPos(poolX + pos.getX(), poolY + pos.getY(), poolZ + pos.getZ());
                if (distance <= radiusSq) {
                    world.setBlockState(posnew, Blocks.AIR.getDefaultState(), 2);
                } else if (world.getBlockState(posnew).getBlock() == DionaBlocks.DIONA_BLOCK && poolY < 0 && rand.nextInt(4) == 0) {
                    world.setBlockState(posnew, DionaBlocks.GLOWING_IRON_BLOCK.getDefaultState(), 2);
                }
            }
        }
    }
    BlockPos blockpos = pos.add(0, -radius + 1, 0);
    if (rand.nextInt(5) == 0) {
        EntityAlienMiner miner = new EntityAlienMiner(world);
        miner.setLocationAndAngles(blockpos.getX() + 0.5D + rand.nextDouble(), blockpos.getY() + 0.5D, blockpos.getZ() + 0.5D, rand.nextFloat() * 360.0F, 0.0F);
        miner.setHealth(5.0F + rand.nextInt(5));
        miner.enablePersistence();
        world.spawnEntity(miner);
    }
    if (rand.nextInt(5) == 0) {
        EntityAlienMiner miner = new EntityAlienMiner(world);
        miner.setLocationAndAngles(blockpos.getX() + 0.5D, blockpos.getY() + 0.5D, blockpos.getZ() + 0.5D + rand.nextDouble(), rand.nextFloat() * 360.0F, 0.0F);
        miner.setHealth(5.0F + rand.nextInt(5));
        miner.enablePersistence();
        world.spawnEntity(miner);
    }
    boolean alien = rand.nextInt(5) == 0;
    BlockPos tilepos = blockpos.down();
    world.setBlockState(tilepos, DionaBlocks.CRASHED_ALIEN_PROBE.getDefaultState().withProperty(BlockCrashedAlienProbe.HAS_ALIEN, alien), 3);
    TileEntityCrashedAlienProbe probe = (TileEntityCrashedAlienProbe) world.getTileEntity(tilepos);
    if (probe != null) {
        probe.setLootTable(MPLootTables.CRASHED_ALIEN_PROBE, rand.nextLong());
    }
    return true;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) TileEntityCrashedAlienProbe(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityCrashedAlienProbe) EntityAlienMiner(stevekung.mods.moreplanets.module.planets.diona.entity.EntityAlienMiner)

Example 2 with TileEntityCrashedAlienProbe

use of stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityCrashedAlienProbe in project MorePlanets by SteveKunG.

the class GuiHandlerMP method getServerGuiElement.

@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
    EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
    if (playerBase == null) {
        return null;
    }
    if (tile != null) {
        if (tile instanceof TileEntityRocketCrusher) {
            return new ContainerRocketCrusher(player.inventory, (TileEntityRocketCrusher) tile);
        } else if (tile instanceof TileEntitySpaceWarpPadFull) {
            return new ContainerSpaceWarpPad(player.inventory, (TileEntitySpaceWarpPadFull) tile);
        } else if (tile instanceof TileEntityDarkEnergyReceiver) {
            return new ContainerDarkEnergyReceiver(player.inventory, (TileEntityDarkEnergyReceiver) tile);
        } else if (tile instanceof TileEntityNuclearWasteGenerator) {
            return new ContainerNuclearWasteGenerator(player.inventory, (TileEntityNuclearWasteGenerator) tile);
        } else if (tile instanceof TileEntityDarkEnergyStorageCluster) {
            return new ContainerDarkEnergyStorage(player.inventory, (TileEntityDarkEnergyStorageCluster) tile);
        } else if (tile instanceof TileEntityNuclearWasteStorageCluster) {
            return new ContainerNuclearWasteEnergyStorage(player.inventory, (TileEntityNuclearWasteStorageCluster) tile);
        } else if (tile instanceof TileEntityDarkEnergyGenerator) {
            return new ContainerDarkEnergyGenerator(player.inventory, (TileEntityDarkEnergyGenerator) tile);
        } else if (tile instanceof TileEntityCrashedAlienProbe) {
            return new ContainerCrashedAlienProbe(player.inventory, (TileEntityCrashedAlienProbe) tile, player);
        } else if (tile instanceof TileEntityBlackHoleStorage) {
            return new ContainerBlackHoleStorage(player.inventory, (TileEntityBlackHoleStorage) tile);
        } else if (tile instanceof TileEntityShieldGenerator) {
            return new ContainerShieldGenerator(player.inventory, (TileEntityShieldGenerator) tile);
        }
        return tile;
    }
    return null;
}
Also used : TileEntityNuclearWasteGenerator(stevekung.mods.moreplanets.module.planets.nibiru.tileentity.TileEntityNuclearWasteGenerator) ContainerDarkEnergyGenerator(stevekung.mods.moreplanets.module.planets.diona.inventory.ContainerDarkEnergyGenerator) TileEntity(net.minecraft.tileentity.TileEntity) ContainerNuclearWasteGenerator(stevekung.mods.moreplanets.module.planets.nibiru.inventory.ContainerNuclearWasteGenerator) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos) TileEntityDarkEnergyGenerator(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyGenerator) ContainerCrashedAlienProbe(stevekung.mods.moreplanets.module.planets.diona.inventory.ContainerCrashedAlienProbe) TileEntityCrashedAlienProbe(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityCrashedAlienProbe)

Aggregations

BlockPos (net.minecraft.util.math.BlockPos)2 TileEntityCrashedAlienProbe (stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityCrashedAlienProbe)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EntityAlienMiner (stevekung.mods.moreplanets.module.planets.diona.entity.EntityAlienMiner)1 ContainerCrashedAlienProbe (stevekung.mods.moreplanets.module.planets.diona.inventory.ContainerCrashedAlienProbe)1 ContainerDarkEnergyGenerator (stevekung.mods.moreplanets.module.planets.diona.inventory.ContainerDarkEnergyGenerator)1 TileEntityDarkEnergyGenerator (stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyGenerator)1 ContainerNuclearWasteGenerator (stevekung.mods.moreplanets.module.planets.nibiru.inventory.ContainerNuclearWasteGenerator)1 TileEntityNuclearWasteGenerator (stevekung.mods.moreplanets.module.planets.nibiru.tileentity.TileEntityNuclearWasteGenerator)1