Java Code Examples for codechicken.core.CommonUtils#getDimension()
The following examples show how to use
codechicken.core.CommonUtils#getDimension() .
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
Source File: ChunkLoaderManager.java From ChickenChunks with MIT License | 6 votes |
public void addChunkLoader(IChickenChunkLoader loader) { if (reviving) return; int dim = CommonUtils.getDimension(loader.getWorld()); if (dormant) { HashSet<BlockCoord> coords = dormantLoaders.get(dim); if (coords == null) dormantLoaders.put(dim, coords = new HashSet<BlockCoord>()); coords.add(loader.getPosition()); } else { forcedChunksByLoader.put(loader, new HashSet<ChunkCoordIntPair>()); forceChunks(loader, dim, loader.getChunks()); } setDirty(); }
Example 2
Source File: PlayerChunkViewerTracker.java From ChickenChunks with MIT License | 6 votes |
@SuppressWarnings("unchecked") public void loadDimension(WorldServer world) { PacketCustom packet = new PacketCustom(channel, 2).compress(); int dim = CommonUtils.getDimension(world); packet.writeInt(dim); List<Chunk> allchunks = world.theChunkProviderServer.loadedChunks; packet.writeInt(allchunks.size()); for(Chunk chunk : allchunks) { packet.writeInt(chunk.xPosition); packet.writeInt(chunk.zPosition); } Map<Ticket, Collection<ChunkCoordIntPair>> tickets = ForgeChunkManager.getPersistentChunksFor(world).inverse().asMap(); packet.writeInt(tickets.size()); for(Entry<Ticket, Collection<ChunkCoordIntPair>> entry : tickets.entrySet()) writeTicketToPacket(packet, entry.getKey(), entry.getValue()); packet.sendToPlayer(owner); }
Example 3
Source File: ChunkLoaderManager.java From ChickenChunks with MIT License | 6 votes |
public void updateChunkLoader(IChickenChunkLoader loader) { HashSet<ChunkCoordIntPair> loaderChunks = forcedChunksByLoader.get(loader); if (loaderChunks == null) { addChunkLoader(loader); return; } HashSet<ChunkCoordIntPair> oldChunks = new HashSet<ChunkCoordIntPair>(loaderChunks); HashSet<ChunkCoordIntPair> newChunks = new HashSet<ChunkCoordIntPair>(); for (ChunkCoordIntPair chunk : loader.getChunks()) if (!oldChunks.remove(chunk)) newChunks.add(chunk); int dim = CommonUtils.getDimension(loader.getWorld()); if (!oldChunks.isEmpty()) unforceChunks(loader, dim, oldChunks, false); if (!newChunks.isEmpty()) forceChunks(loader, dim, newChunks); }
Example 4
Source File: RedstoneEtherServer.java From WirelessRedstone with MIT License | 6 votes |
private void entityJamTest(World world) { if(world.getTotalWorldTime() % 10 != 0) return; int dimension = CommonUtils.getDimension(world); for(Iterator<BlockCoord> iterator = ethers.get(dimension).jammerset.iterator(); iterator.hasNext();) { BlockCoord jammer = iterator.next(); List<Entity> entitiesinrange = world.getEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.getBoundingBox(jammer.x-9.5, jammer.y-9.5, jammer.z-9.5, jammer.x+10.5, jammer.y+10.5, jammer.z+10.5)); for(Iterator<Entity> iterator2 = entitiesinrange.iterator(); iterator2.hasNext();) { Entity entity = iterator2.next(); if(!(entity instanceof EntityLivingBase)) continue; if(entity instanceof EntityPlayer) if(isPlayerJammed((EntityPlayer)entity)) continue; jamEntitySometime((EntityLivingBase) entity); } } }
Example 5
Source File: RedstoneEtherServer.java From WirelessRedstone with MIT License | 6 votes |
public void setTransmitter(World world, int x, int y, int z, int freq, boolean on) { if(freq == 0) { return; } BlockCoord node = new BlockCoord(x, y, z); int dimension = CommonUtils.getDimension(world); if(isNodeInAOEofJammer(node, dimension)) { jamNodeSometime(world, node, dimension, freq); } TXNodeInfo info = ethers.get(dimension).transmittingblocks.get(node); if(info == null) ethers.get(dimension).transmittingblocks.put(node, new TXNodeInfo(freq, on)); else info.on = on; freqarray[freq].setTransmitter(world, node, dimension, on); }
Example 6
Source File: RedstoneEtherServer.java From WirelessRedstone with MIT License | 6 votes |
public void verifyChunkTransmitters(World world, int chunkx, int chunkz) { int dimension = CommonUtils.getDimension(world); DimensionalEtherHash ether = ethers.get(dimension); int blockxmin = chunkx * 16; int blockxmax = blockxmin + 15; int blockzmin = chunkz * 16; int blockzmax = blockzmin + 15; ArrayList<BlockCoord> transmittingblocks = new ArrayList<BlockCoord>(ether.transmittingblocks.keySet()); for(BlockCoord node : transmittingblocks) { if(node.x >= blockxmin && node.x <= blockxmax && node.z >= blockzmin && node.z <= blockzmax) { TileEntity tile = RedstoneEther.getTile(world, node); int freq = ether.transmittingblocks.get(node).freq; if(tile == null || !(tile instanceof ITileWireless) || ((ITileWireless)tile).getFreq() != freq) { remTransmitter(world, node.x, node.y, node.z, freq); System.out.println("Removed Badly Synced node at:"+node.x+","+node.y+","+node.z+" on "+freq+" in dim"+dimension); } } } }
Example 7
Source File: RedstoneEtherServer.java From WirelessRedstone with MIT License | 5 votes |
public void remReceiver(World world, int x, int y, int z, int freq) { if(freq == 0) return; int dimension = CommonUtils.getDimension(world); BlockCoord node = new BlockCoord(x, y, z); ethers.get(dimension).jammednodes.remove(node); ethers.get(dimension).recievingblocks.remove(node); freqarray[freq].remReceiver(world, node, dimension); }
Example 8
Source File: RedstoneEtherServer.java From WirelessRedstone with MIT License | 5 votes |
public void remTransmitter(World world, int x, int y, int z, int freq) { if(freq == 0) { return; } int dimension = CommonUtils.getDimension(world); BlockCoord node = new BlockCoord(x, y, z); ethers.get(dimension).jammednodes.remove(node); ethers.get(dimension).transmittingblocks.remove(node); freqarray[freq].remTransmitter(world, node, dimension); }
Example 9
Source File: RedstoneEtherServer.java From WirelessRedstone with MIT License | 5 votes |
public void saveEther(World world) { int dimension = CommonUtils.getDimension(world); if(!ethers.containsKey(dimension)) return; for(RedstoneEtherFrequency freq : ethers.get(dimension).freqsToSave) freq.saveFreq(dimension); ethers.get(dimension).freqsToSave.clear(); SaveManager.getInstance(dimension).removeTrailingSectors(); SaveManager.saveDimensionHash(); }
Example 10
Source File: RedstoneEther.java From WirelessRedstone with MIT License | 5 votes |
public static void loadServerWorld(World world) { int dimension = CommonUtils.getDimension(world); if (serverEther == null) new RedstoneEtherServer().init(world); serverEther.addEther(world, dimension); }
Example 11
Source File: RedstoneEtherServer.java From WirelessRedstone with MIT License | 5 votes |
public void addJammer(World world, int x, int y, int z) { int dimension = CommonUtils.getDimension(world); BlockCoord jammer = new BlockCoord(x, y, z); ethers.get(dimension).jammerset.add(jammer); jamNodesInAOEOfJammer(world, jammer, dimension); }
Example 12
Source File: PlayerChunkViewerManager.java From ChickenChunks with MIT License | 5 votes |
public TicketChange(Ticket ticket, ChunkCoordIntPair chunk, boolean force) { this.ticket = ticket; this.dimension = CommonUtils.getDimension(ticket.world); this.chunk = chunk; this.force = force; }
Example 13
Source File: RedstoneEtherServer.java From WirelessRedstone with MIT License | 5 votes |
public void unjamTile(World world, int x, int y, int z) { BlockCoord node = new BlockCoord(x, y, z); int dimension = CommonUtils.getDimension(world); Integer timeout = ethers.get(dimension).jammednodes.remove(node); if(timeout != null && timeout >= 0)//tile was jammed { ITileWireless tile = (ITileWireless) getTile(world, node); tile.unjamTile(); } }
Example 14
Source File: ChunkLoaderManager.java From ChickenChunks with MIT License | 5 votes |
public static boolean canLoaderAdd(IChickenChunkLoader loader, Collection<ChunkCoordIntPair> chunks) { String owner = loader.getOwner(); int dim = CommonUtils.getDimension(loader.getWorld()); if (owner != null) return getPlayerOrganiser(owner).canForceNewChunks(dim, chunks); return false; }
Example 15
Source File: ChunkLoaderManager.java From ChickenChunks with MIT License | 5 votes |
public static void addChunkLoader(IChickenChunkLoader loader) { int dim = CommonUtils.getDimension(loader.getWorld()); ChunkLoaderOrganiser organiser = getOrganiser(loader); if (organiser.canForceNewChunks(dim, loader.getChunks())) organiser.addChunkLoader(loader); else loader.deactivate(); }
Example 16
Source File: ChunkLoaderManager.java From ChickenChunks with MIT License | 5 votes |
public void devive() { if (dormant) return; for (IChickenChunkLoader loader : new ArrayList<IChickenChunkLoader>(forcedChunksByLoader.keySet())) { int dim = CommonUtils.getDimension(loader.getWorld()); HashSet<BlockCoord> coords = dormantLoaders.get(dim); if (coords == null) dormantLoaders.put(dim, coords = new HashSet<BlockCoord>()); coords.add(loader.getPosition()); remChunkLoader(loader); } dormant = true; }
Example 17
Source File: ChunkLoaderManager.java From ChickenChunks with MIT License | 5 votes |
public void remChunkLoader(IChickenChunkLoader loader) { int dim = CommonUtils.getDimension(loader.getWorld()); if (dormant) { HashSet<BlockCoord> coords = dormantLoaders.get(dim); if(coords != null) coords.remove(loader.getPosition()); } else { HashSet<ChunkCoordIntPair> chunks = forcedChunksByLoader.remove(loader); if (chunks == null) return; unforceChunks(loader, dim, chunks, true); } setDirty(); }
Example 18
Source File: RedstoneEtherFrequency.java From WirelessRedstone with MIT License | 4 votes |
public DimensionalNodeTracker(World world2) { world = world2; dimension = CommonUtils.getDimension(world2); }
Example 19
Source File: RedstoneEtherServerAddons.java From WirelessRedstone with MIT License | 4 votes |
public void processSMPMaps(World world) { RedstoneEther.loadServerWorld(world); int dimension = CommonUtils.getDimension(world); ArrayList<EntityPlayer> players = ServerUtils.getPlayersInDimension(dimension); Map<BlockCoord, TXNodeInfo> txnodes = RedstoneEther.server().getTransmittersInDimension(dimension); Set<WirelessTransmittingDevice> devices = RedstoneEther.server().getTransmittingDevicesInDimension(dimension); for (EntityPlayer player : players) { ItemStack helditem = player.getCurrentEquippedItem(); if (helditem == null || helditem.getItem() != WirelessRedstoneAddons.wirelessMap || RedstoneEther.server().isPlayerJammed(player)) { continue; } ItemWirelessMap map = (ItemWirelessMap) helditem.getItem(); MapData mapdata = map.getMapData(helditem, world); if (mapdata.dimension != player.dimension) { continue; } WirelessMapNodeStorage mapnodes = getMapNodes(player); TreeSet<FreqCoord> oldnodes = mapnodes.nodes; int lastdevices = mapnodes.devices.size(); updatePlayerMapData(player, world, mapdata, txnodes, devices); TreeSet<FreqCoord> addednodes = new TreeSet<FreqCoord>(mapnodes.nodes); TreeSet<FreqCoord> removednodes = new TreeSet<FreqCoord>(); if (oldnodes.size() != 0) { for (Iterator<FreqCoord> nodeiterator = oldnodes.iterator(); nodeiterator.hasNext(); ) { FreqCoord node = nodeiterator.next(); if (!addednodes.remove(node))//remove returns false if the item was not in the set { removednodes.add(node); } } } if (addednodes.size() != 0 || removednodes.size() != 0 || devices.size() != 0 || lastdevices > 0) { WRAddonSPH.sendMapUpdatePacketTo(player, helditem.getItemDamage(), mapdata, addednodes, removednodes, mapnodes.devices); } } }
Example 20
Source File: RedstoneEther.java From WirelessRedstone with MIT License | 4 votes |
public static void unloadServerWorld(World world) { int dimension = CommonUtils.getDimension(world); if (serverEther != null) serverEther.remEther(world, dimension); }