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