use of net.minecraft.util.math.ChunkPos in project BetterWithAddons by DaedalusGame.
the class TileEntityWorldScaleActive method readDataFromNBT.
@Override
public void readDataFromNBT(NBTTagCompound compound) {
NBTTagList shardlist = compound.getTagList("claimedChunks", 10);
claimedChunks.clear();
for (int i = 0; i < shardlist.tagCount(); i++) {
NBTTagCompound shardcompound = shardlist.getCompoundTagAt(i);
ChunkPos chunkpos = new ChunkPos(shardcompound.getInteger("chunkX"), shardcompound.getInteger("chunkZ"));
claimedChunks.add(chunkpos);
}
}
use of net.minecraft.util.math.ChunkPos in project BetterWithAddons by DaedalusGame.
the class WorldScaleData method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound nbt) {
NBTTagList shardlist = nbt.getTagList("worldShards", 10);
for (int i = 0; i < shardlist.tagCount(); i++) {
NBTTagCompound shardcompound = shardlist.getCompoundTagAt(i);
ChunkPos chunkpos = new ChunkPos(shardcompound.getInteger("chunkX"), shardcompound.getInteger("chunkZ"));
BlockPos shardpos = new BlockPos(shardcompound.getInteger("blockX"), shardcompound.getInteger("blockY"), shardcompound.getInteger("blockZ"));
WorldScales.put(chunkpos, shardpos);
}
}
use of net.minecraft.util.math.ChunkPos in project MorePlanets by SteveKunG.
the class TeleportUtil method teleportEntity.
@Deprecated
private static EntityPlayerMP teleportEntity(World worldNew, EntityPlayerMP player, int x, int y, int z, int dimID, boolean nether) {
BlockPos blockpos = player.getBedLocation(dimID);
boolean flag = player.isSpawnForced(dimID);
boolean dimChange = player.world != worldNew;
player.world.updateEntityWithOptionalForce(player, false);
int oldDimID = GCCoreUtil.getDimensionID(player.world);
ChunkPos pair = worldNew.getChunkFromChunkCoords(x, z).getPos();
y = (int) (y + 1.5F);
if (dimChange) {
World worldOld = player.world;
try {
((WorldServer) worldOld).getPlayerChunkMap().removePlayer(player);
} catch (Exception e) {
e.printStackTrace();
}
player.closeScreen();
player.dimension = dimID;
player.connection.sendPacket(new SPacketRespawn(dimID, player.world.getDifficulty(), player.world.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
worldOld.playerEntities.remove(player);
worldOld.updateAllPlayersSleepingFlag();
int i = player.chunkCoordX;
int j = player.chunkCoordZ;
if (player.addedToChunk && worldOld.isBlockLoaded(new BlockPos(i << 4, 63, j << 4), true)) {
Chunk chunkOld = worldOld.getChunkFromChunkCoords(player.chunkCoordX, player.chunkCoordZ);
chunkOld.removeEntity(player);
chunkOld.setModified(true);
}
worldOld.loadedEntityList.remove(player);
worldOld.onEntityRemoved(player);
worldNew.spawnEntity(player);
player.setWorld(worldNew);
((WorldServer) worldNew).getChunkProvider().loadChunk(pair.x, pair.z);
worldNew.updateEntityWithOptionalForce(player, false);
if (!nether) {
player.setLocationAndAngles(x + 0.5F, y + 0.5F, z + 0.5F, player.rotationYaw, player.rotationPitch);
player.mcServer.getPlayerList().preparePlayer(player, (WorldServer) worldNew);
player.connection.setPlayerLocation(x + 0.5F, y + 0.5F, z + 0.5F, player.rotationYaw, player.rotationPitch);
} else {
if (blockpos != null) {
BlockPos blockpos1 = EntityPlayer.getBedSpawnLocation(player.mcServer.getWorld(player.dimension), blockpos, flag);
if (blockpos1 != null) {
player.setLocationAndAngles(blockpos1.getX() + 0.5F, blockpos1.getY() + 0.1F, blockpos1.getZ() + 0.5F, 0.0F, 0.0F);
player.setSpawnPoint(blockpos, flag);
}
}
}
player.interactionManager.setWorld((WorldServer) worldNew);
player.mcServer.getPlayerList().updateTimeAndWeatherForPlayer(player, (WorldServer) worldNew);
player.mcServer.getPlayerList().syncPlayerInventory(player);
player.setSneaking(false);
for (Object o : player.getActivePotionEffects()) {
PotionEffect potion = (PotionEffect) o;
player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potion));
}
player.connection.sendPacket(new SPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
} else {
player.closeScreen();
player.setSneaking(false);
worldNew.updateEntityWithOptionalForce(player, false);
player.connection.setPlayerLocation(x + 0.5F, y + 0.5F, z + 0.5F, player.rotationYaw, player.rotationPitch);
player.setLocationAndAngles(x + 0.5F, y + 0.5F, z + 0.5F, player.rotationYaw, player.rotationPitch);
worldNew.updateEntityWithOptionalForce(player, false);
}
FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldDimID, dimID);
return player;
}
use of net.minecraft.util.math.ChunkPos in project MorePlanets by SteveKunG.
the class TeleportUtil method startNewDimension.
@Deprecated
public static void startNewDimension(EntityPlayerMP player) {
WorldServer worldOld = (WorldServer) player.world;
WorldServer worldNew = WorldDimensionHelper.getStartWorld(worldOld);
BlockPos blockpos = worldNew.getTopSolidOrLiquidBlock(worldNew.getSpawnPoint());
boolean dimChange = player.world != worldNew;
player.world.updateEntityWithOptionalForce(player, false);
int oldDimID = GCCoreUtil.getDimensionID(player.world);
ChunkPos pair = worldNew.getChunkFromChunkCoords(blockpos.getX(), blockpos.getZ()).getPos();
if (dimChange) {
try {
worldOld.getPlayerChunkMap().removePlayer(player);
} catch (Exception e) {
e.printStackTrace();
}
player.closeScreen();
player.dimension = GCCoreUtil.getDimensionID(worldNew);
player.connection.sendPacket(new SPacketRespawn(GCCoreUtil.getDimensionID(worldNew), player.world.getDifficulty(), player.world.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
worldOld.playerEntities.remove(player);
worldOld.updateAllPlayersSleepingFlag();
if (player.addedToChunk && worldOld.getChunkProvider().chunkExists(player.chunkCoordX, player.chunkCoordZ)) {
Chunk chunkOld = worldOld.getChunkFromChunkCoords(player.chunkCoordX, player.chunkCoordZ);
chunkOld.removeEntity(player);
chunkOld.setModified(true);
}
worldOld.loadedEntityList.remove(player);
worldOld.onEntityRemoved(player);
worldNew.spawnEntity(player);
player.setWorld(worldNew);
MorePlanetsCore.PROXY.resetFloatingTick(player);
if (!(worldNew.provider instanceof IGalacticraftWorldProvider)) {
MPLog.error("{} is not space world!", ConfigManagerMP.startedPlanet);
throw new RuntimeException(ConfigManagerMP.startedPlanet + " is not space world!");
}
if (worldNew.provider instanceof IStartedDimension) {
IStartedDimension dimension = (IStartedDimension) worldNew.provider;
MPLog.debug("Setting up player gear");
dimension.setup(player);
} else {
GCPlayerStats stats = GCPlayerStats.get(player);
MPLog.debug("Setting up player gear for Non-IStartedDimension world");
// Knows how to build T2 rocket
SchematicRegistry.unlockNewPage(player, new ItemStack(GCItems.schematic, 1, 1));
// Knows how to build T3 rocket
SchematicRegistry.unlockNewPage(player, new ItemStack(MarsItems.schematic, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(0, new ItemStack(GCItems.oxMask, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(2, new ItemStack(GCItems.oxTankHeavy, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(3, new ItemStack(GCItems.oxTankHeavy, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
stats.getExtendedInventory().setInventorySlotContents(6, new ItemStack(AsteroidsItems.thermalPadding, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(7, new ItemStack(AsteroidsItems.thermalPadding, 1, 1));
stats.getExtendedInventory().setInventorySlotContents(8, new ItemStack(AsteroidsItems.thermalPadding, 1, 2));
stats.getExtendedInventory().setInventorySlotContents(9, new ItemStack(AsteroidsItems.thermalPadding, 1, 3));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
}
worldNew.getChunkProvider().loadChunk(pair.x, pair.z);
worldNew.updateEntityWithOptionalForce(player, false);
player.setLocationAndAngles(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 15 * 20, 5));
player.mcServer.getPlayerList().preparePlayer(player, worldNew);
player.connection.setPlayerLocation(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.interactionManager.setWorld(worldNew);
player.mcServer.getPlayerList().updateTimeAndWeatherForPlayer(player, worldNew);
player.mcServer.getPlayerList().syncPlayerInventory(player);
for (Object o : player.getActivePotionEffects()) {
PotionEffect potion = (PotionEffect) o;
player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potion));
}
player.connection.sendPacket(new SPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
} else {
player.closeScreen();
worldNew.updateEntityWithOptionalForce(player, false);
player.connection.setPlayerLocation(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.setLocationAndAngles(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 15 * 20, 5));
worldNew.updateEntityWithOptionalForce(player, false);
}
FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldDimID, GCCoreUtil.getDimensionID(worldNew));
if (player.onGround && player.getBedLocation(GCCoreUtil.getDimensionID(player.world)) == null) {
int i = 30000000;
int j = Math.min(i, Math.max(-i, MathHelper.floor(player.posX + 0.5D)));
int k = Math.min(256, Math.max(0, MathHelper.floor(player.posY + 1.5D)));
int l = Math.min(i, Math.max(-i, MathHelper.floor(player.posZ + 0.5D)));
BlockPos coords = new BlockPos(j, k, l);
player.setSpawnChunk(coords, true, GCCoreUtil.getDimensionID(player.world));
}
}
use of net.minecraft.util.math.ChunkPos in project MorePlanets by SteveKunG.
the class ChunkGeneratorNibiru method populate.
@Override
public void populate(int chunkX, int chunkZ) {
BlockFalling.fallInstantly = true;
int x = chunkX * 16;
int z = chunkZ * 16;
BlockPos blockpos = new BlockPos(x, 0, z);
Biome biomegenbase = this.worldObj.getBiome(blockpos.add(16, 0, 16));
this.rand.setSeed(this.worldObj.getSeed());
long k = this.rand.nextLong() / 2L * 2L + 1L;
long l = this.rand.nextLong() / 2L * 2L + 1L;
this.rand.setSeed(chunkX * k + chunkZ * l ^ this.worldObj.getSeed());
ChunkPos chunkcoordintpair = new ChunkPos(chunkX, chunkZ);
this.biomedecoratorplanet.decorate(this.worldObj, this.rand, biomegenbase, blockpos);
this.mineshaftGenerator.generateStructure(this.worldObj, this.rand, chunkcoordintpair);
this.strongholdGenerator.generateStructure(this.worldObj, this.rand, chunkcoordintpair);
this.pyramidGenerator.generateStructure(this.worldObj, this.rand, chunkcoordintpair);
this.jungleTempleGenerator.generateStructure(this.worldObj, this.rand, chunkcoordintpair);
this.oceanMonumentGenerator.generateStructure(this.worldObj, this.rand, chunkcoordintpair);
this.villageGenerator.generateStructure(this.worldObj, this.rand, chunkcoordintpair);
this.dungeonGenerator.generateStructure(this.worldObj, this.rand, chunkcoordintpair);
if (biomegenbase != MPBiomes.INFECTED_OCEAN && biomegenbase != MPBiomes.INFECTED_DEEP_OCEAN && biomegenbase != MPBiomes.INFECTED_RIVER) {
int worldX = chunkX << 4;
int worldZ = chunkZ << 4;
this.generateGas(this.worldObj, this.rand, worldX + 15, worldZ + 15);
this.generateOil(this.worldObj, this.rand, worldX + 15, worldZ + 15);
}
if (biomegenbase != MPBiomes.INFECTED_DESERT && biomegenbase != MPBiomes.GREEN_VEIN && this.rand.nextInt(4) == 0) {
new WorldGenLiquidLakes(NibiruBlocks.INFECTED_WATER_FLUID_BLOCK, NibiruBlocks.NIBIRU_BLOCK, 0, false).generate(this.worldObj, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(256), this.rand.nextInt(16) + 8));
}
if (biomegenbase == MPBiomes.GREEN_VEIN && this.rand.nextInt(6) == 0) {
new WorldGenLiquidLakes(NibiruBlocks.PURIFY_WATER_FLUID_BLOCK, NibiruBlocks.TERRASTONE, 0, true).generate(this.worldObj, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(256), this.rand.nextInt(16) + 8));
}
if (this.rand.nextInt(8) == 0) {
int y = this.rand.nextInt(this.rand.nextInt(248) + 8);
if (y < 63 || this.rand.nextInt(10) == 0) {
new WorldGenLiquidLakes(Blocks.LAVA, NibiruBlocks.NIBIRU_BLOCK, 0, true).generate(this.worldObj, this.rand, blockpos.add(this.rand.nextInt(16) + 8, y, this.rand.nextInt(16) + 8));
}
}
for (int i = 0; i < 8; ++i) {
new WorldGenSpaceDungeons(NibiruBlocks.NIBIRU_ANCIENT_CHEST, NibiruBlocks.NIBIRU_BLOCK, NibiruBlocks.NIBIRU_BLOCK, 1, 2).generate(this.worldObj, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(256), this.rand.nextInt(16) + 8));
}
biomegenbase.decorate(this.worldObj, this.rand, blockpos);
WorldEntitySpawner.performWorldGenSpawning(this.worldObj, biomegenbase, x + 8, z + 8, 16, 16, this.rand);
blockpos = blockpos.add(8, 0, 8);
for (int snowX = 0; snowX < 16; ++snowX) {
for (int snowZ = 0; snowZ < 16; ++snowZ) {
BlockPos blockpos1 = this.worldObj.getPrecipitationHeight(blockpos.add(snowX, 0, snowZ));
BlockPos blockpos2 = blockpos1.down();
if (this.worldObj.canBlockFreezeWater(blockpos2)) {
this.worldObj.setBlockState(blockpos2, NibiruBlocks.INFECTED_ICE.getDefaultState(), 2);
}
if (this.worldObj.canSnowAt(blockpos1, true)) {
this.worldObj.setBlockState(blockpos1, NibiruBlocks.INFECTED_SNOW_LAYER.getDefaultState(), 2);
}
}
}
BlockFalling.fallInstantly = false;
}
Aggregations