@Override public Iterator<NextTickListEntry> iterator() { return new Iterator<NextTickListEntry>() { private final TLongObjectIterator<BlockUpdateEntry> iterator = trackerMap.iterator();; @Override public boolean hasNext() { return iterator.hasNext(); } @Override public NextTickListEntry next() { iterator.advance(); return iterator.value().asMCEntry(); } @Override public void remove() { removeEntry(iterator.value(), true); } }; }
@Override public Iterator<NextTickListEntry> iterator() { return new Iterator<NextTickListEntry>() { private final Iterator<BlockUpdateEntry> iterator = sortedTree.iterator();; private BlockUpdateEntry next; @Override public boolean hasNext() { next = null; return iterator.hasNext(); } @Override public NextTickListEntry next() { return (next = iterator.next()).asMCEntry(); } @Override public void remove() { if (next == null) next(); if (next != null) removeEntry(next, true); } }; }
public boolean add(NextTickListEntry e) { if (add.remove(e)) { allocateEntry(e.xCoord, e.yCoord, e.zCoord, e.priority, e.scheduledTime, e.func_151351_a()); return true; } return add.add(e); }
public boolean remove(NextTickListEntry e) { if (remove.remove(e)) { removeEntry(e.xCoord, e.yCoord, e.zCoord); return true; } return remove.add(e); }
public boolean contains(NextTickListEntry e, boolean allowInterscan) { if (allowInterscan) { if (add.contains(e)) return true; if (remove.contains(e)) return false; } return getEntry(e.xCoord, e.yCoord, e.zCoord) != null; }
public boolean contains(Object p_contains_1_) { if (!(p_contains_1_ instanceof NextTickListEntry)) { return false; } else { NextTickListEntry nextticklistentry = (NextTickListEntry)p_contains_1_; Set set = this.getSubSet(nextticklistentry, false); return set == null ? false : set.contains(nextticklistentry); } }
public boolean add(Object p_add_1_) { if (!(p_add_1_ instanceof NextTickListEntry)) { return false; } else { NextTickListEntry nextticklistentry = (NextTickListEntry)p_add_1_; if (nextticklistentry == null) { return false; } else { Set set = this.getSubSet(nextticklistentry, true); boolean flag = set.add(nextticklistentry); boolean flag1 = super.add(p_add_1_); if (flag != flag1) { throw new IllegalStateException("Added: " + flag + ", addedParent: " + flag1); } else { return flag1; } } } }
public boolean remove(Object p_remove_1_) { if (!(p_remove_1_ instanceof NextTickListEntry)) { return false; } else { NextTickListEntry nextticklistentry = (NextTickListEntry)p_remove_1_; Set set = this.getSubSet(nextticklistentry, false); if (set == null) { return false; } else { boolean flag = set.remove(nextticklistentry); boolean flag1 = super.remove(nextticklistentry); if (flag != flag1) { throw new IllegalStateException("Added: " + flag + ", addedParent: " + flag1); } else { return flag1; } } } }
private Set getSubSet(NextTickListEntry p_getSubSet_1_, boolean p_getSubSet_2_) { if (p_getSubSet_1_ == null) { return null; } else { BlockPos blockpos = p_getSubSet_1_.position; int i = blockpos.getX() >> 4; int j = blockpos.getZ() >> 4; return this.getSubSet(i, j, p_getSubSet_2_); } }
@Override public List<NextTickListEntry> getPendingBlockUpdates(Chunk chunkIn, boolean remove) { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyWorld.getPendingBlockUpdates(chunkIn, remove); } else if (m_realWorld != null) { return m_realWorld.getPendingBlockUpdates(chunkIn, remove); } else { return super.getPendingBlockUpdates(chunkIn, remove); } }
@Override public List<NextTickListEntry> getPendingBlockUpdates(StructureBoundingBox structureBB, boolean remove) { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyWorld.getPendingBlockUpdates(structureBB, remove); } else if (m_realWorld != null) { return m_realWorld.getPendingBlockUpdates(structureBB, remove); } else { return super.getPendingBlockUpdates(structureBB, remove); } }
@Override public void updateBlockTick(BlockPos pos, Block block, int delay, int priority) { if (pos instanceof BlockPos.MutableBlockPos) { pos = new BlockPos(pos); LogManager.getLogger().warn("Tried to assign a mutable BlockPos to tick data...", new Error(pos.getClass().toString())); } Material material = block.getDefaultState().getMaterial(); if (this.scheduledUpdatesAreImmediate && material != Material.AIR) { if (block.requiresUpdates()) { boolean isForced = this.getPersistentChunks().containsKey(new ChunkPos(pos)); int range = isForced ? 0 : 8; if (this.isAreaLoaded(pos.add(-range, -range, -range), pos.add(range, range, range))) { IBlockState state = this.getBlockState(pos); if (state.getMaterial() != Material.AIR && state.getBlock() == block) { state.getBlock().updateTick(this, pos, state, this.rand); } } return; } delay = 1; } NextTickListEntry schedule = new NextTickListEntry(pos, block); if (this.isBlockLoaded(pos)) { if (material != Material.AIR) { schedule.setScheduledTime((long) delay + this.worldInfo.getWorldTotalTime()); schedule.setPriority(priority); } if (!this.scheduledTicksSet.contains(schedule)) { this.scheduledTicksSet.add(schedule); this.scheduledTicksTree.add(schedule); } } }
@Override public void scheduleBlockUpdate(BlockPos pos, Block block, int delay, int priority) { NextTickListEntry schedule = new NextTickListEntry(pos, block); schedule.setPriority(priority); Material material = block.getDefaultState().getMaterial(); if (material != Material.AIR) { schedule.setScheduledTime((long) delay + this.worldInfo.getWorldTotalTime()); } if (!this.scheduledTicksSet.contains(schedule)) { this.scheduledTicksSet.add(schedule); this.scheduledTicksTree.add(schedule); } }
@Override public List<NextTickListEntry> getPendingBlockUpdates(StructureBoundingBox bounds, boolean remove) { List<NextTickListEntry> updates = null; for (int i = 0; i < 2; i++) { Iterator<NextTickListEntry> iterator; if (i == 0) { iterator = this.scheduledTicksTree.iterator(); } else { iterator = this.currentScheduledTicks.iterator(); } while (iterator.hasNext()) { NextTickListEntry scheduledUpdate = iterator.next(); BlockPos position = scheduledUpdate.position; if (position.getX() >= bounds.minX && position.getX() < bounds.maxX && position.getZ() >= bounds.minZ && position.getZ() < bounds.maxZ) { if (remove) { if (i == 0) { this.scheduledTicksSet.remove(scheduledUpdate); } iterator.remove(); } if (updates == null) { updates = Lists.newArrayList(); } updates.add(scheduledUpdate); } } } return updates; }
public void func_147446_b(int x, int y, int z, Block block, int delay, int priority) { if (block.getMaterial() == Material.air) return; final NextTickListEntry tickEntry = new NextTickListEntry(x, y, z, block); // If we can add it isn't a duplicate if (this.containment.add(tickEntry)) { tickEntry.setPriority(priority); tickEntry.setScheduledTime((long) delay + this.worldInfo.getWorldTotalTime()); this.pendingTickListEntries.add(tickEntry); } }
protected void initialize(WorldSettings settings) { // This is here because the World CTOR triggers world // gen that can occur *before* WorldServer has a chance // to initialize. :\ if (this.entityIdMap == null) this.entityIdMap = new IntHashMap(); if (this.pendingTickListEntries == null) this.pendingTickListEntries = new PriorityQueue<NextTickListEntry>(QUEUE_SIZE); if (this.containment == null) containment = new HashSet<NextTickListEntry>(QUEUE_SIZE); this.createSpawnPosition(settings); super.initialize(settings); }
public boolean contains(Object obj) { if (!(obj instanceof NextTickListEntry)) { return false; } else { NextTickListEntry entry = (NextTickListEntry)obj; long key = ChunkCoordIntPair.chunkXZ2Int(entry.xCoord >> 4, entry.zCoord >> 4); HashSet set = (HashSet)this.longHashMap.getValueByKey(key); return set == null ? false : set.contains(entry); } }
public boolean add(Object obj) { if (!(obj instanceof NextTickListEntry)) { return false; } else { NextTickListEntry entry = (NextTickListEntry)obj; long key = ChunkCoordIntPair.chunkXZ2Int(entry.xCoord >> 4, entry.zCoord >> 4); HashSet set = (HashSet)this.longHashMap.getValueByKey(key); if (set == null) { set = new HashSet(); this.longHashMap.add(key, set); } boolean added = set.add(entry); if (added) { ++this.size; } return added; } }
public boolean remove(Object obj) { if (!(obj instanceof NextTickListEntry)) { return false; } else { NextTickListEntry entry = (NextTickListEntry)obj; long key = ChunkCoordIntPair.chunkXZ2Int(entry.xCoord >> 4, entry.zCoord >> 4); HashSet set = (HashSet)this.longHashMap.getValueByKey(key); if (set == null) { return false; } else { boolean removed = set.remove(entry); if (removed) { --this.size; } return removed; } } }
public void func_82740_a(int p_82740_1_, int p_82740_2_, int p_82740_3_, int p_82740_4_, int p_82740_5_, int p_82740_6_) { NextTickListEntry var7 = new NextTickListEntry(p_82740_1_, p_82740_2_, p_82740_3_, p_82740_4_); byte var8 = 0; if(this.field_72999_e && p_82740_4_ > 0) { if(Block.field_71973_m[p_82740_4_].func_82506_l()) { var8 = 8; if(this.func_72904_c(var7.field_77183_a - var8, var7.field_77181_b - var8, var7.field_77182_c - var8, var7.field_77183_a + var8, var7.field_77181_b + var8, var7.field_77182_c + var8)) { int var9 = this.func_72798_a(var7.field_77183_a, var7.field_77181_b, var7.field_77182_c); if(var9 == var7.field_77179_d && var9 > 0) { Block.field_71973_m[var9].func_71847_b(this, var7.field_77183_a, var7.field_77181_b, var7.field_77182_c, this.field_73012_v); } } return; } p_82740_5_ = 1; } if(this.func_72904_c(p_82740_1_ - var8, p_82740_2_ - var8, p_82740_3_ - var8, p_82740_1_ + var8, p_82740_2_ + var8, p_82740_3_ + var8)) { if(p_82740_4_ > 0) { var7.func_77176_a((long)p_82740_5_ + this.field_72986_A.func_82573_f()); var7.func_82753_a(p_82740_6_); } if(!this.field_73064_N.contains(var7)) { this.field_73064_N.add(var7); this.field_73065_O.add(var7); } } }
public void func_72892_b(int p_72892_1_, int p_72892_2_, int p_72892_3_, int p_72892_4_, int p_72892_5_, int p_72892_6_) { NextTickListEntry var7 = new NextTickListEntry(p_72892_1_, p_72892_2_, p_72892_3_, p_72892_4_); var7.func_82753_a(p_72892_6_); if(p_72892_4_ > 0) { var7.func_77176_a((long)p_72892_5_ + this.field_72986_A.func_82573_f()); } if(!this.field_73064_N.contains(var7)) { this.field_73064_N.add(var7); this.field_73065_O.add(var7); } }
public List func_72920_a(Chunk p_72920_1_, boolean p_72920_2_) { ArrayList var3 = null; ChunkCoordIntPair var4 = p_72920_1_.func_76632_l(); int var5 = (var4.field_77276_a << 4) - 2; int var6 = var5 + 16 + 2; int var7 = (var4.field_77275_b << 4) - 2; int var8 = var7 + 16 + 2; for(int var9 = 0; var9 < 2; ++var9) { Iterator var10; if(var9 == 0) { var10 = this.field_73065_O.iterator(); } else { var10 = this.field_94579_S.iterator(); if(!this.field_94579_S.isEmpty()) { System.out.println(this.field_94579_S.size()); } } while(var10.hasNext()) { NextTickListEntry var11 = (NextTickListEntry)var10.next(); if(var11.field_77183_a >= var5 && var11.field_77183_a < var6 && var11.field_77182_c >= var7 && var11.field_77182_c < var8) { if(p_72920_2_) { this.field_73064_N.remove(var11); var10.remove(); } if(var3 == null) { var3 = new ArrayList(); } var3.add(var11); } } } return var3; }
@Override public boolean add(NextTickListEntry e) { return wrapper.add(e); }
@Override public boolean remove(Object o) { return wrapper.remove((NextTickListEntry) o); }
@Override public boolean contains(Object o) { return wrapper.contains((NextTickListEntry) o, true); }
@Override public boolean contains(Object o) { return wrapper.contains((NextTickListEntry) o, false); }
@Override public boolean isBlockTickPending(BlockPos pos, Block block) { NextTickListEntry scheduledTick = new NextTickListEntry(pos, block); return this.currentScheduledTicks.contains(scheduledTick); }
public static TileEntity move(Coord src, Coord dest, boolean wipeSrc, boolean overwriteDestination, int setMethod) { Block id = src.getBlock(); int md = src.getMd(); int blockLight = src.getLightLevelBlock(); int skyLight = src.getLightLevelSky(); if (id == null && !overwriteDestination) { return null; } long block_tick_time = -1; int block_tick_priority = -1; BlockPos srcPos = src.toBlockPos(); { List<NextTickListEntry> pendingTicks = (List<NextTickListEntry>) src.w.getPendingBlockUpdates(src.getChunk(), false); if (pendingTicks != null) { for (NextTickListEntry tick : pendingTicks) { if (tick.position.equals(srcPos)) { block_tick_time = tick.scheduledTime - src.w.getWorldInfo().getWorldTotalTime(); block_tick_priority = tick.priority; break; } } } } TileEntity te = src.getTE(); NBTTagCompound teData = null; if (te != null) { teData = new NBTTagCompound(); te.writeToNBT(teData); if (wipeSrc) { rawRemoveTE(src); } } if (wipeSrc) { setRaw(src, Blocks.air, 0); } if (dest.getTE() != null) { rawRemoveTE(dest); } setRaw(dest, id, md, setMethod); dest.setLightLevelBlock(blockLight); dest.setLightLevelSky(skyLight); TileEntity ret = null; if (teData != null) { teData.setInteger("x", dest.x); teData.setInteger("y", dest.y); teData.setInteger("z", dest.z); ret = TileEntity.createAndLoadEntity(teData); ret.validate(); dest.setTE(ret); } if (block_tick_time > -1) { dest.w.updateBlockTick(dest.toBlockPos(), id, (int) block_tick_time, block_tick_priority); } return ret; }
public boolean tickUpdates(boolean p_72955_1_) { // Cap the number of events that are going to be // processed this tick. int eventsToProcess = Math.min(MAX_EVENTS_PER_TICK, this.pendingTickListEntries.size()); this.theProfiler.startSection("ticking"); while (eventsToProcess-- > 0) { // Is it time to process the next event? If not terminate // the loop because we are done. if (!p_72955_1_ && this.pendingTickListEntries.peek().scheduledTime > this.worldInfo.getWorldTotalTime()) break; final NextTickListEntry tickEntry = this.pendingTickListEntries.poll(); this.containment.remove(tickEntry); // Only update if the chunk is loaded. The chunkExists() name // doesn't match what is really being checked. The reason for the // check is that the chunk may have been saved/unloaded and the tick // info saved with it. When the chunk loads again those events will // be queued for processing. if (this.chunkExists(tickEntry.xCoord >> 4, tickEntry.zCoord >> 4)) { // Get the target of our desire final Block block = this.getBlock(tickEntry.xCoord, tickEntry.yCoord, tickEntry.zCoord); // If it's air, or not the block that is expected go to the next // entry if (block.getMaterial() == Material.air || !Block.isEqualTo(block, tickEntry.func_151351_a())) continue; // Do the update try { block.updateTick(this, tickEntry.xCoord, tickEntry.yCoord, tickEntry.zCoord, this.rand); } catch (Throwable throwable1) { CrashReport crashreport = CrashReport.makeCrashReport(throwable1, "Exception while ticking a block"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being ticked"); int k; try { k = this.getBlockMetadata(tickEntry.xCoord, tickEntry.yCoord, tickEntry.zCoord); } catch (Throwable throwable) { k = -1; } CrashReportCategory.func_147153_a(crashreportcategory, tickEntry.xCoord, tickEntry.yCoord, tickEntry.zCoord, block, k); throw new ReportedException(crashreport); } } } this.theProfiler.endSection(); return !this.pendingTickListEntries.isEmpty(); }
public List<NextTickListEntry> getPendingBlockUpdates(final Chunk chunk, final boolean removeFlag) { final ArrayList<NextTickListEntry> arraylist = new ArrayList<NextTickListEntry>(); final ChunkCoordIntPair chunkcoordintpair = chunk.getChunkCoordIntPair(); int i = (chunkcoordintpair.chunkXPos << 4) - 2; int j = i + 16 + 2; int k = (chunkcoordintpair.chunkZPos << 4) - 2; int l = k + 16 + 2; // pendingTickListEntriesThisTick should be empty because it is filled // and drained during tickUpdate(). Leaving things in tact because the // logic could be crash recoverable. // if (!this.pendingTickListEntriesThisTick.isEmpty()) { // logger.debug("toBeTicked = " + // this.pendingTickListEntriesThisTick.size()); // } /* * for (int x = 0; x < 2; x++) { final Iterator<NextTickListEntry> * iterator = x == 0 ? this.pendingTickListEntries.iterator() : * this.pendingTickListEntriesThisTick.iterator(); */ final Iterator<NextTickListEntry> iterator = this.pendingTickListEntries.iterator(); while (iterator.hasNext()) { final NextTickListEntry tickEntry = iterator.next(); if (tickEntry.xCoord >= i && tickEntry.xCoord < j && tickEntry.zCoord >= k && tickEntry.zCoord < l) { arraylist.add(tickEntry); // Remove if forced. Otherwise they will be removed // in a lazy fashion when tickUpdate() occurs. if (removeFlag) { iterator.remove(); this.containment.remove(tickEntry); } } } // } return arraylist.isEmpty() ? null : arraylist; }
public List getPendingBlockUpdates(Chunk par1Chunk, boolean par2) { if (this.pendingTickListEntriesHashSet != null && this.pendingTickListEntriesTreeSet != null && this.pendingTickListEntriesThisTick != null) { ArrayList var3 = null; ChunkCoordIntPair var4 = par1Chunk.getChunkCoordIntPair(); int var5 = (var4.chunkXPos << 4) - 2; int var6 = var5 + 16 + 2; int var7 = (var4.chunkZPos << 4) - 2; int var8 = var7 + 16 + 2; for (int var9 = 0; var9 < 2; ++var9) { Iterator var10; if (var9 == 0) { TreeSet var11 = new TreeSet(); for (int dx = -1; dx <= 1; ++dx) { for (int dz = -1; dz <= 1; ++dz) { HashSet set = this.pendingTickListEntriesHashSet.getNextTickEntriesSet(var4.chunkXPos + dx, var4.chunkZPos + dz); var11.addAll(set); } } var10 = var11.iterator(); } else { var10 = this.pendingTickListEntriesThisTick.iterator(); if (!this.pendingTickListEntriesThisTick.isEmpty()) { logger.debug("toBeTicked = " + this.pendingTickListEntriesThisTick.size()); } } while (var10.hasNext()) { NextTickListEntry var15 = (NextTickListEntry)var10.next(); if (var15.xCoord >= var5 && var15.xCoord < var6 && var15.zCoord >= var7 && var15.zCoord < var8) { if (par2) { this.pendingTickListEntriesHashSet.remove(var15); this.pendingTickListEntriesTreeSet.remove(var15); var10.remove(); } if (var3 == null) { var3 = new ArrayList(); } var3.add(var15); } } } return var3; } else { return super.getPendingBlockUpdates(par1Chunk, par2); } }
@Override public List<NextTickListEntry> getPendingBlockUpdates(Chunk chunkIn, boolean p_72920_2_) { return Lists.newArrayList(); }
@Override public List<NextTickListEntry> getPendingBlockUpdates(StructureBoundingBox structureBB, boolean p_175712_2_) { return Lists.newArrayList(); }
public boolean func_94573_a(int p_94573_1_, int p_94573_2_, int p_94573_3_, int p_94573_4_) { NextTickListEntry var5 = new NextTickListEntry(p_94573_1_, p_94573_2_, p_94573_3_, p_94573_4_); return this.field_94579_S.contains(var5); }