use of net.minecraft.server.world.ServerWorld in project Carpet-TIS-Addition by TISUnion.
the class ServerWorldMixin method beforeExecuteTileTickEvent.
@Inject(method = { "tickBlock", "tickFluid" }, at = @At("HEAD"))
private void beforeExecuteTileTickEvent(ScheduledTick<?> event, CallbackInfo ci) {
MicroTimingLoggerManager.setTickStageDetail((ServerWorld) (Object) this, String.valueOf(event.priority.getIndex()));
MicroTimingLoggerManager.setSubTickStage((ServerWorld) (Object) this, new TileTickSubStage((ServerWorld) (Object) this, event, this.tileTickOrderCounter++));
}
use of net.minecraft.server.world.ServerWorld in project Carpet-TIS-Addition by TISUnion.
the class EntityMixin method onConstructLifeTimeTracker.
@Inject(method = "<init>", at = @At("TAIL"))
private void onConstructLifeTimeTracker(CallbackInfo ci) {
this.recordedSpawning = false;
this.recordedRemoval = false;
if (this.world instanceof ServerWorld) {
// In case the entity is loaded when the world is being constructed
// Not sure if it's possible in vanilla, at least it happens in #29
LifeTimeWorldTracker tracker = ((ServerWorldWithLifeTimeTracker) this.world).getLifeTimeWorldTracker();
if (tracker != null) {
// do track
this.spawnTime = tracker.getSpawnStageCounter();
this.trackId = LifeTimeTracker.getInstance().getCurrentTrackId();
this.doLifeTimeTracking = LifeTimeTracker.getInstance().willTrackEntity((Entity) (Object) this);
return;
}
}
// dont track
this.trackId = -1;
this.doLifeTimeTracking = false;
}
use of net.minecraft.server.world.ServerWorld in project Carpet-TIS-Addition by TISUnion.
the class InfoCommand method showMoreBlockInfo.
public Collection<BaseText> showMoreBlockInfo(BlockPos pos, World world) {
if (!(world instanceof ServerWorld)) {
return Collections.emptyList();
}
List<BaseText> result = Lists.newArrayList();
BlockBox bound = new BlockBox(pos, pos.add(1, 1, 1));
List<ScheduledTick<Block>> blockTileTicks = ((ServerTickScheduler<Block>) world.getBlockTickScheduler()).getScheduledTicks(bound, false, false);
List<ScheduledTick<Fluid>> liquidTileTicks = ((ServerTickScheduler<Fluid>) world.getFluidTickScheduler()).getScheduledTicks(bound, false, false);
this.appendTileTickInfo(result, blockTileTicks, "Block Tile ticks", world.getTime(), Messenger::block);
this.appendTileTickInfo(result, liquidTileTicks, "Fluid Tile ticks", world.getTime(), Messenger::fluid);
List<BlockAction> blockEvents = ((ServerWorldAccessor) world).getPendingBlockActions().stream().filter(be -> be.getPos().equals(pos)).collect(Collectors.toList());
this.appendBlockEventInfo(result, blockEvents);
return result;
}
use of net.minecraft.server.world.ServerWorld in project Carpet-TIS-Addition by TISUnion.
the class TileEntityListController method showStatistic.
private int showStatistic(ServerCommandSource source) {
ServerWorld world = source.getWorld();
Messenger.tell(source, Messenger.format("===== %1$s =====", tr("statistic.title", Messenger.dimension(DimensionWrapper.of(world)))));
this.showTopNInCollection(source, tr("statistic.all"), world.blockEntities);
this.showTopNInCollection(source, tr("statistic.ticking"), world.tickingBlockEntities);
return 1;
}
use of net.minecraft.server.world.ServerWorld in project Carpet-TIS-Addition by TISUnion.
the class RaidCommand method listRaid.
public int listRaid(ServerCommandSource source, boolean fullMode) {
if (CarpetTISAdditionServer.minecraft_server == null) {
return 0;
}
boolean hasRaid = false;
for (ServerWorld world : CarpetTISAdditionServer.minecraft_server.getWorlds()) {
Map<Integer, Raid> raids = ((RaidManagerAccessor) world.getRaidManager()).getRaids();
if (raids.isEmpty()) {
continue;
}
List<BaseText> result = new ArrayList<>();
result.add(Messenger.c(Messenger.dimension(DimensionWrapper.of(world)), "w ", tr("raid_count", raids.size())));
hasRaid |= raids.size() > 0;
for (Map.Entry<Integer, Raid> entry : raids.entrySet()) {
Raid raid = entry.getValue();
RaidAccessor raidAccessor = (RaidAccessor) raid;
int currentWave = raidAccessor.getWavesSpawned();
String status = raidAccessor.getStatus().getName();
result.add(Messenger.c("g - ", Messenger.tr("event.minecraft.raid"), String.format("w #%d", raid.getRaidId())));
result.add(Messenger.c("g ", tr("status"), "w : ", tr("status." + status)));
result.add(Messenger.c("g ", tr("center"), "w : ", Messenger.coord("w", raid.getCenter(), DimensionWrapper.of(world))));
result.add(Messenger.c("g ", tr("bad_omen_level"), "w : ", Messenger.s(raid.getBadOmenLevel())));
result.add(Messenger.c("g ", tr("waves"), "w : ", String.format("w %d/%d", raidAccessor.getWavesSpawned(), raidAccessor.getWaveCount())));
Set<RaiderEntity> raiders = raidAccessor.getWaveToRaiders().get(currentWave);
boolean hasRaiders = raiders != null && !raiders.isEmpty();
result.add(Messenger.c("g ", tr("raiders"), "w : ", hasRaiders ? Messenger.s(String.format("x%d", raiders.size())) : tr("none")));
if (hasRaiders) {
int counter = 0;
List<Object> line = Lists.newArrayList();
for (Iterator<RaiderEntity> iter = raiders.iterator(); iter.hasNext(); ) {
RaiderEntity raider = iter.next();
BaseText raiderName = Messenger.entity(raider.equals(raidAccessor.getWaveToCaptain().get(currentWave)) ? "r" : "w", raider);
BaseText raiderMessage = Messenger.c(raiderName, "g @ ", Messenger.coord("w", raider.getPos(), DimensionWrapper.of(raider.world)));
if (fullMode) {
result.add(Messenger.c("g - ", raiderMessage));
} else {
BaseText x = Messenger.s(String.format("[%s] ", IdentifierUtil.id(raider.getType()).getPath().substring(0, 1).toUpperCase()));
x.setStyle(raiderName.getStyle().copy());
Messenger.hover(x, raiderMessage);
Messenger.click(x, new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, TextUtil.tp(raider)));
line.add(x);
counter++;
if (counter == 10 || !iter.hasNext()) {
line.add(0, "w ");
result.add(Messenger.c(line.toArray(new Object[0])));
line.clear();
counter = 0;
}
}
}
}
}
Messenger.tell(source, result);
}
if (!hasRaid) {
Messenger.tell(source, tr("no_raid"));
}
return 1;
}
Aggregations