use of net.countercraft.movecraft.mapUpdater.update.UpdateCommand in project Movecraft by APDevTeam.
the class MapUpdateManager method run.
public void run() {
if (updates.isEmpty())
return;
Logger logger = Movecraft.getInstance().getLogger();
long startTime = System.currentTimeMillis();
// and set all crafts that were updated to not processing
// updates.sort((o1, o2) -> o1.getClass().getName().compareToIgnoreCase(o2.getClass().getName()));
UpdateCommand next = updates.poll();
while (next != null) {
next.doUpdate();
next = updates.poll();
}
/*// queue chunks for lighting recalc
if (!Settings.CompatibilityMode) {
for (net.minecraft.server.v1_10_R1.Chunk c : chunksToRelight) {
ChunkUpdater fChunk = FastBlockChanger.getInstance().getChunk(c.world, c.locX, c.locZ, true);
for (int bx = 0; bx < 16; bx++) {
for (int bz = 0; bz < 16; bz++) {
for (int by = 0; by < 4; by++) {
fChunk.bits[bx][bz][by] = Long.MAX_VALUE;
}
}
}
fChunk.last_modified = System.currentTimeMillis();
c.e();
}
}*/
if (Settings.Debug) {
long endTime = System.currentTimeMillis();
logger.info("Map update took (ms): " + (endTime - startTime));
}
}
use of net.countercraft.movecraft.mapUpdater.update.UpdateCommand in project Movecraft by APDevTeam.
the class AsyncManager method processFadingBlocks.
private void processFadingBlocks() {
if (Settings.FadeWrecksAfter == 0)
return;
long ticksElapsed = (System.currentTimeMillis() - lastFadeCheck) / 50;
if (ticksElapsed <= Settings.FadeTickCooldown)
return;
List<HitBox> processed = new ArrayList<>();
for (Map.Entry<HitBox, Long> entry : wrecks.entrySet()) {
if (Settings.FadeWrecksAfter * 1000L > System.currentTimeMillis() - entry.getValue())
continue;
final HitBox hitBox = entry.getKey();
final Map<Location, BlockData> phaseBlocks = wreckPhases.get(hitBox);
final World world = wreckWorlds.get(hitBox);
List<UpdateCommand> commands = new ArrayList<>();
int fadedBlocks = 0;
if (!processedFadeLocs.containsKey(world))
processedFadeLocs.put(world, new HashSet<>());
int maxFadeBlocks = (int) (hitBox.size() * (Settings.FadePercentageOfWreckPerCycle / 100.0));
// Iterate hitbox as a set to get more random locations
for (MovecraftLocation location : hitBox.asSet()) {
if (processedFadeLocs.get(world).contains(location))
continue;
if (fadedBlocks >= maxFadeBlocks)
break;
final Location bLoc = location.toBukkit(world);
if ((Settings.FadeWrecksAfter + Settings.ExtraFadeTimePerBlock.getOrDefault(bLoc.getBlock().getType(), 0)) * 1000L > System.currentTimeMillis() - entry.getValue())
continue;
fadedBlocks++;
processedFadeLocs.get(world).add(location);
BlockData phaseBlock = phaseBlocks.getOrDefault(bLoc, Material.AIR.createBlockData());
commands.add(new BlockCreateCommand(world, location, phaseBlock));
}
MapUpdateManager.getInstance().scheduleUpdates(commands);
if (!processedFadeLocs.get(world).containsAll(hitBox.asSet()))
continue;
processed.add(hitBox);
processedFadeLocs.get(world).removeAll(hitBox.asSet());
}
for (HitBox hitBox : processed) {
wrecks.remove(hitBox);
wreckPhases.remove(hitBox);
wreckWorlds.remove(hitBox);
}
lastFadeCheck = System.currentTimeMillis();
}
Aggregations