@Override protected void handleTileEntities(Random rand) { if (!this.chests.isEmpty()) { HashSet<ChunkCoordinates> removeList = new HashSet<ChunkCoordinates>(); for (ChunkCoordinates coords : this.chests) { this.worldObj.setBlock(coords.posX, coords.posY, coords.posZ, MarsBlocks.tier2TreasureChest, 0, 3); this.worldObj.setTileEntity(coords.posX, coords.posY, coords.posZ, new TileEntityTreasureChestMars()); removeList.add(coords); } this.chests.removeAll(removeList); } }
public static void addToList(World world, int x, int y, int z, String playerName) { HashMap<Integer, HashSet<ChunkCoordinates>> dimensionMap = ChunkLoadingCallback.chunkLoaderList.get(playerName); if (dimensionMap == null) { dimensionMap = new HashMap<Integer, HashSet<ChunkCoordinates>>(); ChunkLoadingCallback.chunkLoaderList.put(playerName, dimensionMap); } HashSet<ChunkCoordinates> chunkLoaders = dimensionMap.get(world.provider.dimensionId); if (chunkLoaders == null) { chunkLoaders = new HashSet<ChunkCoordinates>(); } chunkLoaders.add(new ChunkCoordinates(x, y, z)); dimensionMap.put(world.provider.dimensionId, chunkLoaders); ChunkLoadingCallback.chunkLoaderList.put(playerName, dimensionMap); }
public static void onPlayerLogin(EntityPlayer player) { for (Entry<String, HashMap<Integer, HashSet<ChunkCoordinates>>> playerEntry : ChunkLoadingCallback.chunkLoaderList.entrySet()) { if (player.getGameProfile().getName().equals(playerEntry.getKey())) { for (Entry<Integer, HashSet<ChunkCoordinates>> dimensionEntry : playerEntry.getValue().entrySet()) { int dimID = dimensionEntry.getKey(); if (ChunkLoadingCallback.loadOnLogin) { MinecraftServer.getServer().worldServerForDimension(dimID); } } } } }
@Override protected void handleTileEntities(Random rand) { if (!this.chests.isEmpty()) { HashSet<ChunkCoordinates> removeList = new HashSet<ChunkCoordinates>(); for (ChunkCoordinates coords : this.chests) { this.worldObj.setBlock(coords.posX, coords.posY, coords.posZ, GCBlocks.treasureChestTier1, 0, 3); this.worldObj.setTileEntity(coords.posX, coords.posY, coords.posZ, new TileEntityTreasureChest(1)); removeList.add(coords); } this.chests.removeAll(removeList); } }
public ChunkCoordinates getDungeonNear(long worldSeed, int i, int j) { final int range = 16; for (int x = i - range; x <= i + range; x++) { for (int z = j - range; z <= j + range; z++) { if (this.canGenDungeonAtCoords(worldSeed, x, z)) { return new ChunkCoordinates(x * 16 + 8, 0, z * 16 + 8); } } } return null; }
public boolean wakeUpPlayer(EntityPlayerMP player, boolean par1, boolean par2, boolean par3, boolean bypass) { ChunkCoordinates c = player.playerLocation; if (c != null) { EventWakePlayer event = new EventWakePlayer(player, c.posX, c.posY, c.posZ, par1, par2, par3, bypass); MinecraftForge.EVENT_BUS.post(event); if (bypass || event.result == null || event.result == EntityPlayer.EnumStatus.OK) { return false; } } return true; }
public static ChunkCoordinates verifyRespawnCoordinates(World p_71056_0_, ChunkCoordinates p_71056_1_, boolean p_71056_2_) { IChunkProvider ichunkprovider = p_71056_0_.getChunkProvider(); ichunkprovider.loadChunk(p_71056_1_.posX - 3 >> 4, p_71056_1_.posZ - 3 >> 4); ichunkprovider.loadChunk(p_71056_1_.posX + 3 >> 4, p_71056_1_.posZ - 3 >> 4); ichunkprovider.loadChunk(p_71056_1_.posX - 3 >> 4, p_71056_1_.posZ + 3 >> 4); ichunkprovider.loadChunk(p_71056_1_.posX + 3 >> 4, p_71056_1_.posZ + 3 >> 4); if (p_71056_0_.getBlock(p_71056_1_.posX, p_71056_1_.posY, p_71056_1_.posZ).isBed(p_71056_0_, p_71056_1_.posX, p_71056_1_.posY, p_71056_1_.posZ, null)) { ChunkCoordinates chunkcoordinates1 = p_71056_0_.getBlock(p_71056_1_.posX, p_71056_1_.posY, p_71056_1_.posZ).getBedSpawnPosition(p_71056_0_, p_71056_1_.posX, p_71056_1_.posY, p_71056_1_.posZ, null); return chunkcoordinates1; } Material material = p_71056_0_.getBlock(p_71056_1_.posX, p_71056_1_.posY, p_71056_1_.posZ).getMaterial(); Material material1 = p_71056_0_.getBlock(p_71056_1_.posX, p_71056_1_.posY + 1, p_71056_1_.posZ).getMaterial(); boolean flag1 = (!material.isSolid()) && (!material.isLiquid()); boolean flag2 = (!material1.isSolid()) && (!material1.isLiquid()); return (p_71056_2_) && (flag1) && (flag2) ? p_71056_1_ : null; }
public void setSpawnChunk(ChunkCoordinates p_71063_1_, boolean p_71063_2_) { if (this.dimension != 0) { setSpawnChunk(p_71063_1_, p_71063_2_, this.dimension); return; } if (p_71063_1_ != null) { this.spawnChunk = new ChunkCoordinates(p_71063_1_); this.spawnForced = p_71063_2_; } else { this.spawnChunk = null; this.spawnForced = false; } }
@Override public void generate(Block[] chunk, byte[] meta, int cx, int cz) { for (int i = this.posX - 1; i <= this.posX + this.sizeX; i++) { for (int k = this.posZ - 1; k <= this.posZ + this.sizeZ; k++) { for (int j = this.posY - 1; j <= this.posY + this.sizeY; j++) { if (i == this.posX - 1 || i == this.posX + this.sizeX || j == this.posY - 1 || j == this.posY + this.sizeY || k == this.posZ - 1 || k == this.posZ + this.sizeZ) { this.placeBlock(chunk, meta, i, j, k, cx, cz, this.dungeonInstance.settings.blockBrick.getFirst(), this.dungeonInstance.settings.blockBrick.getSecond()); } else { if ((i == this.posX || i == this.posX + this.sizeX - 1) && (k == this.posZ || k == this.posZ + this.sizeZ - 1)) { this.placeBlock(chunk, meta, i, j, k, cx, cz, Blocks.glowstone, 0); } else { this.placeBlock(chunk, meta, i, j, k, cx, cz, Blocks.air, 0); } } } } } final int hx = (this.posX + this.posX + this.sizeX) / 2; final int hz = (this.posZ + this.posZ + this.sizeZ) / 2; if (this.placeBlock(chunk, meta, hx, this.posY, hz, cx, cz, MarsBlocks.tier2TreasureChest, 0)) { this.chests.add(new ChunkCoordinates(hx, this.posY, hz)); } }
@Override public void generate(Block[] chunk, byte[] meta, int cx, int cz) { for (int i = this.posX - 1; i <= this.posX + this.sizeX; i++) { for (int k = this.posZ - 1; k <= this.posZ + this.sizeZ; k++) { for (int j = this.posY - 1; j <= this.posY + this.sizeY; j++) { if (i == this.posX - 1 || i == this.posX + this.sizeX || j == this.posY - 1 || j == this.posY + this.sizeY || k == this.posZ - 1 || k == this.posZ + this.sizeZ) { this.placeBlock(chunk, meta, i, j, k, cx, cz, this.dungeonInstance.settings.blockBrick.getFirst(), this.dungeonInstance.settings.blockBrick.getSecond()); } else if (i == this.posX && k == this.posZ || i == this.posX + this.sizeX - 1 && k == this.posZ || i == this.posX && k == this.posZ + this.sizeZ - 1 || i == this.posX + this.sizeX - 1 && k == this.posZ + this.sizeZ - 1) { this.placeBlock(chunk, meta, i, j, k, cx, cz, Blocks.flowing_lava, 0); } else if (j % 3 == 0 && j >= this.posY + 2 && (i == this.posX || i == this.posX + this.sizeX - 1 || k == this.posZ || k == this.posZ + this.sizeZ - 1) || i == this.posX + 1 && k == this.posZ || i == this.posX && k == this.posZ + 1 || i == this.posX + this.sizeX - 2 && k == this.posZ || i == this.posX + this.sizeX - 1 && k == this.posZ + 1 || i == this.posX + 1 && k == this.posZ + this.sizeZ - 1 || i == this.posX && k == this.posZ + this.sizeZ - 2 || i == this.posX + this.sizeX - 2 && k == this.posZ + this.sizeZ - 1 || i == this.posX + this.sizeX - 1 && k == this.posZ + this.sizeZ - 2) { this.placeBlock(chunk, meta, i, j, k, cx, cz, Blocks.iron_bars, 0); } else if ((i == this.posX + 1 && k == this.posZ + 1 || i == this.posX + this.sizeX - 2 && k == this.posZ + 1 || i == this.posX + 1 && k == this.posZ + this.sizeZ - 2 || i == this.posX + this.sizeX - 2 && k == this.posZ + this.sizeZ - 2) && j % 3 == 0) { this.placeBlock(chunk, meta, i, j, k, cx, cz, Blocks.iron_bars, 0); } else { this.placeBlock(chunk, meta, i, j, k, cx, cz, Blocks.air, 0); } } } } final int hx = (this.posX + this.posX + this.sizeX) / 2; final int hz = (this.posZ + this.posZ + this.sizeZ) / 2; this.spawnerCoords = new ChunkCoordinates(hx, this.posY + 2, hz); }
@Override public void generate(Block[] chunk, byte[] meta, int cx, int cz) { for (int i = this.posX - 1; i <= this.posX + this.sizeX; i++) { for (int j = this.posY - 1; j <= this.posY + this.sizeY; j++) { for (int k = this.posZ - 1; k <= this.posZ + this.sizeZ; k++) { if (i == this.posX - 1 || i == this.posX + this.sizeX || j == this.posY - 1 || j == this.posY + this.sizeY || k == this.posZ - 1 || k == this.posZ + this.sizeZ) { this.placeBlock(chunk, meta, i, j, k, cx, cz, this.dungeonInstance.settings.blockBrick.getFirst(), this.dungeonInstance.settings.blockBrick.getSecond()); } else { this.placeBlock(chunk, meta, i, j, k, cx, cz, Blocks.air, 0); if (this.rand.nextFloat() < 0.05F) { this.placeBlock(chunk, meta, i, j, k, cx, cz, Blocks.web, 0); } } } } } if (this.placeBlock(chunk, meta, this.posX + 1, this.posY - 1, this.posZ + 1, cx, cz, Blocks.mob_spawner, 0)) { this.spawners.add(new ChunkCoordinates(this.posX + 1, this.posY - 1, this.posZ + 1)); } if (this.placeBlock(chunk, meta, this.posX + this.sizeX - 1, this.posY - 1, this.posZ + this.sizeZ - 1, cx, cz, Blocks.mob_spawner, 0)) { this.spawners.add(new ChunkCoordinates(this.posX + this.sizeX - 1, this.posY - 1, this.posZ + this.sizeZ - 1)); } }
@Override public void generate(Block[] chunk, byte[] meta, int cx, int cz) { for (int i = this.posX - 1; i <= this.posX + this.sizeX; i++) { for (int j = this.posY - 1; j <= this.posY + this.sizeY; j++) { for (int k = this.posZ - 1; k <= this.posZ + this.sizeZ; k++) { if (i == this.posX - 1 || i == this.posX + this.sizeX || j == this.posY - 1 || j == this.posY + this.sizeY || k == this.posZ - 1 || k == this.posZ + this.sizeZ) { this.placeBlock(chunk, meta, i, j, k, cx, cz, this.dungeonInstance.settings.blockBrick.getFirst(), this.dungeonInstance.settings.blockBrick.getSecond()); } else { this.placeBlock(chunk, meta, i, j, k, cx, cz, Blocks.air, 0); } } } } final int hx = (this.posX + this.posX + this.sizeX) / 2; final int hz = (this.posZ + this.posZ + this.sizeZ) / 2; if (this.placeBlock(chunk, meta, hx, this.posY, hz, cx, cz, Blocks.chest, 0)) { this.chests.add(new ChunkCoordinates(hx, this.posY, hz)); } }
/** * main AI tick function, replaces updateEntityActionState */ protected void updateAITick() { if (--this.homeCheckTimer <= 0) { this.homeCheckTimer = 70 + this.rand.nextInt(50); this.villageObj = this.worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 32); if (this.villageObj == null) { this.detachHome(); } else { ChunkCoordinates chunkcoordinates = this.villageObj.getCenter(); this.setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, (int)((float)this.villageObj.getVillageRadius() * 0.6F)); } } super.updateAITick(); }
public ChunkCoordinates getTrunkBlockPosBySide(World world, int x, int y, int z, int side) { ChunkCoordinates ret = new ChunkCoordinates(x, y, z); switch (side) { case 5: ret.set(x - 1, y, z); return ret; case 4: ret.set(x + 1, y, z); return ret; case 2: ret.set(x, y, z + 1); return ret; case 3: ret.set(x, y, z - 1); return ret; } return null; }
public ChunkCoordinates getTrunkBlockPosByRotation(World world, int x, int y, int z, int rotation) { ChunkCoordinates ret = new ChunkCoordinates(x, y, z); switch (rotation) { case 1: ret.set(x - 1, y, z); return ret; case 3: ret.set(x + 1, y, z); return ret; case 0: ret.set(x, y, z + 1); return ret; case 2: ret.set(x, y, z - 1); return ret; } return null; }
public boolean shouldExecute() { if (this.theEntity.isWithinHomeDistanceCurrentPosition()) { return false; } else { ChunkCoordinates chunkcoordinates = this.theEntity.getHomePosition(); Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 16, 7, Vec3.createVectorHelper((double)chunkcoordinates.posX, (double)chunkcoordinates.posY, (double)chunkcoordinates.posZ)); if (vec3 == null) { return false; } else { this.movePosX = vec3.xCoord; this.movePosY = vec3.yCoord; this.movePosZ = vec3.zCoord; return true; } } }
private int updateTargetPosition(ChunkCoordinates target) { int x = target.posX; int y = target.posY; int z = target.posZ; if (!this.worldObj.getChunkFromBlockCoords(x, z).isEmpty()) { if (this.worldObj.getBlock(x, y, z).getBlocksMovement(this.worldObj, x, y, z)) { while (y > 0 && this.worldObj.getBlock(x, --y, z).getBlocksMovement(this.worldObj, x, y, z)) ; if (y == 0) y = target.posY; else ++y; } else { while (y < 256 && !this.worldObj.getBlock(x, ++y, z).getBlocksMovement(this.worldObj, x, y, z)) ; if (y == 256) y = target.posY; } return y; } return target.posY; }
/** * Ensure that a block enabling respawning exists at the specified coordinates and find an empty space nearby to * spawn. */ public static ChunkCoordinates verifyRespawnCoordinates(World par0World, ChunkCoordinates par1ChunkCoordinates, boolean par2) { IChunkProvider var3 = par0World.getChunkProvider(); var3.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ - 3 >> 4); var3.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ - 3 >> 4); var3.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); var3.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); if (par0World.getBlock(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ) == Blocks.bed) { ChunkCoordinates var8 = BlockBed.func_149977_a(par0World, par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ, 0); return var8; } else { Material var4 = par0World.getBlock(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ).getMaterial(); Material var5 = par0World.getBlock(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY + 1, par1ChunkCoordinates.posZ).getMaterial(); boolean var6 = !var4.isSolid() && !var4.isLiquid(); boolean var7 = !var5.isSolid() && !var5.isLiquid(); return par2 && var6 && var7 ? par1ChunkCoordinates : null; } }
public static WorldView createWorldView(int dimid, ChunkCoordinates spawn, int width, int height) { if (ModConfigs.disabled) return null; if (!DimensionManager.isDimensionRegistered(dimid)) return null; WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimid); if (proxyworld == null) return null; Collection<WorldView> worldviews = worldviewsets.get(dimid); if (worldviews == null) return null; WorldView view = new WorldView(proxyworld, spawn, width, height); // Initialize the view rendering system Minecraft mc = Minecraft.getMinecraft(); EntityLivingBase backup = mc.renderViewEntity; mc.renderViewEntity = view.camera; view.getRenderGlobal().setWorldAndLoadRenderers(proxyworld); mc.renderViewEntity = backup; // Inform the server of the new view LookingGlassPacketManager.bus.sendToServer(PacketCreateView.createPacket(view)); worldviews.add(view); return view; }
@Override protected IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { World world = housing.getWorld(); ChunkCoordinates coords = housing.getCoordinates(); IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing); // Get random coords within territory int xRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[0]); int yRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[1]); int zRange = (int) (beeModifier.getTerritoryModifier(genome, 1f) * genome.getTerritory()[2]); int xCoord = coords.posX + world.rand.nextInt(xRange) - xRange / 2; int yCoord = coords.posY + world.rand.nextInt(yRange) - yRange / 2; int zCoord = coords.posZ + world.rand.nextInt(zRange) - zRange / 2; BiomeGenBase biome = world.getBiomeGenForCoords(xCoord, zCoord); transmutationController.attemptTransmutations(world, biome, new ItemStack(world.getBlock(xCoord, yCoord, zCoord), 1, world.getBlockMetadata(xCoord, yCoord, zCoord)), xCoord, yCoord, zCoord); storedData.setInteger(0, 0); return storedData; }
@Override public void updateEntity() { if(worldObj == null) return; ticksExisted++; if(!worldObj.isRemote) { ChunkCoordinates cc = getCoords(); if (!trackedEntities.containsKey(cc)) trackedEntities.put(cc, Lists.<AffectedEntity>newLinkedList()); if ((ticksExisted & 15) == 0) { killAI(); } if (((ticksExisted & 7) == 0)) { handleIO(); } if (((ticksExisted & 31) == 0)) { drainDefaultEssentia(); } } }
@Override public void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world) { Class animalClass = animalClasses[world.rand.nextInt(animalClasses.length)]; EntityLivingBase animal; try { animal = (EntityLivingBase) animalClass.getConstructor(World.class).newInstance(world); } catch (Exception e) { return; } boolean canSpawn = setAndCheckPosition(animal, selectedBlock, world, true); if(canSpawn) { ChunkCoordinates pos = new ChunkCoordinates((int) animal.posX, (int) animal.posY, (int) animal.posZ); pos = iterateDown(pos, world); animal.setPosition(pos.posX + 0.5, pos.posY, pos.posZ + 0.5); world.spawnEntityInWorld(animal); } }
/** * Plays the specified record. Arg: recordName, x, y, z */ public void playRecord(String par1Str, int par2, int par3, int par4) { ChunkCoordinates var5 = new ChunkCoordinates(par2, par3, par4); ISound var6 = (ISound)this.mapSoundPositions.get(var5); if (var6 != null) { this.mc.getSoundHandler().func_147683_b(var6); this.mapSoundPositions.remove(var5); } if (par1Str != null) { ItemRecord var7 = ItemRecord.func_150926_b(par1Str); if (var7 != null) { this.mc.ingameGUI.setRecordPlayingMessage(var7.func_150927_i()); } PositionedSoundRecord var8 = PositionedSoundRecord.func_147675_a(new ResourceLocation(par1Str), (float)par2, (float)par3, (float)par4); this.mapSoundPositions.put(var5, var8); this.mc.getSoundHandler().playSound(var8); } }