com/hypixel/hytale/server/core/universe/PlayerRef.java
package com.hypixel.hytale.server.core.universe;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.logger.sentry.SkipSentryException;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.metrics.MetricProvider;
import com.hypixel.hytale.metrics.MetricResults;
import com.hypixel.hytale.metrics.MetricsRegistry;
import com.hypixel.hytale.protocol.HostAddress;
import com.hypixel.hytale.protocol.io.PacketStatsRecorder;
import com.hypixel.hytale.protocol.packets.auth.ClientReferral;
import com.hypixel.hytale.protocol.packets.connection.PongType;
import com.hypixel.hytale.protocol.packets.interface_.ChatType;
import com.hypixel.hytale.protocol.packets.interface_.ServerMessage;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.entity.entities.player.CameraManager;
import com.hypixel.hytale.server.core.entity.entities.player.HiddenPlayersManager;
import com.hypixel.hytale.server.core.entity.entities.player.movement.MovementManager;
import com.hypixel.hytale.server.core.entity.movement.MovementStatesComponent;
import com.hypixel.hytale.server.core.io.PacketHandler;
import com.hypixel.hytale.server.core.io.PacketStatsRecorderImpl;
import com.hypixel.hytale.server.core.modules.entity.player.ChunkTracker;
import com.hypixel.hytale.server.core.receiver.IMessageReceiver;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PlayerRef implements Component <EntityStore>, MetricProvider, IMessageReceiver {
@Nonnull
public static final MetricsRegistry<PlayerRef> METRICS_REGISTRY;
@Nonnull
public static final MetricsRegistry<PlayerRef> COMPONENT_METRICS_REGISTRY;
@Nonnull
private static final HytaleLogger LOGGER;
@Nonnull
private final UUID uuid;
@Nonnull
private final String username;
@Nonnull
private final PacketHandler packetHandler;
@Nonnull
private final ChunkTracker chunkTracker;
@Nonnull
private final HiddenPlayersManager hiddenPlayersManager = new HiddenPlayersManager ();
@Nonnull
private String language;
@Nullable
private Ref<EntityStore> entity;
@Nullable
private Holder<EntityStore> holder;
@Nullable
private UUID worldUuid;
private Transform transform = new Transform (0.0 , 0.0 , 0.0 , 0.0F , 0.0F , 0.0F );
private Vector3f headRotation = new Vector3f (0.0F , 0.0F , 0.0F );
@Nonnull
public static ComponentType<EntityStore, PlayerRef> getComponentType () {
return Universe.get().getPlayerRefComponentType();
}
public PlayerRef (@Nonnull Holder<EntityStore> holder, @Nonnull UUID uuid, @Nonnull String username, @Nonnull String language, @Nonnull PacketHandler packetHandler, @Nonnull ChunkTracker chunkTracker) {
this .holder = holder;
this .uuid = uuid;
this .username = username;
this .language = language;
this .packetHandler = packetHandler;
this .chunkTracker = chunkTracker;
}
@Nullable
public Ref<EntityStore> addToStore (@Nonnull Store<EntityStore> store) {
store.assertThread();
if (this .holder == null ) {
throw new IllegalStateException ("Already in world" );
} else {
return store.addEntity(this .holder, AddReason.LOAD);
}
}
public void addedToStore (Ref<EntityStore> ref) {
this .holder = null ;
this .entity = ref;
}
@Nonnull
public Holder<EntityStore> removeFromStore () {
if (this .entity == null ) {
throw new IllegalStateException ("Not in world" );
} else {
this .entity.getStore().assertThread();
Ref<EntityStore> entity = this .entity;
this .entity = null ;
return this .holder = entity.getStore().removeEntity(entity, RemoveReason.UNLOAD);
}
}
public boolean isValid () {
return this .entity != null || this .holder != null ;
}
@Nullable
public Ref<EntityStore> getReference () {
return this .entity != null && this .entity.isValid() ? this .entity : null ;
}
@Nullable
public Holder<EntityStore> getHolder () {
return this .holder;
}
@Nullable
@Deprecated
public <T extends Component <EntityStore>> T getComponent (@Nonnull ComponentType<EntityStore, T> componentType) {
if (this .holder != null ) {
return (T)this .holder.getComponent(componentType);
} else {
Store<EntityStore> store = this .entity.getStore();
if (store.isInThread()) {
return (T)store.getComponent(this .entity, componentType);
} else {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(new SkipSentryException ())).log("PlayerRef.getComponent(%s) called async with player in world" , componentType.getTypeClass().getSimpleName());
return (T)(CompletableFuture.supplyAsync(() -> this .getComponent(componentType), ((EntityStore)store.getExternalData()).getWorld()).join());
}
}
}
@Nonnull
public UUID getUuid () {
return this .uuid;
}
@Nonnull
public String getUsername () {
return this .username;
}
@Nonnull
public PacketHandler getPacketHandler () {
return this .packetHandler;
}
@Nonnull
public ChunkTracker getChunkTracker () {
return this .chunkTracker;
}
@Nonnull
public HiddenPlayersManager getHiddenPlayersManager () {
return this .hiddenPlayersManager;
}
@Nonnull
public String getLanguage () {
return this .language;
}
public void setLanguage (@Nonnull String language) {
this .language = language;
}
@Nonnull
public Transform getTransform () {
return this .transform;
}
@Nullable
public UUID getWorldUuid () {
return this .worldUuid;
}
@Nonnull
public Vector3f getHeadRotation () {
return this .headRotation;
}
public void updatePosition (@Nonnull World world, @Nonnull Transform transform, @Nonnull Vector3f headRotation) {
this .worldUuid = world.getWorldConfig().getUuid();
this .transform.assign(transform);
this .headRotation.assign(headRotation);
}
@Deprecated
public void replaceHolder (@Nonnull Holder<EntityStore> holder) {
if (holder == null ) {
throw new IllegalStateException ("Player is still in the world" );
} else {
this .holder = holder;
}
}
@Nonnull
public Component<EntityStore> clone () {
return this ;
}
@Nonnull
public MetricResults toMetricResults () {
return METRICS_REGISTRY.toMetricResults(this );
}
public void referToServer (@Nonnull String host, int port) {
this .referToServer(host, port, (byte [])null );
}
public void referToServer (@Nonnull String host, int port, @Nullable byte [] data) {
int MAX_REFERRAL_DATA_SIZE = 4096 ;
Objects.requireNonNull(host, "Host cannot be null" );
if (port > 0 && port <= 65535 ) {
if (data != null && data.length > 4096 ) {
throw new IllegalArgumentException ("Referral data exceeds maximum size of 4096 bytes (got " + data.length + ")" );
} else {
HytaleLogger.getLogger().at(Level.INFO).log("Referring player %s (%s) to %s:%d with %d bytes of data" , this .username, this .uuid, host, port, data != null ? data.length : 0 );
this .packetHandler.writeNoCache(new ClientReferral (new HostAddress (host, (short )port), data));
}
} else {
throw new IllegalArgumentException ("Port must be between 1 and 65535" );
}
}
public void sendMessage (@Nonnull Message message) {
this .packetHandler.writeNoCache(new ServerMessage (ChatType.Chat, message.getFormattedMessage()));
}
static {
METRICS_REGISTRY = (new MetricsRegistry ()).register("Username" , PlayerRef::getUsername, Codec.STRING).register("Language" , PlayerRef::getLanguage, Codec.STRING).register("QueuedPacketsCount" , (ref) -> ref.getPacketHandler().getQueuedPacketsCount(), Codec.INTEGER).register("PingInfo" , (ref) -> {
PacketHandler handler = ref.getPacketHandler();
PongType[] pongTypes = PongType.values();
PacketHandler.PingInfo[] pingInfos = new PacketHandler .PingInfo[pongTypes.length];
for (int i = 0 ; i < pongTypes.length; ++i) {
pingInfos[i] = handler.getPingInfo(pongTypes[i]);
}
return pingInfos;
}, new ArrayCodec (PacketHandler.PingInfo.METRICS_REGISTRY, (x$0 ) -> new PacketHandler .PingInfo[x$0 ])).register("PacketStatsRecorder" , (ref) -> {
PacketStatsRecorder recorder = ref.getPacketHandler().getPacketStatsRecorder();
PacketStatsRecorderImpl var10000;
if (recorder instanceof PacketStatsRecorderImpl impl) {
var10000 = impl;
} else {
var10000 = null ;
}
return var10000;
}, PacketStatsRecorderImpl.METRICS_REGISTRY).register("ChunkTracker" , PlayerRef::getChunkTracker, ChunkTracker.METRICS_REGISTRY);
COMPONENT_METRICS_REGISTRY = (new MetricsRegistry ()).register("MovementStates" , (ref) -> {
Ref<EntityStore> entityRef = ref.getReference();
if (entityRef == null ) {
return null ;
} else {
MovementStatesComponent component = (MovementStatesComponent)entityRef.getStore().getComponent(entityRef, MovementStatesComponent.getComponentType());
return component != null ? component.getMovementStates().toString() : null ;
}
}, Codec.STRING).register("MovementManager" , (ref) -> {
Ref<EntityStore> entityRef = ref.getReference();
if (entityRef == null ) {
return null ;
} else {
MovementManager component = (MovementManager)entityRef.getStore().getComponent(entityRef, MovementManager.getComponentType());
return component != null ? component.toString() : null ;
}
}, Codec.STRING).register("CameraManager" , (ref) -> {
Ref<EntityStore> entityRef = ref.getReference();
if (entityRef == null ) {
return null ;
} else {
CameraManager component = (CameraManager)entityRef.getStore().getComponent(entityRef, CameraManager.getComponentType());
return component != null ? component.toString() : null ;
}
}, Codec.STRING);
LOGGER = HytaleLogger.forEnclosingClass();
}
}
com/hypixel/hytale/server/core/universe/Universe.java
package com.hypixel.hytale.server.core.universe;
import com.hypixel.hytale.assetstore.AssetRegistry;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.codec.lookup.Priority;
import com.hypixel.hytale.common.plugin.PluginIdentifier;
import com.hypixel.hytale.common.plugin.PluginManifest;
import com.hypixel.hytale.common.semver.SemverRange;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.component.ComponentRegistryProxy;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.event.EventRegistry;
import com.hypixel.hytale.event.IEventDispatcher;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.metrics.MetricProvider;
import com.hypixel.hytale.metrics.MetricResults;
import com.hypixel.hytale.metrics.MetricsRegistry;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.protocol.PlayerSkin;
import com.hypixel.hytale.protocol.packets.setup.ServerTags;
import com.hypixel.hytale.server.core.Constants;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.HytaleServerConfig;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.NameMatching;
com.hypixel.hytale.server.core.Options;
com.hypixel.hytale.server.core.auth.PlayerAuthentication;
com.hypixel.hytale.server.core.command.system.CommandRegistry;
com.hypixel.hytale.server.core.cosmetics.CosmeticsModule;
com.hypixel.hytale.server.core.entity.UUIDComponent;
com.hypixel.hytale.server.core.entity.entities.Player;
com.hypixel.hytale.server.core.entity.entities.player.data.PlayerConfigData;
com.hypixel.hytale.server.core.event.events.PrepareUniverseEvent;
com.hypixel.hytale.server.core.event.events.ShutdownEvent;
com.hypixel.hytale.server.core.event.events.player.PlayerConnectEvent;
com.hypixel.hytale.server.core.event.events.player.PlayerDisconnectEvent;
com.hypixel.hytale.server.core.io.PacketHandler;
com.hypixel.hytale.server.core.io.ProtocolVersion;
com.hypixel.hytale.server.core.io.handlers.game.GamePacketHandler;
com.hypixel.hytale.server.core.io.netty.NettyUtil;
com.hypixel.hytale.server.core.modules.entity.component.ModelComponent;
com.hypixel.hytale.server.core.modules.entity.component.MovementAudioComponent;
com.hypixel.hytale.server.core.modules.entity.component.PositionDataComponent;
com.hypixel.hytale.server.core.modules.entity.player.ChunkTracker;
com.hypixel.hytale.server.core.modules.entity.player.PlayerConnectionFlushSystem;
com.hypixel.hytale.server.core.modules.entity.player.PlayerPingSystem;
com.hypixel.hytale.server.core.modules.entity.player.PlayerSkinComponent;
com.hypixel.hytale.server.core.modules.entity.tracker.EntityTrackerSystems;
com.hypixel.hytale.server.core.modules.singleplayer.SingleplayerModule;
com.hypixel.hytale.server.core.plugin.JavaPlugin;
com.hypixel.hytale.server.core.plugin.JavaPluginInit;
com.hypixel.hytale.server.core.plugin.PluginManager;
com.hypixel.hytale.server.core.receiver.IMessageReceiver;
com.hypixel.hytale.server.core.universe.playerdata.PlayerStorage;
com.hypixel.hytale.server.core.universe.system.PlayerRefAddedSystem;
com.hypixel.hytale.server.core.universe.system.WorldConfigSaveSystem;
com.hypixel.hytale.server.core.universe.world.World;
com.hypixel.hytale.server.core.universe.world.WorldConfig;
com.hypixel.hytale.server.core.universe.world.WorldConfigProvider;
com.hypixel.hytale.server.core.universe.world.commands.SetTickingCommand;
com.hypixel.hytale.server.core.universe.world.commands.block.BlockCommand;
com.hypixel.hytale.server.core.universe.world.commands.block.BlockSelectCommand;
com.hypixel.hytale.server.core.universe.world.commands.world.WorldCommand;
com.hypixel.hytale.server.core.universe.world.events.AddWorldEvent;
com.hypixel.hytale.server.core.universe.world.events.AllWorldsLoadedEvent;
com.hypixel.hytale.server.core.universe.world.events.RemoveWorldEvent;
com.hypixel.hytale.server.core.universe.world.spawn.FitToHeightMapSpawnProvider;
com.hypixel.hytale.server.core.universe.world.spawn.GlobalSpawnProvider;
com.hypixel.hytale.server.core.universe.world.spawn.ISpawnProvider;
com.hypixel.hytale.server.core.universe.world.spawn.IndividualSpawnProvider;
com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
com.hypixel.hytale.server.core.universe.world.storage.component.ChunkSavingSystems;
com.hypixel.hytale.server.core.universe.world.storage.provider.DefaultChunkStorageProvider;
com.hypixel.hytale.server.core.universe.world.storage.provider.EmptyChunkStorageProvider;
com.hypixel.hytale.server.core.universe.world.storage.provider.IChunkStorageProvider;
com.hypixel.hytale.server.core.universe.world.storage.provider.IndexedStorageChunkStorageProvider;
com.hypixel.hytale.server.core.universe.world.storage.provider.MigrationChunkStorageProvider;
com.hypixel.hytale.server.core.universe.world.storage.resources.DefaultResourceStorageProvider;
com.hypixel.hytale.server.core.universe.world.storage.resources.DiskResourceStorageProvider;
com.hypixel.hytale.server.core.universe.world.storage.resources.EmptyResourceStorageProvider;
com.hypixel.hytale.server.core.universe.world.storage.resources.IResourceStorageProvider;
com.hypixel.hytale.server.core.universe.world.system.WorldPregenerateSystem;
com.hypixel.hytale.server.core.universe.world.worldgen.provider.DummyWorldGenProvider;
com.hypixel.hytale.server.core.universe.world.worldgen.provider.FlatWorldGenProvider;
com.hypixel.hytale.server.core.universe.world.worldgen.provider.IWorldGenProvider;
com.hypixel.hytale.server.core.universe.world.worldgen.provider.VoidWorldGenProvider;
com.hypixel.hytale.server.core.universe.world.worldmap.provider.DisabledWorldMapProvider;
com.hypixel.hytale.server.core.universe.world.worldmap.provider.IWorldMapProvider;
com.hypixel.hytale.server.core.universe.world.worldmap.provider.chunk.WorldGenWorldMapProvider;
com.hypixel.hytale.server.core.util.AssetUtil;
com.hypixel.hytale.server.core.util.BsonUtil;
com.hypixel.hytale.server.core.util.backup.BackupTask;
com.hypixel.hytale.server.core.util.io.FileUtil;
com.hypixel.hytale.sneakythrow.SneakyThrow;
com.hypixel.hytale.sneakythrow.supplier.ThrowableSupplier;
io.netty.channel.Channel;
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
it.unimi.dsi.fastutil.objects.ObjectArrayList;
java.io.IOException;
java.nio.file.DirectoryStream;
java.nio.file.Files;
java.nio.file.LinkOption;
java.nio.file.Path;
java.nio.file.StandardCopyOption;
java.util.Collections;
java.util.Comparator;
java.util.ConcurrentModificationException;
java.util.Iterator;
java.util.List;
java.util.Map;
java.util.Objects;
java.util.UUID;
java.util.concurrent.CompletableFuture;
java.util.concurrent.ConcurrentHashMap;
java.util.concurrent.TimeUnit;
java.util.function.BiPredicate;
java.util.logging.Level;
javax.annotation.CheckReturnValue;
javax.annotation.Nonnull;
javax.annotation.Nullable;
joptsimple.OptionSet;
org.bson.BsonArray;
org.bson.BsonDocument;
org.bson.BsonValue;
, MetricProvider {
PluginManifest.corePlugin(Universe.class).build();
Map<Integer, String> LEGACY_BLOCK_ID_MAP = Collections.emptyMap();
MetricsRegistry<Universe> METRICS_REGISTRY;
Universe instance;
ComponentType<EntityStore, PlayerRef> playerRefComponentType;
Path path;
Map<UUID, PlayerRef> players;
Map<String, World> worlds;
Map<UUID, World> worldsByUuid;
Map<String, World> unmodifiableWorlds;
PlayerStorage playerStorage;
WorldConfigProvider worldConfigProvider;
ResourceType<ChunkStore, IndexedStorageChunkStorageProvider.IndexedStorageCache> indexedStorageCacheResourceType;
CompletableFuture<Void> universeReady;
Universe {
instance;
}
{
(init);
.path = Constants.UNIVERSE_PATH;
.players = ();
.worlds = ();
.worldsByUuid = ();
.unmodifiableWorlds = Collections.unmodifiableMap( .worlds);
instance = ;
(!Files.isDirectory( .path, [ ]) && !Options.getOptionSet().has(Options.BARE)) {
{
Files.createDirectories( .path);
} (IOException e) {
( , e);
}
}
(Options.getOptionSet().has(Options.BACKUP)) {
Math.max((Integer)Options.getOptionSet().valueOf(Options.BACKUP_FREQUENCY_MINUTES), );
.getLogger().at(Level.INFO).log( , frequencyMinutes);
HytaleServer.SCHEDULED_EXECUTOR.scheduleWithFixedDelay(() -> {
{
.getLogger().at(Level.INFO).log( );
.runBackup().thenAccept((aVoid) -> .getLogger().at(Level.INFO).log( ));
} (Exception e) {
((HytaleLogger.Api) .getLogger().at(Level.SEVERE).withCause(e)).log( );
}
}, ( )frequencyMinutes, ( )frequencyMinutes, TimeUnit.MINUTES);
}
}
CompletableFuture<Void> {
CompletableFuture.allOf((CompletableFuture[]) .worlds.values().stream().map((world) -> CompletableFuture.supplyAsync(() -> {
Store<ChunkStore> componentStore = world.getChunkStore().getStore();
ChunkSavingSystems. (ChunkSavingSystems.Data)componentStore.getResource(ChunkStore.SAVE_RESOURCE);
data.isSaving = ;
data;
}, world).thenCompose(ChunkSavingSystems.Data::waitForSavingChunks)).toArray((x$ ) -> [x$ ])).thenCompose((aVoid) -> BackupTask.start( .path, (Path)Options.getOptionSet().valueOf(Options.BACKUP_DIRECTORY))).thenCompose((success) -> CompletableFuture.allOf((CompletableFuture[]) .worlds.values().stream().map((world) -> CompletableFuture.runAsync(() -> {
Store<ChunkStore> componentStore = world.getChunkStore().getStore();
ChunkSavingSystems. (ChunkSavingSystems.Data)componentStore.getResource(ChunkStore.SAVE_RESOURCE);
data.isSaving = ;
}, world)).toArray((x$ ) -> [x$ ])).thenApply((aVoid) -> success));
}
{
.getEventRegistry();
ComponentRegistryProxy<ChunkStore> chunkStoreRegistry = .getChunkStoreRegistry();
ComponentRegistryProxy<EntityStore> entityStoreRegistry = .getEntityStoreRegistry();
.getCommandRegistry();
eventRegistry.register(( )- , ShutdownEvent.class, (event) -> .disconnectAllPLayers());
eventRegistry.register(( )- , ShutdownEvent.class, (event) -> .shutdownAllWorlds());
ISpawnProvider.CODEC.register( , GlobalSpawnProvider.class, GlobalSpawnProvider.CODEC);
ISpawnProvider.CODEC.register( , IndividualSpawnProvider.class, IndividualSpawnProvider.CODEC);
ISpawnProvider.CODEC.register( , FitToHeightMapSpawnProvider.class, FitToHeightMapSpawnProvider.CODEC);
IWorldGenProvider.CODEC.register( , FlatWorldGenProvider.class, FlatWorldGenProvider.CODEC);
IWorldGenProvider.CODEC.register( , DummyWorldGenProvider.class, DummyWorldGenProvider.CODEC);
IWorldGenProvider.CODEC.register(Priority.DEFAULT, , VoidWorldGenProvider.class, VoidWorldGenProvider.CODEC);
IWorldMapProvider.CODEC.register( , DisabledWorldMapProvider.class, DisabledWorldMapProvider.CODEC);
IWorldMapProvider.CODEC.register(Priority.DEFAULT, , WorldGenWorldMapProvider.class, WorldGenWorldMapProvider.CODEC);
IChunkStorageProvider.CODEC.register(Priority.DEFAULT, , DefaultChunkStorageProvider.class, DefaultChunkStorageProvider.CODEC);
IChunkStorageProvider.CODEC.register( , MigrationChunkStorageProvider.class, MigrationChunkStorageProvider.CODEC);
IChunkStorageProvider.CODEC.register( , IndexedStorageChunkStorageProvider.class, IndexedStorageChunkStorageProvider.CODEC);
IChunkStorageProvider.CODEC.register( , EmptyChunkStorageProvider.class, EmptyChunkStorageProvider.CODEC);
IResourceStorageProvider.CODEC.register(Priority.DEFAULT, , DefaultResourceStorageProvider.class, DefaultResourceStorageProvider.CODEC);
IResourceStorageProvider.CODEC.register( , DiskResourceStorageProvider.class, DiskResourceStorageProvider.CODEC);
IResourceStorageProvider.CODEC.register( , EmptyResourceStorageProvider.class, EmptyResourceStorageProvider.CODEC);
.indexedStorageCacheResourceType = chunkStoreRegistry.registerResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.class, IndexedStorageChunkStorageProvider.IndexedStorageCache:: );
chunkStoreRegistry.registerSystem( .IndexedStorageCacheSetupSystem());
chunkStoreRegistry.registerSystem( ());
entityStoreRegistry.registerSystem( ());
.playerRefComponentType = entityStoreRegistry.registerComponent(PlayerRef.class, () -> {
();
});
entityStoreRegistry.registerSystem( ());
entityStoreRegistry.registerSystem( ( .playerRefComponentType));
entityStoreRegistry.registerSystem( ( .playerRefComponentType));
commandRegistry.registerCommand( ());
commandRegistry.registerCommand( ());
commandRegistry.registerCommand( ());
commandRegistry.registerCommand( ());
}
{
HytaleServer.get().getConfig();
(config == ) {
( );
} {
.playerStorage = config.getPlayerStorageProvider().getPlayerStorage();
WorldConfigProvider. .Default();
(PrepareUniverseEvent)HytaleServer.get().getEventBus().dispatchFor(PrepareUniverseEvent.class).dispatch( (defaultConfigProvider));
event.getWorldConfigProvider();
(worldConfigProvider == ) {
worldConfigProvider = defaultConfigProvider;
}
.worldConfigProvider = worldConfigProvider;
{
.path.resolve( );
.path.resolve( );
(Files.isRegularFile(blockIdMapPath, [ ])) {
Files.move(blockIdMapPath, path, StandardCopyOption.REPLACE_EXISTING);
}
Files.deleteIfExists( .path.resolve( ));
(Files.isRegularFile(path, [ ])) {
Map<Integer, String> map = ();
(BsonValue bsonValue : (BsonArray)BsonUtil.readDocument(path).thenApply((document) -> document.getArray( )).join()) {
bsonValue.asDocument();
map.put(bsonDocument.getNumber( ).intValue(), bsonDocument.getString( ).getValue());
}
LEGACY_BLOCK_ID_MAP = Collections.unmodifiableMap(map);
}
} (IOException e) {
((HytaleLogger.Api) .getLogger().at(Level.SEVERE).withCause(e)).log( );
}
(Options.getOptionSet().has(Options.BARE)) {
.universeReady = CompletableFuture.completedFuture((Object) );
HytaleServer.get().getEventBus().dispatch(AllWorldsLoadedEvent.class);
} {
ObjectArrayList<CompletableFuture<?>> loadingWorlds = <CompletableFuture<?>>();
{
.path.resolve( );
Files.createDirectories(worldsPath);
DirectoryStream<Path> stream = Files.newDirectoryStream(worldsPath);
label101: {
{
(Path file : stream) {
(HytaleServer.get().isShuttingDown()) {
label101;
}
(!file.equals(worldsPath) && Files.isDirectory(file, [ ])) {
file.getFileName().toString();
( .getWorld(name) == ) {
loadingWorlds.add( .loadWorldFromStart(file, name).exceptionally((throwable) -> {
((HytaleLogger.Api) .getLogger().at(Level.SEVERE).withCause(throwable)).log( , name);
;
}));
} {
.getLogger().at(Level.SEVERE).log( , name);
}
}
}
} (Throwable var12) {
(stream != ) {
{
stream.close();
} (Throwable var11) {
var12.addSuppressed(var11);
}
}
var12;
}
(stream != ) {
stream.close();
}
.universeReady = CompletableFutureUtil.<Void>_catch(CompletableFuture.allOf((CompletableFuture[])loadingWorlds.toArray((x$ ) -> [x$ ])).thenCompose((v) -> {
config.getDefaults().getWorld();
worldName != && ! .worlds.containsKey(worldName.toLowerCase()) ? CompletableFutureUtil._catch( .addWorld(worldName)) : CompletableFuture.completedFuture((Object) );
}).thenRun(() -> HytaleServer.get().getEventBus().dispatch(AllWorldsLoadedEvent.class)));
;
}
(stream != ) {
stream.close();
}
} (IOException e) {
( , e);
}
}
}
}
{
.disconnectAllPLayers();
.shutdownAllWorlds();
}
{
.players.values().forEach((player) -> player.getPacketHandler().disconnect( ));
}
{
Iterator<World> iterator = .worlds.values().iterator();
(iterator.hasNext()) {
(World)iterator.next();
world.stop();
iterator.remove();
}
}
MetricResults {
METRICS_REGISTRY.toMetricResults( );
}
CompletableFuture<Void> {
.universeReady;
}
ResourceType<ChunkStore, IndexedStorageChunkStorageProvider.IndexedStorageCache> getIndexedStorageCacheResourceType() {
.indexedStorageCacheResourceType;
}
{
.path.resolve( ).resolve(name);
Files.isDirectory(savePath, [ ]) && (Files.exists(savePath.resolve( ), [ ]) || Files.exists(savePath.resolve( ), [ ]));
}
CompletableFuture<World> {
.addWorld(name, (String) , (String) );
}
CompletableFuture<World> {
( .worlds.containsKey(name)) {
( + name + );
} ( .isWorldLoadable(name)) {
( + name + );
} {
.path.resolve( ).resolve(name);
.worldConfigProvider.load(savePath, name).thenCompose((worldConfig) -> {
(generatorType != && ! .equals(generatorType)) {
BuilderCodec<? > providerCodec = (BuilderCodec)IWorldGenProvider.CODEC.getCodecFor(generatorType);
(providerCodec == ) {
( + generatorType + );
}
providerCodec.getDefaultValue();
worldConfig.setWorldGenProvider(provider);
worldConfig.markChanged();
}
(chunkStorageType != && ! .equals(chunkStorageType)) {
BuilderCodec<? > providerCodec = (BuilderCodec)IChunkStorageProvider.CODEC.getCodecFor(chunkStorageType);
(providerCodec == ) {
( + chunkStorageType + );
}
providerCodec.getDefaultValue();
worldConfig.setChunkStorageProvider(provider);
worldConfig.markChanged();
}
.makeWorld(name, savePath, worldConfig);
});
}
}
CompletableFuture<World> {
.makeWorld(name, savePath, worldConfig, );
}
CompletableFuture<World> {
Map<PluginIdentifier, SemverRange> map = worldConfig.getRequiredPlugins();
(map != ) {
PluginManager.get();
(Map.Entry<PluginIdentifier, SemverRange> entry : map.entrySet()) {
(!pluginManager.hasPlugin((PluginIdentifier)entry.getKey(), (SemverRange)entry.getValue())) {
.getLogger().at(Level.SEVERE).log( , entry.getKey(), entry.getValue());
( );
}
}
}
( .worlds.containsKey(name)) {
( + name + );
} {
CompletableFuture.supplyAsync(SneakyThrow.sneakySupplier((ThrowableSupplier)(() -> {
(name, savePath, worldConfig);
(AddWorldEvent)HytaleServer.get().getEventBus().dispatchFor(AddWorldEvent.class, name).dispatch( (world));
(!event.isCancelled() && !HytaleServer.get().isShuttingDown()) {
(World) .worlds.putIfAbsent(name.toLowerCase(), world);
(oldWorldByName != ) {
( + name + );
} {
(World) .worldsByUuid.putIfAbsent(worldConfig.getUuid(), world);
(oldWorldByUuid != ) {
( + String.valueOf(worldConfig.getUuid()) + );
} {
world;
}
}
} {
();
}
}))).thenCompose(World::init).thenCompose((world) -> !Options.getOptionSet().has(Options.MIGRATIONS) && start ? world.start().thenApply((v) -> world) : CompletableFuture.completedFuture(world)).whenComplete((world, throwable) -> {
(throwable != ) {
name.toLowerCase();
( .worlds.containsKey(nameLower)) {
{
.removeWorldExceptionally(name);
} (Exception e) {
((HytaleLogger.Api) .getLogger().at(Level.WARNING).withCause(e)).log( , name);
}
}
}
});
}
}
CompletableFuture<Void> {
.worldConfigProvider.load(savePath, name).thenCompose((worldConfig) -> worldConfig.isDeleteOnUniverseStart() ? CompletableFuture.runAsync(() -> {
{
FileUtil.deleteDirectory(savePath);
.getLogger().at(Level.INFO).log( + name + + String.valueOf(savePath));
} (Throwable t) {
( , t);
}
}) : .makeWorld(name, savePath, worldConfig).thenApply((x) -> ));
}
CompletableFuture<World> {
( .worlds.containsKey(name)) {
( + name + );
} {
.path.resolve( ).resolve(name);
(!Files.isDirectory(savePath, [ ])) {
( + name + );
} {
.worldConfigProvider.load(savePath, name).thenCompose((worldConfig) -> .makeWorld(name, savePath, worldConfig));
}
}
}
World {
worldName == ? : (World) .worlds.get(worldName.toLowerCase());
}
World {
(World) .worldsByUuid.get(uuid);
}
World {
HytaleServer.get().getConfig();
(config == ) {
;
} {
config.getDefaults().getWorld();
worldName != ? .getWorld(worldName) : ;
}
}
{
Objects.requireNonNull(name, );
name.toLowerCase();
(World) .worlds.get(nameLower);
(world == ) {
( + name + );
} {
(RemoveWorldEvent)HytaleServer.get().getEventBus().dispatchFor(RemoveWorldEvent.class, name).dispatch( (world, RemoveWorldEvent.RemovalReason.GENERAL));
(event.isCancelled()) {
;
} {
.worlds.remove(nameLower);
.worldsByUuid.remove(world.getWorldConfig().getUuid());
(world.isAlive()) {
world.stopIndividualWorld();
}
world.validateDeleteOnRemove();
;
}
}
}
{
Objects.requireNonNull(name, );
.getLogger().at(Level.INFO).log( , name);
name.toLowerCase();
(World) .worlds.get(nameLower);
(world == ) {
( + name + );
} {
HytaleServer.get().getEventBus().dispatchFor(RemoveWorldEvent.class, name).dispatch( (world, RemoveWorldEvent.RemovalReason.EXCEPTIONAL));
.worlds.remove(nameLower);
.worldsByUuid.remove(world.getWorldConfig().getUuid());
(world.isAlive()) {
world.stopIndividualWorld();
}
world.validateDeleteOnRemove();
}
}
Path {
.path;
}
Map<String, World> {
.unmodifiableWorlds;
}
List<PlayerRef> {
<PlayerRef>( .players.values());
}
PlayerRef {
(PlayerRef) .players.get(uuid);
}
PlayerRef {
(PlayerRef)matching.find( .players.values(), value, (v) -> ((PlayerRef)v.getComponent(PlayerRef.getComponentType())).getUsername());
}
PlayerRef {
(PlayerRef)NameMatching.find( .players.values(), value, (v) -> ((PlayerRef)v.getComponent(PlayerRef.getComponentType())).getUsername(), comparator, equality);
}
PlayerRef {
(PlayerRef)matching.find( .players.values(), value, PlayerRef::getUsername);
}
PlayerRef {
(PlayerRef)NameMatching.find( .players.values(), value, PlayerRef::getUsername, comparator, equality);
}
{
.players.size();
}
CompletableFuture<PlayerRef> {
(channel, protocolVersion, auth);
playerConnection.setQueuePackets( );
.getLogger().at(Level.INFO).log( , username, uuid);
.playerStorage.load(uuid).exceptionally((throwable) -> {
( , throwable);
}).thenCompose((holder) -> {
();
(holder, uuid, username, language, playerConnection, chunkTrackerComponent);
chunkTrackerComponent.setDefaultMaxChunksPerSecond(playerRefComponent);
holder.putComponent(PlayerRef.getComponentType(), playerRefComponent);
holder.putComponent(ChunkTracker.getComponentType(), chunkTrackerComponent);
holder.putComponent(UUIDComponent.getComponentType(), (uuid));
holder.ensureComponent(PositionDataComponent.getComponentType());
holder.ensureComponent(MovementAudioComponent.getComponentType());
(Player)holder.ensureAndGetComponent(Player.getComponentType());
playerComponent.init(uuid, playerRefComponent);
playerComponent.getPlayerConfigData();
playerConfig.cleanup( );
PacketHandler.logConnectionTimings(channel, , Level.FINEST);
(skin != ) {
holder.putComponent(PlayerSkinComponent.getComponentType(), (skin));
holder.putComponent(ModelComponent.getComponentType(), (CosmeticsModule.get().createModel(skin)));
}
playerConnection.setPlayerRef(playerRefComponent, playerComponent);
NettyUtil.setChannelHandler(channel, playerConnection);
playerComponent.setClientViewRadius(clientViewRadiusChunks);
EntityTrackerSystems. (EntityTrackerSystems.EntityViewer)holder.getComponent(EntityTrackerSystems.EntityViewer.getComponentType());
(entityViewerComponent != ) {
entityViewerComponent.viewRadiusBlocks = playerComponent.getViewRadius() * ;
} {
entityViewerComponent = .EntityViewer(playerComponent.getViewRadius() * , playerConnection);
holder.addComponent(EntityTrackerSystems.EntityViewer.getComponentType(), entityViewerComponent);
}
(PlayerRef) .players.putIfAbsent(uuid, playerRefComponent);
(existingPlayer != ) {
.getLogger().at(Level.WARNING).log( , username, uuid);
playerConnection.disconnect( );
CompletableFuture.completedFuture((Object) );
} {
playerConfig.getWorld();
.getWorld(lastWorldName);
(PlayerConnectEvent)HytaleServer.get().getEventBus().dispatchFor(PlayerConnectEvent.class).dispatch( (holder, playerRefComponent, lastWorld != ? lastWorld : .getDefaultWorld()));
event.getWorld() != ? event.getWorld() : .getDefaultWorld();
(world == ) {
.players.remove(uuid, playerRefComponent);
playerConnection.disconnect( );
.getLogger().at(Level.SEVERE).log( , username, uuid);
CompletableFuture.completedFuture((Object) );
} {
(lastWorldName != && lastWorld == ) {
playerComponent.sendMessage(Message.translation( ).param( , lastWorldName).param( , world.getName()));
}
PacketHandler.logConnectionTimings(channel, , Level.FINEST);
playerRefComponent.getPacketHandler().write((Packet)( (AssetRegistry.getClientTags())));
world.addPlayer(playerRefComponent, (Transform) , , ).thenApply((p) -> {
PacketHandler.logConnectionTimings(channel, , Level.FINEST);
(!channel.isActive()) {
(p != ) {
playerComponent.remove();
}
.players.remove(uuid, playerRefComponent);
.getLogger().at(Level.WARNING).log( , username, uuid);
;
} (playerComponent.wasRemoved()) {
.players.remove(uuid, playerRefComponent);
;
} {
p;
}
}).exceptionally((throwable) -> {
.players.remove(uuid, playerRefComponent);
playerComponent.remove();
( , throwable);
});
}
}
});
}
{
HytaleLogger. .getLogger().at(Level.INFO);
playerRef.getUsername();
var10000.log( + var10001 + + String.valueOf(playerRef.getUuid()) + );
IEventDispatcher<PlayerDisconnectEvent, PlayerDisconnectEvent> eventDispatcher = HytaleServer.get().getEventBus().dispatchFor(PlayerDisconnectEvent.class);
(eventDispatcher.hasListener()) {
eventDispatcher.dispatch( (playerRef));
}
Ref<EntityStore> ref = playerRef.getReference();
(ref == ) {
.finalizePlayerRemoval(playerRef);
} {
((EntityStore)ref.getStore().getExternalData()).getWorld();
(world.isInThread()) {
(Player)ref.getStore().getComponent(ref, Player.getComponentType());
(playerComponent != ) {
playerComponent.remove();
}
.finalizePlayerRemoval(playerRef);
} {
CompletableFuture<Void> removedFuture = ();
CompletableFuture.runAsync(() -> {
(Player)ref.getStore().getComponent(ref, Player.getComponentType());
(playerComponent != ) {
playerComponent.remove();
}
}, world).whenComplete((unused, throwable) -> {
(throwable != ) {
removedFuture.completeExceptionally(throwable);
} {
removedFuture.complete(unused);
}
});
removedFuture.orTimeout( , TimeUnit.SECONDS).whenComplete((result, error) -> {
(error != ) {
((HytaleLogger.Api) .getLogger().at(Level.WARNING).withCause(error)).log( , playerRef.getUsername());
}
.finalizePlayerRemoval(playerRef);
});
}
}
}
{
.players.remove(playerRef.getUuid());
(Constants.SINGLEPLAYER) {
( .players.isEmpty()) {
.getLogger().at(Level.INFO).log( );
HytaleServer.get().shutdownServer();
} (SingleplayerModule.isOwner(playerRef)) {
.getLogger().at(Level.INFO).log( );
.getPlayers().forEach((p) -> p.getPacketHandler().disconnect(playerRef.getUsername() + ));
HytaleServer.get().shutdownServer();
}
}
}
CompletableFuture<PlayerRef> {
.playerStorage.load(oldPlayer.getUuid()).exceptionally((throwable) -> {
( , throwable);
}).thenCompose((holder) -> .resetPlayer(oldPlayer, holder));
}
CompletableFuture<PlayerRef> {
.resetPlayer(oldPlayer, holder, (World) , (Transform) );
}
CompletableFuture<PlayerRef> {
playerRef.getUuid();
(Player)playerRef.getComponent(Player.getComponentType());
World targetWorld;
(world == ) {
targetWorld = oldPlayer.getWorld();
} {
targetWorld = world;
}
.getLogger().at(Level.INFO).log( , playerRef.getUsername(), world != ? world.getName() : , transform, playerRef.getUuid());
(GamePacketHandler)playerRef.getPacketHandler();
(Player)holder.ensureAndGetComponent(Player.getComponentType());
newPlayer.init(uuid, playerRef);
CompletableFuture<Void> leaveWorld = ();
(oldPlayer.getWorld() != ) {
oldPlayer.getWorld().execute(() -> {
playerRef.removeFromStore();
leaveWorld.complete((Object) );
});
} {
leaveWorld.complete((Object) );
}
leaveWorld.thenAccept((v) -> {
oldPlayer.resetManagers(holder);
newPlayer.copyFrom(oldPlayer);
EntityTrackerSystems. (EntityTrackerSystems.EntityViewer)holder.getComponent(EntityTrackerSystems.EntityViewer.getComponentType());
(viewer != ) {
viewer.viewRadiusBlocks = newPlayer.getViewRadius() * ;
} {
viewer = .EntityViewer(newPlayer.getViewRadius() * , playerConnection);
holder.addComponent(EntityTrackerSystems.EntityViewer.getComponentType(), viewer);
}
playerConnection.setPlayerRef(playerRef, newPlayer);
playerRef.replaceHolder(holder);
holder.putComponent(PlayerRef.getComponentType(), playerRef);
}).thenCompose((v) -> targetWorld.addPlayer(playerRef, transform));
}
{
(PlayerRef ref : .players.values()) {
ref.sendMessage(message);
}
}
{
(PlayerRef player : .players.values()) {
player.getPacketHandler().write(packet);
}
}
{
(PlayerRef player : .players.values()) {
player.getPacketHandler().writeNoCache(packet);
}
}
{
(PlayerRef player : .players.values()) {
player.getPacketHandler().write(packets);
}
}
PlayerStorage {
.playerStorage;
}
{
.playerStorage = playerStorage;
}
WorldConfigProvider {
.worldConfigProvider;
}
ComponentType<EntityStore, PlayerRef> {
.playerRefComponentType;
}
Map<Integer, String> {
LEGACY_BLOCK_ID_MAP;
}
Path {
Options.getOptionSet();
Path worldGenPath;
(optionSet.has(Options.WORLD_GEN_DIRECTORY)) {
worldGenPath = (Path)optionSet.valueOf(Options.WORLD_GEN_DIRECTORY);
} {
worldGenPath = AssetUtil.getHytaleAssetsPath().resolve( ).resolve( );
}
worldGenPath;
}
{
METRICS_REGISTRY = ( ()).register( , (universe) -> (World[])universe.getWorlds().values().toArray((x$ ) -> [x$ ]), (World.METRICS_REGISTRY, (x$ ) -> [x$ ])).register( , Universe::getPlayerCount, Codec.INTEGER);
}
}
com/hypixel/hytale/server/core/universe/WorldLoadCancelledException.java
package com.hypixel.hytale.server.core.universe;
public class WorldLoadCancelledException extends RuntimeException {
public WorldLoadCancelledException () {
}
}
com/hypixel/hytale/server/core/universe/datastore/DataStore.java
package com.hypixel.hytale.server.core.universe.datastore;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface DataStore <T> {
BuilderCodec<T> getCodec () ;
@Nullable
T load (String var1) throws IOException;
void save (String var1, T var2) ;
void remove (String var1) throws IOException;
List<String> list () throws IOException;
@Nonnull
default Map<String, T> loadAll () throws IOException {
Map<String, T> map = new Object2ObjectOpenHashMap <String, T>();
for (String id : this .list()) {
T value = (T)this .load(id);
if (value != null ) {
map.put(id, value);
}
}
return map;
}
{
(Map.Entry<String, T> entry : objectsToSave.entrySet()) {
.save((String)entry.getKey(), entry.getValue());
}
}
IOException {
(String id : .list()) {
.remove(id);
}
}
}
com/hypixel/hytale/server/core/universe/datastore/DataStoreProvider.java
package com.hypixel.hytale.server.core.universe.datastore;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.lookup.BuilderCodecMapCodec;
public interface DataStoreProvider {
BuilderCodecMapCodec<DataStoreProvider> CODEC = new BuilderCodecMapCodec <DataStoreProvider>("Type" );
<T> DataStore<T> create (BuilderCodec<T> var1) ;
}
com/hypixel/hytale/server/core/universe/datastore/DiskDataStore.java
package com.hypixel.hytale.server.core.universe.datastore;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.util.RawJsonReader;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.util.BsonUtil;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonDocument;
public class DiskDataStore <T> implements DataStore <T> {
private static final String EXTENSION = ".json" ;
private static final int EXTENSION_LEN = ".json" .length();
private static final ;
;
;
HytaleLogger logger;
Path path;
BuilderCodec<T> codec;
{
.logger = HytaleLogger.get( + path);
.path = Universe.get().getPath().resolve(path);
.codec = codec;
(Files.isDirectory( .path, [ ])) {
{
DirectoryStream<Path> paths = Files.newDirectoryStream( .path, );
{
(Path oldPath : paths) {
getPathFromId( .path, getIdFromPath(oldPath));
{
Files.move(oldPath, newPath);
} (IOException var9) {
}
}
} (Throwable var10) {
(paths != ) {
{
paths.close();
} (Throwable var8) {
var10.addSuppressed(var8);
}
}
var10;
}
(paths != ) {
paths.close();
}
} (IOException e) {
((HytaleLogger.Api) .logger.at(Level.SEVERE).withCause(e)).log( );
}
}
}
Path {
.path;
}
BuilderCodec<T> {
.codec;
}
T IOException {
getPathFromId( .path, id);
(T)(Files.exists(filePath, [ ]) ? .load0(filePath) : );
}
{
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
.codec.encode(value, extraInfo);
extraInfo.getValidationResults().logOrThrowValidatorExceptions( .logger);
BsonUtil.writeDocument(getPathFromId( .path, id), bsonValue.asDocument()).join();
}
IOException {
Files.deleteIfExists(getPathFromId( .path, id));
Files.deleteIfExists(getBackupPathFromId( .path, id));
}
List<String> IOException {
List<String> list = <String>();
DirectoryStream<Path> paths = Files.newDirectoryStream( .path, );
{
(Path path : paths) {
list.add(getIdFromPath(path));
}
} (Throwable var6) {
(paths != ) {
{
paths.close();
} (Throwable var5) {
var6.addSuppressed(var5);
}
}
var6;
}
(paths != ) {
paths.close();
}
list;
}
Map<String, T> IOException {
Map<String, T> map = <String, T>();
DirectoryStream<Path> paths = Files.newDirectoryStream( .path, );
{
(Path path : paths) {
map.put(getIdFromPath(path), .load0(path));
}
} (Throwable var6) {
(paths != ) {
{
paths.close();
} (Throwable var5) {
var6.addSuppressed(var5);
}
}
var6;
}
(paths != ) {
paths.close();
}
map;
}
IOException {
DirectoryStream<Path> paths = Files.newDirectoryStream( .path, );
{
(Path path : paths) {
Files.delete(path);
}
} (Throwable var5) {
(paths != ) {
{
paths.close();
} (Throwable var4) {
var5.addSuppressed(var4);
}
}
var5;
}
(paths != ) {
paths.close();
}
}
T IOException {
(T)RawJsonReader.readSync(path, .codec, .logger);
}
Path {
path.resolve(id + );
}
Path {
path.resolve(id + );
}
String {
path.getFileName().toString();
fileName.substring( , fileName.length() - EXTENSION_LEN);
}
}
com/hypixel/hytale/server/core/universe/datastore/DiskDataStoreProvider.java
package com.hypixel.hytale.server.core.universe.datastore;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.validation.Validators;
import javax.annotation.Nonnull;
public class DiskDataStoreProvider implements DataStoreProvider {
public static final String ID = "Disk" ;
public static final BuilderCodec<DiskDataStoreProvider> CODEC;
private String path;
public DiskDataStoreProvider (String path) {
this .path = path;
}
protected DiskDataStoreProvider () {
}
@Nonnull
public <T> DataStore<T> create (BuilderCodec<T> builderCodec) {
return new DiskDataStore <T>(this .path, builderCodec);
}
@Nonnull
public String toString () {
return "DiskDataStoreProvider{path='" + this .path + ;
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(DiskDataStoreProvider.class, DiskDataStoreProvider:: ).append( ( , Codec.STRING), (diskDataStoreProvider, s) -> diskDataStoreProvider.path = s, (diskDataStoreProvider) -> diskDataStoreProvider.path).addValidator(Validators.nonNull()).add()).build();
}
}
com/hypixel/hytale/server/core/universe/playerdata/DefaultPlayerStorageProvider.java
package com.hypixel.hytale.server.core.universe.playerdata;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import javax.annotation.Nonnull;
public class DefaultPlayerStorageProvider implements PlayerStorageProvider {
public static final DefaultPlayerStorageProvider INSTANCE = new DefaultPlayerStorageProvider ();
public static final String ID = "Hytale" ;
public static final BuilderCodec<DefaultPlayerStorageProvider> CODEC = BuilderCodec.builder(DefaultPlayerStorageProvider.class, () -> INSTANCE).build();
public static final DiskPlayerStorageProvider DEFAULT = new DiskPlayerStorageProvider ();
public DefaultPlayerStorageProvider () {
}
@Nonnull
public PlayerStorage getPlayerStorage () {
return DEFAULT.getPlayerStorage();
}
@Nonnull
public String toString {
;
}
}
com/hypixel/hytale/server/core/universe/playerdata/DiskPlayerStorageProvider.java
package com.hypixel.hytale.server.core.universe.playerdata;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.common.util.PathUtil;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.server.core.Constants;
import com.hypixel.hytale.server.core.Options;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.server.core.util.BsonUtil;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import org.bson.BsonDocument;
public class DiskPlayerStorageProvider implements PlayerStorageProvider {
public static final String ID = "Disk" ;
public static final BuilderCodec<DiskPlayerStorageProvider> CODEC;
@Nonnull
private Path path;
public DiskPlayerStorageProvider {
.path = Constants.UNIVERSE_PATH.resolve( );
}
Path {
.path;
}
PlayerStorage {
( .path);
}
String {
+ String.valueOf( .path) + ;
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(DiskPlayerStorageProvider.class, DiskPlayerStorageProvider:: ).append( ( , Codec.STRING), (o, s) -> o.path = PathUtil.get(s), (o) -> o.path.toString()).add()).build();
}
{
;
Path path;
{
.path = path;
(!Options.getOptionSet().has(Options.BARE)) {
{
Files.createDirectories(path);
} (IOException e) {
( , e);
}
}
}
CompletableFuture<Holder<EntityStore>> {
.path.resolve(String.valueOf(uuid) + );
BsonUtil.readDocument(file).thenApply((bsonDocument) -> {
(bsonDocument == ) {
bsonDocument = ();
}
EntityStore.REGISTRY.deserialize(bsonDocument);
});
}
CompletableFuture<Void> {
.path.resolve(String.valueOf(uuid) + );
EntityStore.REGISTRY.serialize(holder);
BsonUtil.writeDocument(file, document);
}
CompletableFuture<Void> {
.path.resolve(String.valueOf(uuid) + );
{
Files.deleteIfExists(file);
CompletableFuture.completedFuture((Object) );
} (IOException e) {
CompletableFuture.failedFuture(e);
}
}
Set<UUID> IOException {
Stream<Path> stream = Files.list( .path);
Set var2;
{
var2 = (Set)stream.map((p) -> {
p.getFileName().toString();
(!fileName.endsWith( )) {
;
} {
{
UUID.fromString(fileName.substring( , fileName.length() - .length()));
} (IllegalArgumentException var3) {
;
}
}
}).filter(Objects::nonNull).collect(Collectors.toSet());
} (Throwable var5) {
(stream != ) {
{
stream.close();
} (Throwable var4) {
var5.addSuppressed(var4);
}
}
var5;
}
(stream != ) {
stream.close();
}
var2;
}
}
}
com/hypixel/hytale/server/core/universe/playerdata/PlayerStorage.java
package com.hypixel.hytale.server.core.universe.playerdata;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.io.IOException;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public interface PlayerStorage {
@Nonnull
CompletableFuture<Holder<EntityStore>> load (@Nonnull UUID var1) ;
@Nonnull
CompletableFuture<Void> save (@Nonnull UUID var1, @Nonnull Holder<EntityStore> var2) ;
@Nonnull
CompletableFuture<Void> remove (@Nonnull UUID var1) ;
@Nonnull
Set<UUID> getPlayers () throws IOException;
}
com/hypixel/hytale/server/core/universe/playerdata/PlayerStorageProvider.java
package com.hypixel.hytale.server.core.universe.playerdata;
import com.hypixel.hytale.codec.lookup.BuilderCodecMapCodec;
public interface PlayerStorageProvider {
BuilderCodecMapCodec<PlayerStorageProvider> CODEC = new BuilderCodecMapCodec <PlayerStorageProvider>("Type" , true );
PlayerStorage getPlayerStorage () ;
}
com/hypixel/hytale/server/core/universe/system/PlayerRefAddedSystem.java
package com.hypixel.hytale.server.core.universe.system;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.dependency.RootDependency;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.RefSystem;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.Set;
import javax.annotation.Nonnull;
public class PlayerRefAddedSystem extends RefSystem <EntityStore> {
@Nonnull
private final ComponentType<EntityStore, PlayerRef> playerRefComponentType;
public PlayerRefAddedSystem (@Nonnull ComponentType<EntityStore, PlayerRef> playerRefComponentType) {
this .playerRefComponentType = playerRefComponentType;
}
@Nonnull
public Set<Dependency<EntityStore>> getDependencies () {
return RootDependency.firstSet();
}
public Query<EntityStore> getQuery () {
.playerRefComponentType;
}
{
(PlayerRef)store.getComponent(ref, .playerRefComponentType);
playerRefComponent != ;
playerRefComponent.addedToStore(ref);
((EntityStore)store.getExternalData()).getWorld().trackPlayerRef(playerRefComponent);
}
{
(PlayerRef)store.getComponent(ref, .playerRefComponentType);
playerRefComponent != ;
((EntityStore)store.getExternalData()).getWorld().untrackPlayerRef(playerRefComponent);
}
}
com/hypixel/hytale/server/core/universe/system/PlayerVelocityInstructionSystem.java
package com.hypixel.hytale.server.core.universe.system;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.dependency.Order;
import com.hypixel.hytale.component.dependency.SystemDependency;
import com.hypixel.hytale.component.dependency.SystemTypeDependency;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.protocol.ChangeVelocityType;
import com.hypixel.hytale.protocol.packets.entities.ChangeVelocity;
import com.hypixel.hytale.server.core.modules.debug.DebugUtils;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.modules.physics.component.Velocity;
import com.hypixel.hytale.server.core.modules.physics.systems.GenericVelocityInstructionSystem;
import com.hypixel.hytale.server.core.modules.splitvelocity.VelocityConfig;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.Set;
import javax.annotation.Nonnull;
public class PlayerVelocityInstructionSystem extends EntityTickingSystem <EntityStore> {
@Nonnull
Set<Dependency<EntityStore>> dependencies;
Query<EntityStore> query;
{
.dependencies = Set.of( (Order.BEFORE, GenericVelocityInstructionSystem.class), (Order.AFTER, EntityModule.get().getVelocityModifyingSystemType()));
.query = Query.<EntityStore>and(PlayerRef.getComponentType(), Velocity.getComponentType());
}
{
(PlayerRef)archetypeChunk.getComponent(index, PlayerRef.getComponentType());
playerRefComponent != ;
(Velocity)archetypeChunk.getComponent(index, Velocity.getComponentType());
velocityComponent != ;
(Velocity.Instruction instruction : velocityComponent.getInstructions()) {
(instruction.getType()) {
Set:
instruction.getVelocity();
instruction.getConfig();
playerRefComponent.getPacketHandler().writeNoCache( (( )velocity.x, ( )velocity.y, ( )velocity.z, ChangeVelocityType.Set, velocityConfig != ? velocityConfig.toPacket() : ));
(DebugUtils.DISPLAY_FORCES) {
(TransformComponent)archetypeChunk.getComponent(index, TransformComponent.getComponentType());
transformComponent != ;
((EntityStore)commandBuffer.getExternalData()).getWorld();
DebugUtils.addForce(world, transformComponent.getPosition(), velocity, velocityConfig);
}
;
Add:
instruction.getVelocity();
instruction.getConfig();
playerRefComponent.getPacketHandler().writeNoCache( (( )velocity.x, ( )velocity.y, ( )velocity.z, ChangeVelocityType.Add, velocityConfig != ? velocityConfig.toPacket() : ));
(DebugUtils.DISPLAY_FORCES) {
(TransformComponent)archetypeChunk.getComponent(index, TransformComponent.getComponentType());
transformComponent != ;
((EntityStore)commandBuffer.getExternalData()).getWorld();
DebugUtils.addForce(world, transformComponent.getPosition(), (velocity.x, velocity.y, velocity.z), velocityConfig);
}
}
}
velocityComponent.getInstructions().clear();
}
Set<Dependency<EntityStore>> {
.dependencies;
}
Query<EntityStore> {
.query;
}
}
com/hypixel/hytale/server/core/universe/system/WorldConfigSaveSystem.java
package com.hypixel.hytale.server.core.universe.system;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.system.DelayedSystem;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldConfig;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public class WorldConfigSaveSystem extends DelayedSystem <EntityStore> {
public WorldConfigSaveSystem () {
super (10.0F );
}
public void delayedTick (float dt, int systemIndex, @Nonnull Store<EntityStore> store) {
World world = ((EntityStore)store.getExternalData()).getWorld();
saveWorldConfigAndResources(world).join();
}
@Nonnull
public static CompletableFuture<Void> saveWorldConfigAndResources (@Nonnull World world) {
WorldConfig worldConfig = world.getWorldConfig();
return worldConfig.isSavingConfig() && worldConfig.consumeHasChanged() ? CompletableFuture.allOf(world.getChunkStore().getStore().saveAllResources(), world.getEntityStore().getStore().saveAllResources(), Universe.get().getWorldConfigProvider().save(world.getSavePath(), world.getWorldConfig(), world)) : CompletableFuture.allOf(world.getChunkStore().getStore().saveAllResources(), world.getEntityStore().getStore().saveAllResources());
}
}
com/hypixel/hytale/server/core/universe/world/ClientEffectWorldSettings.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.protocol.packets.world.UpdatePostFxSettings;
import com.hypixel.hytale.protocol.packets.world.UpdateSunSettings;
public class ClientEffectWorldSettings {
public static BuilderCodec<ClientEffectWorldSettings> CODEC;
private float sunHeightPercent = 100.0F ;
private float sunAngleRadians = 0.0F ;
private float bloomIntensity = 0.3F ;
private float bloomPower = 8.0F ;
private float sunIntensity = 0.25F ;
private float sunshaftIntensity = 0.3F ;
private float sunshaftScaleFactor = 4.0F ;
public ClientEffectWorldSettings {
}
{
.sunHeightPercent;
}
{
.sunHeightPercent = sunHeightPercent;
}
{
.sunAngleRadians;
}
{
.sunAngleRadians = sunAngleRadians;
}
{
.bloomIntensity;
}
{
.bloomIntensity = bloomIntensity;
}
{
.bloomPower;
}
{
.bloomPower = bloomPower;
}
{
.sunIntensity;
}
{
.sunIntensity = sunIntensity;
}
{
.sunshaftIntensity;
}
{
.sunshaftIntensity = sunshaftIntensity;
}
{
.sunshaftScaleFactor;
}
{
.sunshaftScaleFactor = sunshaftScaleFactor;
}
UpdateSunSettings {
( .sunHeightPercent, .sunAngleRadians);
}
UpdatePostFxSettings {
( .bloomIntensity, .bloomPower, .sunshaftScaleFactor, .sunIntensity, .sunshaftIntensity);
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ClientEffectWorldSettings.class, ClientEffectWorldSettings:: ).append( ( , Codec.FLOAT), (settings, o) -> settings.sunHeightPercent = o, (settings) -> settings.sunHeightPercent).add()).append( ( , Codec.FLOAT), (settings, o) -> settings.sunAngleRadians = ( )Math.toRadians(( )o), (settings) -> ( )Math.toDegrees(( )settings.sunAngleRadians)).add()).append( ( , Codec.FLOAT), (settings, o) -> settings.bloomIntensity = o, (settings) -> settings.bloomIntensity).add()).append( ( , Codec.FLOAT), (settings, o) -> settings.bloomPower = o, (settings) -> settings.bloomPower).add()).append( ( , Codec.FLOAT), (settings, o) -> settings.sunIntensity = o, (settings) -> settings.sunIntensity).add()).append( ( , Codec.FLOAT), (settings, o) -> settings.sunshaftIntensity = o, (settings) -> settings.sunshaftIntensity).add()).append( ( , Codec.FLOAT), (settings, o) -> settings.sunshaftScaleFactor = o, (settings) -> settings.sunshaftScaleFactor).add()).build();
}
}
com/hypixel/hytale/server/core/universe/world/IWorldChunks.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.assetstore.AssetRegistry;
import com.hypixel.hytale.server.core.universe.world.accessor.IChunkAccessorSync;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
@Deprecated
public interface IWorldChunks extends IChunkAccessorSync <WorldChunk>, IWorldChunksAsync {
@Deprecated
void consumeTaskQueue () ;
boolean isInThread () ;
default WorldChunk getChunk (long index) {
WorldChunk worldChunk = (WorldChunk)this .loadChunkIfInMemory(index);
if (worldChunk != null ) {
return worldChunk;
} else {
CompletableFuture<WorldChunk> future = this .getChunkAsync(index);
return (WorldChunk)this .waitForFutureWithoutLock(future);
}
}
default WorldChunk getNonTickingChunk (long index) {
(WorldChunk) .getChunkIfInMemory(index);
(worldChunk != ) {
worldChunk;
} {
CompletableFuture<WorldChunk> future = .getNonTickingChunkAsync(index);
(WorldChunk) .waitForFutureWithoutLock(future);
}
}
<T> T {
(! .isInThread()) {
(T)future.join();
} {
AssetRegistry.ASSET_LOCK.readLock().unlock();
(; !future.isDone(); Thread. ()) {
AssetRegistry.ASSET_LOCK.readLock().lock();
{
.consumeTaskQueue();
} {
AssetRegistry.ASSET_LOCK.readLock().unlock();
}
}
AssetRegistry.ASSET_LOCK.readLock().lock();
(T)future.join();
}
}
}
com/hypixel/hytale/server/core/universe/world/IWorldChunksAsync.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import java.util.concurrent.CompletableFuture;
@Deprecated
public interface IWorldChunksAsync {
CompletableFuture<WorldChunk> getChunkAsync (long var1) ;
CompletableFuture<WorldChunk> getNonTickingChunkAsync (long var1) ;
default CompletableFuture<WorldChunk> getChunkAsync (int x, int z) {
return this .getChunkAsync(ChunkUtil.indexChunk(x, z));
}
default CompletableFuture<WorldChunk> getNonTickingChunkAsync (int x, int z) {
return this .getNonTickingChunkAsync(ChunkUtil.indexChunk(x, z));
}
}
com/hypixel/hytale/server/core/universe/world/ParticleUtil.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.spatial.SpatialResource;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.protocol.Color;
import com.hypixel.hytale.protocol.Direction;
import com.hypixel.hytale.protocol.Position;
import com.hypixel.hytale.protocol.packets.world.SpawnParticleSystem;
import com.hypixel.hytale.server.core.asset.type.particle.config.WorldParticle;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.objects.ObjectList;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ParticleUtil {
public static final double DEFAULT_PARTICLE_DISTANCE = 75.0 ;
public ParticleUtil () {
}
public static void spawnParticleEffect (@Nonnull String name, Vector3d position, ComponentAccessor<EntityStore> componentAccessor) {
SpatialResource<Ref<EntityStore>, EntityStore> playerSpatialResource = (SpatialResource)componentAccessor.getResource(EntityModule.get().getPlayerSpatialResourceType());
ObjectList<Ref<EntityStore>> playerRefs = SpatialResource.getThreadLocalReferenceList();
playerSpatialResource.getSpatialStructure().collect(position, , playerRefs);
spawnParticleEffect(name, position.getX(), position.getY(), position.getZ(), (Ref) , playerRefs, componentAccessor);
}
{
spawnParticleEffect(name, position.getX(), position.getY(), position.getZ(), (Ref) , playerRefs, componentAccessor);
}
{
spawnParticleEffect(name, position.getX(), position.getY(), position.getZ(), sourceRef, playerRefs, componentAccessor);
}
{
spawnParticleEffect(name, position.getX(), position.getY(), position.getZ(), rotation.getYaw(), rotation.getPitch(), rotation.getRoll(), (Ref) , playerRefs, componentAccessor);
}
{
spawnParticleEffect(name, position.getX(), position.getY(), position.getZ(), rotation.getYaw(), rotation.getPitch(), rotation.getRoll(), sourceRef, playerRefs, componentAccessor);
}
{
spawnParticleEffect(name, position.getX(), position.getY(), position.getZ(), yaw, pitch, roll, sourceRef, playerRefs, componentAccessor);
}
{
spawnParticleEffect(name, position.getX(), position.getY(), position.getZ(), yaw, pitch, roll, scale, color, (Ref) , playerRefs, componentAccessor);
}
{
spawnParticleEffect((WorldParticle)particles, position, (Ref) , playerRefs, componentAccessor);
}
{
spawnParticleEffect(particles, position, , , , sourceRef, playerRefs, componentAccessor);
}
{
(WorldParticle particle : particles) {
spawnParticleEffect(particle, position, sourceRef, playerRefs, componentAccessor);
}
}
{
com.hypixel.hytale.protocol. particles.getPositionOffset();
(positionOffset != ) {
(( )positionOffset.x, ( )positionOffset.y, ( )positionOffset.z);
offset.rotateY(yaw);
offset.rotateX(pitch);
offset.rotateZ(roll);
position.x += offset.x;
position.y += offset.y;
position.z += offset.z;
}
particles.getRotationOffset();
(rotationOffset != ) {
yaw += ( )Math.toRadians(( )rotationOffset.yaw);
pitch += ( )Math.toRadians(( )rotationOffset.pitch);
roll += ( )Math.toRadians(( )rotationOffset.roll);
}
particles.getSystemId();
(systemId != ) {
spawnParticleEffect(systemId, position.getX(), position.getY(), position.getZ(), yaw, pitch, roll, particles.getScale(), particles.getColor(), sourceRef, playerRefs, componentAccessor);
}
}
{
spawnParticleEffect(name, x, y, z, (Ref) , playerRefs, componentAccessor);
}
{
spawnParticleEffect(name, x, y, z, , , , , (Color) , sourceRef, playerRefs, componentAccessor);
}
{
spawnParticleEffect(name, x, y, z, rotationYaw, rotationPitch, rotationRoll, , (Color) , sourceRef, playerRefs, componentAccessor);
}
{
;
(rotationYaw != || rotationPitch != || rotationRoll != ) {
rotation = (rotationYaw, rotationPitch, rotationRoll);
}
(name, (x, y, z), rotation, scale, color);
ComponentType<EntityStore, PlayerRef> playerRefComponentType = PlayerRef.getComponentType();
(Ref<EntityStore> playerRef : playerRefs) {
(playerRef.isValid() && (sourceRef == || !playerRef.equals(sourceRef))) {
(PlayerRef)componentAccessor.getComponent(playerRef, playerRefComponentType);
playerRefComponent != ;
playerRefComponent.getPacketHandler().writeNoCache(packet);
}
}
}
}
com/hypixel/hytale/server/core/universe/world/PlaceBlockSettings.java
package com.hypixel.hytale.server.core.universe.world;
public class PlaceBlockSettings {
public static final int NONE = 0 ;
public static final int PERFORM_BLOCK_UPDATE = 2 ;
public static final int UPDATE_CONNECTIONS = 8 ;
public PlaceBlockSettings () {
}
}
com/hypixel/hytale/server/core/universe/world/PlayerUtil.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.function.consumer.TriConsumer;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.model.config.Model;
import com.hypixel.hytale.server.core.cosmetics.CosmeticsModule;
import com.hypixel.hytale.server.core.entity.entities.player.HiddenPlayersManager;
import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent;
import com.hypixel.hytale.server.core.modules.entity.player.PlayerSkinComponent;
import com.hypixel.hytale.server.core.modules.entity.tracker.EntityTrackerSystems;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.UUID;
import java.util.function.BiConsumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PlayerUtil {
public PlayerUtil () {
}
public static void forEachPlayerThatCanSeeEntity (@Nonnull Ref<EntityStore> ref, @Nonnull TriConsumer<Ref<EntityStore>, PlayerRef, ComponentAccessor<EntityStore>> consumer, @Nonnull ComponentAccessor<EntityStore> componentAccessor) {
Store<EntityStore> store = ((EntityStore)componentAccessor.getExternalData()).getStore();
ComponentType<EntityStore, PlayerRef> playerRefComponentType = PlayerRef.getComponentType();
store.forEachChunk(playerRefComponentType, (BiConsumer)((archetypeChunk, commandBuffer) -> {
( ; index < archetypeChunk.size(); ++index) {
EntityTrackerSystems. (EntityTrackerSystems.EntityViewer)archetypeChunk.getComponent(index, EntityTrackerSystems.EntityViewer.getComponentType());
(entityViewerComponent != && entityViewerComponent.visible.contains(ref)) {
Ref<EntityStore> targetPlayerRef = archetypeChunk.getReferenceTo(index);
(PlayerRef)archetypeChunk.getComponent(index, playerRefComponentType);
targetPlayerRefComponent != ;
consumer.accept(targetPlayerRef, targetPlayerRefComponent, commandBuffer);
}
}
}));
}
{
Store<EntityStore> store = ((EntityStore)componentAccessor.getExternalData()).getStore();
ComponentType<EntityStore, PlayerRef> playerRefComponentType = PlayerRef.getComponentType();
store.forEachChunk(playerRefComponentType, (BiConsumer)((archetypeChunk, commandBuffer) -> {
( ; index < archetypeChunk.size(); ++index) {
EntityTrackerSystems. (EntityTrackerSystems.EntityViewer)archetypeChunk.getComponent(index, EntityTrackerSystems.EntityViewer.getComponentType());
(entityViewerComponent != && entityViewerComponent.visible.contains(ref)) {
Ref<EntityStore> targetRef = archetypeChunk.getReferenceTo(index);
(!targetRef.equals(ignoredPlayerRef)) {
(PlayerRef)archetypeChunk.getComponent(index, playerRefComponentType);
targetPlayerRefComponent != ;
consumer.accept(targetRef, targetPlayerRefComponent, commandBuffer);
}
}
}
}));
}
{
((EntityStore)store.getExternalData()).getWorld();
(PlayerRef targetPlayerRef : world.getPlayerRefs()) {
targetPlayerRef.getHiddenPlayersManager();
(sourcePlayerUuid == || !targetHiddenPlayersManager.isPlayerHidden(sourcePlayerUuid)) {
targetPlayerRef.sendMessage(message);
}
}
}
{
((EntityStore)componentAccessor.getExternalData()).getWorld();
(PlayerRef targetPlayerRef : world.getPlayerRefs()) {
targetPlayerRef.getPacketHandler().write(packet);
}
}
{
((EntityStore)componentAccessor.getExternalData()).getWorld();
(PlayerRef targetPlayerRef : world.getPlayerRefs()) {
targetPlayerRef.getPacketHandler().writeNoCache(packet);
}
}
{
((EntityStore)componentAccessor.getExternalData()).getWorld();
(PlayerRef targetPlayerRef : world.getPlayerRefs()) {
targetPlayerRef.getPacketHandler().write(packets);
}
}
{
(PlayerSkinComponent)componentAccessor.getComponent(ref, PlayerSkinComponent.getComponentType());
(playerSkinComponent != ) {
playerSkinComponent.setNetworkOutdated();
CosmeticsModule.get().createModel(playerSkinComponent.getPlayerSkin());
(newModel != ) {
componentAccessor.putComponent(ref, ModelComponent.getComponentType(), (newModel));
}
}
}
}
com/hypixel/hytale/server/core/universe/world/SetBlockSettings.java
package com.hypixel.hytale.server.core.universe.world;
public class SetBlockSettings {
public static final int NONE = 0 ;
public static final int NO_NOTIFY = 1 ;
public static final int NO_UPDATE_STATE = 2 ;
public static final int NO_SEND_PARTICLES = 4 ;
public static final int NO_SET_FILLER = 8 ;
public static final int NO_BREAK_FILLER = 16 ;
public static final int PHYSICS = 32 ;
public ;
;
;
;
;
;
{
}
}
com/hypixel/hytale/server/core/universe/world/SoundUtil.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.spatial.SpatialResource;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.protocol.Position;
import com.hypixel.hytale.protocol.SoundCategory;
import com.hypixel.hytale.protocol.packets.world.PlaySoundEvent2D;
import com.hypixel.hytale.protocol.packets.world.PlaySoundEvent3D;
import com.hypixel.hytale.protocol.packets.world.PlaySoundEventEntity;
import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
import com.hypixel.hytale.server.core.entity.Entity;
import com.hypixel.hytale.server.core.entity.EntityUtils;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.objects.ObjectList;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class SoundUtil {
public SoundUtil () {
}
public static void playSoundEventEntity (int soundEventIndex, networkId, ComponentAccessor<EntityStore> componentAccessor) {
playSoundEventEntity(soundEventIndex, networkId, , , componentAccessor);
}
{
(soundEventIndex != ) {
PlayerUtil.broadcastPacketToPlayers(componentAccessor, (Packet)( (soundEventIndex, networkId, volumeModifier, pitchModifier)));
}
}
{
playSoundEvent2dToPlayer(playerRefComponent, soundEventIndex, soundCategory, , );
}
{
(soundEventIndex != ) {
playerRefComponent.getPacketHandler().write((Packet)( (soundEventIndex, soundCategory, volumeModifier, pitchModifier)));
}
}
{
playSoundEvent2d(soundEventIndex, soundCategory, , , componentAccessor);
}
{
(soundEventIndex != ) {
PlayerUtil.broadcastPacketToPlayers(componentAccessor, (Packet)( (soundEventIndex, soundCategory, volumeModifier, pitchModifier)));
}
}
{
playSoundEvent2d(ref, soundEventIndex, soundCategory, , , componentAccessor);
}
{
(soundEventIndex != ) {
(PlayerRef)componentAccessor.getComponent(ref, PlayerRef.getComponentType());
(playerRefComponent != ) {
playerRefComponent.getPacketHandler().write((Packet)( (soundEventIndex, soundCategory, volumeModifier, pitchModifier)));
}
}
}
{
playSoundEvent3d(soundEventIndex, soundCategory, x, y, z, , , componentAccessor);
}
{
(soundEventIndex != ) {
(SoundEvent)SoundEvent.getAssetMap().getAsset(soundEventIndex);
(soundEvent != ) {
(soundEventIndex, soundCategory, (x, y, z), volumeModifier, pitchModifier);
(x, y, z);
SpatialResource<Ref<EntityStore>, EntityStore> playerSpatialResource = (SpatialResource)componentAccessor.getResource(EntityModule.get().getPlayerSpatialResourceType());
ObjectList<Ref<EntityStore>> results = SpatialResource.getThreadLocalReferenceList();
playerSpatialResource.getSpatialStructure().collect(position, ( )soundEvent.getMaxDistance(), results);
(Ref<EntityStore> playerRef : results) {
(playerRef != && playerRef.isValid()) {
(PlayerRef)componentAccessor.getComponent(playerRef, PlayerRef.getComponentType());
playerRefComponent != ;
playerRefComponent.getPacketHandler().write((Packet)packet);
}
}
}
}
}
{
playSoundEvent3d(soundEventIndex, soundCategory, position.getX(), position.getY(), position.getZ(), componentAccessor);
}
{
playSoundEvent3d(soundEventIndex, soundCategory, x, y, z, , , shouldHear, componentAccessor);
}
{
(soundEventIndex != ) {
(SoundEvent)SoundEvent.getAssetMap().getAsset(soundEventIndex);
(soundEvent != ) {
(soundEventIndex, soundCategory, (x, y, z), volumeModifier, pitchModifier);
SpatialResource<Ref<EntityStore>, EntityStore> playerSpatialResource = (SpatialResource)componentAccessor.getResource(EntityModule.get().getPlayerSpatialResourceType());
ObjectList<Ref<EntityStore>> results = SpatialResource.getThreadLocalReferenceList();
playerSpatialResource.getSpatialStructure().collect( (x, y, z), ( )soundEvent.getMaxDistance(), results);
(Ref<EntityStore> playerRef : results) {
(playerRef != && playerRef.isValid() && shouldHear.test(playerRef)) {
(PlayerRef)componentAccessor.getComponent(playerRef, PlayerRef.getComponentType());
playerRefComponent != ;
playerRefComponent.getPacketHandler().write((Packet)packet);
}
}
}
}
}
{
playSoundEvent3d(sourceRef, soundEventIndex, pos.getX(), pos.getY(), pos.getZ(), componentAccessor);
}
{
playSoundEvent3d(sourceRef, soundEventIndex, x, y, z, , componentAccessor);
}
{
playSoundEvent3d(sourceRef, soundEventIndex, position.getX(), position.getY(), position.getZ(), ignoreSource, componentAccessor);
}
{
sourceRef != ? EntityUtils.getEntity(sourceRef, componentAccessor) : ;
playSoundEvent3d(soundEventIndex, x, y, z, (playerRef) -> {
(sourceEntity == ) {
;
} (ignoreSource && sourceRef.equals(playerRef)) {
;
} {
!sourceEntity.isHiddenFromLivingEntity(sourceRef, playerRef, componentAccessor);
}
}, componentAccessor);
}
{
playSoundEvent3d(soundEventIndex, SoundCategory.SFX, x, y, z, shouldHear, componentAccessor);
}
{
playSoundEvent3dToPlayer(playerRef, soundEventIndex, soundCategory, x, y, z, , , componentAccessor);
}
{
(playerRef != && soundEventIndex != ) {
(SoundEvent)SoundEvent.getAssetMap().getAsset(soundEventIndex);
(soundEventAsset != ) {
soundEventAsset.getMaxDistance();
(TransformComponent)componentAccessor.getComponent(playerRef, TransformComponent.getComponentType());
transformComponent != ;
(transformComponent.getPosition().distanceSquaredTo(x, y, z) <= ( )(maxDistance * maxDistance)) {
(PlayerRef)componentAccessor.getComponent(playerRef, PlayerRef.getComponentType());
playerRefComponent != ;
playerRefComponent.getPacketHandler().write((Packet)( (soundEventIndex, soundCategory, (x, y, z), volumeModifier, pitchModifier)));
}
}
}
}
{
playSoundEvent3dToPlayer(playerRef, soundEventIndex, soundCategory, position.x, position.y, position.z, componentAccessor);
}
}
com/hypixel/hytale/server/core/universe/world/SpawnUtil.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.world.spawn.ISpawnProvider;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public final class SpawnUtil {
public SpawnUtil () {
}
@Nullable
public static TransformComponent applyFirstSpawnTransform (@Nonnull Holder<EntityStore> holder, @Nonnull World world, @Nonnull WorldConfig worldConfig, @Nonnull UUID playerUuid) {
ISpawnProvider spawnProvider = worldConfig.getSpawnProvider();
if (spawnProvider == null ) {
return null ;
} else {
Transform spawnPoint = spawnProvider.getSpawnPoint(world, playerUuid);
Vector3f bodyRotation ( , spawnPoint.getRotation().getYaw(), );
(spawnPoint.getPosition(), bodyRotation);
holder.addComponent(TransformComponent.getComponentType(), transformComponent);
(HeadRotation)holder.ensureAndGetComponent(HeadRotation.getComponentType());
headRotationComponent.teleportRotation(spawnPoint.getRotation());
transformComponent;
}
}
{
(TransformComponent)holder.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.setPosition(transform.getPosition());
transformComponent.getRotation().setYaw(transform.getRotation().getYaw());
(HeadRotation)holder.ensureAndGetComponent(HeadRotation.getComponentType());
headRotationComponent.teleportRotation(transform.getRotation());
}
}
com/hypixel/hytale/server/core/universe/world/ValidationOption.java
package com.hypixel.hytale.server.core.universe.world;
public enum ValidationOption {
PHYSICS,
BLOCKS,
BLOCK_STATES,
ENTITIES,
BLOCK_FILLER;
private ValidationOption () {
}
}
com/hypixel/hytale/server/core/universe/world/World.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.assetstore.AssetRegistry;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.common.util.FormatUtil;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.IResourceStorage;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.data.unknown.UnknownComponents;
import com.hypixel.hytale.event.EventRegistry;
import com.hypixel.hytale.event.IEventDispatcher;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.logger.sentry.SkipSentryException;
import com.hypixel.hytale.math.block.BlockUtil;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.metrics.ExecutorMetricsRegistry;
import com.hypixel.hytale.metrics.metric.HistoricMetric;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.protocol.packets.entities.SetEntitySeed;
import com.hypixel.hytale.protocol.packets.player.JoinWorld;
import com.hypixel.hytale.protocol.packets.player.SetClientId;
import com.hypixel.hytale.protocol.packets.setup.ClientFeature;
import com.hypixel.hytale.protocol.packets.setup.SetTimeDilation;
import com.hypixel.hytale.protocol.packets.setup.SetUpdateRate;
com.hypixel.hytale.protocol.packets.setup.UpdateFeatures;
com.hypixel.hytale.protocol.packets.setup.ViewRadius;
com.hypixel.hytale.protocol.packets.world.ServerSetPaused;
com.hypixel.hytale.server.core.HytaleServer;
com.hypixel.hytale.server.core.Message;
com.hypixel.hytale.server.core.ShutdownReason;
com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
com.hypixel.hytale.server.core.asset.type.gameplay.CombatConfig;
com.hypixel.hytale.server.core.asset.type.gameplay.DeathConfig;
com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
com.hypixel.hytale.server.core.blocktype.component.BlockPhysics;
com.hypixel.hytale.server.core.console.ConsoleModule;
com.hypixel.hytale.server.core.entity.Entity;
com.hypixel.hytale.server.core.entity.EntityUtils;
com.hypixel.hytale.server.core.entity.UUIDComponent;
com.hypixel.hytale.server.core.entity.entities.Player;
com.hypixel.hytale.server.core.entity.entities.player.data.PlayerConfigData;
com.hypixel.hytale.server.core.event.events.player.AddPlayerToWorldEvent;
com.hypixel.hytale.server.core.event.events.player.DrainPlayerFromWorldEvent;
com.hypixel.hytale.server.core.io.PacketHandler;
com.hypixel.hytale.server.core.modules.entity.EntityModule;
com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
com.hypixel.hytale.server.core.modules.entity.player.ChunkTracker;
com.hypixel.hytale.server.core.modules.entity.tracker.LegacyEntityTrackerSystems;
com.hypixel.hytale.server.core.modules.time.TimeResource;
com.hypixel.hytale.server.core.modules.time.WorldTimeResource;
com.hypixel.hytale.server.core.prefab.selection.buffer.impl.IPrefabBuffer;
com.hypixel.hytale.server.core.receiver.IMessageReceiver;
com.hypixel.hytale.server.core.universe.PlayerRef;
com.hypixel.hytale.server.core.universe.Universe;
com.hypixel.hytale.server.core.universe.world.accessor.ChunkAccessor;
com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn;
com.hypixel.hytale.server.core.universe.world.chunk.ChunkFlag;
com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
com.hypixel.hytale.server.core.universe.world.chunk.section.ChunkSection;
com.hypixel.hytale.server.core.universe.world.events.StartWorldEvent;
com.hypixel.hytale.server.core.universe.world.lighting.ChunkLightingManager;
com.hypixel.hytale.server.core.universe.world.path.WorldPathConfig;
com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
com.hypixel.hytale.server.core.universe.world.storage.resources.DiskResourceStorageProvider;
com.hypixel.hytale.server.core.universe.world.worldgen.IWorldGen;
com.hypixel.hytale.server.core.universe.world.worldgen.WorldGenLoadException;
com.hypixel.hytale.server.core.universe.world.worldmap.IWorldMap;
com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapLoadException;
com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
com.hypixel.hytale.server.core.util.FillerBlockUtil;
com.hypixel.hytale.server.core.util.MessageUtil;
com.hypixel.hytale.server.core.util.io.FileUtil;
com.hypixel.hytale.server.core.util.thread.TickingThread;
it.unimi.dsi.fastutil.longs.Long2ObjectMap;
it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
it.unimi.dsi.fastutil.longs.LongIterator;
it.unimi.dsi.fastutil.objects.ObjectArrayList;
java.io.IOException;
java.nio.file.Files;
java.nio.file.LinkOption;
java.nio.file.Path;
java.util.Collection;
java.util.Collections;
java.util.Deque;
java.util.EnumMap;
java.util.EnumSet;
java.util.List;
java.util.Map;
java.util.Random;
java.util.UUID;
java.util.concurrent.CompletableFuture;
java.util.concurrent.CompletionException;
java.util.concurrent.ConcurrentHashMap;
java.util.concurrent.CopyOnWriteArrayList;
java.util.concurrent.Executor;
java.util.concurrent.LinkedBlockingDeque;
java.util.concurrent.TimeUnit;
java.util.concurrent.atomic.AtomicBoolean;
java.util.concurrent.atomic.AtomicInteger;
java.util.function.BiConsumer;
java.util.function.IntUnaryOperator;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
, ExecutorMetricsRegistry.ExecutorMetric, ChunkAccessor<WorldChunk>, IWorldChunks, IMessageReceiver {
;
;
ExecutorMetricsRegistry<World> METRICS_REGISTRY;
HytaleLogger logger;
String name;
Path savePath;
WorldConfig worldConfig;
( );
( );
ChunkLightingManager chunkLighting;
WorldMapManager worldMapManager;
WorldPathConfig worldPathConfig;
( );
Deque<Runnable> taskQueue = ();
( );
( (), () -> , (String) , HytaleServer.get().getEventBus());
( );
isTicking;
isPaused;
tick;
();
();
Map<UUID, PlayerRef> players = ();
Collection<PlayerRef> playerRefs;
Map<ClientFeature, Boolean> features;
gcHasRun;
IOException {
( + name);
.playerRefs = Collections.unmodifiableCollection( .players.values());
.features = Collections.synchronizedMap( (ClientFeature.class));
.name = name;
.logger = HytaleLogger.get( + name);
.savePath = savePath;
.worldConfig = worldConfig;
.logger.at(Level.INFO).log( , name, worldConfig.getWorldGenProvider(), worldConfig.getChunkStorageProvider());
.worldMapManager = ( );
.chunkLighting = ( );
.isTicking = worldConfig.isTicking();
(ClientFeature feature : ClientFeature.VALUES) {
.features.put(feature, );
}
.getGameplayConfig().getCombatConfig();
.features.put(ClientFeature.DisplayHealthBars, combatConfig.isDisplayHealthBars());
.features.put(ClientFeature.DisplayCombatText, combatConfig.isDisplayCombatText());
.logger.at(Level.INFO).log( , name, Long.toString(worldConfig.getSeed()), worldConfig.getGameTime());
}
CompletableFuture<World> {
CompletableFuture<Void> savingFuture;
( .worldConfig.isSavingConfig()) {
savingFuture = Universe.get().getWorldConfigProvider().save( .savePath, .worldConfig, );
} {
savingFuture = CompletableFuture.completedFuture((Object) );
}
CompletableFuture<World> loadWorldGen = CompletableFuture.supplyAsync(() -> {
{
.worldConfig.getWorldGenProvider().getGenerator();
.chunkStore.setGenerator(worldGen);
.worldConfig.setDefaultSpawnProvider(worldGen);
.worldConfig.getWorldMapProvider().getGenerator( );
.worldMapManager.setGenerator(worldMap);
;
} (WorldGenLoadException var3) {
( .name.equals(HytaleServer.get().getConfig().getDefaults().getWorld())) {
HytaleServer.get().shutdownServer(ShutdownReason.WORLD_GEN.withMessage(var3.getTraceMessage( )));
}
( , var3);
} (WorldMapLoadException var4) {
( .name.equals(HytaleServer.get().getConfig().getDefaults().getWorld())) {
HytaleServer.get().shutdownServer(ShutdownReason.WORLD_GEN.withMessage(var4.getTraceMessage( )));
}
( , var4);
}
});
CompletableFuture<Void> loadPaths = WorldPathConfig.load( ).thenAccept((config) -> .worldPathConfig = config);
.worldConfig.getSpawnProvider() != ? CompletableFuture.allOf(savingFuture, loadPaths).thenApply((v) -> ) : CompletableFuture.allOf(savingFuture, loadPaths).thenCompose((v) -> loadWorldGen);
}
{
DiskResourceStorageProvider.migrateFiles( );
.worldConfig.getResourceStorageProvider().getResourceStorage( );
.chunkStore.start(resourceStorage);
.entityStore.start(resourceStorage);
.chunkLighting.start();
.worldMapManager.updateTickingState( .worldMapManager.isStarted());
.savePath.resolve( );
(Files.exists(rffPath, [ ])) {
(String.valueOf(rffPath) + );
} {
IEventDispatcher<StartWorldEvent, StartWorldEvent> dispatcher = HytaleServer.get().getEventBus().dispatchFor(StartWorldEvent.class, .name);
(dispatcher.hasListener()) {
dispatcher.dispatch( ( ));
}
}
}
{
.logger.at(Level.INFO).log( , .name);
Universe.get().getDefaultWorld();
(defaultWorld != ) {
.drainPlayersTo(defaultWorld).join();
} {
(PlayerRef playerRef : .players.values()) {
playerRef.getPacketHandler().disconnect( );
}
}
( .alive.getAndSet( )) {
{
.stop();
} (Throwable t) {
((HytaleLogger.Api) .logger.at(Level.SEVERE).withCause(t)).log( );
}
}
}
{
( .worldConfig.isDeleteOnRemove()) {
{
FileUtil.deleteDirectory( .getSavePath());
} (Throwable t) {
((HytaleLogger.Api) .logger.at(Level.SEVERE).withCause(t)).log( );
}
}
}
{
.players.isEmpty();
}
{
( .alive.get()) {
(TimeResource) .entityStore.getStore().getResource(TimeResource.getResourceType());
dt *= worldTimeResource.getTimeDilationModifier();
AssetRegistry.ASSET_LOCK.readLock().lock();
{
.consumeTaskQueue();
(! .isPaused) {
.entityStore.getStore().tick(dt);
} {
.entityStore.getStore().pausedTick(dt);
}
( .isTicking && ! .isPaused) {
.chunkStore.getStore().tick(dt);
} {
.chunkStore.getStore().pausedTick(dt);
}
.consumeTaskQueue();
} {
AssetRegistry.ASSET_LOCK.readLock().unlock();
}
++ .tick;
}
}
{
.logger.at(Level.INFO).log( , .name);
.logger.at(Level.INFO).log( );
System.nanoTime();
( .chunkLighting.interrupt() || .worldMapManager.interrupt()) {
.consumeTaskQueue();
(System.nanoTime() - start > ) {
;
}
}
.chunkLighting.stop();
.worldMapManager.stop();
.logger.at(Level.INFO).log( );
(PlayerRef playerRef : .playerRefs) {
(playerRef.getReference() != ) {
playerRef.removeFromStore();
}
}
.consumeTaskQueue();
.logger.at(Level.INFO).log( );
.chunkStore.waitForLoadingChunks();
{
.logger.at(Level.INFO).log( );
HytaleServer.get().reportSingleplayerStatus( + .name + );
.chunkStore.shutdown();
.consumeTaskQueue();
.entityStore.shutdown();
.consumeTaskQueue();
} {
.logger.at(Level.INFO).log( );
( .worldConfig.isSavingConfig()) {
Universe.get().getWorldConfigProvider().save( .savePath, .worldConfig, ).join();
}
}
.acceptingTasks.set( );
( .alive.getAndSet( )) {
Universe.get().removeWorldExceptionally( .name);
}
HytaleServer.get().reportSingleplayerStatus( + .name + );
}
{
.setTps(tps);
(tps);
.entityStore.getStore().forEachEntityParallel(PlayerRef.getComponentType(), (index, archetypeChunk, commandBuffer) -> ((PlayerRef)archetypeChunk.getComponent(index, PlayerRef.getComponentType())).getPacketHandler().writeNoCache(setUpdateRatePacket));
}
{
((EntityStore)componentAccessor.getExternalData()).getWorld();
(!(( )timeDilationModifier <= ) && !(timeDilationModifier > )) {
(TimeResource)componentAccessor.getResource(TimeResource.getResourceType());
worldTimeResource.setTimeDilationModifier(timeDilationModifier);
(timeDilationModifier);
(PlayerRef playerRef : world.playerRefs) {
playerRef.getPacketHandler().writeNoCache(setTimeDilationPacket);
}
} {
( );
}
}
String {
.name;
}
{
.alive.get();
}
WorldConfig {
.worldConfig;
}
DeathConfig {
.worldConfig.getDeathConfigOverride();
override != ? override : .getGameplayConfig().getDeathConfig();
}
{
.worldConfig.getDaytimeDurationSecondsOverride();
override != ? override : .getGameplayConfig().getWorldConfig().getDaytimeDurationSeconds();
}
{
.worldConfig.getNighttimeDurationSecondsOverride();
override != ? override : .getGameplayConfig().getWorldConfig().getNighttimeDurationSeconds();
}
{
.isTicking;
}
{
.isTicking = ticking;
.worldConfig.setTicking(ticking);
.worldConfig.markChanged();
}
{
.isPaused;
}
{
( .isPaused != paused) {
.isPaused = paused;
(paused);
PlayerUtil.broadcastPacketToPlayersNoCache( .entityStore.getStore(), setPaused);
}
}
{
.tick;
}
HytaleLogger {
.logger;
}
{
.worldConfig.isCompassUpdating();
}
{
.worldMapManager.shouldTick();
.worldConfig.setCompassUpdating(compassUpdating);
.worldConfig.markChanged();
.worldMapManager.updateTickingState(before);
}
<T> {
Long2ObjectMap<WorldChunk> chunks = <WorldChunk>();
blocks.forEach((a, b) -> {
BlockUtil.unpackX(a);
BlockUtil.unpackY(a);
BlockUtil.unpackZ(a);
xConvert.applyAsInt(localX);
yConvert.applyAsInt(localY);
zConvert.applyAsInt(localZ);
ChunkUtil.indexChunkFromBlock(x, z);
(WorldChunk)chunks.get(chunkIndex);
(chunk == ) {
chunk = .getNonTickingChunk(chunkIndex);
chunks.put(chunkIndex, chunk);
}
consumer.apply( , b, chunkIndex, chunk, x, y, z, localX, localY, localZ);
});
}
WorldChunk {
(! .isInThread()) {
(WorldChunk)CompletableFuture.supplyAsync(() -> .loadChunkIfInMemory(index), ).join();
} {
Ref<ChunkStore> reference = .chunkStore.getChunkReference(index);
(reference == ) {
;
} {
(WorldChunk) .chunkStore.getStore().getComponent(reference, WorldChunk.getComponentType());
worldChunkComponent != ;
worldChunkComponent.setFlag(ChunkFlag.TICKING, );
worldChunkComponent;
}
}
}
WorldChunk {
Ref<ChunkStore> reference = .chunkStore.getChunkReference(index);
(reference == ) {
;
} {
! .isInThread() ? (WorldChunk)CompletableFuture.supplyAsync(() -> .getChunkIfInMemory(index), ).join() : (WorldChunk) .chunkStore.getStore().getComponent(reference, WorldChunk.getComponentType());
}
}
WorldChunk {
(! .isInThread()) {
(WorldChunk)CompletableFuture.supplyAsync(() -> .getChunkIfLoaded(index), ).join();
} {
Ref<ChunkStore> reference = .chunkStore.getChunkReference(index);
(reference == ) {
;
} {
(WorldChunk) .chunkStore.getStore().getComponent(reference, WorldChunk.getComponentType());
worldChunkComponent != ;
worldChunkComponent.is(ChunkFlag.TICKING) ? worldChunkComponent : ;
}
}
}
WorldChunk {
(! .isInThread()) {
(WorldChunk)CompletableFuture.supplyAsync(() -> .getChunkIfNonTicking(index), ).join();
} {
Ref<ChunkStore> reference = .chunkStore.getChunkReference(index);
(reference == ) {
;
} {
(WorldChunk) .chunkStore.getStore().getComponent(reference, WorldChunk.getComponentType());
worldChunkComponent != ;
worldChunkComponent.is(ChunkFlag.TICKING) ? : worldChunkComponent;
}
}
}
CompletableFuture<WorldChunk> {
.chunkStore.getChunkReferenceAsync(index, ).thenApplyAsync((reference) -> reference == ? : (WorldChunk) .chunkStore.getStore().getComponent(reference, WorldChunk.getComponentType()), );
}
CompletableFuture<WorldChunk> {
.chunkStore.getChunkReferenceAsync(index).thenApplyAsync((reference) -> reference == ? : (WorldChunk) .chunkStore.getStore().getComponent(reference, WorldChunk.getComponentType()), );
}
List<Player> {
(! .isInThread()) {
! .isStarted() ? Collections.emptyList() : (List)CompletableFuture.supplyAsync( ::getPlayers, ).join();
} {
ObjectArrayList<Player> players = <Player>( );
.entityStore.getStore().forEachChunk(Player.getComponentType(), (BiConsumer)((archetypeChunk, commandBuffer) -> {
players.ensureCapacity(players.size() + archetypeChunk.size());
( ; index < archetypeChunk.size(); ++index) {
players.add((Player)archetypeChunk.getComponent(index, Player.getComponentType()));
}
}));
players;
}
}
Entity {
(! .isInThread()) {
(Entity)CompletableFuture.supplyAsync(() -> .getEntity(uuid), ).join();
} {
Ref<EntityStore> reference = .entityStore.getRefFromUUID(uuid);
EntityUtils.getEntity(reference, .entityStore.getStore());
}
}
Ref<EntityStore> {
! .isInThread() ? (Ref)CompletableFuture.supplyAsync(() -> .getEntityRef(uuid), ).join() : .entityStore.getRefFromUUID(uuid);
}
{
.players.size();
}
Collection<PlayerRef> {
.playerRefs;
}
{
.players.put(playerRef.getUuid(), playerRef);
}
{
.players.remove(playerRef.getUuid(), playerRef);
}
<T > T {
(T) .addEntity(entity, position, rotation, AddReason.SPAWN);
}
<T > T {
(!EntityModule.get().isKnown(entity)) {
( );
} (entity Player) {
( );
} (entity.getNetworkId() == - ) {
( );
} (! .equals(entity.getWorld())) {
.getName();
( + var10002 + + String.valueOf(entity.getWorld()));
} (entity.getReference() != && entity.getReference().isValid()) {
( + String.valueOf(((Entity)entity).getReference()));
} (position.getY() < - ) {
( + String.valueOf(position));
} (! .isInThread()) {
((HytaleLogger.Api) .logger.at(Level.WARNING).withCause( ())).log( );
.execute(() -> .addEntity(entity, position, rotation, reason));
entity;
} {
entity.unloadFromWorld();
Holder<EntityStore> holder = ((Entity)entity).toHolder();
(HeadRotation)holder.ensureAndGetComponent(HeadRotation.getComponentType());
(rotation != ) {
headRotation.teleportRotation(rotation);
}
holder.addComponent(TransformComponent.getComponentType(), (position, rotation));
holder.ensureComponent(UUIDComponent.getComponentType());
.entityStore.getStore().addEntity(holder, reason);
entity;
}
}
{
(! .isInThread()) {
.execute(() -> .sendMessage(message));
} {
.entityStore.getStore().forEachEntityParallel(PlayerRef.getComponentType(), (index, archetypeChunk, commandBuffer) -> {
(PlayerRef)archetypeChunk.getComponent(index, PlayerRef.getComponentType());
playerRefComponent != ;
playerRefComponent.sendMessage(message);
});
.logger.at(Level.INFO).log( , MessageUtil.toAnsiString(message).toAnsi(ConsoleModule.get().getTerminal()));
}
}
{
(! .acceptingTasks.get()) {
.name;
( ( + var10004 + + String.valueOf( .getThread())));
} {
.taskQueue.offer(command);
}
}
{
.debugAssertInTickingThread();
.getTickStepNanos();
Runnable runnable;
((runnable = (Runnable) .taskQueue.poll()) != ) {
{
System.nanoTime();
runnable.run();
System.nanoTime();
after - before;
(diff > ( )tickStepNanos) {
.logger.at(Level.WARNING).log( , FormatUtil.nanosToString(diff), runnable);
}
} (Exception t) {
((HytaleLogger.Api) .logger.at(Level.SEVERE).withCause(t)).log( );
}
}
}
ChunkStore {
.chunkStore;
}
EntityStore {
.entityStore;
}
ChunkLightingManager {
.chunkLighting;
}
WorldMapManager {
.worldMapManager;
}
WorldPathConfig {
.worldPathConfig;
}
WorldNotificationHandler {
.notificationHandler;
}
EventRegistry {
.eventRegistry;
}
CompletableFuture<PlayerRef> {
.addPlayer(playerRef, (Transform) );
}
CompletableFuture<PlayerRef> {
.addPlayer(playerRef, transform, (Boolean) , (Boolean) );
}
CompletableFuture<PlayerRef> {
(! .alive.get()) {
CompletableFuture.failedFuture( ( ));
} (playerRef.getReference() != ) {
( );
} {
playerRef.getPacketHandler();
(!packetHandler.stillActive()) {
;
} {
Holder<EntityStore> holder = playerRef.getHolder();
holder != ;
(TransformComponent)holder.getComponent(TransformComponent.getComponentType());
(transformComponent == && transform == ) {
transformComponent = SpawnUtil.applyFirstSpawnTransform(holder, , .worldConfig, playerRef.getUuid());
(transformComponent == ) {
CompletableFuture.failedFuture( ( ));
}
}
transformComponent != ;
(Player)holder.getComponent(Player.getComponentType());
playerComponent != ;
!playerComponent.getPlayerConfigData().getPerWorldData().containsKey( .name);
playerComponent.setFirstSpawn(firstSpawn);
(transform != ) {
SpawnUtil.applyTransform(holder, transform);
}
(AddPlayerToWorldEvent)HytaleServer.get().getEventBus().dispatchFor(AddPlayerToWorldEvent.class, .name).dispatch( (holder, ));
(ChunkTracker)holder.getComponent(ChunkTracker.getComponentType());
clearWorldOverride != ? clearWorldOverride : ;
fadeInOutOverride != ? fadeInOutOverride : ;
(chunkTrackerComponent != && (clearWorld || fadeInOut)) {
chunkTrackerComponent.setReadyForChunks( );
}
transformComponent.getPosition();
ChunkUtil.indexChunkFromBlock(spawnPosition.getX(), spawnPosition.getZ());
CompletableFuture<Void> loadTargetChunkFuture = .chunkStore.getChunkReferenceAsync(chunkIndex).thenAccept((v) -> playerComponent.startClientReadyTimeout());
CompletableFuture<Void> clientReadyFuture = ();
packetHandler.setClientReadyForChunksFuture(clientReadyFuture);
CompletableFuture<Void> setupPlayerFuture = CompletableFuture.runAsync(() -> .onSetupPlayerJoining(holder, playerComponent, playerRef, packetHandler, transform, clearWorld, fadeInOut));
CompletableFuture<Void> playerReadyFuture = clientReadyFuture.orTimeout( , TimeUnit.SECONDS);
CompletableFuture.allOf(setupPlayerFuture, playerReadyFuture, loadTargetChunkFuture).thenApplyAsync((aVoid) -> .onFinishPlayerJoining(playerComponent, playerRef, packetHandler, event.shouldBroadcastJoinMessage()), ).exceptionally((throwable) -> {
((HytaleLogger.Api) .logger.at(Level.WARNING).withCause(throwable)).log( );
playerRef.getPacketHandler().disconnect( );
( + playerRef.getUsername() + + .name + , throwable);
});
}
}
}
PlayerRef {
(TimeResource) .entityStore.getStore().getResource(TimeResource.getResourceType());
timeResource.getTimeDilationModifier();
HytaleServer.get().getConfig().getMaxViewRadius();
packetHandler.write( (maxViewRadius * ), ( .entitySeed.get()), (playerComponent.getNetworkId()), (timeDilationModifier));
packetHandler.write((Packet)( ( .features)));
packetHandler.write((Packet) .worldConfig.getClientEffects().createSunSettingsPacket());
packetHandler.write((Packet) .worldConfig.getClientEffects().createPostFxSettingsPacket());
playerRefComponent.getUuid();
Store<EntityStore> store = .entityStore.getStore();
(WorldTimeResource)store.getResource(WorldTimeResource.getResourceType());
((EntityStore)store.getExternalData()).getWorld();
packetHandler.writeNoCache( ( .getTps()));
( .isPaused) {
.setPaused( );
}
Ref<EntityStore> ref = playerRefComponent.addToStore(store);
(ref != && ref.isValid()) {
worldTimeResource.sendTimePackets(playerRefComponent);
playerComponent.getWorldMapTracker();
worldMapTracker.clear();
worldMapTracker.sendSettings(world);
(broadcastJoin) {
Message.translation( ).param( , playerRefComponent.getUsername()).param( , .worldConfig.getDisplayName() != ? .worldConfig.getDisplayName() : WorldConfig.formatDisplayName( .name));
PlayerUtil.broadcastMessageToPlayers(playerUuid, message, store);
}
(TransformComponent)store.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition().toString();
.logger.at(Level.INFO).log( , playerRefComponent.getUsername(), .name, position, playerUuid);
(HeadRotation)store.getComponent(ref, HeadRotation.getComponentType());
headRotationComponent != ;
playerRefComponent;
} {
( );
}
}
{
playerRefComponent.getUuid();
.logger.at(Level.INFO).log( , playerRefComponent.getUsername(), .name, transform, playerUuid);
.entityStore.takeNextNetworkId();
playerComponent.setNetworkId(entityId);
playerComponent.getPlayerConfigData();
configData.setWorld( .name);
(clearWorld) {
LegacyEntityTrackerSystems.clear(playerComponent, holder);
(ChunkTracker)holder.getComponent(ChunkTracker.getComponentType());
(chunkTrackerComponent != ) {
chunkTrackerComponent.clear();
}
}
playerComponent.getPageManager().clearCustomPageAcknowledgements();
(clearWorld, fadeInOut, .worldConfig.getUuid());
packetHandler.write((Packet)packet);
packetHandler.tryFlush();
HytaleLogger.getLogger().at(Level.INFO).log( , packetHandler.getIdentifier(), packet);
packetHandler.setQueuePackets( );
}
CompletableFuture<Void> {
CompletableFuture.completedFuture((Void) ).thenComposeAsync((aVoid) -> {
ObjectArrayList<CompletableFuture<PlayerRef>> futures = <CompletableFuture<PlayerRef>>();
(PlayerRef playerRef : .playerRefs) {
Holder<EntityStore> holder = playerRef.removeFromStore();
(DrainPlayerFromWorldEvent)HytaleServer.get().getEventBus().dispatchFor(DrainPlayerFromWorldEvent.class, .name).dispatch( (holder, fallbackTargetWorld, (Transform) ));
futures.add(event.getWorld().addPlayer(playerRef, event.getTransform()));
}
CompletableFuture.allOf((CompletableFuture[])futures.toArray((x$ ) -> [x$ ]));
}, );
}
GameplayConfig {
.worldConfig.getGameplayConfig();
(GameplayConfig)GameplayConfig.getAssetMap().getAsset(gameplayConfigId);
(gameplayConfig == ) {
gameplayConfig = GameplayConfig.DEFAULT;
}
gameplayConfig;
}
Map<ClientFeature, Boolean> {
Collections.unmodifiableMap( .features);
}
{
(Boolean) .features.getOrDefault(feature, );
}
{
.features.put(feature, enabled);
.broadcastFeatures();
}
{
( .features);
(PlayerRef playerRef : .playerRefs) {
playerRef.getPacketHandler().write((Packet)packet);
}
}
Path {
.savePath;
}
{
.random.nextInt();
.entitySeed.set(newEntitySeed);
PlayerUtil.broadcastPacketToPlayers(store, (Packet)( (newEntitySeed)));
}
{
.gcHasRun = ;
}
{
.gcHasRun;
.gcHasRun = ;
gcHasRun;
}
{
.name != ? .name.hashCode() : ;
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
(World)o;
.name.equals(world.name);
} {
;
}
}
String {
.name;
+ var10000 + + .alive.get() + + .chunkStore.getLoadedChunksCount() + + .chunkStore.getTotalLoadedChunksCount() + + .chunkStore.getTotalGeneratedChunksCount() + + .entityStore.getStore().getEntityCount() + ;
}
IOException {
.setThread(Thread.currentThread());
.onStart();
Store<ChunkStore> store = .chunkStore.getStore();
();
.chunkStore.getLoader().getIndexes().iterator();
(var6.hasNext()) {
(Long)var6.next();
ChunkUtil.xOfChunkIndex(index);
ChunkUtil.zOfChunkIndex(index);
{
CompletableFuture<Ref<ChunkStore>> future = .chunkStore.getChunkReferenceAsync(index, );
(!future.isDone()) {
.consumeTaskQueue();
}
Ref<ChunkStore> reference = (Ref)future.join();
(reference != && reference.isValid()) {
(WorldChunk)store.getComponent(reference, WorldChunk.getComponentType());
(ChunkColumn)store.getComponent(reference, ChunkColumn.getComponentType());
(chunkColumn != ) {
(Ref<ChunkStore> section : chunkColumn.getSections()) {
(ChunkSection)store.getComponent(section, ChunkSection.getComponentType());
(BlockSection)store.getComponent(section, BlockSection.getComponentType());
(blockSection != ) {
(BlockPhysics)store.getComponent(section, BlockPhysics.getComponentType());
( ; y < ; ++y) {
(sectionInfo.getY() << ) + y;
( ; z < ; ++z) {
( ; x < ; ++x) {
blockSection.get(x, y, z);
blockSection.getFiller(x, y, z);
blockSection.getRotationIndex(x, y, z);
Holder<ChunkStore> holder = chunk.getBlockComponentHolder(x, worldY, z);
ChunkUtil.minBlock(chunk.getX()) + x;
ChunkUtil.minBlock(chunk.getZ()) + z;
blockValidator.accept(worldX, worldY, worldZ, blockId, , , holder, blockPhys != ? blockPhys.get(x, y, z) : , rotation, filler, (Object) );
(options.contains(ValidationOption.BLOCK_FILLER)) {
<undefinedtype> fetcher = .FillerFetcher<BlockSection, ChunkStore>() {
{
(x >= && y >= && z >= && x < && y < && z < ) {
blockSection.get(x, y, z);
} {
sectionInfo.getX() + ChunkUtil.chunkCoordinate(x);
sectionInfo.getY() + ChunkUtil.chunkCoordinate(y);
sectionInfo.getZ() + ChunkUtil.chunkCoordinate(z);
CompletableFuture<Ref<ChunkStore>> refFuture = chunkStore.getChunkSectionReferenceAsync(nx, ny, nz);
(!refFuture.isDone()) {
World. .consumeTaskQueue();
}
Ref<ChunkStore> ref = (Ref)refFuture.join();
(BlockSection)chunkStore.getStore().getComponent(ref, BlockSection.getComponentType());
blocks == ? - : blocks.get(x, y, z);
}
}
{
(x >= && y >= && z >= && x < && y < && z < ) {
blockSection.getFiller(x, y, z);
} {
sectionInfo.getX() + ChunkUtil.chunkCoordinate(x);
sectionInfo.getY() + ChunkUtil.chunkCoordinate(y);
sectionInfo.getZ() + ChunkUtil.chunkCoordinate(z);
CompletableFuture<Ref<ChunkStore>> refFuture = chunkStore.getChunkSectionReferenceAsync(nx, ny, nz);
(!refFuture.isDone()) {
World. .consumeTaskQueue();
}
Ref<ChunkStore> ref = (Ref)refFuture.join();
(BlockSection)chunkStore.getStore().getComponent(ref, BlockSection.getComponentType());
blocks == ? - : blocks.getFiller(x, y, z);
}
}
{
(x >= && y >= && z >= && x < && y < && z < ) {
blockSection.getFiller(x, y, z);
} {
sectionInfo.getX() + ChunkUtil.chunkCoordinate(x);
sectionInfo.getY() + ChunkUtil.chunkCoordinate(y);
sectionInfo.getZ() + ChunkUtil.chunkCoordinate(z);
CompletableFuture<Ref<ChunkStore>> refFuture = chunkStore.getChunkSectionReferenceAsync(nx, ny, nz);
(!refFuture.isDone()) {
World. .consumeTaskQueue();
}
Ref<ChunkStore> ref = (Ref)refFuture.join();
(BlockSection)chunkStore.getStore().getComponent(ref, BlockSection.getComponentType());
blocks == ? - : blocks.getRotationIndex(x, y, z);
}
}
};
FillerBlockUtil. FillerBlockUtil.validateBlock(x, y, z, blockId, rotation, filler, blockSection, .chunkStore, fetcher);
(fillerResult) {
OK:
:
;
INVALID_BLOCK:
(BlockType)BlockType.getAssetMap().getAsset(blockId);
tempBuilder.append( ).append(blockType != ? blockType.getId() : ).append( ).append(x).append( ).append(y).append( ).append(z).append( ).append( );
;
INVALID_FILLER:
(BlockType)BlockType.getAssetMap().getAsset(blockId);
tempBuilder.append( ).append(blockType != ? blockType.getId() : ).append( ).append(x).append( ).append(y).append( ).append(z).append( ).append( );
}
}
}
}
}
(!tempBuilder.isEmpty()) {
errors.append( ).append(sectionInfo.getX()).append( ).append(sectionInfo.getY()).append( ).append(sectionInfo.getZ()).append( ).append(tempBuilder);
tempBuilder.setLength( );
}
}
}
(options.contains(ValidationOption.ENTITIES)) {
ComponentType<EntityStore, UnknownComponents<EntityStore>> unknownComponentType = EntityStore.REGISTRY.getUnknownComponentType();
(Holder<EntityStore> entityHolder : chunk.getEntityChunk().getEntityHolders()) {
UnknownComponents<EntityStore> unknownComponents = (UnknownComponents)entityHolder.getComponent(unknownComponentType);
(unknownComponents != && !unknownComponents.getUnknownComponents().isEmpty()) {
errors.append( ).append(unknownComponents.getUnknownComponents()).append( );
}
}
}
store.tick( );
}
}
} (CompletionException e) {
((HytaleLogger.Api) .getLogger().at(Level.SEVERE).withCause(e)).log( , chunkX, chunkZ);
errors.append( ).append( ).append(chunkX).append( ).append(chunkZ).append( ).append( ).append(e.getCause().getMessage()).append( );
}
}
( .alive.getAndSet( )) {
.onShutdown();
}
.setThread((Thread) );
}
{
METRICS_REGISTRY = ( ()).register( , (world) -> world.name, Codec.STRING).register( , (world) -> world.alive.get(), Codec.BOOLEAN).register( , TickingThread::getBufferedTickLengthMetricSet, HistoricMetric.METRICS_CODEC).register( , World::getEntityStore, EntityStore.METRICS_REGISTRY).register( , World::getChunkStore, ChunkStore.METRICS_REGISTRY);
}
<T> {
;
}
}
com/hypixel/hytale/server/core/universe/world/WorldConfig.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.map.ObjectMapCodec;
import com.hypixel.hytale.codec.lookup.MapKeyMapCodec;
import com.hypixel.hytale.codec.schema.metadata.NoDefaultValue;
import com.hypixel.hytale.codec.util.RawJsonReader;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.common.plugin.PluginIdentifier;
import com.hypixel.hytale.common.semver.SemverRange;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.shape.Box;
import com.hypixel.hytale.math.shape.Box2D;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector2d;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.asset.type.gameplay.DeathConfig;
import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
import com.hypixel.hytale.server.core.asset.type.weather.config.Weather;
import com.hypixel.hytale.server.core.codec.ProtocolCodecs;
import com.hypixel.hytale.server.core.codec.ShapeCodecs;
import com.hypixel.hytale.server.core.modules.time.WorldTimeResource;
import com.hypixel.hytale.server.core.universe.world.spawn.GlobalSpawnProvider;
import com.hypixel.hytale.server.core.universe.world.spawn.ISpawnProvider;
import com.hypixel.hytale.server.core.universe.world.storage.provider.IChunkStorageProvider;
import com.hypixel.hytale.server.core.universe.world.storage.resources.IResourceStorageProvider;
com.hypixel.hytale.server.core.universe.world.worldgen.IWorldGen;
com.hypixel.hytale.server.core.universe.world.worldgen.provider.IWorldGenProvider;
com.hypixel.hytale.server.core.universe.world.worldmap.provider.IWorldMapProvider;
com.hypixel.hytale.server.core.util.BsonUtil;
java.nio.file.Path;
java.time.Instant;
java.time.temporal.ChronoUnit;
java.util.Collections;
java.util.HashMap;
java.util.Map;
java.util.UUID;
java.util.concurrent.CompletableFuture;
java.util.concurrent.atomic.AtomicBoolean;
javax.annotation.Nonnull;
javax.annotation.Nullable;
org.bson.BsonDocument;
{
;
;
;
MapKeyMapCodec<Object> PLUGIN_CODEC = <Object>( );
BuilderCodec<WorldConfig> CODEC;
();
UUID.randomUUID();
String displayName;
System.currentTimeMillis();
;
IWorldGenProvider worldGenProvider;
IWorldMapProvider worldMapProvider;
IChunkStorageProvider chunkStorageProvider;
ChunkConfig chunkConfig;
isTicking;
isBlockTicking;
isPvpEnabled;
isFallDamageEnabled;
isGameTimePaused;
Instant gameTime;
String forcedWeather;
ClientEffectWorldSettings clientEffects;
Map<PluginIdentifier, SemverRange> requiredPlugins;
GameMode gameMode;
isSpawningNPC;
isSpawnMarkersEnabled;
isAllNPCFrozen;
String gameplayConfig;
DeathConfig deathConfigOverride;
Integer daytimeDurationSecondsOverride;
Integer nighttimeDurationSecondsOverride;
isCompassUpdating;
isSavingPlayers;
canSaveChunks;
saveNewChunks;
canUnloadChunks;
isObjectiveMarkersEnabled;
deleteOnUniverseStart;
deleteOnRemove;
IResourceStorageProvider resourceStorageProvider;
MapKeyMapCodec.TypeMap<Object> pluginConfig;
ISpawnProvider defaultSpawnProvider;
isSavingConfig;
{
.worldGenProvider = IWorldGenProvider.CODEC.getDefault();
.worldMapProvider = IWorldMapProvider.CODEC.getDefault();
.chunkStorageProvider = IChunkStorageProvider.CODEC.getDefault();
.chunkConfig = ();
.isTicking = ;
.isBlockTicking = ;
.isPvpEnabled = ;
.isFallDamageEnabled = ;
.isGameTimePaused = ;
.gameTime = WorldTimeResource.ZERO_YEAR.plus( , ChronoUnit.HOURS).plus( , ChronoUnit.MINUTES);
.clientEffects = ();
.requiredPlugins = Collections.emptyMap();
.isSpawningNPC = ;
.isSpawnMarkersEnabled = ;
.isAllNPCFrozen = ;
.gameplayConfig = ;
.deathConfigOverride = ;
.daytimeDurationSecondsOverride = ;
.nighttimeDurationSecondsOverride = ;
.isCompassUpdating = ;
.isSavingPlayers = ;
.canSaveChunks = ;
.saveNewChunks = ;
.canUnloadChunks = ;
.isObjectiveMarkersEnabled = ;
.deleteOnUniverseStart = ;
.deleteOnRemove = ;
.resourceStorageProvider = IResourceStorageProvider.CODEC.getDefault();
.pluginConfig = .TypeMap<Object>(PLUGIN_CODEC);
.isSavingConfig = ;
.markChanged();
}
{
.worldGenProvider = IWorldGenProvider.CODEC.getDefault();
.worldMapProvider = IWorldMapProvider.CODEC.getDefault();
.chunkStorageProvider = IChunkStorageProvider.CODEC.getDefault();
.chunkConfig = ();
.isTicking = ;
.isBlockTicking = ;
.isPvpEnabled = ;
.isFallDamageEnabled = ;
.isGameTimePaused = ;
.gameTime = WorldTimeResource.ZERO_YEAR.plus( , ChronoUnit.HOURS).plus( , ChronoUnit.MINUTES);
.clientEffects = ();
.requiredPlugins = Collections.emptyMap();
.isSpawningNPC = ;
.isSpawnMarkersEnabled = ;
.isAllNPCFrozen = ;
.gameplayConfig = ;
.deathConfigOverride = ;
.daytimeDurationSecondsOverride = ;
.nighttimeDurationSecondsOverride = ;
.isCompassUpdating = ;
.isSavingPlayers = ;
.canSaveChunks = ;
.saveNewChunks = ;
.canUnloadChunks = ;
.isObjectiveMarkersEnabled = ;
.deleteOnUniverseStart = ;
.deleteOnRemove = ;
.resourceStorageProvider = IResourceStorageProvider.CODEC.getDefault();
.pluginConfig = .TypeMap<Object>(PLUGIN_CODEC);
.isSavingConfig = ;
}
UUID {
.uuid;
}
{
.uuid = uuid;
}
{
.deleteOnUniverseStart;
}
{
.deleteOnUniverseStart = deleteOnUniverseStart;
}
{
.deleteOnRemove;
}
{
.deleteOnRemove = deleteOnRemove;
}
{
.isSavingConfig;
}
{
.isSavingConfig = savingConfig;
}
String {
.displayName;
}
{
.displayName = name;
}
String {
name.replaceAll( , ).replaceAll( , ).replaceAll( , );
}
{
.seed;
}
{
.seed = seed;
}
ISpawnProvider {
.spawnProvider != ? .spawnProvider : .defaultSpawnProvider;
}
{
.spawnProvider = spawnProvider;
}
{
.defaultSpawnProvider = generator.getDefaultSpawnProvider(( ) .seed);
}
IWorldGenProvider {
.worldGenProvider;
}
{
.worldGenProvider = worldGenProvider;
}
IWorldMapProvider {
.worldMapProvider;
}
{
.worldMapProvider = worldMapProvider;
}
IChunkStorageProvider {
.chunkStorageProvider;
}
{
.chunkStorageProvider = chunkStorageProvider;
}
ChunkConfig {
.chunkConfig;
}
{
.chunkConfig = chunkConfig;
}
{
.isTicking;
}
{
.isTicking = ticking;
}
{
.isBlockTicking;
}
{
.isBlockTicking = ticking;
}
{
.isPvpEnabled;
}
{
.isFallDamageEnabled;
}
{
.isPvpEnabled = pvpEnabled;
}
{
.isGameTimePaused;
}
{
.isGameTimePaused = gameTimePaused;
}
Instant {
.gameTime;
}
{
.gameTime = gameTime;
}
String {
.forcedWeather;
}
{
.forcedWeather = forcedWeather;
}
{
.clientEffects = clientEffects;
}
ClientEffectWorldSettings {
.clientEffects;
}
Map<PluginIdentifier, SemverRange> {
Collections.unmodifiableMap( .requiredPlugins);
}
{
.requiredPlugins = requiredPlugins;
}
GameMode {
.gameMode != ? .gameMode : HytaleServer.get().getConfig().getDefaults().getGameMode();
}
{
.gameMode = gameMode;
}
{
.isSpawningNPC;
}
{
.isSpawningNPC = spawningNPC;
}
{
.isSpawnMarkersEnabled;
}
{
.isSpawnMarkersEnabled = spawnMarkersEnabled;
}
{
.isAllNPCFrozen;
}
{
.isAllNPCFrozen = allNPCFrozen;
}
String {
.gameplayConfig;
}
{
.gameplayConfig = gameplayConfig;
}
DeathConfig {
.deathConfigOverride;
}
Integer {
.daytimeDurationSecondsOverride;
}
Integer {
.nighttimeDurationSecondsOverride;
}
{
.isCompassUpdating;
}
{
.isCompassUpdating = compassUpdating;
}
{
.isSavingPlayers;
}
{
.isSavingPlayers = savingPlayers;
}
{
.canUnloadChunks;
}
{
.canUnloadChunks = unloadingChunks;
}
{
.canSaveChunks;
}
{
.canSaveChunks = savingChunks;
}
{
.saveNewChunks;
}
{
.saveNewChunks = saveNewChunks;
}
{
.isObjectiveMarkersEnabled;
}
{
.isObjectiveMarkersEnabled = objectiveMarkersEnabled;
}
IResourceStorageProvider {
.resourceStorageProvider;
}
{
.resourceStorageProvider = resourceStorageProvider;
}
MapKeyMapCodec.TypeMap<Object> {
.pluginConfig;
}
{
.hasChanged.set( );
}
{
.hasChanged.getAndSet( );
}
CompletableFuture<WorldConfig> {
CompletableFuture.supplyAsync(() -> {
(WorldConfig)RawJsonReader.readSyncWithBak(path, CODEC, HytaleLogger.getLogger());
config != ? config : ();
});
}
CompletableFuture<Void> {
CODEC.encode(worldConfig, (ExtraInfo)ExtraInfo.THREAD_LOCAL.get());
BsonUtil.writeDocument(path, document);
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(WorldConfig.class, () -> ((Void) )).versioned()).codecVersion( )).documentation( )).append( ( , Codec.UUID_BINARY), (o, s) -> o.uuid = s, (o) -> o.uuid).documentation( ).add()).append( ( , Codec.STRING), (o, s) -> o.displayName = s, (o) -> o.displayName).documentation( ).add()).append( ( , Codec.LONG), (o, i) -> o.seed = i, (o) -> o.seed).documentation( ).metadata(NoDefaultValue.INSTANCE).add()).append( ( , Transform.CODEC), (o, s) -> o.spawnProvider = (s), (o) -> ).documentation( ).setVersionRange( , ).add()).append( ( , ISpawnProvider.CODEC), (o, s) -> o.spawnProvider = s, (o) -> o.spawnProvider).documentation( ).add()).append( ( , IWorldGenProvider.CODEC), (o, i) -> o.worldGenProvider = i, (o) -> o.worldGenProvider).documentation( ).add()).append( ( , IWorldMapProvider.CODEC), (o, i) -> o.worldMapProvider = i, (o) -> o.worldMapProvider).add()).append( ( , IChunkStorageProvider.CODEC), (o, i) -> o.chunkStorageProvider = i, (o) -> o.chunkStorageProvider).documentation( ).add()).append( ( , WorldConfig.ChunkConfig.CODEC), (o, i) -> o.chunkConfig = i, (o) -> o.chunkConfig).documentation( ).addValidator(Validators.nonNull()).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isTicking = i, (o) -> o.isTicking).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isBlockTicking = i, (o) -> o.isBlockTicking).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isPvpEnabled = i, (o) -> o.isPvpEnabled).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isFallDamageEnabled = i, (o) -> o.isFallDamageEnabled).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isGameTimePaused = i, (o) -> o.isGameTimePaused).documentation( ).add()).append( ( , Codec.INSTANT), (o, i) -> o.gameTime = i, (o) -> o.gameTime).documentation( ).add()).append( ( , Codec.STRING), (o, i) -> o.forcedWeather = i, (o) -> o.forcedWeather).documentation( ).addValidator(Weather.VALIDATOR_CACHE.getValidator()).add()).append( ( , ClientEffectWorldSettings.CODEC), (o, i) -> o.clientEffects = i, (o) -> o.clientEffects).documentation( ).add()).append( ( , ShapeCodecs.BOX), (o, i) -> o.chunkConfig.setPregenerateRegion( ( (i.min.x, i.min.z), (i.max.x, i.max.z))), (o) -> ).setVersionRange( , ).addValidator(Validators.deprecated()).add()).append( ( , (SemverRange.CODEC, HashMap:: , PluginIdentifier::toString, PluginIdentifier::fromString, )), (o, i) -> o.requiredPlugins = i, (o) -> o.requiredPlugins).documentation( ).add()).append( ( , ProtocolCodecs.GAMEMODE), (o, i) -> o.gameMode = i, (o) -> o.gameMode).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isSpawningNPC = i, (o) -> o.isSpawningNPC).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isSpawnMarkersEnabled = i, (o) -> o.isSpawnMarkersEnabled).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isAllNPCFrozen = i, (o) -> o.isAllNPCFrozen).documentation( ).add()).append( ( , Codec.STRING), (o, i) -> o.gameplayConfig = i, (o) -> o.gameplayConfig).addValidator(GameplayConfig.VALIDATOR_CACHE.getValidator()).documentation( ).add()).append( ( , DeathConfig.CODEC), (o, i) -> o.deathConfigOverride = i, (o) -> o.deathConfigOverride).documentation( ).add()).append( ( , Codec.INTEGER), (o, i) -> o.daytimeDurationSecondsOverride = i, (o) -> o.daytimeDurationSecondsOverride).documentation( ).add()).append( ( , Codec.INTEGER), (o, i) -> o.nighttimeDurationSecondsOverride = i, (o) -> o.nighttimeDurationSecondsOverride).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isCompassUpdating = i, (o) -> o.isCompassUpdating).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isSavingPlayers = i, (o) -> o.isSavingPlayers).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.canSaveChunks = i, (o) -> o.canSaveChunks).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.saveNewChunks = i, (o) -> o.saveNewChunks).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.canUnloadChunks = i, (o) -> o.canUnloadChunks).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.isObjectiveMarkersEnabled = i, (o) -> o.isObjectiveMarkersEnabled).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.deleteOnUniverseStart = i, (o) -> o.deleteOnUniverseStart).documentation( ).add()).append( ( , Codec.BOOLEAN), (o, i) -> o.deleteOnRemove = i, (o) -> o.deleteOnRemove).documentation( ).add()).append( ( , Codec.BSON_DOCUMENT), (o, i, e) -> o.pluginConfig.put(PLUGIN_CODEC.getKeyForId( ), PLUGIN_CODEC.decodeById( , i, e)), (o, e) -> ).setVersionRange( , ).documentation( ).addValidator(Validators.deprecated()).add()).append( ( , IResourceStorageProvider.CODEC), (o, i) -> o.resourceStorageProvider = i, (o) -> o.resourceStorageProvider).documentation( ).add()).appendInherited( ( , PLUGIN_CODEC), (o, i) -> {
(o.pluginConfig.isEmpty()) {
o.pluginConfig = i;
} {
MapKeyMapCodec.TypeMap<Object> temp = o.pluginConfig;
o.pluginConfig.putAll(temp);
o.pluginConfig.putAll(i);
}
}, (o) -> o.pluginConfig, (o, p) -> o.pluginConfig = p.pluginConfig).addValidator(Validators.nonNull()).add()).build();
}
{
BuilderCodec<ChunkConfig> CODEC;
Box2D DEFAULT_PREGENERATE_REGION;
Box2D pregenerateRegion;
Box2D keepLoadedRegion;
{
}
Box2D {
.pregenerateRegion;
}
{
(pregenerateRegion != ) {
pregenerateRegion.normalize();
}
.pregenerateRegion = pregenerateRegion;
}
Box2D {
.keepLoadedRegion;
}
{
(keepLoadedRegion != ) {
keepLoadedRegion.normalize();
}
.keepLoadedRegion = keepLoadedRegion;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ChunkConfig.class, ChunkConfig:: ).appendInherited( ( , Box2D.CODEC), (o, i) -> o.pregenerateRegion = i, (o) -> o.pregenerateRegion, (o, p) -> o.pregenerateRegion = p.pregenerateRegion).documentation( ).add()).appendInherited( ( , Box2D.CODEC), (o, i) -> o.keepLoadedRegion = i, (o) -> o.keepLoadedRegion, (o, p) -> o.keepLoadedRegion = p.keepLoadedRegion).documentation( ).add()).afterDecode((o) -> {
(o.pregenerateRegion != ) {
o.pregenerateRegion.normalize();
}
(o.keepLoadedRegion != ) {
o.keepLoadedRegion.normalize();
}
})).build();
DEFAULT_PREGENERATE_REGION = ( (- , - ), ( , ));
}
}
}
com/hypixel/hytale/server/core/universe/world/WorldConfigProvider.java
package com.hypixel.hytale.server.core.universe.world;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public interface WorldConfigProvider {
@Nonnull
default CompletableFuture<WorldConfig> load (@Nonnull Path savePath, String name) {
Path oldPath = savePath.resolve("config.bson" );
Path path = savePath.resolve("config.json" );
if (Files.exists(oldPath, new LinkOption [0 ]) && !Files.exists(path, new LinkOption [0 ])) {
try {
Files.move(oldPath, path);
} catch (IOException var6) {
}
}
return WorldConfig.load(path);
}
@Nonnull
default CompletableFuture<Void> save (@Nonnull Path savePath, WorldConfig config, World world) {
return WorldConfig.save(savePath.resolve("config.json" ), config);
}
public static class {
{
}
}
}
com/hypixel/hytale/server/core/universe/world/WorldMapTracker.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.common.fastutil.HLongOpenHashSet;
import com.hypixel.hytale.common.fastutil.HLongSet;
import com.hypixel.hytale.common.thread.ticking.Tickable;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.function.function.TriFunction;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.iterator.CircleSpiralIterator;
import com.hypixel.hytale.math.shape.Box2D;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector2d;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.protocol.Position;
import com.hypixel.hytale.protocol.SoundCategory;
import com.hypixel.hytale.protocol.packets.worldmap.ClearWorldMap;
import com.hypixel.hytale.protocol.packets.worldmap.MapChunk;
import com.hypixel.hytale.protocol.packets.worldmap.MapImage;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.protocol.packets.worldmap.UpdateWorldMap;
import com.hypixel.hytale.protocol.packets.worldmap.UpdateWorldMapSettings;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
import com.hypixel.hytale.server.core.entity.entities.Player;
com.hypixel.hytale.server.core.event.events.ecs.DiscoverZoneEvent;
com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
com.hypixel.hytale.server.core.universe.PlayerRef;
com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapSettings;
com.hypixel.hytale.server.core.util.EventTitleUtil;
it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
it.unimi.dsi.fastutil.longs.LongIterator;
it.unimi.dsi.fastutil.longs.LongSet;
it.unimi.dsi.fastutil.objects.ObjectArrayList;
java.util.HashSet;
java.util.List;
java.util.Map;
java.util.Set;
java.util.concurrent.CompletableFuture;
java.util.concurrent.ConcurrentHashMap;
java.util.concurrent.locks.ReentrantReadWriteLock;
java.util.function.Predicate;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
HytaleLogger.forEnclosingClass();
;
;
;
;
;
;
;
;
Player player;
();
();
();
();
Long2ObjectOpenHashMap<CompletableFuture<MapImage>> pendingReloadFutures = <CompletableFuture<MapImage>>();
Map<String, MapMarker> sentMarkers = ();
updateTimer;
playerMarkersUpdateTimer;
Integer viewRadiusOverride;
started;
sentViewRadius;
lastChunkX;
lastChunkZ;
String currentBiomeName;
ZoneDiscoveryInfo currentZone;
;
;
clientHasWorldMapVisible;
Predicate<PlayerRef> playerMapFilter;
Set<String> tempToRemove = ();
Set<MapMarker> tempToAdd = ();
Set<String> tempTestedMarkers = ();
TransformComponent transformComponent;
{
.player = player;
}
{
(! .started) {
.started = ;
LOGGER.at(Level.INFO).log( );
}
.player.getWorld();
(world != ) {
( .transformComponent == ) {
.transformComponent = .player.getTransformComponent();
( .transformComponent == ) {
;
}
}
world.getWorldMapManager();
worldMapManager.getWorldMapSettings();
viewRadius;
( .viewRadiusOverride != ) {
viewRadius = .viewRadiusOverride;
} {
viewRadius = worldMapSettings.getViewRadius( .player.getViewRadius());
}
.transformComponent.getPosition();
MathUtil.floor(position.getX());
MathUtil.floor(position.getZ());
playerX >> ;
playerZ >> ;
(world.isCompassUpdating()) {
.playerMarkersUpdateTimer -= dt;
.updatePointsOfInterest(world, viewRadius, playerChunkX, playerChunkZ);
}
(worldMapManager.isWorldMapEnabled()) {
.updateWorldMap(world, dt, worldMapSettings, viewRadius, playerChunkX, playerChunkZ);
}
}
}
{
.currentBiomeName = biomeName;
.currentZone = zoneDiscoveryInfo;
(Player)componentAccessor.getComponent(ref, Player.getComponentType());
playerComponent != ;
(!playerComponent.isWaitingForClientReady()) {
((EntityStore)componentAccessor.getExternalData()).getWorld();
(zoneDiscoveryInfo != && .discoverZone(world, zoneDiscoveryInfo.regionName())) {
.onZoneDiscovered(ref, zoneDiscoveryInfo, componentAccessor);
}
}
}
{
zoneDiscoveryInfo.clone();
DiscoverZoneEvent. .Display(discoverZoneEventInfo);
componentAccessor.invoke(ref, discoverZoneEvent);
(!discoverZoneEvent.isCancelled() && discoverZoneEventInfo.display()) {
(PlayerRef)componentAccessor.getComponent(ref, PlayerRef.getComponentType());
playerRefComponent != ;
EventTitleUtil.showEventTitleToPlayer(playerRefComponent, Message.translation(String.format( , discoverZoneEventInfo.regionName())), Message.translation(String.format( , discoverZoneEventInfo.zoneName())), discoverZoneEventInfo.major(), discoverZoneEventInfo.icon(), discoverZoneEventInfo.duration(), discoverZoneEventInfo.fadeInDuration(), discoverZoneEventInfo.fadeOutDuration());
discoverZoneEventInfo.discoverySoundEventId();
(discoverySoundEventId != ) {
SoundEvent.getAssetMap().getIndex(discoverySoundEventId);
(assetIndex != - ) {
SoundUtil.playSoundEvent2d(ref, assetIndex, SoundCategory.UI, componentAccessor);
}
}
}
}
{
.processPendingReloadChunks(world);
worldMapSettings.getWorldMapArea();
(worldMapArea == ) {
Math.abs( .lastChunkX - playerChunkX);
Math.abs( .lastChunkZ - playerChunkZ);
xDiff <= && zDiff <= ? : ( )Math.ceil(Math.sqrt(( )(xDiff * xDiff + zDiff * zDiff)));
.sentViewRadius = Math.max( , .sentViewRadius - chunkMoveDistance);
.lastChunkX = playerChunkX;
.lastChunkZ = playerChunkZ;
.updateTimer -= dt;
( .updateTimer > ) {
;
}
( .sentViewRadius != chunkViewRadius) {
( .sentViewRadius > chunkViewRadius) {
.sentViewRadius = chunkViewRadius;
}
.unloadImages(chunkViewRadius, playerChunkX, playerChunkZ);
( .sentViewRadius < chunkViewRadius) {
.loadImages(world, chunkViewRadius, playerChunkX, playerChunkZ, );
}
} {
.updateTimer = ;
}
} {
.updateTimer -= dt;
( .updateTimer > ) {
;
}
.loadWorldMap(world, worldMapArea, );
}
}
{
( .transformComponent != ) {
world.getWorldMapManager();
Map<String, WorldMapManager.MarkerProvider> markerProviders = worldMapManager.getMarkerProviders();
.tempToAdd.clear();
.tempTestedMarkers.clear();
(WorldMapManager.MarkerProvider provider : markerProviders.values()) {
provider.update(world, world.getGameplayConfig(), , chunkViewRadius, playerChunkX, playerChunkZ);
}
.tempToRemove.clear();
.tempToRemove.addAll( .sentMarkers.keySet());
(! .tempTestedMarkers.isEmpty()) {
.tempToRemove.removeAll( .tempTestedMarkers);
}
(String removedMarkerId : .tempToRemove) {
.sentMarkers.remove(removedMarkerId);
}
(! .tempToAdd.isEmpty() || ! .tempToRemove.isEmpty()) {
MapMarker[] addedMarkers = ! .tempToAdd.isEmpty() ? (MapMarker[]) .tempToAdd.toArray((x$ ) -> [x$ ]) : ;
String[] removedMarkers = ! .tempToRemove.isEmpty() ? (String[]) .tempToRemove.toArray((x$ ) -> [x$ ]) : ;
.player.getPlayerConnection().writeNoCache( ((MapChunk[]) , addedMarkers, removedMarkers));
}
}
}
{
.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, marker.transform.position.x, marker.transform.position.z, marker.transform.orientation.yaw, marker.id, marker.name, marker, (id, name, m) -> m);
}
<T> {
.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, markerPos.x, markerPos.z, markerYaw, markerId, markerDisplayName, param, markerSupplier);
}
<T> {
MathUtil.floor(markerX);
MathUtil.floor(markerZ);
chunkViewRadius == - || shouldBeVisible(chunkViewRadius, markerXBlock >> , markerZBlock >> , playerChunkX, playerChunkZ);
(shouldBeVisible) {
.tempTestedMarkers.add(markerId);
;
(MapMarker) .sentMarkers.get(markerId);
(oldMarker != ) {
(!markerName.equals(oldMarker.name)) {
needsUpdate = ;
}
(!needsUpdate) {
( )Math.abs(oldMarker.transform.orientation.yaw - markerYaw);
needsUpdate = distance > || .playerMarkersUpdateTimer < && distance > ;
}
(!needsUpdate) {
oldMarker.transform.position;
Vector2d.distance(oldPosition.x, oldPosition.z, markerX, markerZ);
needsUpdate = distance > || .playerMarkersUpdateTimer < && distance > ;
}
} {
needsUpdate = ;
}
(needsUpdate) {
markerSupplier.apply(markerId, markerName, param);
.sentMarkers.put(markerId, marker);
.tempToAdd.add(marker);
}
}
}
{
List<MapChunk> currentUnloadList = ;
List<List<MapChunk>> allUnloadLists = ;
.loadedLock.writeLock().lock();
{
;
.loaded.iterator();
(iterator.hasNext()) {
iterator.nextLong();
ChunkUtil.xOfChunkIndex(chunkCoordinates);
ChunkUtil.zOfChunkIndex(chunkCoordinates);
(!shouldBeVisible(chunkViewRadius, playerChunkX, playerChunkZ, mapChunkX, mapChunkZ)) {
(currentUnloadList == ) {
currentUnloadList = <MapChunk>(packetSize / );
}
currentUnloadList.add( (mapChunkX, mapChunkZ, (MapImage) ));
packetSize -= ;
iterator.remove();
(packetSize < ) {
packetSize = ;
(allUnloadLists == ) {
allUnloadLists = <List<MapChunk>>( .loaded.size() / (packetSize / ));
}
allUnloadLists.add(currentUnloadList);
currentUnloadList = <MapChunk>(packetSize / );
}
}
}
(allUnloadLists != ) {
(List<MapChunk> unloadList : allUnloadLists) {
.writeUpdatePacket(unloadList);
}
}
.writeUpdatePacket(currentUnloadList);
} {
.loadedLock.writeLock().unlock();
}
}
{
List<MapChunk> chunksToSend = ;
.loadedLock.writeLock().lock();
{
(! .pendingReloadChunks.isEmpty()) {
MathUtil.fastFloor( * world.getWorldMapManager().getWorldMapSettings().getImageScale());
+ * imageSize * imageSize;
;
.pendingReloadChunks.iterator();
(iterator.hasNext()) {
iterator.nextLong();
CompletableFuture<MapImage> future = .pendingReloadFutures.get(chunkCoordinates);
(future == ) {
future = world.getWorldMapManager().getImageAsync(chunkCoordinates);
.pendingReloadFutures.put(chunkCoordinates, future);
}
(future.isDone()) {
iterator.remove();
.pendingReloadFutures.remove(chunkCoordinates);
(chunksToSend == ) {
chunksToSend = <MapChunk>(packetSize / fullMapChunkSize);
}
ChunkUtil.xOfChunkIndex(chunkCoordinates);
ChunkUtil.zOfChunkIndex(chunkCoordinates);
chunksToSend.add( (mapChunkX, mapChunkZ, (MapImage)future.getNow((Object) )));
.loaded.add(chunkCoordinates);
packetSize -= fullMapChunkSize;
(packetSize < fullMapChunkSize) {
.writeUpdatePacket(chunksToSend);
chunksToSend = <MapChunk>( - / fullMapChunkSize);
packetSize = ;
}
}
}
.writeUpdatePacket(chunksToSend);
;
}
} {
.loadedLock.writeLock().unlock();
}
}
{
List<MapChunk> currentLoadList = ;
List<List<MapChunk>> allLoadLists = ;
.loadedLock.writeLock().lock();
{
;
MathUtil.fastFloor( * world.getWorldMapManager().getWorldMapSettings().getImageScale());
+ * imageSize * imageSize;
;
.spiralIterator.init(playerChunkX, playerChunkZ, .sentViewRadius, chunkViewRadius);
(maxGeneration > && .spiralIterator.hasNext()) {
.spiralIterator.next();
(! .loaded.contains(chunkCoordinates)) {
areAllLoaded = ;
CompletableFuture<MapImage> future = world.getWorldMapManager().getImageAsync(chunkCoordinates);
(!future.isDone()) {
--maxGeneration;
} ( .loaded.add(chunkCoordinates)) {
(currentLoadList == ) {
currentLoadList = <MapChunk>(packetSize / fullMapChunkSize);
}
ChunkUtil.xOfChunkIndex(chunkCoordinates);
ChunkUtil.zOfChunkIndex(chunkCoordinates);
currentLoadList.add( (mapChunkX, mapChunkZ, (MapImage)future.getNow((Object) )));
packetSize -= fullMapChunkSize;
(packetSize < fullMapChunkSize) {
packetSize = ;
(allLoadLists == ) {
allLoadLists = <List<MapChunk>>();
}
allLoadLists.add(currentLoadList);
currentLoadList = <MapChunk>(packetSize / fullMapChunkSize);
}
}
} (areAllLoaded) {
.sentViewRadius = .spiralIterator.getCompletedRadius();
}
}
(areAllLoaded) {
.sentViewRadius = .spiralIterator.getCompletedRadius();
}
(allLoadLists != ) {
(List<MapChunk> unloadList : allLoadLists) {
.writeUpdatePacket(unloadList);
}
}
.writeUpdatePacket(currentLoadList);
} {
.loadedLock.writeLock().unlock();
}
maxGeneration;
}
{
List<MapChunk> currentLoadList = ;
List<List<MapChunk>> allLoadLists = ;
.loadedLock.writeLock().lock();
{
;
MathUtil.fastFloor( * world.getWorldMapManager().getWorldMapSettings().getImageScale());
+ * imageSize * imageSize;
( MathUtil.floor(worldMapArea.min.x); mapChunkX < MathUtil.ceil(worldMapArea.max.x) && maxGeneration > ; ++mapChunkX) {
( MathUtil.floor(worldMapArea.min.y); mapChunkZ < MathUtil.ceil(worldMapArea.max.y) && maxGeneration > ; ++mapChunkZ) {
ChunkUtil.indexChunk(mapChunkX, mapChunkZ);
(! .loaded.contains(chunkCoordinates)) {
CompletableFuture<MapImage> future = CompletableFutureUtil.<MapImage>_catch(world.getWorldMapManager().getImageAsync(chunkCoordinates));
(!future.isDone()) {
--maxGeneration;
} {
(currentLoadList == ) {
currentLoadList = <MapChunk>(packetSize / fullMapChunkSize);
}
currentLoadList.add( (mapChunkX, mapChunkZ, (MapImage)future.getNow((Object) )));
.loaded.add(chunkCoordinates);
packetSize -= fullMapChunkSize;
(packetSize < fullMapChunkSize) {
packetSize = ;
(allLoadLists == ) {
allLoadLists = <List<MapChunk>>(Math.max(packetSize / fullMapChunkSize, ));
}
allLoadLists.add(currentLoadList);
currentLoadList = <MapChunk>(packetSize / fullMapChunkSize);
}
}
}
}
}
} {
.loadedLock.writeLock().unlock();
}
(allLoadLists != ) {
(List<MapChunk> unloadList : allLoadLists) {
.writeUpdatePacket(unloadList);
}
}
.writeUpdatePacket(currentLoadList);
maxGeneration;
}
{
(list != ) {
((MapChunk[])list.toArray((x$ ) -> [x$ ]), (MapMarker[]) , (String[]) );
LOGGER.at(Level.FINE).log( , .player.getUuid(), list.size());
.player.getPlayerConnection().write((Packet)packet);
}
}
Map<String, MapMarker> {
.sentMarkers;
}
Player {
.player;
}
{
.loadedLock.writeLock().lock();
{
.loaded.clear();
.sentViewRadius = ;
.sentMarkers.clear();
} {
.loadedLock.writeLock().unlock();
}
.player.getPlayerConnection().write((Packet)( ()));
}
{
.loadedLock.writeLock().lock();
{
chunkIndices.forEach((index) -> {
.loaded.remove(index);
.pendingReloadChunks.add(index);
.pendingReloadFutures.remove(index);
});
} {
.loadedLock.writeLock().unlock();
}
.updateTimer = ;
}
{
(world.getWorldMapManager().getWorldMapSettings().getSettingsPacket());
world.execute(() -> {
Store<EntityStore> store = world.getEntityStore().getStore();
Ref<EntityStore> ref = .player.getReference();
(ref != ) {
(Player)store.getComponent(ref, Player.getComponentType());
playerComponent != ;
(PlayerRef)store.getComponent(ref, PlayerRef.getComponentType());
playerRefComponent != ;
worldMapSettingsPacket.allowTeleportToCoordinates = .allowTeleportToCoordinates && playerComponent.getGameMode() != GameMode.Adventure;
worldMapSettingsPacket.allowTeleportToMarkers = .allowTeleportToMarkers && playerComponent.getGameMode() != GameMode.Adventure;
playerRefComponent.getPacketHandler().write((Packet)worldMapSettingsPacket);
}
});
}
{
.player.getPlayerConfigData().getDiscoveredZones().contains(zoneName);
}
{
Set<String> discoveredZones = .player.getPlayerConfigData().getDiscoveredZones();
(!discoveredZones.contains(zoneName)) {
discoveredZones = (discoveredZones);
discoveredZones.add(zoneName);
.player.getPlayerConfigData().setDiscoveredZones(discoveredZones);
.sendSettings(world);
;
} {
;
}
}
{
Set<String> discoveredZones = .player.getPlayerConfigData().getDiscoveredZones();
(discoveredZones.contains(zoneName)) {
discoveredZones = (discoveredZones);
discoveredZones.remove(zoneName);
.player.getPlayerConfigData().setDiscoveredZones(discoveredZones);
.sendSettings(world);
;
} {
;
}
}
{
Set<String> discoveredZones = .player.getPlayerConfigData().getDiscoveredZones();
(!discoveredZones.containsAll(zoneNames)) {
discoveredZones = (discoveredZones);
discoveredZones.addAll(zoneNames);
.player.getPlayerConfigData().setDiscoveredZones(discoveredZones);
.sendSettings(world);
;
} {
;
}
}
{
Set<String> discoveredZones = .player.getPlayerConfigData().getDiscoveredZones();
(discoveredZones.containsAll(zoneNames)) {
discoveredZones = (discoveredZones);
discoveredZones.removeAll(zoneNames);
.player.getPlayerConfigData().setDiscoveredZones(discoveredZones);
.sendSettings(world);
;
} {
;
}
}
{
.allowTeleportToCoordinates;
}
{
.allowTeleportToCoordinates = allowTeleportToCoordinates;
.sendSettings(world);
}
{
.allowTeleportToMarkers;
}
{
.allowTeleportToMarkers = allowTeleportToMarkers;
.sendSettings(world);
}
Predicate<PlayerRef> {
.playerMapFilter;
}
{
.playerMapFilter = playerMapFilter;
}
{
.clientHasWorldMapVisible = visible;
}
{
.clientHasWorldMapVisible || .playerMarkersUpdateTimer < ;
}
{
.playerMarkersUpdateTimer = ;
}
Integer {
.viewRadiusOverride;
}
String {
.currentBiomeName;
}
ZoneDiscoveryInfo {
.currentZone;
}
{
.viewRadiusOverride = viewRadiusOverride;
.clear();
}
{
.viewRadiusOverride != ? .viewRadiusOverride : world.getWorldMapManager().getWorldMapSettings().getViewRadius( .player.getViewRadius());
}
{
( .player != && .transformComponent != ) {
.transformComponent.getPosition();
MathUtil.floor(position.getX()) >> ;
MathUtil.floor(position.getZ()) >> ;
ChunkUtil.xOfChunkIndex(chunkCoordinates);
ChunkUtil.zOfChunkIndex(chunkCoordinates);
shouldBeVisible(chunkViewRadius, chunkX, chunkZ, x, z);
} {
;
}
}
{
.loadedLock.writeLock().lock();
{
worldMapTracker.loadedLock.readLock().lock();
{
.loaded.addAll(worldMapTracker.loaded);
(Map.Entry<String, MapMarker> entry : worldMapTracker.sentMarkers.entrySet()) {
.sentMarkers.put((String)entry.getKey(), ((MapMarker)entry.getValue()));
}
} {
worldMapTracker.loadedLock.readLock().unlock();
}
} {
.loadedLock.writeLock().unlock();
}
}
{
Math.abs(x - chunkX);
Math.abs(z - chunkZ);
xDiff * xDiff + zDiff * zDiff;
distanceSq <= chunkViewRadius * chunkViewRadius;
}
{
ZoneDiscoveryInfo {
( .zoneName, .regionName, .display, .discoverySoundEventId, .icon, .major, .duration, .fadeInDuration, .fadeOutDuration);
}
}
}
com/hypixel/hytale/server/core/universe/world/WorldNotificationHandler.java
package com.hypixel.hytale.server.core.universe.world;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.protocol.BlockParticleEvent;
import com.hypixel.hytale.protocol.BlockPosition;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.protocol.Position;
import com.hypixel.hytale.protocol.packets.world.SpawnBlockParticleSystem;
import com.hypixel.hytale.protocol.packets.world.UpdateBlockDamage;
import com.hypixel.hytale.server.core.modules.entity.player.ChunkTracker;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.meta.BlockState;
import com.hypixel.hytale.server.core.universe.world.meta.state.SendableBlockState;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class WorldNotificationHandler {
@Nonnull
private final World world;
public WorldNotificationHandler (@Nonnull World world) {
this .world = world;
}
public void updateState (int x, int y, z, BlockState state, BlockState oldState) {
.updateState(x, y, z, state, oldState, (Predicate) );
}
{
(y >= && y < ) {
Consumer<List<Packet>> removeOldState;
Predicate<PlayerRef> canPlayerSeeOld;
label71: {
(oldState SendableBlockState) {
(SendableBlockState)oldState;
(state != oldState) {
Objects.requireNonNull(sendableBlockState);
removeOldState = sendableBlockState::unloadFrom;
Objects.requireNonNull(sendableBlockState);
canPlayerSeeOld = sendableBlockState::canPlayerSee;
label71;
}
}
removeOldState = ;
canPlayerSeeOld = ;
}
Predicate<PlayerRef> canPlayerSee;
Consumer<List<Packet>> updateBlockState;
(state SendableBlockState) {
(SendableBlockState)state;
Objects.requireNonNull(sendableBlockState);
updateBlockState = sendableBlockState::sendTo;
Objects.requireNonNull(sendableBlockState);
canPlayerSee = sendableBlockState::canPlayerSee;
} {
updateBlockState = ;
canPlayerSee = ;
}
(removeOldState != || updateBlockState != ) {
ChunkUtil.indexChunkFromBlock(x, z);
List<Packet> packets = <Packet>();
(PlayerRef playerRef : .world.getPlayerRefs()) {
playerRef.getChunkTracker();
(chunkTracker.isLoaded(indexChunk) && (skip == || !skip.test(playerRef))) {
(removeOldState != && canPlayerSeeOld.test(playerRef)) {
removeOldState.accept(packets);
}
(updateBlockState != && canPlayerSee.test(playerRef)) {
updateBlockState.accept(packets);
}
(Packet packet : packets) {
playerRef.getPacketHandler().write(packet);
}
packets.clear();
}
}
}
} {
( + x + + y + + z);
}
}
{
(PlayerRef playerRef : .world.getPlayerRefs()) {
playerRef.getChunkTracker().removeForReload(indexChunk);
}
}
{
.sendPacketIfChunkLoaded( .getBlockParticlePacket(x, y, z, id, particleType), MathUtil.floor(x), MathUtil.floor(z));
}
{
.sendPacketIfChunkLoaded(playerRef, .getBlockParticlePacket(x, y, z, id, particleType), MathUtil.floor(x), MathUtil.floor(z));
}
{
.sendPacketIfChunkLoaded( .getBlockDamagePacket(x, y, z, health, healthDelta), x, z);
}
{
.sendPacketIfChunkLoaded( .getBlockDamagePacket(x, y, z, health, healthDelta), x, z, filter);
}
{
ChunkUtil.indexChunkFromBlock(x, z);
.sendPacketIfChunkLoaded(packet, indexChunk);
}
{
(PlayerRef playerRef : .world.getPlayerRefs()) {
(playerRef.getChunkTracker().isLoaded(indexChunk)) {
playerRef.getPacketHandler().write(packet);
}
}
}
{
ChunkUtil.indexChunkFromBlock(x, z);
.sendPacketIfChunkLoaded(packet, indexChunk, filter);
}
{
(PlayerRef playerRef : .world.getPlayerRefs()) {
((filter == || filter.test(playerRef)) && playerRef.getChunkTracker().isLoaded(indexChunk)) {
playerRef.getPacketHandler().write(packet);
}
}
}
{
ChunkUtil.indexChunkFromBlock(x, z);
.sendPacketIfChunkLoaded(player, packet, indexChunk);
}
{
(playerRef.getChunkTracker().isLoaded(indexChunk)) {
playerRef.getPacketHandler().write(packet);
}
}
SpawnBlockParticleSystem {
(!(y < ) && !(y >= )) {
(id, particleType, (x, y, z));
} {
( + x + + y + + z);
}
}
UpdateBlockDamage {
(y >= && y < ) {
( (x, y, z), health, healthDelta);
} {
( + x + + y + + z);
}
}
}
com/hypixel/hytale/server/core/universe/world/WorldProvider.java
package com.hypixel.hytale.server.core.universe.world;
import javax.annotation.Nonnull;
public interface WorldProvider {
@Nonnull
World getWorld () ;
}
com/hypixel/hytale/server/core/universe/world/accessor/BlockAccessor.java
package com.hypixel.hytale.server.core.universe.world.accessor;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.function.predicate.TriIntPredicate;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.BlockMaterial;
import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.universe.world.meta.BlockState;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.util.FillerBlockUtil;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface BlockAccessor {
int getX () ;
int getZ () ;
ChunkAccessor getChunkAccessor () ;
int getBlock (int var1, int var2, int var3) ;
default int getBlock (@Nonnull Vector3i pos) {
.getBlock(pos.getX(), pos.getY(), pos.getZ());
}
;
{
.setBlock(x, y, z, id, blockType, , , );
}
{
.setBlock(x, y, z, (String)blockTypeKey, );
}
{
BlockType.getAssetMap().getIndex(blockTypeKey);
(index == - ) {
( + blockTypeKey);
} {
.setBlock(x, y, z, index, settings);
}
}
{
.setBlock(x, y, z, id, );
}
{
.setBlock(x, y, z, id, (BlockType)BlockType.getAssetMap().getAsset(id), , , settings);
}
{
.setBlock(x, y, z, (BlockType)blockType, );
}
{
blockType.getId();
BlockType.getAssetMap().getIndex(key);
(index == - ) {
( + key);
} {
.setBlock(x, y, z, index, blockType, , , settings);
}
}
{
((settings & ) == ) {
x -= FillerBlockUtil.unpackX(filler);
y -= FillerBlockUtil.unpackY(filler);
z -= FillerBlockUtil.unpackZ(filler);
}
.setBlock(x, y, z, , BlockType.EMPTY, , , settings);
}
{
.breakBlock(x, y, z, );
}
{
.breakBlock(x, y, z, , settings);
}
{
( .getX() << ) + (x & );
( .getZ() << ) + (z & );
FillerBlockUtil.testFillerBlocks(((BlockBoundingBoxes)BlockBoundingBoxes.getAssetMap().getAsset(blockTypeToTest.getHitboxTypeIndex())).get(rotation), (x1, y1, z1) -> {
worldX + x1;
y + y1;
worldZ + z1;
predicate.test(blockX, blockY, blockZ);
});
}
{
( .getX() << ) + (x & );
( .getZ() << ) + (z & );
.testBlocks(x, y, z, blockTypeToTest, rotation, (blockX, blockY, blockZ) -> {
ChunkUtil.isSameChunk(worldX, worldZ, blockX, blockZ);
block;
otherRotation;
filler;
(sameChunk) {
block = .getBlock(blockX, blockY, blockZ);
otherRotation = .getRotationIndex(blockX, blockY, blockZ);
filler = .getFiller(blockX, blockY, blockZ);
} {
.getChunkAccessor().getNonTickingChunk(ChunkUtil.indexChunkFromBlock(blockX, blockZ));
block = chunk.getBlock(blockX, blockY, blockZ);
otherRotation = chunk.getRotationIndex(blockX, blockY, blockZ);
filler = chunk.getFiller(blockX, blockY, blockZ);
}
predicate.test(blockX, blockY, blockZ, (BlockType)BlockType.getAssetMap().getAsset(block), otherRotation, filler);
});
}
{
.placeBlock(x, y, z, originalBlockTypeKey, RotationTuple.of(yaw, pitch, roll), settings, );
}
{
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
(BlockType)assetMap.getAsset(originalBlockTypeKey);
rotationTuple.index();
(validatePlacement && ! .testPlaceBlock(x, y, z, placedBlockType, rotationIndex)) {
;
} {
;
((settings & ) != ) {
setBlockSettings |= ;
}
.setBlock(x, y, z, assetMap.getIndex(originalBlockTypeKey), placedBlockType, rotationIndex, , setBlockSettings);
;
}
}
{
.placeBlock(x, y, z, blockTypeKey, yaw, pitch, roll, );
}
{
.testPlaceBlock(x, y, z, blockTypeToTest, rotationIndex, (x1, y1, z1, blockType, rotation, filler) -> );
}
{
.testBlockTypes(x, y, z, blockTypeToTest, rotationIndex, (blockX, blockY, blockZ, blockType, rotation, filler) -> {
(blockType == BlockType.EMPTY) {
;
} (blockType.getMaterial() == BlockMaterial.Empty) {
;
} {
filler != && blockType.isUnknown() ? : filter.test(blockX, blockY, blockZ, blockType, rotation, filler);
}
});
}
BlockType {
(BlockType)BlockType.getAssetMap().getAsset( .getBlock(x, y, z));
}
BlockType {
.getBlockType(block.getX(), block.getY(), block.getZ());
}
;
;
BlockState ;
Holder<ChunkStore> ;
;
{
.setState(x, y, z, state, );
}
{
.setBlockInteractionState(blockPosition.x, blockPosition.y, blockPosition.z, blockType, state, );
}
{
getCurrentInteractionState(blockType);
(force || currentState == || !currentState.equals(state)) {
blockType.getBlockForState(state);
(newState != ) {
;
.getRotationIndex(x, y, z);
.setBlock(x, y, z, BlockType.getAssetMap().getIndex(newState.getId()), newState, currentRotation, , );
}
}
}
String {
blockType.getState() != ? blockType.getStateForBlock(blockType) : ;
}
;
;
;
;
;
RotationTuple {
RotationTuple.get( .getRotationIndex(x, y, z));
}
}
com/hypixel/hytale/server/core/universe/world/accessor/ChunkAccessor.java
package com.hypixel.hytale.server.core.universe.world.accessor;
import com.hypixel.hytale.math.util.ChunkUtil;
@Deprecated
public interface ChunkAccessor <WorldChunk extends BlockAccessor > extends IChunkAccessorSync <WorldChunk> {
default int getFluidId (int x, int y, int z) {
WorldChunk chunk = this .getChunk(ChunkUtil.indexChunkFromBlock(x, z));
return chunk != null ? chunk.getFluidId(x, y, z) : 0 ;
}
default boolean performBlockUpdate (int x, int y, int z) {
return this .performBlockUpdate(x, y, z, true );
}
default boolean performBlockUpdate (int x, int y, int z, boolean allowPartialLoad) {
boolean success = true ;
for ( - ; ix < ; ++ix) {
x + ix;
( - ; iz < ; ++iz) {
z + iz;
allowPartialLoad ? .getNonTickingChunk(ChunkUtil.indexChunkFromBlock(wx, wz)) : .getChunkIfInMemory(ChunkUtil.indexChunkFromBlock(wx, wz));
(worldChunk == ) {
success = ;
} {
( - ; iy < ; ++iy) {
y + iy;
worldChunk.setTicking(wx, wy, wz, );
}
}
}
}
success;
}
}
com/hypixel/hytale/server/core/universe/world/accessor/EmptyBlockAccessor.java
package com.hypixel.hytale.server.core.universe.world.accessor;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.function.predicate.TriIntPredicate;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.universe.world.meta.BlockState;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import javax.annotation.Nullable;
public class EmptyBlockAccessor implements BlockAccessor {
public static final EmptyBlockAccessor INSTANCE = new EmptyBlockAccessor ();
public EmptyBlockAccessor () {
}
public int getX () {
throw new UnsupportedOperationException ("Empty block accessor doesn't have a position!" );
}
public int getZ () {
throw new UnsupportedOperationException ("Empty block accessor doesn't have a position!" );
}
public ChunkAccessor getChunkAccessor () {
throw ( );
}
{
;
}
{
;
}
{
;
}
{
;
}
{
;
}
{
;
}
{
;
}
{
;
}
{
;
}
BlockState {
;
}
Holder<ChunkStore> {
;
}
{
}
{
;
}
{
;
}
{
;
}
{
;
}
{
;
}
}
com/hypixel/hytale/server/core/universe/world/accessor/IChunkAccessorSync.java
package com.hypixel.hytale.server.core.universe.world.accessor;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.BlockPosition;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.universe.world.meta.BlockState;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.util.FillerBlockUtil;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@Deprecated
public interface IChunkAccessorSync <WorldChunk extends BlockAccessor > {
@Nullable
WorldChunk getChunkIfInMemory (long var1) ;
@Nullable
WorldChunk loadChunkIfInMemory (long var1) ;
@Nullable
WorldChunk getChunkIfLoaded (long var1) ;
@Nullable
WorldChunk getChunkIfNonTicking (long var1) ;
@Nullable
WorldChunk getChunk (long var1) ;
@Nullable
WorldChunk getNonTickingChunk ;
{
.getChunk(ChunkUtil.indexChunkFromBlock(pos.getX(), pos.getZ())).getBlock(pos.getX(), pos.getY(), pos.getZ());
}
{
.getChunk(ChunkUtil.indexChunkFromBlock(x, z)).getBlock(x, y, z);
}
BlockType {
.getBlockType(pos.getX(), pos.getY(), pos.getZ());
}
BlockType {
.getChunk(ChunkUtil.indexChunkFromBlock(x, z));
chunk.getBlock(x, y, z);
(BlockType)BlockType.getAssetMap().getAsset(blockId);
}
{
.setBlock(x, y, z, blockTypeKey, );
}
{
.getChunk(ChunkUtil.indexChunkFromBlock(x, z)).setBlock(x, y, z, blockTypeKey, settings);
}
{
.getChunk(ChunkUtil.indexChunkFromBlock(x, z)).breakBlock(x, y, z, settings);
}
{
.getChunk(ChunkUtil.indexChunkFromBlock(x, z)).testBlockTypes(x, y, z, blockTypeToTest, rotation, predicate);
}
{
.getChunk(ChunkUtil.indexChunkFromBlock(x, z)).testPlaceBlock(x, y, z, blockTypeToTest, rotation);
}
{
.getChunk(ChunkUtil.indexChunkFromBlock(x, z)).testPlaceBlock(x, y, z, blockTypeToTest, rotation, predicate);
}
BlockState {
.getChunk(ChunkUtil.indexChunkFromBlock(x, z));
(followFiller) {
chunk.getFiller(x, y, z);
(filler != ) {
x -= FillerBlockUtil.unpackX(filler);
y -= FillerBlockUtil.unpackY(filler);
z -= FillerBlockUtil.unpackZ(filler);
}
}
y >= && y < ? chunk.getState(x, y, z) : ;
}
Holder<ChunkStore> {
y >= && y < ? .getChunk(ChunkUtil.indexChunkFromBlock(x, z)).getBlockComponentHolder(x, y, z) : ;
}
{
.getChunk(ChunkUtil.indexChunkFromBlock(blockPosition.x, blockPosition.z)).setBlockInteractionState(blockPosition, blockType, state);
}
BlockPosition {
.getNonTickingChunk(ChunkUtil.indexChunkFromBlock(position.x, position.z));
chunk.getFiller(position.x, position.y, position.z);
filler != ? (position.x - FillerBlockUtil.unpackX(filler), position.y - FillerBlockUtil.unpackY(filler), position.z - FillerBlockUtil.unpackZ(filler)) : position;
}
{
.getChunk(ChunkUtil.indexChunkFromBlock(x, z)).getRotationIndex(x, y, z);
}
{
;
}
}
com/hypixel/hytale/server/core/universe/world/accessor/LocalCachedChunkAccessor.java
package com.hypixel.hytale.server.core.universe.world.accessor;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.server.core.universe.world.chunk.ChunkFlag;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class LocalCachedChunkAccessor implements OverridableChunkAccessor <WorldChunk> {
private final ChunkAccessor<WorldChunk> delegate;
private final int minX;
private final int minZ;
private final int length;
@Nonnull
private final WorldChunk[] chunks;
@Nonnull
public static LocalCachedChunkAccessor atWorldCoords (ChunkAccessor<WorldChunk> delegate, int centerX, int centerZ, int blockRadius) {
int chunkRadius = ChunkUtil.chunkCoordinate(blockRadius) + 1 ;
return atChunkCoords(delegate, ChunkUtil.chunkCoordinate(centerX), ChunkUtil.chunkCoordinate(centerZ), chunkRadius);
}
@Nonnull
public static LocalCachedChunkAccessor atChunkCoords {
(delegate, centerX, centerZ, chunkRadius);
}
LocalCachedChunkAccessor {
(delegate, chunk.getX(), chunk.getZ(), chunkRadius);
accessor.overwrite(chunk);
accessor;
}
{
.delegate = delegate;
.minX = centerX - radius;
.minZ = centerZ - radius;
.length = radius * + ;
.chunks = [ .length * .length];
}
ChunkAccessor {
.delegate;
}
{
.minX;
}
{
.minZ;
}
{
.length;
}
{
.minX + .length / ;
}
{
.minZ + .length / ;
}
{
( ; xOffset < .length; ++xOffset) {
( ; zOffset < .length; ++zOffset) {
xOffset * .length + zOffset;
.chunks[arrayIndex];
(chunk == ) {
.chunks[arrayIndex] = (WorldChunk) .delegate.getChunkIfInMemory(ChunkUtil.indexChunk( .minX + xOffset, .minZ + zOffset));
}
}
}
}
{
wc.getX();
wc.getZ();
x -= .minX;
z -= .minZ;
(x >= && x < .length && z >= && z < .length) {
x * .length + z;
.chunks[arrayIndex] = wc;
}
}
WorldChunk {
ChunkUtil.xOfChunkIndex(index);
ChunkUtil.zOfChunkIndex(index);
x -= .minX;
z -= .minZ;
(x >= && x < .length && z >= && z < .length) {
x * .length + z;
.chunks[arrayIndex];
chunk != ? chunk : ( .chunks[arrayIndex] = (WorldChunk) .delegate.getChunkIfInMemory(index));
} {
(WorldChunk) .delegate.getChunkIfInMemory(index);
}
}
WorldChunk {
x - .minX;
z - .minZ;
(xOffset >= && xOffset < .length && zOffset >= && zOffset < .length) {
xOffset * .length + zOffset;
.chunks[arrayIndex];
chunk != ? chunk : ( .chunks[arrayIndex] = (WorldChunk) .delegate.getChunkIfInMemory(ChunkUtil.indexChunk(x, z)));
} {
(WorldChunk) .delegate.getChunkIfInMemory(ChunkUtil.indexChunk(x, z));
}
}
WorldChunk {
ChunkUtil.xOfChunkIndex(index);
ChunkUtil.zOfChunkIndex(index);
x -= .minX;
z -= .minZ;
(x >= && x < .length && z >= && z < .length) {
x * .length + z;
.chunks[arrayIndex];
(chunk != ) {
chunk.setFlag(ChunkFlag.TICKING, );
chunk;
} {
.chunks[arrayIndex] = (WorldChunk) .delegate.loadChunkIfInMemory(index);
}
} {
(WorldChunk) .delegate.loadChunkIfInMemory(index);
}
}
WorldChunk {
ChunkUtil.xOfChunkIndex(index);
ChunkUtil.zOfChunkIndex(index);
x -= .minX;
z -= .minZ;
(x >= && x < .length && z >= && z < .length) {
x * .length + z;
.chunks[arrayIndex];
(chunk == ) {
chunk = .chunks[arrayIndex] = (WorldChunk) .delegate.getChunkIfInMemory(index);
}
chunk != && chunk.is(ChunkFlag.TICKING) ? chunk : ;
} {
(WorldChunk) .delegate.getChunkIfLoaded(index);
}
}
WorldChunk {
x - .minX;
z - .minZ;
(xOffset >= && xOffset < .length && zOffset >= && zOffset < .length) {
xOffset * .length + zOffset;
.chunks[arrayIndex];
(chunk == ) {
chunk = .chunks[arrayIndex] = (WorldChunk) .delegate.getChunkIfInMemory(ChunkUtil.indexChunk(x, z));
}
chunk != && chunk.is(ChunkFlag.TICKING) ? chunk : ;
} {
(WorldChunk) .delegate.getChunkIfLoaded(ChunkUtil.indexChunk(x, z));
}
}
WorldChunk {
ChunkUtil.xOfChunkIndex(index);
ChunkUtil.zOfChunkIndex(index);
x -= .minX;
z -= .minZ;
(x >= && x < .length && z >= && z < .length) {
x * .length + z;
.chunks[arrayIndex];
(chunk == ) {
chunk = .chunks[arrayIndex] = (WorldChunk) .delegate.getChunkIfInMemory(index);
}
chunk != && chunk.is(ChunkFlag.TICKING) ? : chunk;
} {
(WorldChunk) .delegate.getChunkIfNonTicking(index);
}
}
WorldChunk {
ChunkUtil.xOfChunkIndex(index);
ChunkUtil.zOfChunkIndex(index);
x -= .minX;
z -= .minZ;
(x >= && x < .length && z >= && z < .length) {
x * .length + z;
.chunks[arrayIndex];
chunk != ? chunk : ( .chunks[arrayIndex] = (WorldChunk) .delegate.getChunk(index));
} {
(WorldChunk) .delegate.getChunk(index);
}
}
WorldChunk {
ChunkUtil.xOfChunkIndex(index);
ChunkUtil.zOfChunkIndex(index);
x -= .minX;
z -= .minZ;
(x >= && x < .length && z >= && z < .length) {
x * .length + z;
.chunks[arrayIndex];
chunk != ? chunk : ( .chunks[arrayIndex] = (WorldChunk) .delegate.getNonTickingChunk(index));
} {
(WorldChunk) .delegate.getNonTickingChunk(index);
}
}
}
com/hypixel/hytale/server/core/universe/world/accessor/OverridableChunkAccessor.java
package com.hypixel.hytale.server.core.universe.world.accessor;
public interface OverridableChunkAccessor <X extends BlockAccessor > extends ChunkAccessor <X> {
void overwrite (X var1) ;
}
com/hypixel/hytale/server/core/universe/world/chunk/AbstractCachedAccessor.java
package com.hypixel.hytale.server.core.universe.world.chunk;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import java.util.Arrays;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class AbstractCachedAccessor {
protected ComponentAccessor<ChunkStore> commandBuffer;
private int minX;
private int minY;
private int minZ;
private int length;
private Ref<ChunkStore>[] chunks;
private Ref<ChunkStore>[] sections;
private Component<ChunkStore>[][] sectionComponents;
protected AbstractCachedAccessor (int numComponents) {
this .sectionComponents = new Component [numComponents][];
}
protected void init (ComponentAccessor<ChunkStore> commandBuffer, int cx, int cy, int cz, int radius) {
.commandBuffer = commandBuffer;
radius = ChunkUtil.chunkCoordinate(radius) + ;
.minX = cx - radius;
.minY = cy - radius;
.minZ = cz - radius;
.length = radius * + ;
.length * .length;
.length * .length * .length;
( .chunks != && .chunks.length >= size2d) {
Arrays.fill( .chunks, (Object) );
} {
.chunks = [size2d];
}
( ; i < .sectionComponents.length; ++i) {
Component<ChunkStore>[] sectionComps = .sectionComponents[i];
(sectionComps != && sectionComps.length >= size3d) {
Arrays.fill(sectionComps, (Object) );
} {
.sectionComponents[i] = [size3d];
}
}
( .sections != && .sections.length >= size3d) {
Arrays.fill( .sections, (Object) );
} {
.sections = [size3d];
}
}
{
cx - .minX;
cy - .minY;
cz - .minZ;
x + z * .length + y * .length * .length;
(index3d >= && index3d < .sections.length) {
.sections[index3d] = section;
}
}
{
cx - .minX;
cy - .minY;
cz - .minZ;
x + z * .length + y * .length * .length;
(index3d >= && index3d < .sectionComponents[index].length) {
.sectionComponents[index][index3d] = component;
}
}
Ref<ChunkStore> {
cx - .minX;
cz - .minZ;
x + z * .length;
(index >= && index < .chunks.length) {
Ref<ChunkStore> chunk = .chunks[index];
(chunk == ) {
.chunks[index] = chunk = ((ChunkStore) .commandBuffer.getExternalData()).getChunkReference(ChunkUtil.indexChunk(cx, cz));
}
chunk;
} {
((ChunkStore) .commandBuffer.getExternalData()).getChunkReference(ChunkUtil.indexChunk(cx, cz));
}
}
Ref<ChunkStore> {
(cy >= && cy < ) {
cx - .minX;
cy - .minY;
cz - .minZ;
x + z * .length + y * .length * .length;
(index >= && index < .sections.length) {
Ref<ChunkStore> section = .sections[index];
(section == ) {
.sections[index] = section = ((ChunkStore) .commandBuffer.getExternalData()).getChunkSectionReference( .commandBuffer, cx, cy, cz);
}
section;
} {
((ChunkStore) .commandBuffer.getExternalData()).getChunkSectionReference( .commandBuffer, cx, cy, cz);
}
} {
;
}
}
<T <ChunkStore>> T {
cx - .minX;
cy - .minY;
cz - .minZ;
x + z * .length + y * .length * .length;
(index >= && index < .sections.length) {
.sectionComponents[typeIndex][index];
(comp == ) {
Ref<ChunkStore> section = .getSection(cx, cy, cz);
(section == ) {
;
}
.sectionComponents[typeIndex][index] = comp = .commandBuffer.getComponent(section, componentType);
}
comp;
} {
Ref<ChunkStore> section = .getSection(cx, cy, cz);
(T)(section == ? : .commandBuffer.getComponent(section, componentType));
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/BlockChunk.java
package com.hypixel.hytale.server.core.universe.world.chunk;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.function.predicate.ObjectPositionBlockFunction;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.CachedPacket;
import com.hypixel.hytale.protocol.Opacity;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.protocol.packets.world.SetChunkEnvironments;
import com.hypixel.hytale.protocol.packets.world.SetChunkHeightmap;
import com.hypixel.hytale.protocol.packets.world.SetChunkTintmap;
import com.hypixel.hytale.server.core.asset.type.blocktick.BlockTickStrategy;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.chunk.environment.EnvironmentChunk;
com.hypixel.hytale.server.core.universe.world.chunk.environment.EnvironmentColumn;
com.hypixel.hytale.server.core.universe.world.chunk.palette.IntBytePalette;
com.hypixel.hytale.server.core.universe.world.chunk.palette.ShortBytePalette;
com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
com.hypixel.hytale.server.core.util.io.ByteBufUtil;
com.hypixel.hytale.sneakythrow.SneakyThrow;
io.netty.buffer.ByteBuf;
io.netty.buffer.ByteBufAllocator;
io.netty.buffer.Unpooled;
it.unimi.dsi.fastutil.ints.Int2IntMap;
it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
it.unimi.dsi.fastutil.ints.Int2ShortMap;
it.unimi.dsi.fastutil.ints.IntBinaryOperator;
it.unimi.dsi.fastutil.ints.IntOpenHashSet;
it.unimi.dsi.fastutil.ints.IntSet;
java.lang.ref.SoftReference;
java.time.Instant;
java.util.List;
java.util.concurrent.CompletableFuture;
java.util.function.Function;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
<ChunkStore> {
;
BuilderCodec<BlockChunk> CODEC;
HytaleLogger LOGGER;
SEND_LOCAL_LIGHTING_DATA;
SEND_GLOBAL_LIGHTING_DATA;
index;
x;
z;
ShortBytePalette height;
IntBytePalette tint;
BlockSection[] chunkSections;
BlockSection[] migratedChunkSections;
EnvironmentChunk environments;
needsPhysics;
needsSaving;
SoftReference<CompletableFuture<CachedPacket<SetChunkHeightmap>>> cachedHeightmapPacket;
SoftReference<CompletableFuture<CachedPacket<SetChunkTintmap>>> cachedTintmapPacket;
SoftReference<CompletableFuture<CachedPacket<SetChunkEnvironments>>> cachedEnvironmentsPacket;
ComponentType<ChunkStore, BlockChunk> {
LegacyModule.get().getBlockChunkComponentType();
}
{
( (), (), (), [ ]);
}
{
.x = x;
.z = z;
.index = ChunkUtil.indexChunk(x, z);
}
{
(x, z, (), (), ());
}
{
(height, tint, environments, [ ]);
.x = x;
.z = z;
.index = ChunkUtil.indexChunk(x, z);
}
{
.needsPhysics = ;
.needsSaving = ;
.height = height;
.tint = tint;
.environments = environments;
.chunkSections = chunkSections;
}
Component<ChunkStore> {
( );
}
Component<ChunkStore> {
;
}
{
.index;
}
{
.x;
}
{
.z;
}
EnvironmentChunk {
.environments;
}
{
.environments = environmentChunk;
}
{
.height.get(x, z);
}
{
.height.get(index);
}
{
.height.set(x, z, height);
.cachedHeightmapPacket = ;
.markNeedsSaving();
}
{
( ; cx < ; ++cx) {
( ; cz < ; ++cz) {
.updateHeight(cx, cz);
}
}
}
{
.updateHeight(x, z, ( ) );
}
{
startY;
( ) {
--y;
(y <= ) {
;
}
.getSectionAtBlockY(y);
(section.isSolidAir()) {
y = ( )(ChunkUtil.indexSection(y) * );
(y == ) {
;
}
} {
section.get(x, y, z);
(BlockType)BlockType.getAssetMap().getAsset(blockId);
(blockId != && type != && type.getOpacity() != Opacity.Transparent) {
;
}
}
}
.setHeight(x, z, y);
y;
}
{
(ChunkColumn)holder.getComponent(ChunkColumn.getComponentType());
(column != ) {
Holder<ChunkStore>[] sections = column.getSectionHolders();
( ; i < sections.length; ++i) {
Holder<ChunkStore> section = sections[i];
.chunkSections[i] = .migratedChunkSections != ? .migratedChunkSections[i] : (BlockSection)section.ensureAndGetComponent(BlockSection.getComponentType());
}
}
}
BlockSection {
(index >= && index < .chunkSections.length) {
.chunkSections[index];
} {
.chunkSections.length;
( + var10002 + + index);
}
}
BlockSection {
ChunkUtil.indexSection(y);
(index >= && index < .chunkSections.length) {
.chunkSections[index];
} {
( + y);
}
}
BlockSection[] getChunkSections() {
.chunkSections;
}
{
.chunkSections.length;
}
{
.tint.get(x, z);
}
{
.tint.set(x, z, tint);
.cachedTintmapPacket = ;
.markNeedsSaving();
}
{
.getEnvironment(MathUtil.floor(position.x), MathUtil.floor(position.y), MathUtil.floor(position.z));
}
{
.getEnvironment(position.x, position.y, position.z);
}
{
y >= && y < ? .environments.get(x, y, z) : ;
}
EnvironmentColumn {
.environments.get(x, z);
}
{
(y >= && y < ) {
.environments.set(x, y, z, environment);
.cachedEnvironmentsPacket = ;
.markNeedsSaving();
}
}
{
y >= && y < ? .getSectionAtBlockY(y).getGlobalLight().getRedBlockLight(x, y, z) : ;
}
{
y >= && y < ? .getSectionAtBlockY(y).getGlobalLight().getGreenBlockLight(x, y, z) : ;
}
{
y >= && y < ? .getSectionAtBlockY(y).getGlobalLight().getBlueBlockLight(x, y, z) : ;
}
{
y >= && y < ? .getSectionAtBlockY(y).getGlobalLight().getBlockLight(x, y, z) : ;
}
{
y >= && y < ? .getSectionAtBlockY(y).getGlobalLight().getSkyLight(x, y, z) : ;
}
{
y >= && y < ? .getSectionAtBlockY(y).getGlobalLight().getBlockLightIntensity(x, y, z) : ;
}
{
y >= && y < ? .getSectionAtBlockY(y).get(x, y, z) : ;
}
{
(y >= && y < ) {
ChunkUtil.indexSection(y);
.chunkSections[sectionIndex];
section.set(x, y, z, blockId, rotation, filler);
(changed) {
.invalidateChunkSection(sectionIndex);
.markNeedsSaving();
}
changed;
} {
(String.format( , x, y, z, blockId));
}
}
{
.count(blockId) != ;
}
{
;
(BlockSection section : .chunkSections) {
count += section.count(blockId);
}
count;
}
Int2IntMap {
();
(BlockSection section : .chunkSections) {
(Int2ShortMap.Entry entry : section.valueCounts().int2ShortEntrySet()) {
entry.getIntKey();
entry.getShortValue();
map.mergeInt(blockId, count, (IntBinaryOperator)(Integer::sum));
}
}
map;
}
IntSet {
();
(BlockSection section : .chunkSections) {
set.addAll(section.values());
}
set;
}
{
.blocks().size();
}
{
( ; sectionIndex < .chunkSections.length; ++sectionIndex) {
.chunkSections[sectionIndex].preTick(gameTime);
}
}
<T, V> {
;
( ; sectionIndex < .chunkSections.length; ++sectionIndex) {
.chunkSections[sectionIndex];
ticked += section.forEachTicking(t, v, sectionIndex, acceptor);
}
(ticked > ) {
.markNeedsSaving();
}
ticked;
}
{
(BlockSection section : .chunkSections) {
section.mergeTickingBlocks();
}
}
{
(y >= && y < ) {
.getSectionAtBlockY(y).setTicking(x, y, z, ticking);
(changed) {
.markNeedsSaving();
}
changed;
} {
;
}
}
{
y >= && y < ? .getSectionAtBlockY(y).isTicking(x, y, z) : ;
}
{
;
(BlockSection chunkSection : .chunkSections) {
ticking += chunkSection.getTickingBlocksCount();
}
ticking;
}
{
;
( - ; ix < ; ++ix) {
x + ix;
( - ; iz < ; ++iz) {
z + iz;
(!ChunkUtil.isInsideChunkRelative(wx, wz)) {
success = ;
} {
( - ; iy < ; ++iy) {
y + iy;
.setTicking(wx, wy, wz, );
}
}
}
}
success;
}
{
.needsSaving = ;
}
{
.needsSaving;
}
{
.needsSaving;
.needsSaving = ;
out;
}
{
.needsPhysics = ;
}
{
.needsPhysics;
.needsPhysics = ;
old;
}
{
.chunkSections[sectionIndex].invalidate();
}
BlockSection[] takeMigratedSections() {
BlockSection[] temp = .migratedChunkSections;
.migratedChunkSections = ;
temp;
}
BlockSection[] getMigratedSections() {
.migratedChunkSections;
}
[] serialize(ExtraInfo extraInfo) {
ByteBufAllocator.DEFAULT.buffer();
{
buf.writeBoolean( .needsPhysics);
.height.serialize(buf);
.tint.serialize(buf);
ByteBufUtil.getBytesRelease(buf);
} (Throwable t) {
buf.release();
SneakyThrow.sneakyThrow(t);
}
}
{
Unpooled.wrappedBuffer(bytes);
.needsPhysics = buf.readBoolean();
.height.deserialize(buf);
.tint.deserialize(buf);
(extraInfo.getVersion() <= ) {
buf.readInt();
.migratedChunkSections = [sections];
( ; y < sections; ++y) {
();
section.deserialize(BlockType.KEY_DESERIALIZER, buf, extraInfo.getVersion());
.migratedChunkSections[y] = section;
}
}
}
CompletableFuture<CachedPacket<SetChunkHeightmap>> {
SoftReference<CompletableFuture<CachedPacket<SetChunkHeightmap>>> ref = .cachedHeightmapPacket;
CompletableFuture<CachedPacket<SetChunkHeightmap>> future = ref != ? (CompletableFuture)ref.get() : ;
(future != ) {
future;
} {
future = CompletableFuture.supplyAsync(() -> {
( .x, .z, .height.serialize());
CachedPacket.cache(packet);
});
.cachedHeightmapPacket = (future);
future;
}
}
CompletableFuture<CachedPacket<SetChunkTintmap>> {
SoftReference<CompletableFuture<CachedPacket<SetChunkTintmap>>> ref = .cachedTintmapPacket;
CompletableFuture<CachedPacket<SetChunkTintmap>> future = ref != ? (CompletableFuture)ref.get() : ;
(future != ) {
future;
} {
future = CompletableFuture.supplyAsync(() -> {
( .x, .z, .tint.serialize());
CachedPacket.cache(packet);
});
.cachedTintmapPacket = (future);
future;
}
}
CompletableFuture<CachedPacket<SetChunkEnvironments>> {
SoftReference<CompletableFuture<CachedPacket<SetChunkEnvironments>>> ref = .cachedEnvironmentsPacket;
CompletableFuture<CachedPacket<SetChunkEnvironments>> future = ref != ? (CompletableFuture)ref.get() : ;
(future != ) {
future;
} {
future = CompletableFuture.supplyAsync(() -> {
( .x, .z, .environments.serializeProtocol());
CachedPacket.cache(packet);
});
.cachedEnvironmentsPacket = (future);
future;
}
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(BlockChunk.class, BlockChunk:: ).versioned()).codecVersion( )).append( ( , Codec.BYTE_ARRAY), BlockChunk::deserialize, BlockChunk::serialize).add()).build();
LOGGER = HytaleLogger.forEnclosingClass();
SEND_LOCAL_LIGHTING_DATA = ;
SEND_GLOBAL_LIGHTING_DATA = ;
}
.LoadFuturePacketDataQuerySystem {
ComponentType<ChunkStore, BlockChunk> componentType;
{
.componentType = blockChunkComponentType;
}
Query<ChunkStore> {
.componentType;
}
{
(BlockChunk)archetypeChunk.getComponent(index, .componentType);
results.add(component.getCachedHeightmapPacket().exceptionally((throwable) -> {
(throwable != ) {
((HytaleLogger.Api)BlockChunk.LOGGER.at(Level.SEVERE).withCause(throwable)).log( );
}
;
}).thenApply(Function.identity()));
results.add(component.getCachedTintsPacket().exceptionally((throwable) -> {
(throwable != ) {
((HytaleLogger.Api)BlockChunk.LOGGER.at(Level.SEVERE).withCause(throwable)).log( );
}
;
}).thenApply(Function.identity()));
results.add(component.getCachedEnvironmentsPacket().exceptionally((throwable) -> {
(throwable != ) {
((HytaleLogger.Api)BlockChunk.LOGGER.at(Level.SEVERE).withCause(throwable)).log( );
}
;
}).thenApply(Function.identity()));
( ; y < component.chunkSections.length; ++y) {
component.chunkSections[y];
results.add(section.getCachedChunkPacket(component.getX(), y, component.getZ()).exceptionally((throwable) -> {
(throwable != ) {
((HytaleLogger.Api)BlockChunk.LOGGER.at(Level.SEVERE).withCause(throwable)).log( , component.x, component.z);
}
;
}).thenApply(Function.identity()));
}
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/BlockComponentChunk.java
package com.hypixel.hytale.server.core.universe.world.chunk;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.map.Int2ObjectMapCodec;
import com.hypixel.hytale.codec.store.StoredCodec;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.NonTicking;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.RefChangeSystem;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.server.core.modules.block.BlockModule;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.meta.BlockState;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
it.unimi.dsi.fastutil.objects.ObjectCollection;
java.util.List;
java.util.Objects;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
<ChunkStore> {
BuilderCodec<BlockComponentChunk> CODEC;
Int2ObjectMap<Holder<ChunkStore>> entityHolders;
Int2ObjectMap<Ref<ChunkStore>> entityReferences;
Int2ObjectMap<Holder<ChunkStore>> entityHoldersUnmodifiable;
Int2ObjectMap<Ref<ChunkStore>> entityReferencesUnmodifiable;
needsSaving;
ComponentType<ChunkStore, BlockComponentChunk> {
LegacyModule.get().getBlockComponentChunkComponentType();
}
{
.entityHolders = <Holder<ChunkStore>>();
.entityReferences = <Ref<ChunkStore>>();
.entityHoldersUnmodifiable = Int2ObjectMaps.<Holder<ChunkStore>>unmodifiable( .entityHolders);
.entityReferencesUnmodifiable = Int2ObjectMaps.<Ref<ChunkStore>>unmodifiable( .entityReferences);
}
{
.entityHolders = entityHolders;
.entityReferences = entityReferences;
.entityHoldersUnmodifiable = Int2ObjectMaps.<Holder<ChunkStore>>unmodifiable(entityHolders);
.entityReferencesUnmodifiable = Int2ObjectMaps.<Ref<ChunkStore>>unmodifiable(entityReferences);
}
Component<ChunkStore> {
Int2ObjectOpenHashMap<Holder<ChunkStore>> entityHoldersClone = <Holder<ChunkStore>>( .entityHolders.size() + .entityReferences.size());
(Int2ObjectMap.Entry<Holder<ChunkStore>> entry : .entityHolders.int2ObjectEntrySet()) {
entityHoldersClone.put(entry.getIntKey(), ((Holder)entry.getValue()).clone());
}
(Int2ObjectMap.Entry<Ref<ChunkStore>> entry : .entityReferences.int2ObjectEntrySet()) {
Ref<ChunkStore> reference = (Ref)entry.getValue();
entityHoldersClone.put(entry.getIntKey(), reference.getStore().copyEntity(reference));
}
(entityHoldersClone, ());
}
Component<ChunkStore> {
ComponentRegistry.Data<ChunkStore> data = ChunkStore.REGISTRY.getData();
Int2ObjectOpenHashMap<Holder<ChunkStore>> entityHoldersClone = <Holder<ChunkStore>>( .entityHolders.size() + .entityReferences.size());
(Int2ObjectMap.Entry<Holder<ChunkStore>> entry : .entityHolders.int2ObjectEntrySet()) {
Holder<ChunkStore> holder = (Holder)entry.getValue();
(holder.getArchetype().hasSerializableComponents(data)) {
entityHoldersClone.put(entry.getIntKey(), holder.cloneSerializable(data));
}
}
(Int2ObjectMap.Entry<Ref<ChunkStore>> entry : .entityReferences.int2ObjectEntrySet()) {
Ref<ChunkStore> reference = (Ref)entry.getValue();
Store<ChunkStore> store = reference.getStore();
(store.getArchetype(reference).hasSerializableComponents(data)) {
entityHoldersClone.put(entry.getIntKey(), store.copySerializableEntity(reference));
}
}
(entityHoldersClone, ());
}
Int2ObjectMap<Holder<ChunkStore>> {
.entityHoldersUnmodifiable;
}
Holder<ChunkStore> {
(Holder) .entityHolders.get(index);
}
{
( .entityReferences.containsKey(index)) {
( + index);
} ( .entityHolders.putIfAbsent(index, (Holder)Objects.requireNonNull(holder)) != ) {
( + index);
} {
.markNeedsSaving();
}
}
{
( .entityHolders.putIfAbsent(index, (Holder)Objects.requireNonNull(holder)) != ) {
( + index);
}
}
Holder<ChunkStore> {
Holder<ChunkStore> reference = (Holder) .entityHolders.remove(index);
(reference != ) {
.markNeedsSaving();
}
reference;
}
Int2ObjectMap<Ref<ChunkStore>> {
.entityReferencesUnmodifiable;
}
Ref<ChunkStore> {
(Ref) .entityReferences.get(index);
}
{
reference.validate();
( .entityHolders.containsKey(index)) {
( + index);
} ( .entityReferences.putIfAbsent(index, (Ref)Objects.requireNonNull(reference)) != ) {
( + index);
} {
.markNeedsSaving();
}
}
{
reference.validate();
( .entityHolders.containsKey(index)) {
( + index);
} ( .entityReferences.putIfAbsent(index, (Ref)Objects.requireNonNull(reference)) != ) {
( + index);
}
}
{
( .entityReferences.remove(index, reference)) {
.markNeedsSaving();
}
}
{
.entityReferences.remove(index, reference);
}
Int2ObjectMap<Holder<ChunkStore>> {
( .entityHolders.isEmpty()) {
;
} {
Int2ObjectOpenHashMap<Holder<ChunkStore>> holders = <Holder<ChunkStore>>( .entityHolders);
.entityHolders.clear();
holders;
}
}
Int2ObjectMap<Ref<ChunkStore>> {
( .entityReferences.isEmpty()) {
;
} {
Int2ObjectOpenHashMap<Ref<ChunkStore>> holders = <Ref<ChunkStore>>( .entityReferences);
.entityReferences.clear();
holders;
}
}
<T <ChunkStore>> T {
Ref<ChunkStore> reference = (Ref) .entityReferences.get(index);
(reference != ) {
(T)reference.getStore().getComponent(reference, componentType);
} {
Holder<ChunkStore> holder = (Holder) .entityHolders.get(index);
(T)(holder != ? holder.getComponent(componentType) : );
}
}
{
.entityReferences.containsKey(index) || .entityHolders.containsKey(index);
}
{
.needsSaving;
}
{
.needsSaving = ;
}
{
.needsSaving;
.needsSaving = ;
out;
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(BlockComponentChunk.class, BlockComponentChunk:: ).addField( ( , ( (ChunkStore.HOLDER_CODEC_KEY), Int2ObjectOpenHashMap:: )), (entityChunk, map) -> {
entityChunk.entityHolders.clear();
entityChunk.entityHolders.putAll(map);
}, (entityChunk) -> {
(entityChunk.entityReferences.isEmpty()) {
entityChunk.entityHolders;
} {
Int2ObjectMap<Holder<ChunkStore>> map = <Holder<ChunkStore>>(entityChunk.entityHolders.size() + entityChunk.entityReferences.size());
map.putAll(entityChunk.entityHolders);
(Int2ObjectMap.Entry<Ref<ChunkStore>> entry : entityChunk.entityReferences.int2ObjectEntrySet()) {
Ref<ChunkStore> reference = (Ref)entry.getValue();
Store<ChunkStore> store = reference.getStore();
(store.getArchetype(reference).hasSerializableComponents(store.getRegistry().getData())) {
map.put(entry.getIntKey(), store.copySerializableEntity(reference));
}
}
map;
}
})).build();
}
<ChunkStore, NonTicking<ChunkStore>> {
HytaleLogger.forEnclosingClass();
Archetype<ChunkStore> archetype = Archetype.of(WorldChunk.getComponentType(), BlockComponentChunk.getComponentType());
{
}
Query<ChunkStore> {
.archetype;
}
ComponentType<ChunkStore, NonTicking<ChunkStore>> {
ChunkStore.REGISTRY.getNonTickingComponentType();
}
{
(BlockComponentChunk)store.getComponent(ref, BlockComponentChunk.getComponentType());
Int2ObjectMap<Ref<ChunkStore>> entityReferences = blockComponentChunk.takeEntityReferences();
(entityReferences != ) {
entityReferences.size();
[] indexes = [size];
Ref<ChunkStore>[] references = [size];
;
(Int2ObjectMap.Entry<Ref<ChunkStore>> entry : entityReferences.int2ObjectEntrySet()) {
indexes[j] = entry.getIntKey();
references[j] = (Ref)entry.getValue();
++j;
}
ComponentRegistry.Data<ChunkStore> data = ChunkStore.REGISTRY.getData();
( ; i < size; ++i) {
(store.getArchetype(references[i]).hasSerializableComponents(data)) {
Holder<ChunkStore> holder = ChunkStore.REGISTRY.newHolder();
commandBuffer.removeEntity(references[i], holder, RemoveReason.UNLOAD);
blockComponentChunk.storeEntityHolder(indexes[i], holder);
} {
commandBuffer.removeEntity(references[i], RemoveReason.UNLOAD);
}
}
}
}
{
}
{
(WorldChunk)store.getComponent(ref, WorldChunk.getComponentType());
(BlockComponentChunk)store.getComponent(ref, BlockComponentChunk.getComponentType());
Int2ObjectMap<Holder<ChunkStore>> entityHolders = blockComponentChunk.takeEntityHolders();
(entityHolders != ) {
entityHolders.size();
[] indexes = [holderCount];
Holder<ChunkStore>[] holders = [holderCount];
;
(Int2ObjectMap.Entry<Holder<ChunkStore>> entry : entityHolders.int2ObjectEntrySet()) {
indexes[j] = entry.getIntKey();
holders[j] = (Holder)entry.getValue();
++j;
}
( holderCount - ; i >= ; --i) {
Holder<ChunkStore> holder = holders[i];
(holder.getArchetype().isEmpty()) {
LOGGER.at(Level.SEVERE).log( , holder, i);
--holderCount;
holders[i] = holders[holderCount];
holders[holderCount] = holder;
chunk.markNeedsSaving();
} {
indexes[i];
ChunkUtil.xFromBlockInColumn(index);
ChunkUtil.yFromBlockInColumn(index);
ChunkUtil.zFromBlockInColumn(index);
holder.putComponent(BlockModule.BlockStateInfo.getComponentType(), .BlockStateInfo(index, ref));
BlockState.getBlockState(holder);
(state != ) {
state.setPosition(chunk, (x, y, z));
}
}
}
commandBuffer.addEntities(holders, AddReason.LOAD);
}
}
}
.LoadPacketDataQuerySystem {
ComponentType<ChunkStore, BlockComponentChunk> componentType;
{
.componentType = blockComponentChunkComponentType;
}
Query<ChunkStore> {
.componentType;
}
{
(BlockComponentChunk)archetypeChunk.getComponent(index, .componentType);
ObjectCollection<Ref<ChunkStore>> references = component.entityReferences.values();
Store<ChunkStore> componentStore = ((ChunkStore)store.getExternalData()).getWorld().getChunkStore().getStore();
componentStore.fetch(references, ChunkStore.LOAD_PACKETS_DATA_QUERY_SYSTEM_TYPE, player, results);
}
}
.UnloadPacketDataQuerySystem {
ComponentType<ChunkStore, BlockComponentChunk> componentType;
{
.componentType = blockComponentChunkComponentType;
}
Query<ChunkStore> {
.componentType;
}
{
(BlockComponentChunk)archetypeChunk.getComponent(index, .componentType);
ObjectCollection<Ref<ChunkStore>> references = component.entityReferences.values();
Store<ChunkStore> componentStore = ((ChunkStore)store.getExternalData()).getWorld().getChunkStore().getStore();
componentStore.fetch(references, ChunkStore.UNLOAD_PACKETS_DATA_QUERY_SYSTEM_TYPE, player, results);
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/BlockRotationUtil.java
package com.hypixel.hytale.server.core.universe.world.chunk;
import com.hypixel.hytale.math.Axis;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockFlipType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.VariantRotation;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockRotationUtil {
public BlockRotationUtil () {
}
@Nullable
public static RotationTuple getFlipped (@Nonnull RotationTuple blockRotation, @Nullable BlockFlipType flipType, @Nonnull Axis axis, @Nonnull VariantRotation variantRotation) {
Rotation rotationYaw = blockRotation.yaw();
Rotation rotationPitch = blockRotation.pitch();
Rotation rotationRoll = blockRotation.roll();
if (flipType != null ) {
rotationYaw = flipType.flipYaw(rotationYaw, axis);
}
boolean preventPitchRotation = axis != Axis.Y;
return get(rotationYaw, rotationPitch, rotationRoll, axis, Rotation.OneEighty, variantRotation, preventPitchRotation);
}
RotationTuple {
get(blockRotation.yaw(), blockRotation.pitch(), blockRotation.roll(), axis, rotation, variantRotation, );
}
RotationTuple {
;
(axis) {
X:
variantRotation.rotateX(RotationTuple.of(rotationYaw, rotationPitch), rotation);
rotationPair = variantRotation.verify(rotateX);
;
Y:
rotationPair = variantRotation.verify(RotationTuple.of(rotationYaw.add(rotation), rotationPitch));
;
Z:
variantRotation.rotateZ(RotationTuple.of(rotationYaw, rotationPitch), rotation);
rotationPair = variantRotation.verify(rotateZ);
}
(rotationPair == ) {
;
} {
(preventPitchRotation) {
rotationPair = RotationTuple.of(rotationPair.yaw(), rotationPitch);
}
rotationPair;
}
}
{
getRotatedFiller(filler, axis, Rotation.OneEighty);
}
{
var10000;
(axis) {
X -> var10000 = rotation.rotateX(filler);
Y -> var10000 = rotation.rotateY(filler);
Z -> var10000 = rotation.rotateZ(filler);
-> ((String) , (Throwable) );
}
var10000;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/ChunkColumn.java
package com.hypixel.hytale.server.core.universe.world.chunk;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.codec.store.StoredCodec;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@Deprecated
public class ChunkColumn implements Component <ChunkStore> {
public static final BuilderCodec<ChunkColumn> CODEC;
private final Ref<ChunkStore>[] sections = new Ref [10 ];
@Nullable
private Holder<ChunkStore>[] sectionHolders;
public static ComponentType<ChunkStore, ChunkColumn> getComponentType () {
return LegacyModule.get().getChunkColumnComponentType();
}
public ChunkColumn {
}
{
.sectionHolders = sectionHolders;
}
Ref<ChunkStore> {
section >= && section < .sections.length ? .sections[section] : ;
}
Ref<ChunkStore>[] getSections() {
.sections;
}
Holder<ChunkStore>[] getSectionHolders() {
.sectionHolders;
}
Holder<ChunkStore>[] takeSectionHolders() {
Holder<ChunkStore>[] temp = .sectionHolders;
.sectionHolders = ;
temp;
}
{
.sectionHolders = holders;
}
Component<ChunkStore> {
();
.sections.length;
( .sectionHolders != ) {
length = Math.max( .sectionHolders.length, .sections.length);
}
Holder<ChunkStore>[] holders = [length];
( .sectionHolders != ) {
( ; i < .sectionHolders.length; ++i) {
Holder<ChunkStore> sectionHolder = .sectionHolders[i];
(sectionHolder != ) {
holders[i] = sectionHolder.clone();
}
}
}
( ; i < .sections.length; ++i) {
Ref<ChunkStore> section = .sections[i];
(section != ) {
holders[i] = section.getStore().copyEntity(section);
}
}
newChunk.sectionHolders = holders;
newChunk;
}
Component<ChunkStore> {
();
.sections.length;
( .sectionHolders != ) {
length = Math.max( .sectionHolders.length, .sections.length);
}
Holder<ChunkStore>[] holders = [length];
( .sectionHolders != ) {
( ; i < .sectionHolders.length; ++i) {
Holder<ChunkStore> sectionHolder = .sectionHolders[i];
(sectionHolder != ) {
holders[i] = sectionHolder.clone();
}
}
}
( ; i < .sections.length; ++i) {
Ref<ChunkStore> section = .sections[i];
(section != ) {
holders[i] = section.getStore().copySerializableEntity(section);
}
}
newChunk.sectionHolders = holders;
newChunk;
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(ChunkColumn.class, ChunkColumn:: ).append( ( , ( (ChunkStore.HOLDER_CODEC_KEY), (x$ ) -> [x$ ])), (chunk, holders) -> chunk.sectionHolders = holders, (chunk) -> {
chunk.sections.length;
(chunk.sectionHolders != ) {
length = Math.max(chunk.sectionHolders.length, chunk.sections.length);
}
Holder<ChunkStore>[] array = [length];
(chunk.sectionHolders != ) {
System.arraycopy(chunk.sectionHolders, , array, , chunk.sectionHolders.length);
}
( ; i < chunk.sections.length; ++i) {
Ref<ChunkStore> section = chunk.sections[i];
(section == ) {
;
}
Store<ChunkStore> store = section.getStore();
array[i] = store.copySerializableEntity(section);
}
array;
}).add()).build();
}
}
com/hypixel/hytale/server/core/universe/world/chunk/ChunkFlag.java
package com.hypixel.hytale.server.core.universe.world.chunk;
import com.hypixel.hytale.common.collection.Flag;
public enum ChunkFlag implements Flag {
START_INIT,
INIT,
NEWLY_GENERATED,
ON_DISK,
TICKING;
public static final ChunkFlag[] VALUES = values();
private final int mask = 1 << this .ordinal();
private ChunkFlag () {
}
public int mask () {
return this .mask;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/EntityChunk.java
package com.hypixel.hytale.server.core.universe.world.chunk;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.codec.store.StoredCodec;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.NonTicking;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.RefChangeSystem;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.entity.Entity;
import com.hypixel.hytale.server.core.entity.EntityUtils;
import com.hypixel.hytale.server.core.entity.nameplate.Nameplate;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.Arrays;
import java.util.Collections;
java.util.HashSet;
java.util.Iterator;
java.util.List;
java.util.Objects;
java.util.Set;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
<ChunkStore> {
BuilderCodec<EntityChunk> CODEC;
List<Holder<EntityStore>> entityHolders;
Set<Ref<EntityStore>> entityReferences;
List<Holder<EntityStore>> entityHoldersUnmodifiable;
Set<Ref<EntityStore>> entityReferencesUnmodifiable;
needsSaving;
ComponentType<ChunkStore, EntityChunk> {
LegacyModule.get().getEntityChunkComponentType();
}
{
.entityHolders = <Holder<EntityStore>>();
.entityReferences = ();
.entityHoldersUnmodifiable = Collections.unmodifiableList( .entityHolders);
.entityReferencesUnmodifiable = Collections.unmodifiableSet( .entityReferences);
}
{
.entityHolders = entityHolders;
.entityReferences = entityReferences;
.entityHoldersUnmodifiable = Collections.unmodifiableList(entityHolders);
.entityReferencesUnmodifiable = Collections.unmodifiableSet(entityReferences);
}
Component<ChunkStore> {
ObjectArrayList<Holder<EntityStore>> entityHoldersClone = <Holder<EntityStore>>( .entityHolders.size() + .entityReferences.size());
(Holder<EntityStore> entityHolder : .entityHolders) {
entityHoldersClone.add(entityHolder.clone());
}
(Ref<EntityStore> reference : .entityReferences) {
entityHoldersClone.add(reference.getStore().copyEntity(reference));
}
(entityHoldersClone, ());
}
Component<ChunkStore> {
ComponentRegistry.Data<EntityStore> data = EntityStore.REGISTRY.getData();
ObjectArrayList<Holder<EntityStore>> entityHoldersClone = <Holder<EntityStore>>( .entityHolders.size() + .entityReferences.size());
(Holder<EntityStore> entityHolder : .entityHolders) {
(entityHolder.getArchetype().hasSerializableComponents(data)) {
entityHoldersClone.add(entityHolder.cloneSerializable(data));
}
}
(Ref<EntityStore> reference : .entityReferences) {
Store<EntityStore> store = reference.getStore();
(store.getArchetype(reference).hasSerializableComponents(data)) {
entityHoldersClone.add(store.copySerializableEntity(reference));
}
}
(entityHoldersClone, ());
}
List<Holder<EntityStore>> {
.entityHoldersUnmodifiable;
}
{
.entityHolders.add((Holder)Objects.requireNonNull(holder));
.markNeedsSaving();
}
{
.entityHolders.add((Holder)Objects.requireNonNull(holder));
}
Set<Ref<EntityStore>> {
.entityReferencesUnmodifiable;
}
{
.entityReferences.add((Ref)Objects.requireNonNull(reference));
.markNeedsSaving();
}
{
.entityReferences.add((Ref)Objects.requireNonNull(reference));
}
{
.entityReferences.remove(Objects.requireNonNull(reference));
.markNeedsSaving();
}
{
.entityReferences.remove(Objects.requireNonNull(reference));
}
Holder<EntityStore>[] takeEntityHolders() {
( .entityHolders.isEmpty()) {
;
} {
Holder<EntityStore>[] holders = (Holder[]) .entityHolders.toArray((x$ ) -> [x$ ]);
.entityHolders.clear();
holders;
}
}
Ref<EntityStore>[] takeEntityReferences() {
( .entityReferences.isEmpty()) {
;
} {
Ref<EntityStore>[] holders = (Ref[]) .entityReferences.toArray((x$ ) -> [x$ ]);
.entityReferences.clear();
holders;
}
}
{
.needsSaving;
}
{
.needsSaving = ;
}
{
.needsSaving;
.needsSaving = ;
out;
}
Iterable<Entity> {
( .entityReferences.isEmpty()) {
Collections.emptyList();
} {
Ref<EntityStore>[] references = (Ref[]) .entityReferences.toArray((x$ ) -> [x$ ]);
() -> <Entity>() {
references.length;
{
( .index <= ) {
;
} {
(Ref<EntityStore> reference = references[ .index - ]; !reference.isValid() || EntityUtils.getEntity(reference, reference.getStore()) == ; reference = references[ .index - ]) {
-- .index;
( .index <= ) {
;
}
}
;
}
}
Entity {
Ref<EntityStore> reference = references[-- .index];
EntityUtils.getEntity(reference, reference.getStore());
}
};
}
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(EntityChunk.class, EntityChunk:: ).addField( ( , ( (EntityStore.HOLDER_CODEC_KEY), (x$ ) -> [x$ ])), (entityChunk, array) -> {
entityChunk.entityHolders.clear();
Collections.addAll(entityChunk.entityHolders, array);
}, (entityChunk) -> {
(entityChunk.entityReferences.isEmpty()) {
(Holder[])entityChunk.entityHolders.toArray( [entityChunk.entityHolders.size()]);
} {
Holder<EntityStore>[] array = [entityChunk.entityHolders.size() + entityChunk.entityReferences.size()];
array = (Holder[])entityChunk.entityHolders.toArray(array);
entityChunk.entityHolders.size();
(Ref<EntityStore> reference : entityChunk.entityReferences) {
Store<EntityStore> store = reference.getStore();
(store.getArchetype(reference).hasSerializableComponents(store.getRegistry().getData())) {
array[index++] = store.copyEntity(reference);
}
}
index == array.length ? array : (Holder[])Arrays.copyOfRange(array, , index);
}
})).build();
}
<ChunkStore, NonTicking<ChunkStore>> {
HytaleLogger.forEnclosingClass();
Archetype<ChunkStore> archetype = Archetype.of(WorldChunk.getComponentType(), EntityChunk.getComponentType());
{
}
Query<ChunkStore> {
.archetype;
}
ComponentType<ChunkStore, NonTicking<ChunkStore>> {
ChunkStore.REGISTRY.getNonTickingComponentType();
}
{
((ChunkStore)store.getExternalData()).getWorld();
(EntityChunk)store.getComponent(ref, EntityChunk.getComponentType());
entityChunkComponent != ;
Ref<EntityStore>[] references = entityChunkComponent.takeEntityReferences();
(references != ) {
Store<EntityStore> entityStore = world.getEntityStore().getStore();
Holder<EntityStore>[] holders = entityStore.removeEntities(references, RemoveReason.UNLOAD);
ComponentRegistry.Data<EntityStore> data = EntityStore.REGISTRY.getData();
( ; i < holders.length; ++i) {
Holder<EntityStore> holder = holders[i];
(holder.hasSerializableComponents(data)) {
entityChunkComponent.storeEntityHolder(holder);
}
}
}
}
{
}
{
((ChunkStore)store.getExternalData()).getWorld();
(WorldChunk)store.getComponent(ref, WorldChunk.getComponentType());
worldChunkComponent != ;
(EntityChunk)store.getComponent(ref, EntityChunk.getComponentType());
entityChunkComponent != ;
Store<EntityStore> entityStore = world.getEntityStore().getStore();
Holder<EntityStore>[] holders = entityChunkComponent.takeEntityHolders();
(holders != ) {
holders.length;
( holderCount - ; i >= ; --i) {
Holder<EntityStore> holder = holders[i];
Archetype<EntityStore> archetype = holder.getArchetype();
archetype != ;
(archetype.isEmpty()) {
LOGGER.at(Level.SEVERE).log( , holder, i);
--holderCount;
holders[i] = holders[holderCount];
holders[holderCount] = holder;
worldChunkComponent.markNeedsSaving();
} (archetype.count() == && archetype.contains(Nameplate.getComponentType())) {
LOGGER.at(Level.SEVERE).log( , holder, i);
--holderCount;
holders[i] = holders[holderCount];
holders[holderCount] = holder;
worldChunkComponent.markNeedsSaving();
} {
(TransformComponent)holder.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.setChunkLocation(ref, worldChunkComponent);
}
}
Ref<EntityStore>[] refs = entityStore.addEntities(holders, , holderCount, AddReason.LOAD);
( ; i < refs.length; ++i) {
Ref<EntityStore> entityRef = refs[i];
(!entityRef.isValid()) {
;
}
entityChunkComponent.loadEntityReference(entityRef);
}
}
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/WorldChunk.java
package com.hypixel.hytale.server.core.universe.world.chunk;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.common.collection.Flags;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.BlockParticleEvent;
import com.hypixel.hytale.protocol.Opacity;
import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
import com.hypixel.hytale.server.core.asset.type.blocktick.BlockTickManager;
import com.hypixel.hytale.server.core.asset.type.blocktick.config.TickProcedure;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.blocktype.component.BlockPhysics;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.server.core.modules.block.BlockModule;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldNotificationHandler;
import com.hypixel.hytale.server.core.universe.world.accessor.BlockAccessor;
com.hypixel.hytale.server.core.universe.world.accessor.ChunkAccessor;
com.hypixel.hytale.server.core.universe.world.chunk.environment.EnvironmentChunk;
com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
com.hypixel.hytale.server.core.universe.world.chunk.section.FluidSection;
com.hypixel.hytale.server.core.universe.world.meta.BlockState;
com.hypixel.hytale.server.core.universe.world.meta.BlockStateModule;
com.hypixel.hytale.server.core.universe.world.meta.state.ItemContainerState;
com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
com.hypixel.hytale.server.core.util.FillerBlockUtil;
java.util.concurrent.CompletableFuture;
java.util.concurrent.atomic.AtomicLong;
java.util.concurrent.locks.StampedLock;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
, Component<ChunkStore> {
;
BuilderCodec<WorldChunk> CODEC = BuilderCodec.builder(WorldChunk.class, WorldChunk:: ).build();
HytaleLogger.forEnclosingClass();
World world;
StampedLock flagsLock;
Flags<ChunkFlag> flags;
Ref<ChunkStore> reference;
BlockChunk blockChunk;
BlockComponentChunk blockComponentChunk;
EntityChunk entityChunk;
keepAlive;
activeTimer;
needsSaving;
isSaving;
keepLoaded;
lightingUpdatesEnabled;
AtomicLong chunkLightTiming;
ComponentType<ChunkStore, WorldChunk> {
LegacyModule.get().getWorldChunkComponentType();
}
{
.flagsLock = ();
.keepAlive = ;
.activeTimer = ;
.lightingUpdatesEnabled = ;
.chunkLightTiming = ();
.flags = <ChunkFlag>( [ ]);
}
{
.flagsLock = ();
.keepAlive = ;
.activeTimer = ;
.lightingUpdatesEnabled = ;
.chunkLightTiming = ();
.world = world;
.flags = flags;
}
{
(world, state);
.blockChunk = blockChunk;
.blockComponentChunk = blockComponentChunk;
.entityChunk = entityChunk;
}
Holder<ChunkStore> {
( .reference != && .reference.isValid() && .world != ) {
Holder<ChunkStore> holder = ChunkStore.REGISTRY.newHolder();
Store<ChunkStore> componentStore = .world.getChunkStore().getStore();
Archetype<ChunkStore> archetype = componentStore.getArchetype( .reference);
( archetype.getMinIndex(); i < archetype.length(); ++i) {
archetype.get(i);
(componentType != ) {
holder.addComponent(componentType, componentStore.getComponent( .reference, componentType));
}
}
holder;
} {
Holder<ChunkStore> holder = ChunkStore.REGISTRY.newHolder();
holder.addComponent(getComponentType(), );
holder.addComponent(BlockChunk.getComponentType(), .blockChunk);
holder.addComponent(EnvironmentChunk.getComponentType(), .blockChunk.getEnvironmentChunk());
holder.addComponent(EntityChunk.getComponentType(), .entityChunk);
holder.addComponent(BlockComponentChunk.getComponentType(), .blockComponentChunk);
holder;
}
}
{
( .reference != && .reference.isValid()) {
String.valueOf( .reference);
( + var10002 + + String.valueOf(reference));
} {
.reference = reference;
}
}
Ref<ChunkStore> {
.reference;
}
Component<ChunkStore> {
();
}
{
.flagsLock.tryOptimisticRead();
.flags.is(flag);
( .flagsLock.validate(stamp)) {
value;
} {
stamp = .flagsLock.readLock();
var5;
{
var5 = .flags.is(flag);
} {
.flagsLock.unlockRead(stamp);
}
var5;
}
}
{
.flagsLock.tryOptimisticRead();
.flags.not(flag);
( .flagsLock.validate(stamp)) {
value;
} {
stamp = .flagsLock.readLock();
var5;
{
var5 = .flags.not(flag);
} {
.flagsLock.unlockRead(stamp);
}
var5;
}
}
{
.flagsLock.writeLock();
isInit;
{
(! .flags.set(flag, value)) {
;
}
isInit = .flags.is(ChunkFlag.INIT);
} {
.flagsLock.unlockWrite(lock);
}
(isInit) {
.updateFlag(flag, value);
}
LOGGER.at(Level.FINER).log( , .getX(), .getZ(), isInit, flag, value);
}
{
.flagsLock.writeLock();
value;
isInit;
{
value = .flags.toggle(flag);
isInit = .flags.is(ChunkFlag.INIT);
} {
.flagsLock.unlockWrite(lock);
}
(isInit) {
.updateFlag(flag, value);
}
LOGGER.at(Level.FINER).log( , .getX(), .getZ(), isInit, flag, value);
value;
}
{
.world = world;
.blockChunk = (BlockChunk)holder.getComponent(BlockChunk.getComponentType());
.blockChunk.setEnvironmentChunk((EnvironmentChunk)holder.getComponent(EnvironmentChunk.getComponentType()));
.blockComponentChunk = (BlockComponentChunk)holder.getComponent(BlockComponentChunk.getComponentType());
.entityChunk = (EntityChunk)holder.getComponent(EntityChunk.getComponentType());
.blockChunk.load(x, z);
}
{
.blockComponentChunk = blockComponentChunk;
}
{
.world.debugAssertInTickingThread();
(! .is(ChunkFlag.START_INIT)) {
( );
} ( .is(ChunkFlag.INIT)) {
( );
} {
( ; i < ChunkFlag.VALUES.length; ++i) {
ChunkFlag.VALUES[i];
.updateFlag(flag, .is(flag));
}
.setFlag(ChunkFlag.INIT, );
}
}
{
(flag == ChunkFlag.TICKING) {
.world.debugAssertInTickingThread();
.resetKeepAlive();
(value) {
.startsTicking();
} {
.stopsTicking();
}
}
}
{
.world.debugAssertInTickingThread();
LOGGER.at(Level.FINER).log( , );
Store<ChunkStore> componentStore = .world.getChunkStore().getStore();
componentStore.tryRemoveComponent( .reference, ChunkStore.REGISTRY.getNonTickingComponentType());
}
{
.world.debugAssertInTickingThread();
LOGGER.at(Level.FINER).log( , );
Store<ChunkStore> componentStore = .world.getChunkStore().getStore();
componentStore.ensureComponent( .reference, ChunkStore.REGISTRY.getNonTickingComponentType());
}
BlockChunk {
.blockChunk;
}
BlockComponentChunk {
.blockComponentChunk;
}
EntityChunk {
.entityChunk;
}
{
.keepLoaded;
}
{
.keepLoaded = keepLoaded;
}
{
.keepAlive = Math.max( .keepAlive - pollCount, );
}
{
.keepAlive = ;
}
{
.activeTimer = Math.max( .activeTimer - pollCount, );
}
{
.activeTimer = ;
}
ChunkAccessor {
.world;
}
{
y >= && y < ? .blockChunk.getBlock(x, y, z) : ;
}
{
(y >= && y < ) {
.blockChunk.getHeight(x, z);
.blockChunk.getSectionAtBlockY(y);
blockSection.getRotationIndex(x, y, z);
blockSection.getFiller(x, y, z);
blockSection.get(x, y, z);
(oldBlock != id || rotation != oldRotation) && blockSection.set(x, y, z, id, rotation, filler);
(changed || (settings & ) != ) {
( .getX() << ) + (x & );
( .getZ() << ) + (z & );
((settings & ) != ) {
blockSection.invalidateBlock(x, y, z);
}
oldHeight;
((settings & ) == && oldHeight <= y) {
(oldHeight == y && id == ) {
newHeight = .blockChunk.updateHeight(x, z, ( )y);
} (oldHeight < y && id != && blockType.getOpacity() != Opacity.Transparent) {
newHeight = ( )y;
.blockChunk.setHeight(x, z, newHeight);
}
}
.getWorld().getNotificationHandler();
((settings & ) == ) {
(oldBlock == && id != ) {
notificationHandler.sendBlockParticle(( )worldX + , ( )y + , ( )worldZ + , id, BlockParticleEvent.Build);
} (oldBlock != && id == ) {
(settings & ) != ? BlockParticleEvent.Physics : BlockParticleEvent.Break;
notificationHandler.sendBlockParticle(( )worldX + , ( )y + , ( )worldZ + , oldBlock, particleType);
} {
notificationHandler.sendBlockParticle(( )worldX + , ( )y + , ( )worldZ + , oldBlock, BlockParticleEvent.Break);
notificationHandler.sendBlockParticle(( )worldX + , ( )y + , ( )worldZ + , id, BlockParticleEvent.Build);
}
}
BlockTypeAssetMap<String, BlockType> blockTypeAssetMap = BlockType.getAssetMap();
IndexedLookupTableAssetMap<String, BlockBoundingBoxes> hitboxAssetMap = BlockBoundingBoxes.getAssetMap();
blockType.getId();
((settings & ) == ) {
Holder<ChunkStore> blockEntity = blockType.getBlockEntity();
(blockEntity != && filler == ) {
Holder<ChunkStore> newComponents = blockEntity.clone();
.setState(x, y, z, newComponents);
} {
;
blockType.getState() != ? blockType.getState().getId() : ;
(id != && blockStateType != && filler == ) {
blockState = BlockStateModule.get().createBlockState(blockStateType, , (x, y, z), blockType);
(blockState == ) {
LOGGER.at(Level.WARNING).log( , blockStateType, blockTypeKey);
}
}
.getState(x, y, z);
(blockState ItemContainerState) {
(ItemContainerState)blockState;
FillerBlockUtil.forEachFillerBlock(((BlockBoundingBoxes)hitboxAssetMap.getAsset(blockType.getHitboxTypeIndex())).get(rotation), (x1, y1, z1) -> {
worldX + x1;
y + y1;
worldZ + z1;
x1 == && y1 == && z1 == ;
isZero ? oldState : .getState(blockX, blockY, blockZ);
(stateAtFiller ItemContainerState oldContainer) {
oldContainer.getItemContainer().moveAllItemStacksTo(newState.getItemContainer());
}
});
}
.setState(x, y, z, blockState, (settings & ) == );
}
}
( .lightingUpdatesEnabled) {
.world.getChunkLighting().invalidateLightAtBlock( , x, y, z, blockType, oldHeight, newHeight);
}
BlockTickManager.getBlockTickProvider().getTickProcedure(id);
.blockChunk.setTicking(x, y, z, tickProcedure != );
((settings & ) == ) {
settings | | ;
blockTypeAssetMap.getAsset(oldBlock);
oldBlockType.getId();
worldX - FillerBlockUtil.unpackX(oldFiller);
y - FillerBlockUtil.unpackY(oldFiller);
worldZ - FillerBlockUtil.unpackZ(oldFiller);
FillerBlockUtil.forEachFillerBlock(((BlockBoundingBoxes)hitboxAssetMap.getAsset(oldBlockType.getHitboxTypeIndex())).get(oldRotation), (x1, y1, z1) -> {
(x1 != || y1 != || z1 != ) {
baseX + x1;
baseY + y1;
baseZ + z1;
(ChunkUtil.isSameChunk(worldX, worldZ, blockX, blockZ)) {
.getBlockType(blockX, blockY, blockZ).getId();
(blockTypeKey1.equals(oldBlockKey)) {
.breakBlock(blockX, blockY, blockZ, settingsWithoutFiller);
}
} {
.getWorld().getBlockType(blockX, blockY, blockZ).getId();
(blockTypeKey1.equals(oldBlockKey)) {
.getWorld().breakBlock(blockX, blockY, blockZ, settingsWithoutFiller);
}
}
}
});
}
((settings & ) == && filler == ) {
settings | ;
FillerBlockUtil.forEachFillerBlock(((BlockBoundingBoxes)hitboxAssetMap.getAsset(blockType.getHitboxTypeIndex())).get(rotation), (x1, y1, z1) -> {
(x1 != || y1 != || z1 != ) {
worldX + x1;
y + y1;
worldZ + z1;
ChunkUtil.isSameChunk(worldX, worldZ, blockX, blockZ);
(sameChunk) {
.setBlock(blockX, blockY, blockZ, id, blockType, rotation, FillerBlockUtil.pack(x1, y1, z1), settingsWithoutSetFiller);
} {
.getWorld().getNonTickingChunk(ChunkUtil.indexChunkFromBlock(blockX, blockZ)).setBlock(blockX, blockY, blockZ, id, blockType, rotation, FillerBlockUtil.pack(x1, y1, z1), settingsWithoutSetFiller);
}
}
});
}
((settings & ) != ) {
FillerBlockUtil.forEachFillerBlock(((BlockBoundingBoxes)hitboxAssetMap.getAsset(blockType.getHitboxTypeIndex())).get(rotation), (x1, y1, z1) -> .getChunkAccessor().performBlockUpdate(worldX + x1, y + y1, worldZ + z1));
}
( .reference != && .reference.isValid()) {
( .world.isInThread()) {
.setBlockPhysics(x, y, z, blockType);
} {
CompletableFutureUtil._catch(CompletableFuture.runAsync(() -> .setBlockPhysics(x, y, z, blockType), .world));
}
}
}
changed;
} {
;
}
}
{
Store<ChunkStore> store = .reference.getStore();
(ChunkColumn)store.getComponent( .reference, ChunkColumn.getComponentType());
Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(y));
(section != ) {
(!blockType.hasSupport()) {
BlockPhysics.clear(store, section, x, y, z);
} {
BlockPhysics.reset(store, section, x, y, z);
}
}
}
{
y >= && y < ? .blockChunk.getSectionAtBlockY(y).getFiller(x, y, z) : ;
}
{
y >= && y < ? .blockChunk.getSectionAtBlockY(y).getRotationIndex(x, y, z) : ;
}
{
.blockChunk.setTicking(x, y, z, ticking);
}
{
.blockChunk.isTicking(x, y, z);
}
{
.blockChunk.getHeight(x, z);
}
{
.blockChunk.getHeight(index);
}
{
.blockChunk.getTint(x, z);
}
BlockState {
(y >= && y < ) {
(! .world.isInThread()) {
(BlockState)CompletableFuture.supplyAsync(() -> .getState(x, y, z), .world).join();
} {
ChunkUtil.indexBlockInColumn(x, y, z);
Ref<ChunkStore> reference = .blockComponentChunk.getEntityReference(index);
(reference != ) {
BlockState.getBlockState(reference, reference.getStore());
} {
Holder<ChunkStore> holder = .blockComponentChunk.getEntityHolder(index);
holder != ? BlockState.getBlockState(holder) : ;
}
}
} {
;
}
}
Ref<ChunkStore> {
(y >= && y < ) {
(! .world.isInThread()) {
(Ref)CompletableFuture.supplyAsync(() -> .getBlockComponentEntity(x, y, z), .world).join();
} {
ChunkUtil.indexBlockInColumn(x, y, z);
.blockComponentChunk.getEntityReference(index);
}
} {
;
}
}
Holder<ChunkStore> {
(y >= && y < ) {
(! .world.isInThread()) {
(Holder)CompletableFuture.supplyAsync(() -> .getBlockComponentHolder(x, y, z), .world).join();
} {
ChunkUtil.indexBlockInColumn(x, y, z);
Ref<ChunkStore> reference = .blockComponentChunk.getEntityReference(index);
(reference != ) {
reference.getStore().copyEntity(reference);
} {
Holder<ChunkStore> holder = .blockComponentChunk.getEntityHolder(index);
holder != ? holder.clone() : ;
}
}
} {
;
}
}
{
(y >= && y < ) {
Holder<ChunkStore> holder = state != ? state.toHolder() : ;
.setState(x, y, z, holder);
}
}
{
Ref<ChunkStore> columnRef = .getReference();
Store<ChunkStore> store = columnRef.getStore();
(ChunkColumn)store.getComponent(columnRef, ChunkColumn.getComponentType());
Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(y));
(section == ) {
- ;
} {
(FluidSection)store.getComponent(section, FluidSection.getComponentType());
fluidSection.getFluidId(x, y, z);
}
}
{
Ref<ChunkStore> columnRef = .getReference();
Store<ChunkStore> store = columnRef.getStore();
(ChunkColumn)store.getComponent(columnRef, ChunkColumn.getComponentType());
Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(y));
(section == ) {
;
} {
(FluidSection)store.getComponent(section, FluidSection.getComponentType());
fluidSection.getFluidLevel(x, y, z);
}
}
{
Ref<ChunkStore> columnRef = .getReference();
Store<ChunkStore> store = columnRef.getStore();
(ChunkColumn)store.getComponent(columnRef, ChunkColumn.getComponentType());
Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(y));
(section == ) {
;
} {
(BlockPhysics)store.getComponent(section, BlockPhysics.getComponentType());
blockPhysics != ? blockPhysics.get(x, y, z) : ;
}
}
{
(y >= && y < ) {
(! .world.isInThread()) {
CompletableFutureUtil._catch(CompletableFuture.runAsync(() -> .setState(x, y, z, holder), .world));
} {
;
ChunkUtil.indexBlockInColumn(x, y, z);
(holder == ) {
Ref<ChunkStore> reference = .blockComponentChunk.getEntityReference(index);
(reference != ) {
Holder<ChunkStore> oldHolder = reference.getStore().removeEntity(reference, RemoveReason.REMOVE);
BlockState.getBlockState(oldHolder);
(notify) {
.world.getNotificationHandler().updateState(x, y, z, (BlockState) , oldState);
}
} {
.blockComponentChunk.removeEntityHolder(index);
}
} {
BlockState.getBlockState(holder);
(state != ) {
state.setPosition( , (x, y, z));
}
Store<ChunkStore> blockComponentStore = .world.getChunkStore().getStore();
(! .is(ChunkFlag.TICKING)) {
Holder<ChunkStore> oldHolder = .blockComponentChunk.getEntityHolder(index);
;
(oldHolder != ) {
oldState = BlockState.getBlockState(oldHolder);
}
.blockComponentChunk.removeEntityHolder(index);
holder.putComponent(BlockModule.BlockStateInfo.getComponentType(), .BlockStateInfo(index, .reference));
.blockComponentChunk.addEntityHolder(index, holder);
(notify) {
.world.getNotificationHandler().updateState(x, y, z, state, oldState);
}
} {
Ref<ChunkStore> oldReference = .blockComponentChunk.getEntityReference(index);
;
(oldReference != ) {
Holder<ChunkStore> oldEntityHolder = blockComponentStore.removeEntity(oldReference, RemoveReason.REMOVE);
oldState = BlockState.getBlockState(oldEntityHolder);
} {
.blockComponentChunk.removeEntityHolder(index);
}
holder.putComponent(BlockModule.BlockStateInfo.getComponentType(), .BlockStateInfo(index, .reference));
blockComponentStore.addEntity(holder, AddReason.SPAWN);
(notify) {
.world.getNotificationHandler().updateState(x, y, z, state, oldState);
}
}
}
}
}
}
{
.needsSaving = ;
}
{
.needsSaving || .blockChunk.getNeedsSaving() || .blockComponentChunk.getNeedsSaving() || .entityChunk.getNeedsSaving();
}
{
.needsSaving;
( .blockChunk.consumeNeedsSaving()) {
out = ;
}
( .blockComponentChunk.consumeNeedsSaving()) {
out = ;
}
( .entityChunk.consumeNeedsSaving()) {
out = ;
}
.needsSaving = ;
out;
}
{
.isSaving;
}
{
.isSaving = saving;
}
{
.blockChunk.getIndex();
}
{
.blockChunk.getX();
}
{
.blockChunk.getZ();
}
{
.lightingUpdatesEnabled = enableLightUpdates;
}
{
.lightingUpdatesEnabled;
}
World {
.world;
}
String {
.blockChunk.getX();
+ var10000 + + .blockChunk.getZ() + + String.valueOf( .flags) + ;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/environment/EnvironmentChunk.java
package com.hypixel.hytale.server.core.universe.world.chunk.environment;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.server.core.asset.type.environment.config.Environment;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.util.io.ByteBufUtil;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2LongMap;
import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
import javax.annotation.Nonnull;
public class EnvironmentChunk implements Component <ChunkStore> {
public static final BuilderCodec<EnvironmentChunk> CODEC;
private final EnvironmentColumn[] columns;
private final Int2LongMap counts;
public static ComponentType<ChunkStore, EnvironmentChunk> getComponentType {
LegacyModule.get().getEnvironmentChunkComponentType();
}
{
( );
}
{
.columns = [ ];
.counts = ();
( ; i < .columns.length; ++i) {
.columns[i] = (defaultId);
}
}
Component<ChunkStore> {
();
( ; i < .columns.length; ++i) {
chunk.columns[i].copyFrom( .columns[i]);
}
chunk.counts.putAll( .counts);
chunk;
}
{
.columns[idx(x, z)].get(y);
}
EnvironmentColumn {
.columns[idx(x, z)];
}
{
.columns[idx(x, z)];
column.set(environmentId);
- ;
maxY;
{
column.get(minY);
maxY = column.getMax(minY);
maxY - minY + ;
.decrementBlockCount(id, ( )count);
} (maxY < );
.createIfNotExist(environmentId);
.incrementBlockCount(environmentId, );
column.set(environmentId);
}
{
.columns[idx(x, z)];
column.get(y);
(environmentId != oldInternalId) {
.decrementBlockCount(oldInternalId, );
.createIfNotExist(environmentId);
.incrementBlockCount(environmentId);
column.set(y, environmentId);
;
} {
;
}
}
{
.counts.containsKey(environmentId);
}
{
(! .counts.containsKey(environmentId)) {
.counts.put(environmentId, );
}
}
{
.counts.mergeLong(internalId, , Long::sum);
}
{
.counts.get(internalId);
.counts.put(internalId, oldCount + ( )count);
}
{
.counts.get(environmentId);
(oldCount <= count) {
.counts.remove(environmentId);
;
} {
.counts.put(environmentId, oldCount - count);
;
}
}
[] serialize() {
ByteBufAllocator.DEFAULT.buffer();
{
buf.writeInt( .counts.size());
(Int2LongMap.Entry entry : .counts.int2LongEntrySet()) {
entry.getIntKey();
(Environment)Environment.getAssetMap().getAsset(environmentId);
environment != ? environment.getId() : Environment.UNKNOWN.getId();
buf.writeInt(environmentId);
ByteBufUtil.writeUTF(buf, key);
}
( ; i < .columns.length; ++i) {
.columns[i].serialize(buf, (environmentIdx, buf0) -> buf0.writeInt(environmentIdx));
}
ByteBufUtil.getBytesRelease(buf);
} (Throwable t) {
buf.release();
SneakyThrow.sneakyThrow(t);
}
}
{
Unpooled.wrappedBuffer(bytes);
.counts.clear();
buf.readInt();
(mappingCount);
( ; i < mappingCount; ++i) {
buf.readInt();
ByteBufUtil.readUTF(buf);
Environment.getIndexOrUnknown(key, , key);
idMapping.put(serialId, environmentId);
.counts.put(environmentId, );
}
( ; i < .columns.length; ++i) {
.columns[i];
column.deserialize(buf, (buf0) -> idMapping.get(buf0.readInt()));
( ; x < column.size(); ++x) {
.counts.mergeLong(column.getValue(x), , Long::sum);
}
}
}
[] serializeProtocol() {
ByteBufAllocator.DEFAULT.buffer();
( ; i < .columns.length; ++i) {
.columns[i].serializeProtocol(buf);
}
ByteBufUtil.getBytesRelease(buf);
}
{
( ; i < .columns.length; ++i) {
.columns[i].trim();
}
}
{
ChunkUtil.indexColumn(x, z);
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(EnvironmentChunk.class, EnvironmentChunk:: ).addField( ( , Codec.BYTE_ARRAY), EnvironmentChunk::deserialize, EnvironmentChunk::serialize)).build();
}
}
com/hypixel/hytale/server/core/universe/world/chunk/environment/EnvironmentColumn.java
package com.hypixel.hytale.server.core.universe.world.chunk.environment;
import com.hypixel.hytale.function.consumer.IntObjectConsumer;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import java.util.function.ToIntFunction;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class EnvironmentColumn {
public static final int MIN = -2147483648 ;
public static final int MAX = 2147483647 ;
@Nonnull
private final IntArrayList maxYs;
@Nonnull
private final IntArrayList values;
public EnvironmentColumn (@Nonnull int [] maxYs, @Nonnull int [] values) {
this (new IntArrayList (maxYs), new IntArrayList (values));
}
public EnvironmentColumn (@Nonnull IntArrayList maxYs, @Nonnull IntArrayList values) {
(maxYs.size() + != values.size()) {
( );
} {
.maxYs = maxYs;
.values = values;
}
}
{
( ( ), ( []{initialId}));
}
{
.maxYs.size();
}
{
.values.size();
}
{
.values.getInt(index);
}
{
index <= ? - : .maxYs.getInt(index - ) + ;
}
{
index >= .maxYs.size() ? : .maxYs.getInt(index);
}
{
.maxYs.size();
(n == ) {
;
} {
;
n - ;
n;
(l <= r) {
(l + r) / ;
( .maxYs.getInt(mid) < y) {
l = mid + ;
} {
i = mid;
r = mid - ;
}
}
i;
}
}
{
.maxYs.clear();
.values.clear();
.values.add(value);
}
{
.values.getInt( .indexOf(y));
}
{
.indexOf(y);
.values.getInt(idx);
(currentValue != value) {
.maxYs.size();
;
(idx < keys) {
max = .maxYs.getInt(idx);
}
- ;
(idx > ) {
min = .maxYs.getInt(idx - ) + ;
}
(min == max) {
(idx < keys && .values.getInt(idx + ) == value) {
.maxYs.removeInt(idx);
.values.removeInt(idx);
} {
.values.set(idx, value);
}
(idx != && .values.getInt(idx - ) == value) {
.maxYs.removeInt(idx - );
.values.removeInt(idx - );
}
} (min == y) {
(idx != && .values.getInt(idx - ) == value) {
.maxYs.set(idx - , y);
} {
.maxYs.add(idx, y);
.values.add(idx, value);
}
} (max == y) {
(idx == keys) {
.maxYs.add(idx, y - );
.values.add(idx + , value);
} {
.maxYs.set(idx, y - );
( .values.getInt(idx + ) != value) {
.maxYs.add(idx + , y);
.values.add(idx + , value);
}
}
} {
.maxYs.add(idx, y);
.values.add(idx, value);
.maxYs.add(idx, y - );
.values.add(idx, currentValue);
}
}
}
{
.indexOf(y);
- ;
(idx > ) {
min = .maxYs.getInt(idx - ) + ;
}
min;
}
{
.indexOf(y);
.maxYs.size();
;
(idx < keys) {
max = .maxYs.getInt(idx);
}
max;
}
{
( fromY; y <= toY; ++y) {
.set(y, value);
}
}
{
.maxYs.size();
buf.writeInt(n);
( ; i < n; ++i) {
buf.writeInt( .maxYs.getInt(i));
}
( ; i <= n; ++i) {
valueSerializer.accept( .values.getInt(i), buf);
}
}
{
.maxYs.size();
buf.writeShortLE(n + );
- ;
( ; i < n; ++i) {
buf.writeShortLE(min);
buf.writeShortLE( .values.getInt(i));
.maxYs.getInt(i);
min = max + ;
}
buf.writeShortLE(min);
buf.writeShortLE( .values.getInt(n));
}
{
.maxYs.clear();
.values.clear();
buf.readInt();
.maxYs.ensureCapacity(n);
.values.ensureCapacity(n + );
( ; i < n; ++i) {
.maxYs.add(buf.readInt());
}
( ; i <= n; ++i) {
.values.add(valueDeserializer.applyAsInt(buf));
}
}
{
.maxYs.clear();
.values.clear();
.maxYs.ensureCapacity(other.maxYs.size());
.values.ensureCapacity(other.values.size());
.maxYs.addAll(other.maxYs);
.values.addAll(other.values);
}
{
.maxYs.trim();
.values.trim();
}
{
( == o) {
;
} (o != && .getClass() == o.getClass()) {
(EnvironmentColumn)o;
( .maxYs != ) {
(! .maxYs.equals(that.maxYs)) {
;
}
} (that.maxYs != ) {
;
}
.values != ? .values.equals(that.values) : that.values == ;
} {
;
}
}
{
.maxYs != ? .maxYs.hashCode() : ;
result = * result + ( .values != ? .values.hashCode() : );
result;
}
String {
String.valueOf( .maxYs);
+ var10000 + + String.valueOf( .values) + ;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/environment/EnvironmentRange.java
package com.hypixel.hytale.server.core.universe.world.chunk.environment;
import javax.annotation.Nonnull;
public class EnvironmentRange {
private int min;
private int max;
private int id;
public EnvironmentRange (int id) {
this (0 , 2147483646 , id);
}
public EnvironmentRange (int min, int max, int id) {
this .min = min;
this .max = max;
this .id = id;
}
public int getMin () {
return this .min;
}
void setMin (int min) {
this .min = min;
}
public int getMax () {
return this .max;
}
void setMax (int max) {
this .max = max;
}
public {
.id;
}
{
.id = id;
}
{
.max - .min + ;
}
EnvironmentRange {
( .min, .max, .id);
}
String {
+ .min + + .max + + .id + ;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/palette/BitFieldArr.java
package com.hypixel.hytale.server.core.universe.world.chunk.palette;
import javax.annotation.Nonnull;
public class BitFieldArr {
public static final int BITS_PER_INDEX = 8 ;
public static final int LAST_BIT_INDEX = 7 ;
public static final int INDEX_MASK = 255 ;
private final int bits;
private final int length;
@Nonnull
private final byte [] array;
public BitFieldArr (int bits, int length) {
if (bits <= 0 ) {
throw new IllegalArgumentException ("The number of bits must be greater than zero." );
} else if (length <= 0 ) {
throw ( );
} {
.bits = bits;
.array = [length * bits / ];
.length = length;
}
}
{
.length;
}
{
index * .bits;
(index + ) * .bits - ;
endBitIndex / ;
;
( ; i < .bits; ++bitIndex) {
bitIndex / ;
bitIndex % ;
(arrIndex <= endArrIndex && startBit != ) {
endBit;
(arrIndex == endArrIndex) {
endBit = endBitIndex % ;
(startBit == endBit) {
value |= ( .array[arrIndex] >> startBit & ) << i;
} (startBit == && endBit == ) {
value |= ( .array[arrIndex] & ) << i;
} {
- >>> - (endBit + - startBit);
value |= ( .array[arrIndex] >>> startBit & mask) << i;
}
} {
endBit = ;
(startBit == ) {
value |= ( .array[arrIndex] & ) << i;
} {
- >>> - (endBit + - startBit);
value |= ( .array[arrIndex] >>> startBit & mask) << i;
}
}
endBit - startBit;
i += inc;
bitIndex += inc;
} {
value |= ( .array[arrIndex] >> startBit & ) << i;
}
++i;
}
value;
}
{
index * .bits;
( ; i < .bits; ++bitIndex) {
.setBit(bitIndex, value >> i & );
++i;
}
}
{
(bit == ) {
.array[bitIndex / ] = ( )( .array[bitIndex / ] & ~( << bitIndex % ));
} {
.array[bitIndex / ] = ( )( .array[bitIndex / ] | << bitIndex % );
}
}
[] get() {
[] bytes = [ .array.length];
System.arraycopy( .array, , bytes, , .array.length);
bytes;
}
{
System.arraycopy(bytes, , .array, , Math.min(bytes.length, .array.length));
}
String {
();
( b : .array) {
sb.append(String.format( , Integer.toBinaryString(b & )).replace( , ));
}
sb.toString();
}
{
( .bits == other.bits) {
( );
} ( .length == other.length) {
( );
} {
System.arraycopy(other.array, , .array, , .array.length);
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/palette/IntBytePalette.java
package com.hypixel.hytale.server.core.universe.world.chunk.palette;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.server.core.util.io.ByteBufUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Nonnull;
public class IntBytePalette {
public static final int LENGTH = 1024 ;
private short count = 1 ;
private final Lock keysLock = new ReentrantLock ();
private int [] keys = new int []{0 };
private final BitFieldArr array = new BitFieldArr (10 , 1024 );
public IntBytePalette () {
}
public {
.keys = []{aDefault};
}
{
.contains(key);
ChunkUtil.indexColumn(x, z);
(id >= ) {
.optimize(index);
id = .contains(key);
}
(id >= ) {
.array.set(index, id);
} {
.keysLock.lock();
{
.contains(key);
(oldId >= ) {
.optimize(index);
oldId = .contains(key);
}
(oldId >= ) {
.array.set(index, oldId);
} {
.count;
.count = ( )(var10002 + );
var10002;
(newId >= ) {
( );
}
(newId >= ) {
.optimize(index);
var10002 = .count;
.count = ( )(var10002 + );
newId = var10002;
}
(newId >= .keys.length) {
[] keys = [newId + ];
System.arraycopy( .keys, , keys, , .keys.length);
.keys = keys;
}
.keys[newId] = key;
.array.set(index, newId);
}
} {
.keysLock.unlock();
}
}
;
}
{
.keys[ .array.get(ChunkUtil.indexColumn(x, z))];
}
{
.keysLock.lock();
{
( ; i < .keys.length; ++i) {
.keys[i];
(k == key) {
i;
var4;
}
}
- ;
} {
.keysLock.unlock();
}
}
{
.optimize(- );
}
{
( .keys[ .array.get( )]);
( ; i < .array.getLength(); ++i) {
(i != index) {
intBytePalette.set(ChunkUtil.xFromColumn(i), ChunkUtil.zFromColumn(i), .keys[ .array.get(i)]);
}
}
.keysLock.lock();
{
.count = intBytePalette.count;
.keys = intBytePalette.keys;
.array.set(intBytePalette.array.get());
} {
.keysLock.unlock();
}
}
{
.keysLock.lock();
{
dos.writeShortLE( .count);
( ; i < .count; ++i) {
dos.writeIntLE( .keys[i]);
}
[] bytes = .array.get();
dos.writeIntLE(bytes.length);
dos.writeBytes(bytes);
} {
.keysLock.unlock();
}
}
{
.keysLock.lock();
{
.count = dis.readShortLE();
.keys = [ .count];
( ; i < .count; ++i) {
.keys[i] = dis.readIntLE();
}
dis.readIntLE();
[] bytes = [length];
dis.readBytes(bytes);
.array.set(bytes);
( .count == ) {
.count = ;
.keys = []{ };
}
} {
.keysLock.unlock();
}
}
[] serialize() {
ByteBufAllocator.DEFAULT.buffer();
.serialize(buf);
ByteBufUtil.getBytesRelease(buf);
}
{
.keysLock.lock();
{
.count = other.count;
System.arraycopy(other.keys, , .keys, , .keys.length);
.array.copyFrom(other.array);
} {
.keysLock.unlock();
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/palette/ShortBytePalette.java
package com.hypixel.hytale.server.core.universe.world.chunk.palette;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.server.core.util.io.ByteBufUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Nonnull;
public class ShortBytePalette {
public static final int LENGTH = 1024 ;
private short count = 1 ;
private final Lock keysLock = new ReentrantLock ();
private short [] keys = new short []{0 };
private final BitFieldArr array = new BitFieldArr (10 , 1024 );
public ShortBytePalette () {
}
public {
.keys = []{aDefault};
}
{
.contains(key);
ChunkUtil.indexColumn(x, z);
(id >= ) {
.optimize(index);
id = .contains(key);
}
(id >= ) {
.array.set(index, id);
} {
.keysLock.lock();
{
.contains(key);
(oldId >= ) {
.optimize(index);
oldId = .contains(key);
}
(oldId >= ) {
.array.set(index, oldId);
} {
.count;
.count = ( )(var10002 + );
var10002;
(newId >= ) {
( );
}
(newId >= ) {
.optimize(index);
var10002 = .count;
.count = ( )(var10002 + );
newId = var10002;
}
(newId >= .keys.length) {
[] keys = [newId + ];
System.arraycopy( .keys, , keys, , .keys.length);
.keys = keys;
}
.keys[newId] = key;
.array.set(index, newId);
}
} {
.keysLock.unlock();
}
}
;
}
{
.keys[ .array.get(ChunkUtil.indexColumn(x, z))];
}
{
.keys[ .array.get(index)];
}
{
.keysLock.lock();
{
( ; i < .keys.length; ++i) {
( .keys[i] == key) {
i;
var3;
}
}
- ;
} {
.keysLock.unlock();
}
}
{
.optimize(- );
}
{
( .keys[ .array.get( )]);
( ; i < .array.getLength(); ++i) {
(i != index) {
shortBytePalette.set(ChunkUtil.xFromColumn(i), ChunkUtil.zFromColumn(i), .keys[ .array.get(i)]);
}
}
.keysLock.lock();
{
.count = shortBytePalette.count;
.keys = shortBytePalette.keys;
.array.set(shortBytePalette.array.get());
} {
.keysLock.unlock();
}
}
{
.keysLock.lock();
{
dos.writeShortLE( .count);
( ; i < .count; ++i) {
dos.writeShortLE( .keys[i]);
}
[] bytes = .array.get();
dos.writeIntLE(bytes.length);
dos.writeBytes(bytes);
} {
.keysLock.unlock();
}
}
{
.keysLock.lock();
{
.count = buf.readShortLE();
.keys = [ .count];
( ; i < .count; ++i) {
.keys[i] = buf.readShortLE();
}
buf.readIntLE();
[] bytes = [length];
buf.readBytes(bytes);
.array.set(bytes);
( .count == ) {
.count = ;
.keys = []{ };
}
} {
.keysLock.unlock();
}
}
[] serialize() {
ByteBufAllocator.DEFAULT.buffer();
.serialize(buf);
ByteBufUtil.getBytesRelease(buf);
}
{
.keysLock.lock();
{
.count = other.count;
System.arraycopy(other.keys, , .keys, , .keys.length);
.array.copyFrom(other.array);
} {
.keysLock.unlock();
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/BlockSection.java
package com.hypixel.hytale.server.core.universe.world.chunk.section;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.common.util.BitSetUtil;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.function.predicate.ObjectPositionBlockFunction;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.protocol.CachedPacket;
import com.hypixel.hytale.protocol.packets.world.PaletteType;
import com.hypixel.hytale.protocol.packets.world.SetChunk;
import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
import com.hypixel.hytale.server.core.asset.type.blocktick.BlockTickStrategy;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockMigration;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.asset.type.fluid.Fluid;
import com.hypixel.hytale.server.core.blocktype.component.BlockPhysics;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.palette.EmptySectionPalette;
import com.hypixel.hytale.server.core.universe.world.chunk.section.palette.ISectionPalette;
com.hypixel.hytale.server.core.universe.world.chunk.section.palette.PaletteTypeEnum;
com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
com.hypixel.hytale.server.core.util.FillerBlockUtil;
com.hypixel.hytale.server.core.util.io.ByteBufUtil;
com.hypixel.hytale.sneakythrow.SneakyThrow;
io.netty.buffer.ByteBuf;
io.netty.buffer.ByteBufAllocator;
io.netty.buffer.Unpooled;
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
it.unimi.dsi.fastutil.ints.Int2ShortMap;
it.unimi.dsi.fastutil.ints.IntList;
it.unimi.dsi.fastutil.ints.IntOpenHashSet;
it.unimi.dsi.fastutil.ints.IntSet;
it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
it.unimi.dsi.fastutil.objects.ObjectHeapPriorityQueue;
java.lang.ref.SoftReference;
java.time.Instant;
java.util.BitSet;
java.util.Comparator;
java.util.Map;
java.util.Objects;
java.util.concurrent.CompletableFuture;
java.util.concurrent.locks.StampedLock;
java.util.function.Function;
java.util.function.IntConsumer;
java.util.function.ToIntFunction;
javax.annotation.Nonnull;
javax.annotation.Nullable;
<ChunkStore> {
;
BuilderCodec<BlockSection> CODEC;
StampedLock chunkSectionLock;
loaded;
IntOpenHashSet changedPositions;
IntOpenHashSet swapChangedPositions;
ISectionPalette chunkSection;
ISectionPalette fillerSection;
ISectionPalette rotationSection;
ChunkLightData localLight;
localChangeCounter;
ChunkLightData globalLight;
globalChangeCounter;
BitSet tickingBlocks;
BitSet tickingBlocksCopy;
BitSet tickingWaitAdjacentBlocks;
tickingBlocksCount;
tickingBlocksCountCopy;
tickingWaitAdjacentBlockCount;
ObjectHeapPriorityQueue<TickRequest> tickRequests;
maximumHitboxExtent;
SoftReference<CompletableFuture<CachedPacket<SetChunk>>> cachedChunkPacket;
FluidSection migratedFluidSection;
BlockPhysics migratedBlockPhysics;
Comparator<TickRequest> TICK_REQUEST_COMPARATOR;
ComponentType<ChunkStore, BlockSection> {
LegacyModule.get().getBlockSectionComponentType();
}
{
(EmptySectionPalette.INSTANCE, EmptySectionPalette.INSTANCE, EmptySectionPalette.INSTANCE);
}
{
.chunkSectionLock = ();
.loaded = ;
.changedPositions = ( );
.swapChangedPositions = ( );
.tickRequests = <TickRequest>(TICK_REQUEST_COMPARATOR);
.maximumHitboxExtent = - ;
.chunkSection = chunkSection;
.fillerSection = fillerSection;
.rotationSection = rotationSection;
.tickingBlocks = ();
.tickingBlocksCopy = ();
.tickingWaitAdjacentBlocks = ();
.tickingBlocksCount = ;
.tickingBlocksCountCopy = ;
.localLight = ChunkLightData.EMPTY;
.localChangeCounter = ;
.globalLight = ChunkLightData.EMPTY;
.globalChangeCounter = ;
}
ISectionPalette {
.chunkSection;
}
{
.chunkSection = chunkSection;
}
{
Objects.requireNonNull(localLight);
.localLight = localLight.build();
}
{
Objects.requireNonNull(globalLight);
.globalLight = globalLight.build();
}
ChunkLightData {
.localLight;
}
ChunkLightData {
.globalLight;
}
{
.localLight.getChangeId() == .localChangeCounter;
}
{
.globalLight.getChangeId() == .globalChangeCounter;
}
{
++ .localChangeCounter;
.invalidateGlobalLight();
}
{
++ .globalChangeCounter;
}
{
.localChangeCounter;
}
{
.globalChangeCounter;
}
{
.cachedChunkPacket = ;
}
{
.chunkSectionLock.tryOptimisticRead();
.chunkSection.get(index);
(! .chunkSectionLock.validate(lock)) {
lock = .chunkSectionLock.readLock();
var5;
{
var5 = .chunkSection.get(index);
} {
.chunkSectionLock.unlockRead(lock);
}
var5;
} {
i;
}
}
{
.chunkSectionLock.tryOptimisticRead();
.fillerSection.get(index);
(! .chunkSectionLock.validate(lock)) {
lock = .chunkSectionLock.readLock();
var5;
{
var5 = .fillerSection.get(index);
} {
.chunkSectionLock.unlockRead(lock);
}
var5;
} {
i;
}
}
{
.getFiller(ChunkUtil.indexBlock(x, y, z));
}
{
.chunkSectionLock.tryOptimisticRead();
.rotationSection.get(index);
(! .chunkSectionLock.validate(lock)) {
lock = .chunkSectionLock.readLock();
var5;
{
var5 = .rotationSection.get(index);
} {
.chunkSectionLock.unlockRead(lock);
}
var5;
} {
i;
}
}
{
.getRotationIndex(ChunkUtil.indexBlock(x, y, z));
}
RotationTuple {
RotationTuple.get( .getRotationIndex(index));
}
RotationTuple {
.getRotation(ChunkUtil.indexBlock(x, y, z));
}
{
.chunkSectionLock.writeLock();
changed;
{
ISectionPalette. .chunkSection.set(blockIdx, blockId);
(result == ISectionPalette.SetResult.REQUIRES_PROMOTE) {
.chunkSection = .chunkSection.promote();
ISectionPalette. .chunkSection.set(blockIdx, blockId);
(repeatResult != ISectionPalette.SetResult.ADDED_OR_REMOVED) {
( );
}
} {
(result == ISectionPalette.SetResult.ADDED_OR_REMOVED) {
.maximumHitboxExtent = - ;
}
( .chunkSection.shouldDemote()) {
.chunkSection = .chunkSection.demote();
}
}
changed = result != ISectionPalette.SetResult.UNCHANGED;
result = .fillerSection.set(blockIdx, filler);
(result == ISectionPalette.SetResult.REQUIRES_PROMOTE) {
.fillerSection = .fillerSection.promote();
ISectionPalette. .fillerSection.set(blockIdx, filler);
(repeatResult != ISectionPalette.SetResult.ADDED_OR_REMOVED) {
( );
}
} ( .fillerSection.shouldDemote()) {
.fillerSection = .fillerSection.demote();
}
changed |= result != ISectionPalette.SetResult.UNCHANGED;
result = .rotationSection.set(blockIdx, rotation);
(result == ISectionPalette.SetResult.REQUIRES_PROMOTE) {
.rotationSection = .rotationSection.promote();
ISectionPalette. .rotationSection.set(blockIdx, rotation);
(repeatResult != ISectionPalette.SetResult.ADDED_OR_REMOVED) {
( );
}
} ( .rotationSection.shouldDemote()) {
.rotationSection = .rotationSection.demote();
}
changed |= result != ISectionPalette.SetResult.UNCHANGED;
(changed && .loaded) {
.changedPositions.add(blockIdx);
}
} {
.chunkSectionLock.unlockWrite(lock);
}
(changed) {
.invalidateLocalLight();
}
changed;
}
IntOpenHashSet {
.chunkSectionLock.writeLock();
IntOpenHashSet var4;
{
.swapChangedPositions.clear();
.changedPositions;
.changedPositions = .swapChangedPositions;
.swapChangedPositions = tmp;
var4 = tmp;
} {
.chunkSectionLock.unlockWrite(stamp);
}
var4;
}
{
.chunkSectionLock.tryOptimisticRead();
.chunkSection.contains(id);
(! .chunkSectionLock.validate(lock)) {
lock = .chunkSectionLock.readLock();
var5;
{
var5 = .chunkSection.contains(id);
} {
.chunkSectionLock.unlockRead(lock);
}
var5;
} {
contains;
}
}
{
.chunkSectionLock.tryOptimisticRead();
.chunkSection.containsAny(ids);
(! .chunkSectionLock.validate(lock)) {
lock = .chunkSectionLock.readLock();
var5;
{
var5 = .chunkSection.containsAny(ids);
} {
.chunkSectionLock.unlockRead(lock);
}
var5;
} {
contains;
}
}
{
.chunkSectionLock.tryOptimisticRead();
.chunkSection.count();
(! .chunkSectionLock.validate(lock)) {
lock = .chunkSectionLock.readLock();
var4;
{
var4 = .chunkSection.count();
} {
.chunkSectionLock.unlockRead(lock);
}
var4;
} {
count;
}
}
{
.chunkSectionLock.tryOptimisticRead();
.chunkSection.count(id);
(! .chunkSectionLock.validate(lock)) {
lock = .chunkSectionLock.readLock();
var5;
{
var5 = .chunkSection.count(id);
} {
.chunkSectionLock.unlockRead(lock);
}
var5;
} {
count;
}
}
IntSet {
.chunkSectionLock.tryOptimisticRead();
.chunkSection.values();
(! .chunkSectionLock.validate(lock)) {
lock = .chunkSectionLock.readLock();
IntSet var4;
{
var4 = .chunkSection.values();
} {
.chunkSectionLock.unlockRead(lock);
}
var4;
} {
values;
}
}
{
.chunkSectionLock.readLock();
{
.chunkSection.forEachValue(consumer);
} {
.chunkSectionLock.unlockRead(lock);
}
}
Int2ShortMap {
.chunkSectionLock.tryOptimisticRead();
.chunkSection.valueCounts();
(! .chunkSectionLock.validate(lock)) {
lock = .chunkSectionLock.readLock();
Int2ShortMap var4;
{
var4 = .chunkSection.valueCounts();
} {
.chunkSectionLock.unlockRead(lock);
}
var4;
} {
valueCounts;
}
}
{
.chunkSectionLock.tryOptimisticRead();
.chunkSection.isSolid( );
(! .chunkSectionLock.validate(lock)) {
lock = .chunkSectionLock.readLock();
var4;
{
var4 = .chunkSection.isSolid( );
} {
.chunkSectionLock.unlockRead(lock);
}
var4;
} {
isSolid;
}
}
{
.chunkSectionLock.readLock();
{
.chunkSection.find(ids, internalIdHolder, indexConsumer);
} {
.chunkSectionLock.unlockRead(lock);
}
}
{
.chunkSectionLock.readLock();
{
( .tickingBlocks.get(blockIdx) == ticking) {
;
var5;
}
} {
.chunkSectionLock.unlockRead(readStamp);
}
.chunkSectionLock.writeLock();
var7;
{
( .tickingBlocks.get(blockIdx) == ticking) {
var7 = ;
var7;
}
(ticking) {
++ .tickingBlocksCount;
} {
-- .tickingBlocksCount;
}
.tickingBlocks.set(blockIdx, ticking);
var7 = ;
} {
.chunkSectionLock.unlockWrite(var15);
}
var7;
}
{
.tickingBlocksCount > ? .tickingBlocksCount : ;
}
{
.tickingBlocksCountCopy;
}
{
.tickingBlocksCount > ;
}
{
( .tickingBlocksCount > ) {
.chunkSectionLock.readLock();
var4;
{
var4 = .tickingBlocks.get(blockIdx);
} {
.chunkSectionLock.unlockRead(readStamp);
}
var4;
} {
;
}
}
{
(gameTime != ) {
.tickRequests.enqueue( (index, gameTime));
}
}
{
TickRequest request;
(! .tickRequests.isEmpty() && (request = .tickRequests.first()).requestedGameTime.isBefore(gameTime)) {
.tickRequests.dequeue();
.setTicking(request.index, );
}
.chunkSectionLock.writeLock();
{
( .tickingBlocksCount != ) {
BitSetUtil.copyValues( .tickingBlocks, .tickingBlocksCopy);
.tickingBlocksCountCopy = .tickingBlocksCount;
.tickingBlocks.clear();
.tickingBlocksCount = ;
;
}
.tickingBlocksCountCopy = ;
} {
.chunkSectionLock.unlockWrite(writeStamp);
}
}
<T, V> {
( .tickingBlocksCountCopy == ) {
;
} {
sectionIndex << ;
;
( .tickingBlocksCopy.nextSetBit( ); index >= ; index = .tickingBlocksCopy.nextSetBit(index + )) {
ChunkUtil.xFromIndex(index);
ChunkUtil.yFromIndex(index);
ChunkUtil.zFromIndex(index);
acceptor.accept(t, v, x, y | sectionStartYBlock, z, .get(index));
.chunkSectionLock.writeLock();
{
(strategy) {
WAIT_FOR_ADJACENT_CHUNK_LOAD:
(! .tickingWaitAdjacentBlocks.get(index)) {
++ .tickingWaitAdjacentBlockCount;
.tickingWaitAdjacentBlocks.set(index, );
}
;
CONTINUE:
(! .tickingBlocks.get(index)) {
++ .tickingBlocksCount;
.tickingBlocks.set(index, );
}
}
} {
.chunkSectionLock.unlockWrite(writeStamp);
}
++ticked;
}
ticked;
}
}
{
.chunkSectionLock.writeLock();
{
.tickingBlocks.or( .tickingWaitAdjacentBlocks);
.tickingBlocksCount = .tickingBlocks.cardinality();
.tickingWaitAdjacentBlocks.clear();
.tickingWaitAdjacentBlockCount = ;
} {
.chunkSectionLock.unlockWrite(writeStamp);
}
}
{
.maximumHitboxExtent;
(extent != - ) {
extent;
} {
BlockBoundingBoxes.UNIT_BOX_MAXIMUM_EXTENT;
.chunkSectionLock.readLock();
{
IndexedLookupTableAssetMap<String, BlockBoundingBoxes> hitBoxAssetMap = BlockBoundingBoxes.getAssetMap();
BlockTypeAssetMap<String, BlockType> blockTypeMap = BlockType.getAssetMap();
( ; idx < ; ++idx) {
.chunkSection.get(idx);
(blockId != ) {
.rotationSection.get(idx);
blockTypeMap.getAsset(blockId);
(blockType != && !blockType.isUnknown()) {
hitBoxAssetMap.getAsset(blockType.getHitboxTypeIndex());
(asset != BlockBoundingBoxes.UNIT_BOX) {
asset.get(rotation).getBoundingBox().getMaximumExtent();
(boxMaximumExtent > maximumExtent) {
maximumExtent = boxMaximumExtent;
}
}
}
}
}
} {
.chunkSectionLock.unlockRead(lock);
}
.maximumHitboxExtent = maximumExtent;
}
}
{
.chunkSectionLock.writeLock();
{
.changedPositions.add(ChunkUtil.indexBlock(x, y, z));
} {
.chunkSectionLock.unlockWrite(stamp);
}
}
FluidSection {
.migratedFluidSection;
.migratedFluidSection = ;
temp;
}
BlockPhysics {
.migratedBlockPhysics;
.migratedBlockPhysics = ;
temp;
}
{
.chunkSectionLock.readLock();
{
.chunkSection.getPaletteType();
( )paletteType.ordinal();
buf.writeByte(paletteTypeId);
.chunkSection.serializeForPacket(buf);
.fillerSection.getPaletteType();
( )fillerType.ordinal();
buf.writeByte(fillerTypeId);
.fillerSection.serializeForPacket(buf);
.rotationSection.getPaletteType();
( )rotationType.ordinal();
buf.writeByte(rotationTypeId);
.rotationSection.serializeForPacket(buf);
} {
.chunkSectionLock.unlockRead(lock);
}
}
{
.chunkSectionLock.readLock();
{
buf.writeInt(BlockMigration.getAssetMap().getAssetCount());
.chunkSection.getPaletteType();
buf.writeByte(paletteType.ordinal());
.chunkSection.serialize(keySerializer, buf);
(paletteType != PaletteType.Empty) {
(BitSet) .tickingBlocks.clone();
combinedTickingBlock.or( .tickingWaitAdjacentBlocks);
buf.writeShort(combinedTickingBlock.cardinality());
[] data = combinedTickingBlock.toLongArray();
buf.writeShort(data.length);
( l : data) {
buf.writeLong(l);
}
}
buf.writeByte( .fillerSection.getPaletteType().ordinal());
.fillerSection.serialize(ByteBuf::writeShort, buf);
buf.writeByte( .rotationSection.getPaletteType().ordinal());
.rotationSection.serialize(ByteBuf::writeByte, buf);
.localLight.serialize(buf);
.globalLight.serialize(buf);
buf.writeShort( .localChangeCounter);
buf.writeShort( .globalChangeCounter);
} {
.chunkSectionLock.unlockRead(lock);
}
}
[] serialize(ExtraInfo extraInfo) {
ByteBufAllocator.DEFAULT.buffer();
{
.serialize(BlockType.KEY_SERIALIZER, buf);
ByteBufUtil.getBytesRelease(buf);
} (Throwable t) {
buf.release();
SneakyThrow.sneakyThrow(t);
}
}
{
;
(version >= ) {
blockMigrationVersion = buf.readInt();
}
Function<String, String> blockMigration = ;
Map<Integer, BlockMigration> blockMigrationMap = BlockMigration.getAssetMap().getAssetMap();
( (BlockMigration)blockMigrationMap.get(blockMigrationVersion); migration != ; migration = (BlockMigration)blockMigrationMap.get(blockMigrationVersion)) {
(blockMigration == ) {
Objects.requireNonNull(migration);
blockMigration = migration::getMigration;
} {
Objects.requireNonNull(migration);
blockMigration = blockMigration.andThen(migration::getMigration);
}
++blockMigrationVersion;
}
PaletteTypeEnum.get(buf.readByte());
typeEnum.getPaletteType();
.chunkSection = (ISectionPalette)typeEnum.getConstructor().get();
(version <= ) {
(ISectionPalette)typeEnum.getConstructor().get();
[] foundMigratable = []{ };
[] needsPhysics = []{ };
[] nextTempIndex = []{- };
Int2ObjectOpenHashMap<String> types = <String>();
Object2IntOpenHashMap<String> typesRev = <String>();
typesRev.defaultReturnValue(- );
tempSection.deserialize((bytebuf) -> {
ByteBufUtil.readUTF(bytebuf);
(blockMigration != ) {
key = (String)blockMigration.apply(key);
}
typesRev.getInt(key);
(index != - ) {
index;
} {
key.startsWith( ) || key.contains( ) || key.contains( ) || key.contains( ) || key.contains( ) || key.contains( ) || key.contains( ) || key.contains( );
foundMigratable[ ] |= migratable;
(migratable) {
nextTempIndex[ ];
nextTempIndex[ ];
nextTempIndex[ ] = var10003 - ;
index = var10000;
} {
index = BlockType.getBlockIdOrUnknown(key, , key);
needsPhysics[ ] |= ((BlockType)BlockType.getAssetMap().getAsset(index)).hasSupport();
}
types.put(index, key);
typesRev.put(key, index);
index;
}
}, buf, version);
(needsPhysics[ ]) {
.migratedBlockPhysics = ();
}
(foundMigratable[ ]) {
( ; index < ; ++index) {
tempSection.get(index);
(id >= ) {
.chunkSection.set(index, id);
} {
Rotation.None;
Rotation.None;
Rotation.None;
types.get(id);
(key.startsWith( ) || key.contains( )) {
( .migratedFluidSection == ) {
.migratedFluidSection = ();
}
Fluid. Fluid.convertBlockToFluid(key);
(result == ) {
( + key);
}
(result.blockTypeStr == ) {
.migratedFluidSection.setFluid(index, result.fluidId, result.fluidLevel);
;
}
key = result.blockTypeStr;
.migratedFluidSection.setFluid(index, result.fluidId, result.fluidLevel);
}
(key.contains( )) {
( .migratedBlockPhysics == ) {
.migratedBlockPhysics = ();
}
.migratedBlockPhysics.set(index, );
}
(key.contains( )) {
( .migratedBlockPhysics == ) {
.migratedBlockPhysics = ();
}
key.indexOf( ) + .length();
key.indexOf( , start);
(end == - ) {
end = key.length();
}
.migratedBlockPhysics.set(index, Integer.parseInt(key, start, end, ));
}
(key.contains( )) {
key.indexOf( ) + .length();
key.indexOf( , start);
(firstComma == - ) {
( );
}
key.indexOf( , firstComma + );
(secondComma == - ) {
( );
}
key.indexOf( , start);
(end == - ) {
end = key.length();
}
Integer.parseInt(key, start, firstComma, );
Integer.parseInt(key, firstComma + , secondComma, );
Integer.parseInt(key, secondComma + , end, );
FillerBlockUtil.pack(fillerX, fillerY, fillerZ);
ISectionPalette. .fillerSection.set(index, filler);
(result == ISectionPalette.SetResult.REQUIRES_PROMOTE) {
.fillerSection = .fillerSection.promote();
.fillerSection.set(index, filler);
}
}
(key.contains( )) {
key.indexOf( ) + .length();
key.indexOf( , start);
(end == - ) {
end = key.length();
}
rotationYaw = Rotation.ofDegrees(Integer.parseInt(key, start, end, ));
}
(key.contains( )) {
key.indexOf( ) + .length();
key.indexOf( , start);
(end == - ) {
end = key.length();
}
rotationPitch = Rotation.ofDegrees(Integer.parseInt(key, start, end, ));
}
(key.contains( )) {
key.indexOf( ) + .length();
key.indexOf( , start);
(end == - ) {
end = key.length();
}
rotationRoll = Rotation.ofDegrees(Integer.parseInt(key, start, end, ));
}
(rotationYaw != Rotation.None || rotationPitch != Rotation.None || rotationRoll != Rotation.None) {
RotationTuple.index(rotationYaw, rotationPitch, rotationRoll);
ISectionPalette. .rotationSection.set(index, rotation);
(result == ISectionPalette.SetResult.REQUIRES_PROMOTE) {
.rotationSection = .rotationSection.promote();
.rotationSection.set(index, rotation);
}
}
key.indexOf( );
(endOfName != - ) {
key = key.substring( , endOfName);
}
.chunkSection.set(index, BlockType.getBlockIdOrUnknown(key, , key));
}
}
( .chunkSection.shouldDemote()) {
.chunkSection.demote();
}
} {
.chunkSection = tempSection;
}
} (blockMigration != ) {
.chunkSection.deserialize((bytebuf) -> {
ByteBufUtil.readUTF(bytebuf);
key = (String)blockMigration.apply(key);
BlockType.getBlockIdOrUnknown(key, , key);
}, buf, version);
} {
.chunkSection.deserialize(keyDeserializer, buf, version);
}
(paletteType != PaletteType.Empty) {
.tickingBlocksCount = buf.readUnsignedShort();
buf.readUnsignedShort();
[] tickingBlocksData = [len];
( ; i < tickingBlocksData.length; ++i) {
tickingBlocksData[i] = buf.readLong();
}
.tickingBlocks = BitSet.valueOf(tickingBlocksData);
.tickingBlocksCount = .tickingBlocks.cardinality();
}
(version >= ) {
PaletteTypeEnum.get(buf.readByte());
.fillerSection = (ISectionPalette)fillerTypeEnum.getConstructor().get();
.fillerSection.deserialize(ByteBuf::readUnsignedShort, buf, version);
}
(version >= ) {
PaletteTypeEnum.get(buf.readByte());
.rotationSection = (ISectionPalette)rotationTypeEnum.getConstructor().get();
.rotationSection.deserialize(ByteBuf::readUnsignedByte, buf, version);
}
.localLight = ChunkLightData.deserialize(buf, version);
.globalLight = ChunkLightData.deserialize(buf, version);
.localChangeCounter = buf.readShort();
.globalChangeCounter = buf.readShort();
}
{
Unpooled.wrappedBuffer(bytes);
.deserialize(BlockType.KEY_DESERIALIZER, buf, extraInfo.getVersion());
}
Component<ChunkStore> {
( );
}
Component<ChunkStore> {
;
}
CompletableFuture<CachedPacket<SetChunk>> {
SoftReference<CompletableFuture<CachedPacket<SetChunk>>> ref = .cachedChunkPacket;
CompletableFuture<CachedPacket<SetChunk>> future = ref != ? (CompletableFuture)ref.get() : ;
(future != ) {
future;
} {
future = CompletableFuture.supplyAsync(() -> {
[] localLightArr = ;
[] globalLightArr = ;
[] data = ;
(BlockChunk.SEND_LOCAL_LIGHTING_DATA && .hasLocalLight()) {
.getLocalLight();
Unpooled.buffer();
localLight.serializeForPacket(buffer);
( .getLocalChangeCounter() == localLight.getChangeId()) {
localLightArr = ByteBufUtil.getBytesRelease(buffer);
}
}
(BlockChunk.SEND_GLOBAL_LIGHTING_DATA && .hasGlobalLight()) {
Unpooled.buffer();
.getGlobalLight();
globalLight.serializeForPacket(buffer);
( .getGlobalChangeCounter() == globalLight.getChangeId()) {
globalLightArr = ByteBufUtil.getBytesRelease(buffer);
}
}
(! .isSolidAir()) {
Unpooled.buffer( );
.serializeForPacket(buf);
data = ByteBufUtil.getBytesRelease(buf);
}
(x, y, z, localLightArr, globalLightArr, data);
CachedPacket.cache(setChunk);
});
.cachedChunkPacket = (future);
future;
}
}
{
.get(ChunkUtil.indexBlock(x, y, z));
}
{
.set(ChunkUtil.indexBlock(x, y, z), blockId, rotation, filler);
}
{
.setTicking(ChunkUtil.indexBlock(x, y, z), ticking);
}
{
.isTicking(ChunkUtil.indexBlock(x, y, z));
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(BlockSection.class, BlockSection:: ).versioned()).codecVersion( )).append( ( , Codec.BYTE_ARRAY), BlockSection::deserialize, BlockSection::serialize).add()).build();
TICK_REQUEST_COMPARATOR = Comparator.comparing((t) -> t.requestedGameTime);
}
{
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/ChunkLightData.java
package com.hypixel.hytale.server.core.universe.world.chunk.section;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import javax.annotation.Nonnull;
public class ChunkLightData {
public static final ChunkLightData EMPTY = new ChunkLightData ((ByteBuf)null , (short )0 );
public static final int TREE_SIZE = 8 ;
public static final int TREE_MASK = 7 ;
public static final int DEPTH_MAGIC = 12 ;
public static final int SIZE_MAGIC = 17 ;
public static final ;
;
;
;
;
;
;
;
;
;
;
;
;
- ;
changeId;
ByteBuf light;
{
.light = light;
.changeId = changeId;
}
{
.changeId;
}
{
.getRedBlockLight(ChunkUtil.indexBlock(x, y, z));
}
{
.light == ? : .getLight(index, );
}
{
.getGreenBlockLight(ChunkUtil.indexBlock(x, y, z));
}
{
.light == ? : .getLight(index, );
}
{
.getBlueBlockLight(ChunkUtil.indexBlock(x, y, z));
}
{
.light == ? : .getLight(index, );
}
{
.getBlockLightIntensity(ChunkUtil.indexBlock(x, y, z));
}
{
( .light == ) {
;
} {
.getLight(index, );
.getLight(index, );
.getLight(index, );
( )(MathUtil.maxValue(b, g, r) & );
}
}
{
.getBlockLight(ChunkUtil.indexBlock(x, y, z));
}
{
.light == ? : ( )( .getLightRaw(index) & - );
}
{
.getSkyLight(ChunkUtil.indexBlock(x, y, z));
}
{
.light == ? : .getLight(index, );
}
{
(channel >= && channel < ) {
( .light == ) {
;
} {
.getLightRaw(index);
( )(value >> channel * & );
}
} {
();
}
}
{
.getLightRaw(ChunkUtil.indexBlock(x, y, z));
}
{
( .light == ) {
;
} (index >= && index < ) {
getTraverse( .light, index, , );
} {
( + index + );
}
}
{
- ;
- ;
{
pointer * ;
local.getByte(position);
index >> - depth & ;
loc = innerIndex * + position + ;
result = local.getUnsignedShort(loc);
(mask >> innerIndex & ) == ? getTraverse(local, index, result, depth + ) : ( )result;
} (Throwable t) {
( + index + + pointer + + depth + + result + + loc, t);
}
}
{
buf.writeShort( .changeId);
.light != ;
buf.writeBoolean(hasLight);
(hasLight) {
buf.ensureWritable( .light.readableBytes());
buf.writerIndex();
buf.writeInt( );
.serializeOctree(buf, );
buf.writerIndex();
buf.writerIndex(before);
buf.writeInt(after - before - );
buf.writerIndex(after);
}
}
{
.light.getByte(position * );
buf.writeByte(mask);
( ; i < ; ++i) {
.light.getUnsignedShort(position * + i * + );
((mask >> i & ) == ) {
.serializeOctree(buf, val);
} {
buf.writeShort(val);
}
}
}
{
.light != ;
buf.writeBoolean(hasLight);
(hasLight) {
buf.ensureWritable( .light.readableBytes());
.serializeOctreeForPacket(buf, );
}
}
{
.light.getByte(position * );
buf.writeByte(mask);
( ; i < ; ++i) {
.light.getUnsignedShort(position * + i * + );
((mask >> i & ) == ) {
.serializeOctreeForPacket(buf, val);
} {
buf.writeShortLE(val);
}
}
}
ChunkLightData {
buf.readShort();
buf.readBoolean();
ChunkLightData chunkLightData;
(hasLight) {
buf.readInt();
buf.readSlice(length);
length * / ;
Unpooled.buffer(estSize);
buffer.writerIndex( );
deserializeOctree(from, buffer, , );
chunkLightData = (buffer.copy(), changeId);
} {
chunkLightData = ((ByteBuf) , changeId);
}
chunkLightData;
}
{
from.readByte();
to.setByte(position * , mask);
( ; i < ; ++i) {
val;
((mask >> i & ) == ) {
++segmentIndex;
to.writerIndex((segmentIndex + ) * );
val = segmentIndex;
segmentIndex = deserializeOctree(from, to, segmentIndex, segmentIndex);
} {
val = from.readShort();
}
to.setShort(position * + i * + , val);
}
segmentIndex;
}
String {
.light == ? : ChunkLightDataBuilder.octreeToString( .light);
}
{
( )(sky << | blue << | green << | red << );
}
{
( )(blue << | green << | red << );
}
{
( )(value >> channel * & );
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/ChunkLightDataBuilder.java
package com.hypixel.hytale.server.core.universe.world.chunk.section;
import com.hypixel.hytale.math.util.ChunkUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import java.util.BitSet;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ChunkLightDataBuilder extends ChunkLightData {
static boolean DEBUG = false ;
protected BitSet currentSegments;
public ChunkLightDataBuilder (short changeId) {
super ((ByteBuf)null , changeId);
}
public ChunkLightDataBuilder (@Nonnull ChunkLightData lightData, short changeId) {
super (lightData.light != null ? lightData.light.copy() : null , changeId);
if (lightData instanceof ChunkLightDataBuilder) {
throw new IllegalArgumentException ("ChunkLightDataBuilder light data isn't compacted so we can't read this cleanly atm" );
} else {
if (this .light != null ) {
.currentSegments = ();
.currentSegments.set( );
findSegments( .light, , .currentSegments);
}
}
}
{
light.getByte(position * );
( ; i < ; ++i) {
light.getUnsignedShort(position * + i * + );
((mask >> i & ) == ) {
currentSegments.set(val);
findSegments(light, val, currentSegments);
}
}
}
{
.setBlockLight(ChunkUtil.indexBlock(x, y, z), red, green, blue);
}
{
.getLight(index, );
.setLightRaw(index, combineLightValues(red, green, blue, sky));
}
{
.setSkyLight(ChunkUtil.indexBlock(x, y, z), light);
}
{
.setLight(index, , light);
}
{
(channel >= && channel < ) {
.getLightRaw(index);
current &= ~( << channel * );
current |= (value & ) << channel * ;
.setLightRaw(index, ( )current);
} {
();
}
}
{
(index >= && index < ) {
( .light == ) {
.light = Unpooled.buffer( );
}
( .currentSegments == ) {
.currentSegments = ();
.currentSegments.set( );
}
setTraverse( .light, .currentSegments, index, , , value);
} {
( + index + );
}
}
ChunkLightData {
( .light == ) {
((ByteBuf) , .changeId);
} {
Unpooled.buffer( .currentSegments.cardinality() * );
buffer.writerIndex( );
.serializeOctree(buffer, , );
(buffer, .changeId);
}
}
{
segmentIndex;
.light.getByte(position * );
to.setByte(segmentIndex * , mask);
( ; i < ; ++i) {
.light.getUnsignedShort(position * + i * + );
((mask >> i & ) == ) {
to.ensureWritable( );
++segmentIndex;
to.writerIndex((segmentIndex + ) * );
val;
val = segmentIndex;
segmentIndex = .serializeOctree(to, from, segmentIndex);
}
to.setShort(toPosition * + i * + , val);
}
segmentIndex;
}
Res {
pointer * ;
local.getByte(headerLocation);
index >> - depth & ;
innerIndex * + headerLocation + ;
local.getShort(position);
{
((i >> innerIndex & ) == ) {
currentValue & ;
(depth == ) {
( + i + + innerIndex + + depth + + value + + currentValue + + index + + pointer);
}
(setTraverse(local, currentSegments, index, currentValueMasked, depth + , value) != ) {
currentSegments.clear(currentValueMasked);
local.setShort(position, value);
~( << innerIndex);
i = ( )(i & mask);
local.setByte(headerLocation, i);
(i == ) {
( ; j < ; ++j) {
local.getShort(j * + headerLocation + );
(s != value) {
;
}
}
ChunkLightDataBuilder.Res.INSTANCE;
}
}
} (value != currentValue) {
(depth > ) {
( + octreeToString(local) + + index + + pointer + + depth + + value + );
}
(depth == ) {
[] bytes = ;
(DEBUG) {
bytes = [ ];
local.getBytes(headerLocation, ( [])bytes, , bytes.length);
}
local.setShort(position, value);
( ; j < ; ++j) {
local.getShort(j * + headerLocation + );
(s != value) {
;
}
}
DEBUG ? (ByteBufUtil.hexDump(bytes)) : ChunkLightDataBuilder.Res.INSTANCE;
}
i = ( )(i | << innerIndex);
local.setByte(headerLocation, i);
growSegment(local, currentSegments, currentValue);
local.setShort(position, newSegmentIndex);
setTraverse(local, currentSegments, index, newSegmentIndex, depth + , value);
(out != ) {
( + index + + pointer + + depth + + value + + currentValue + + String.valueOf(out));
}
;
}
;
} (Throwable t) {
( + index + + pointer + + depth + + value + + i + + innerIndex + + position + + currentValue, t);
}
}
{
currentSegments.nextClearBit( );
currentSegments.set(newSegmentIndex);
local.capacity();
(currentCapacity <= (newSegmentIndex + ) * ) {
currentCapacity + ;
local.capacity(newCap);
}
local.setByte(newSegmentIndex * , );
( ; j < ; ++j) {
local.setShort(newSegmentIndex * + j * + , val);
}
newSegmentIndex;
}
String {
.light == ? : octreeToString( .light);
}
String {
();
{
octreeToString(buffer, , out, );
} (Throwable t) {
( + String.valueOf(out), t);
}
out.toString();
}
{
buffer.getByte(pointer * );
( ; j < ; ++j) {
pointer * + j * + ;
buffer.getUnsignedShort(loc);
out.append( .repeat(Math.max( , recursion)));
((i & << j) != ) {
out.append( ).append(j).append( );
octreeToString(buffer, s, out, recursion + );
} {
out.append( ).append(j).append( ).append(s);
}
(j != ) {
out.append( );
}
}
}
{
((String) );
String segment;
{
.segment = segment;
}
String {
+ .segment + ;
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/ChunkSection.java
package com.hypixel.hytale.server.core.universe.world.chunk.section;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import javax.annotation.Nonnull;
public class ChunkSection implements Component <ChunkStore> {
public static final BuilderCodec<ChunkSection> CODEC = BuilderCodec.builder(ChunkSection.class, ChunkSection::new ).build();
private Ref<ChunkStore> chunkColumnReference;
private int x;
private int y;
private int z;
public static ComponentType<ChunkStore, ChunkSection> getComponentType () {
return LegacyModule.get().getChunkSectionComponentType();
}
private ChunkSection () {
}
public ChunkSection (Ref<ChunkStore> chunkColumnReference, int x, int y, int z) {
this .chunkColumnReference = chunkColumnReference;
this .x = x;
.y = y;
.z = z;
}
{
.chunkColumnReference = chunkReference;
.x = x;
.y = y;
.z = z;
}
Ref<ChunkStore> {
.chunkColumnReference;
}
{
.x;
}
{
.y;
}
{
.z;
}
Component<ChunkStore> {
;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/ChunkSectionReference.java
package com.hypixel.hytale.server.core.universe.world.chunk.section;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
public class ChunkSectionReference {
private BlockChunk chunk;
private BlockSection section;
private int sectionIndex;
public ChunkSectionReference (BlockChunk chunk, BlockSection section, int sectionIndex) {
this .section = section;
this .chunk = chunk;
this .sectionIndex = sectionIndex;
}
public BlockChunk getChunk () {
return this .chunk;
}
public BlockSection getSection () {
return this .section;
}
public int getSectionIndex () {
return this .sectionIndex;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/FluidSection.java
package com.hypixel.hytale.server.core.universe.world.chunk.section;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.protocol.CachedPacket;
import com.hypixel.hytale.protocol.packets.world.SetFluids;
import com.hypixel.hytale.server.core.asset.type.fluid.Fluid;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.server.core.universe.world.chunk.section.palette.EmptySectionPalette;
import com.hypixel.hytale.server.core.universe.world.chunk.section.palette.ISectionPalette;
import com.hypixel.hytale.server.core.universe.world.chunk.section.palette.PaletteTypeEnum;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.util.io.ByteBufUtil;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import java.lang.ref.SoftReference;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.StampedLock;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class FluidSection <ChunkStore> {
;
;
BuilderCodec<FluidSection> CODEC;
();
x;
y;
z;
;
ISectionPalette typePalette;
[] levelData;
nonZeroLevels;
IntOpenHashSet changedPositions;
IntOpenHashSet swapChangedPositions;
SoftReference<CompletableFuture<CachedPacket<SetFluids>>> cachedPacket;
{
.typePalette = EmptySectionPalette.INSTANCE;
.levelData = ;
.nonZeroLevels = ;
.changedPositions = ( );
.swapChangedPositions = ( );
.cachedPacket = ;
}
ComponentType<ChunkStore, FluidSection> {
LegacyModule.get().getFluidSectionComponentType();
}
{
.x = x;
.y = y;
.z = z;
}
{
.x = x;
.y = y;
.z = z;
.loaded = ;
}
{
.setFluidRaw(ChunkUtil.indexBlock(x, y, z), fluidId);
}
{
ISectionPalette. .typePalette.set(index, fluidId);
(result == ISectionPalette.SetResult.REQUIRES_PROMOTE) {
.typePalette = .typePalette.promote();
result = .typePalette.set(index, fluidId);
(result != ISectionPalette.SetResult.ADDED_OR_REMOVED) {
( );
}
} ( .typePalette.shouldDemote()) {
.typePalette = .typePalette.demote();
}
result != ISectionPalette.SetResult.UNCHANGED;
}
{
.setFluid(ChunkUtil.indexBlock(x, y, z), Fluid.getAssetMap().getIndex(fluid.getId()), level);
}
{
.setFluid(ChunkUtil.indexBlock(x, y, z), fluidId, level);
}
{
.setFluid(index, Fluid.getAssetMap().getIndex(fluid.getId()), level);
}
{
level = ( )(level & );
(level == ) {
fluidId = ;
}
(fluidId == ) {
level = ;
}
.lock.writeLock();
var7;
{
.setFluidRaw(index, fluidId);
changed |= .setFluidLevel(index, level);
(changed && .loaded) {
.cachedPacket = ;
.changedPositions.add(index);
}
var7 = changed;
} {
.lock.unlockWrite(stamp);
}
var7;
}
{
.setFluidRaw(ChunkUtil.indexBlock(x, y, z), fluid);
}
{
IndexedLookupTableAssetMap<String, Fluid> assetMap = Fluid.getAssetMap();
.setFluidRaw(index, assetMap.getIndex(fluid.getId()));
}
{
.getFluidId(ChunkUtil.indexBlock(x, y, z));
}
{
.lock.tryOptimisticRead();
.typePalette.get(index);
(! .lock.validate(stamp)) {
stamp = .lock.readLock();
{
currentId = .typePalette.get(index);
} {
.lock.unlockRead(stamp);
}
}
currentId;
}
Fluid {
.getFluid(ChunkUtil.indexBlock(x, y, z));
}
Fluid {
IndexedLookupTableAssetMap<String, Fluid> assetMap = Fluid.getAssetMap();
assetMap.getAsset( .getFluidId(index));
}
{
.setFluidLevel(ChunkUtil.indexBlock(x, y, z), level);
}
{
level = ( )(level & );
( .levelData == ) {
(level == ) {
;
}
.levelData = [ ];
}
index >> ;
.levelData[byteIndex];
byteValue >> (index & ) * & ;
(value == level) {
;
} {
(value == ) {
++ .nonZeroLevels;
} (level == ) {
-- .nonZeroLevels;
( .nonZeroLevels <= ) {
.levelData = ;
;
}
}
((index & ) == ) {
.levelData[byteIndex] = ( )(byteValue & | level);
} {
.levelData[byteIndex] = ( )(byteValue & | level << );
}
;
}
}
{
.getFluidLevel(ChunkUtil.indexBlock(x, y, z));
}
{
.lock.tryOptimisticRead();
[] localData = .levelData;
;
(localData != ) {
index >> ;
localData[byteIndex];
result = ( )(byteValue >> (index & ) * & );
}
(! .lock.validate(stamp)) {
stamp = .lock.readLock();
byteIndex;
{
( .levelData != ) {
byteIndex = index >> ;
.levelData[byteIndex];
( )(byteValue >> (index & ) * & );
var8;
}
byteIndex = ;
} {
.lock.unlockRead(stamp);
}
( )byteIndex;
} {
result;
}
}
{
.x;
}
{
.y;
}
{
.z;
}
IntOpenHashSet {
.lock.writeLock();
IntOpenHashSet var4;
{
.swapChangedPositions.clear();
.changedPositions;
.changedPositions = .swapChangedPositions;
.swapChangedPositions = tmp;
var4 = tmp;
} {
.lock.unlockWrite(stamp);
}
var4;
}
Component<ChunkStore> {
;
}
{
.lock.readLock();
{
buf.writeByte( .typePalette.getPaletteType().ordinal());
.typePalette.serializeForPacket(buf);
( .levelData != ) {
buf.writeBoolean( );
buf.writeBytes( .levelData);
} {
buf.writeBoolean( );
}
} {
.lock.unlockRead(stamp);
}
}
[] serialize(ExtraInfo extraInfo) {
ByteBufAllocator.DEFAULT.buffer();
.lock.readLock();
[] var5;
{
buf.writeByte( .typePalette.getPaletteType().ordinal());
.typePalette.serialize(Fluid.KEY_SERIALIZER, buf);
( .levelData != ) {
buf.writeBoolean( );
buf.writeBytes( .levelData);
} {
buf.writeBoolean( );
}
var5 = ByteBufUtil.getBytesRelease(buf);
} (Throwable e) {
buf.release();
SneakyThrow.sneakyThrow(e);
} {
.lock.unlockRead(stamp);
}
var5;
}
{
Unpooled.wrappedBuffer(bytes);
PaletteTypeEnum.get(buf.readByte());
.typePalette = (ISectionPalette)type.getConstructor().get();
.typePalette.deserialize(Fluid.KEY_DESERIALIZER, buf, );
(buf.readBoolean()) {
.levelData = [ ];
buf.readBytes( .levelData);
.nonZeroLevels = ;
( ; i < ; ++i) {
.levelData[i];
((v & ) != ) {
++ .nonZeroLevels;
}
((v & ) != ) {
++ .nonZeroLevels;
}
}
} {
.levelData = ;
}
}
CompletableFuture<CachedPacket<SetFluids>> {
SoftReference<CompletableFuture<CachedPacket<SetFluids>>> ref = .cachedPacket;
CompletableFuture<CachedPacket<SetFluids>> future = ref != ? (CompletableFuture)ref.get() : ;
(future != ) {
future;
} {
future = CompletableFuture.supplyAsync(() -> {
Unpooled.buffer( );
.serializeForPacket(buf);
[] data = ByteBufUtil.getBytesRelease(buf);
( .x, .y, .z, data);
CachedPacket.cache(packet);
});
.cachedPacket = (future);
future;
}
}
{
.typePalette.isSolid( ) && .nonZeroLevels == ;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(FluidSection.class, FluidSection:: ).versioned()).codecVersion( )).append( ( , Codec.BYTE_ARRAY), FluidSection::deserialize, FluidSection::serialize).add()).build();
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/blockpositions/BlockPositionData.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.blockpositions;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.chunk.section.ChunkSectionReference;
public class BlockPositionData implements IBlockPositionData {
private static final double HALF_BLOCK = 0.5 ;
private int blockIndex;
private ChunkSectionReference section;
private int blockType;
public BlockPositionData (int blockIndex, ChunkSectionReference section, int blockType) {
this .blockIndex = blockIndex;
this .section = section;
this .blockType = blockType;
}
public BlockSection getChunkSection () {
return this .section.getSection();
}
public int getBlockType () {
return this .blockType;
}
public int getX () {
ChunkUtil.xFromIndex( .blockIndex) + ( .section.getChunk().getX() << );
}
{
ChunkUtil.yFromIndex( .blockIndex) + ( .section.getSectionIndex() << );
}
{
ChunkUtil.zFromIndex( .blockIndex) + ( .section.getChunk().getZ() << );
}
{
( ) .getX() + ;
}
{
( ) .getY() + ;
}
{
( ) .getZ() + ;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/blockpositions/BlockPositionProvider.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.blockpositions;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.function.consumer.IntObjectConsumer;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.modules.LegacyModule;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.util.BitSet;
import java.util.List;
import java.util.Objects;
import java.util.function.BiPredicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockPositionProvider implements Component <ChunkStore> {
private final BitSet searchedBlockSets;
@Nullable
private final Int2ObjectMap<List<IBlockPositionData>> blockData;
private final short lightChangeCounter;
public ComponentType<ChunkStore, BlockPositionProvider> {
LegacyModule.get().getBlockPositionProviderComponentType();
}
{
.searchedBlockSets = (BitSet)blockSets.clone();
.lightChangeCounter = lightChangeCounter;
(data != ) {
.blockData = Int2ObjectMaps.<List<IBlockPositionData>>unmodifiable(data);
} {
.blockData = ;
}
}
{
.lightChangeCounter != section.getLocalChangeCounter() || ! .searchedBlockSets.get(currentBlockSet);
}
<T> {
( .blockData != ) {
List<IBlockPositionData> data = .blockData.getOrDefault(blockSet, (Object) );
(data != ) {
(TransformComponent)componentAccessor.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
range * range;
( ; i < data.size(); ++i) {
(IBlockPositionData)data.get(i);
entry.getYCentre();
(Math.abs(pos.y - entryY) <= yRange && pos.distanceSquaredTo(entry.getXCentre(), entryY, entry.getZCentre()) <= range2 && (filter == || !filter.test(entry, obj))) {
resultList.add(entry);
}
}
}
}
}
BitSet {
(BitSet) .searchedBlockSets.clone();
}
{
( .blockData != ) {
.blockData;
Objects.requireNonNull(listConsumer);
var10000.forEach(listConsumer::accept);
}
}
Component<ChunkStore> {
;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/blockpositions/IBlockPositionData.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.blockpositions;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
public interface IBlockPositionData {
BlockSection getChunkSection () ;
int getBlockType () ;
int getX () ;
int getY () ;
int getZ () ;
double getXCentre () ;
double getYCentre () ;
double getZCentre () ;
}
com/hypixel/hytale/server/core/universe/world/chunk/section/palette/AbstractByteSectionPalette.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.palette;
import com.hypixel.hytale.math.util.NumberUtil;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.bytes.Byte2ByteMap;
import it.unimi.dsi.fastutil.bytes.Byte2ByteOpenHashMap;
import it.unimi.dsi.fastutil.bytes.Byte2IntMap;
import it.unimi.dsi.fastutil.bytes.Byte2IntOpenHashMap;
import it.unimi.dsi.fastutil.bytes.Byte2ShortMap;
import it.unimi.dsi.fastutil.bytes.Byte2ShortOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ByteMap;
import it.unimi.dsi.fastutil.ints.Int2ByteOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ShortMap;
import it.unimi.dsi.fastutil.ints.Int2ShortOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.shorts.ShortBinaryOperator;
import java.util.BitSet;
import java.util.function.IntConsumer;
import java.util.function.ToIntFunction;
import javax.annotation.Nonnull;
public abstract class AbstractByteSectionPalette implements ISectionPalette {
protected final Int2ByteMap externalToInternal;
protected final Byte2IntMap internalToExternal;
protected final BitSet internalIdSet;
protected final Byte2ShortMap internalIdCount;
protected [] blocks;
{
( (), (), (), (), blocks);
.externalToInternal.put( , ( ) );
.internalToExternal.put(( ) , );
.internalIdSet.set( );
.internalIdCount.put(( ) , ( )- );
}
{
( (count), (count), (count), (count), blocks);
( ; internalId < count; ++internalId) {
unique[internalId];
.internalToExternal.put(( )internalId, blockId);
.externalToInternal.put(blockId, ( )internalId);
.internalIdSet.set( .unsignedInternalId(( )internalId));
.internalIdCount.put(( )internalId, ( ) );
}
( ; index < data.length; ++index) {
data[index];
.externalToInternal.get(id);
.incrementBlockCount(internalId);
.set0(index, internalId);
}
}
{
.externalToInternal = externalToInternal;
.internalToExternal = internalToExternal;
.internalIdSet = internalIdSet;
.internalIdCount = internalIdCount;
.blocks = blocks;
}
{
.get0(index);
.internalToExternal.get(internalId);
}
ISectionPalette.SetResult {
.get0(index);
( .externalToInternal.containsKey(id)) {
.externalToInternal.get(id);
(newInternalId == oldInternalId) {
ISectionPalette.SetResult.UNCHANGED;
} {
.decrementBlockCount(oldInternalId);
.incrementBlockCount(newInternalId);
.set0(index, newInternalId);
removed ? ISectionPalette.SetResult.ADDED_OR_REMOVED : ISectionPalette.SetResult.CHANGED;
}
} {
.nextInternalId(oldInternalId);
(! .isValidInternalId(nextInternalId)) {
ISectionPalette.SetResult.REQUIRES_PROMOTE;
} {
.decrementBlockCount(oldInternalId);
( )nextInternalId;
.createBlockId(newInternalId, id);
.set0(index, newInternalId);
ISectionPalette.SetResult.ADDED_OR_REMOVED;
}
}
}
;
;
{
.externalToInternal.containsKey(id);
}
{
( ; i < ids.size(); ++i) {
( .externalToInternal.containsKey(ids.getInt(i))) {
;
}
}
;
}
{
.internalIdCount.size();
}
{
( .externalToInternal.containsKey(id)) {
.externalToInternal.get(id);
.internalIdCount.get(internalId);
} {
;
}
}
IntSet {
( .externalToInternal.keySet());
}
{
.externalToInternal.keySet().forEach(consumer);
}
Int2ShortMap {
();
(Byte2ShortMap.Entry entry : .internalIdCount.byte2ShortEntrySet()) {
entry.getByteKey();
entry.getShortValue();
.internalToExternal.get(internalId);
map.put(externalId, count);
}
map;
}
{
.internalToExternal.put(internalId, blockId);
.externalToInternal.put(blockId, internalId);
.internalIdSet.set( .unsignedInternalId(internalId));
.internalIdCount.put(internalId, ( ) );
}
{
.internalIdCount.get(internalId);
(oldCount == ) {
.internalIdCount.remove(internalId);
.internalToExternal.remove(internalId);
.externalToInternal.remove(externalId);
.internalIdSet.clear( .unsignedInternalId(internalId));
;
} {
.internalIdCount.mergeShort(internalId, ( ) , (ShortBinaryOperator)(NumberUtil::subtract));
;
}
}
{
.internalIdCount.mergeShort(internalId, ( ) , (ShortBinaryOperator)(NumberUtil::sum));
}
{
.internalIdCount.get(oldInternalId) == ? .unsignedInternalId(oldInternalId) : .internalIdSet.nextClearBit( );
}
;
;
{
buf.writeShortLE( .internalToExternal.size());
(Byte2IntMap.Entry entry : .internalToExternal.byte2IntEntrySet()) {
entry.getByteKey();
entry.getIntValue();
buf.writeByte(internalId);
buf.writeIntLE(externalId);
buf.writeShortLE( .internalIdCount.get(internalId));
}
buf.writeBytes( .blocks);
}
{
buf.writeShort( .internalToExternal.size());
(Byte2IntMap.Entry entry : .internalToExternal.byte2IntEntrySet()) {
entry.getByteKey();
entry.getIntValue();
buf.writeByte(internalId);
keySerializer.serialize(buf, externalId);
buf.writeShort( .internalIdCount.get(internalId));
}
buf.writeBytes( .blocks);
}
{
.externalToInternal.clear();
.internalToExternal.clear();
.internalIdSet.clear();
.internalIdCount.clear();
;
buf.readShort();
( ; i < blockCount; ++i) {
buf.readByte();
deserializer.applyAsInt(buf);
buf.readShort();
( .externalToInternal.containsKey(externalId)) {
.externalToInternal.get(externalId);
(internalIdRemapping == ) {
internalIdRemapping = ();
}
internalIdRemapping.put(internalId, existingInternalId);
.internalIdCount.mergeShort(existingInternalId, count, NumberUtil::sum);
} {
.externalToInternal.put(externalId, internalId);
.internalToExternal.put(internalId, externalId);
.internalIdSet.set( .unsignedInternalId(internalId));
.internalIdCount.put(internalId, count);
}
}
buf.readBytes( .blocks);
(internalIdRemapping != ) {
( ; i < ; ++i) {
.get0(i);
(internalIdRemapping.containsKey(oldInternalId)) {
.set0(i, internalIdRemapping.get(oldInternalId));
}
}
}
}
{
( ; i < ids.size(); ++i) {
.externalToInternal.getOrDefault(ids.getInt(i), ( )- );
(internal != - ) {
internalIdHolder.add(internal);
}
}
( ; i < ; ++i) {
.get0(i);
(internalIdHolder.contains(type)) {
indexConsumer.accept(i);
}
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/palette/AbstractShortSectionPalette.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.palette;
import com.hypixel.hytale.math.util.NumberUtil;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ShortMap;
import it.unimi.dsi.fastutil.ints.Int2ShortOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.shorts.Short2IntMap;
import it.unimi.dsi.fastutil.shorts.Short2IntOpenHashMap;
import it.unimi.dsi.fastutil.shorts.Short2ShortMap;
import it.unimi.dsi.fastutil.shorts.Short2ShortOpenHashMap;
import it.unimi.dsi.fastutil.shorts.ShortBinaryOperator;
import java.util.BitSet;
import java.util.function.IntConsumer;
import java.util.function.ToIntFunction;
import javax.annotation.Nonnull;
public abstract class AbstractShortSectionPalette implements ISectionPalette {
protected final Int2ShortMap externalToInternal;
protected final Short2IntMap internalToExternal;
protected final BitSet internalIdSet;
protected final Short2ShortMap internalIdCount;
protected final short [] blocks;
public AbstractShortSectionPalette (short [] blocks) {
( (), (), (), (), blocks);
.externalToInternal.put( , ( ) );
.internalToExternal.put(( ) , );
.internalIdSet.set( );
.internalIdCount.put(( ) , ( )- );
}
{
( (count), (count), (count), (count), blocks);
( ; internalId < count; ++internalId) {
unique[internalId];
.internalToExternal.put(( )internalId, blockId);
.externalToInternal.put(blockId, ( )internalId);
.internalIdSet.set(internalId);
.internalIdCount.put(( )internalId, ( ) );
}
( ; index < data.length; ++index) {
data[index];
.externalToInternal.get(id);
.incrementBlockCount(internalId);
.set0(index, internalId);
}
}
{
.externalToInternal = externalToInternal;
.internalToExternal = internalToExternal;
.internalIdSet = internalIdSet;
.internalIdCount = internalIdCount;
.blocks = blocks;
}
{
.get0(index);
.internalToExternal.get(internalId);
}
ISectionPalette.SetResult {
.get0(index);
( .externalToInternal.containsKey(id)) {
.externalToInternal.get(id);
(newInternalId == oldInternalId) {
ISectionPalette.SetResult.UNCHANGED;
} {
.decrementBlockCount(oldInternalId);
.incrementBlockCount(newInternalId);
.set0(index, newInternalId);
removed ? ISectionPalette.SetResult.ADDED_OR_REMOVED : ISectionPalette.SetResult.CHANGED;
}
} {
.nextInternalId(oldInternalId);
(! .isValidInternalId(nextInternalId)) {
ISectionPalette.SetResult.REQUIRES_PROMOTE;
} {
.decrementBlockCount(oldInternalId);
( )nextInternalId;
.createBlockId(newInternalId, id);
.set0(index, newInternalId);
ISectionPalette.SetResult.ADDED_OR_REMOVED;
}
}
}
;
;
{
.externalToInternal.containsKey(id);
}
{
( ; i < ids.size(); ++i) {
( .externalToInternal.containsKey(ids.getInt(i))) {
;
}
}
;
}
{
.internalIdCount.size();
}
{
( .externalToInternal.containsKey(id)) {
.externalToInternal.get(id);
.internalIdCount.get(internalId);
} {
;
}
}
IntSet {
( .externalToInternal.keySet());
}
{
.externalToInternal.keySet().forEach(consumer);
}
Int2ShortMap {
();
(Short2ShortMap.Entry entry : .internalIdCount.short2ShortEntrySet()) {
entry.getShortKey();
entry.getShortValue();
.internalToExternal.get(internalId);
map.put(externalId, count);
}
map;
}
{
.internalToExternal.put(internalId, blockId);
.externalToInternal.put(blockId, internalId);
.internalIdSet.set(internalId);
.internalIdCount.put(internalId, ( ) );
}
{
.internalIdCount.get(internalId);
(oldCount == ) {
.internalIdCount.remove(internalId);
.internalToExternal.remove(internalId);
.externalToInternal.remove(externalId);
.internalIdSet.clear(internalId);
;
} {
.internalIdCount.mergeShort(internalId, ( ) , (ShortBinaryOperator)(NumberUtil::subtract));
;
}
}
{
.internalIdCount.mergeShort(internalId, ( ) , (ShortBinaryOperator)(NumberUtil::sum));
}
{
.internalIdCount.get(oldInternalId) == ? oldInternalId : .internalIdSet.nextClearBit( );
}
;
{
buf.writeShortLE( .internalToExternal.size());
(Short2IntMap.Entry entry : .internalToExternal.short2IntEntrySet()) {
entry.getShortKey();
entry.getIntValue();
buf.writeShortLE(internalId & );
buf.writeIntLE(externalId);
buf.writeShortLE( .internalIdCount.get(internalId));
}
( ; i < .blocks.length; ++i) {
buf.writeShortLE( .blocks[i]);
}
}
{
buf.writeShort( .internalToExternal.size());
(Short2IntMap.Entry entry : .internalToExternal.short2IntEntrySet()) {
entry.getShortKey();
entry.getIntValue();
buf.writeShort(internalId & );
keySerializer.serialize(buf, externalId);
buf.writeShort( .internalIdCount.get(internalId));
}
( ; i < .blocks.length; ++i) {
buf.writeShort( .blocks[i]);
}
}
{
.externalToInternal.clear();
.internalToExternal.clear();
.internalIdSet.clear();
.internalIdCount.clear();
;
buf.readShort();
( ; i < blockCount; ++i) {
buf.readShort();
deserializer.applyAsInt(buf);
buf.readShort();
( .externalToInternal.containsKey(externalId)) {
.externalToInternal.get(externalId);
(internalIdRemapping == ) {
internalIdRemapping = ();
}
internalIdRemapping.put(internalId, existingInternalId);
.internalIdCount.mergeShort(existingInternalId, count, NumberUtil::sum);
} {
.externalToInternal.put(externalId, internalId);
.internalToExternal.put(internalId, externalId);
.internalIdSet.set(internalId);
.internalIdCount.put(internalId, count);
}
}
( ; i < .blocks.length; ++i) {
.blocks[i] = buf.readShort();
}
(internalIdRemapping != ) {
( ; i < ; ++i) {
.get0(i);
(internalIdRemapping.containsKey(oldInternalId)) {
.set0(i, internalIdRemapping.get(oldInternalId));
}
}
}
}
{
( ; i < ids.size(); ++i) {
.externalToInternal.getOrDefault(ids.getInt(i), ( )- );
(internal != - ) {
internalIdHolder.add(internal);
}
}
( ; i < ; ++i) {
.get0(i);
(internalIdHolder.contains(type)) {
indexConsumer.accept(i);
}
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/palette/ByteSectionPalette.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.palette;
import com.hypixel.hytale.common.util.BitSetUtil;
import com.hypixel.hytale.protocol.packets.world.PaletteType;
import it.unimi.dsi.fastutil.bytes.Byte2IntMap;
import it.unimi.dsi.fastutil.bytes.Byte2ShortMap;
import it.unimi.dsi.fastutil.ints.Int2ByteMap;
import it.unimi.dsi.fastutil.shorts.Short2ByteMap;
import it.unimi.dsi.fastutil.shorts.Short2ByteOpenHashMap;
import it.unimi.dsi.fastutil.shorts.Short2IntMap;
import java.util.BitSet;
import javax.annotation.Nonnull;
public class ByteSectionPalette extends AbstractByteSectionPalette {
private static final int KEY_MASK = 255 ;
public static final int MAX_SIZE = 256 ;
public static final int DEMOTE_SIZE = 14 ;
public ByteSectionPalette () {
super (new byte ['耀' ]);
}
public {
(externalToInternal, internalToExternal, internalIdSet, internalIdCount, blocks);
}
{
( [ ], data, unique, count);
}
PaletteType {
PaletteType.Byte;
}
{
.blocks[idx];
}
{
.blocks[idx] = b;
}
{
.count() <= ;
}
HalfByteSectionPalette {
HalfByteSectionPalette.fromBytePalette( );
}
ShortSectionPalette {
ShortSectionPalette.fromBytePalette( );
}
{
(internalId & ) == internalId;
}
{
internalId & ;
}
{
internalId & ;
}
ByteSectionPalette {
();
byteSection.externalToInternal.clear();
byteSection.externalToInternal.putAll(section.externalToInternal);
byteSection.internalToExternal.clear();
byteSection.internalToExternal.putAll(section.internalToExternal);
BitSetUtil.copyValues(section.internalIdSet, byteSection.internalIdSet);
byteSection.internalIdCount.clear();
byteSection.internalIdCount.putAll(section.internalIdCount);
( ; i < byteSection.blocks.length; ++i) {
byteSection.blocks[i] = section.get0(i);
}
byteSection;
}
ByteSectionPalette {
(section.count() > ) {
( + section.count());
} {
();
();
byteSection.internalToExternal.clear();
byteSection.externalToInternal.clear();
byteSection.internalIdSet.clear();
byteSection.internalIdCount.clear();
(Short2IntMap.Entry entry : section.internalToExternal.short2IntEntrySet()) {
entry.getShortKey();
entry.getIntValue();
( )byteSection.internalIdSet.nextClearBit( );
byteSection.internalIdSet.set(sUnsignedInternalId(newInternalId));
internalIdRemapping.put(oldInternalId, newInternalId);
byteSection.internalToExternal.put(newInternalId, externalId);
byteSection.externalToInternal.put(externalId, newInternalId);
byteSection.internalIdCount.put(newInternalId, section.internalIdCount.get(oldInternalId));
}
( ; i < ; ++i) {
section.blocks[i];
internalIdRemapping.get(internalId);
byteSection.blocks[i] = byteInternalId;
}
byteSection;
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/palette/EmptySectionPalette.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.palette;
import com.hypixel.hytale.protocol.packets.world.PaletteType;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ShortMap;
import it.unimi.dsi.fastutil.ints.Int2ShortOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import java.util.function.IntConsumer;
import java.util.function.ToIntFunction;
import javax.annotation.Nonnull;
public class EmptySectionPalette implements ISectionPalette {
public static final int EMPTY_ID = 0 ;
public static final EmptySectionPalette INSTANCE = new EmptySectionPalette ();
private EmptySectionPalette () {
}
@Nonnull
public PaletteType getPaletteType () {
return PaletteType.Empty;
}
@Nonnull
public ISectionPalette.SetResult set (int index, id) {
id == ? ISectionPalette.SetResult.UNCHANGED : ISectionPalette.SetResult.REQUIRES_PROMOTE;
}
{
;
}
{
;
}
ISectionPalette {
( );
}
ISectionPalette {
();
}
{
id == ;
}
{
ids.contains( );
}
{
id == ;
}
{
;
}
{
id == ? : ;
}
IntSet {
();
set.add( );
set;
}
{
consumer.accept( );
}
Int2ShortMap {
();
map.put( , ( )- );
map;
}
{
(ids.contains( )) {
( ; i < ; ++i) {
indexConsumer.accept(i);
}
}
}
{
}
{
}
{
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/palette/HalfByteSectionPalette.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.palette;
import com.hypixel.hytale.common.util.BitUtil;
import com.hypixel.hytale.protocol.packets.world.PaletteType;
import it.unimi.dsi.fastutil.bytes.Byte2ByteMap;
import it.unimi.dsi.fastutil.bytes.Byte2ByteOpenHashMap;
import it.unimi.dsi.fastutil.bytes.Byte2IntMap;
import it.unimi.dsi.fastutil.bytes.Byte2ShortMap;
import it.unimi.dsi.fastutil.ints.Int2ByteMap;
import java.util.BitSet;
import javax.annotation.Nonnull;
public class HalfByteSectionPalette extends AbstractByteSectionPalette {
private static final int KEY_MASK = 15 ;
public static final int MAX_SIZE = 16 ;
public HalfByteSectionPalette () {
super (new byte [16384 ]);
}
public HalfByteSectionPalette (Int2ByteMap externalToInternal, Byte2IntMap internalToExternal, BitSet internalIdSet, Byte2ShortMap internalIdCount, byte [] blocks) {
super (externalToInternal, internalToExternal, internalIdSet, internalIdCount, blocks);
}
{
( [ ], data, unique, count);
}
PaletteType {
PaletteType.HalfByte;
}
{
BitUtil.setNibble( .blocks, idx, b);
}
{
BitUtil.getNibble( .blocks, idx);
}
{
.isSolid( );
}
ISectionPalette {
EmptySectionPalette.INSTANCE;
}
ByteSectionPalette {
ByteSectionPalette.fromHalfBytePalette( );
}
{
(internalId & ) == internalId;
}
{
internalId & ;
}
{
internalId & ;
}
HalfByteSectionPalette {
(section.count() > ) {
( + section.count());
} {
();
();
halfByteSection.internalToExternal.clear();
halfByteSection.externalToInternal.clear();
halfByteSection.internalIdSet.clear();
(Byte2IntMap.Entry entry : section.internalToExternal.byte2IntEntrySet()) {
entry.getByteKey();
entry.getIntValue();
( )halfByteSection.internalIdSet.nextClearBit( );
halfByteSection.internalIdSet.set(sUnsignedInternalId(newInternalId));
internalIdRemapping.put(oldInternalId, newInternalId);
halfByteSection.internalToExternal.put(newInternalId, externalId);
halfByteSection.externalToInternal.put(externalId, newInternalId);
}
halfByteSection.internalIdCount.clear();
(Byte2ShortMap.Entry entry : section.internalIdCount.byte2ShortEntrySet()) {
entry.getByteKey();
entry.getShortValue();
internalIdRemapping.get(internalId);
halfByteSection.internalIdCount.put(newInternalId, count);
}
( ; i < section.blocks.length; ++i) {
section.blocks[i];
internalIdRemapping.get(internalId);
halfByteSection.set0(i, byteInternalId);
}
halfByteSection;
}
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/palette/ISectionPalette.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.palette;
import com.hypixel.hytale.protocol.packets.world.PaletteType;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ShortMap;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntSet;
import java.util.function.IntConsumer;
import java.util.function.ToIntFunction;
import javax.annotation.Nonnull;
public interface ISectionPalette {
PaletteType getPaletteType () ;
SetResult set (int var1, int var2) ;
int get (int var1) ;
boolean contains (int var1) ;
boolean containsAny (IntList var1) ;
default boolean isSolid (int id) {
return this .count() == 1 && this .contains(id);
}
int count () ;
int count (int var1) ;
IntSet values ;
;
Int2ShortMap ;
;
;
ISectionPalette ;
ISectionPalette ;
;
;
;
ISectionPalette {
(count == && unique[ ] == ) {
EmptySectionPalette.INSTANCE;
} (count < ) {
(data, unique, count);
} (count < ) {
(data, unique, count);
} (count < ) {
(data, unique, count);
} {
( );
}
}
{
ADDED_OR_REMOVED,
CHANGED,
UNCHANGED,
REQUIRES_PROMOTE;
{
}
}
{
;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/palette/PaletteTypeEnum.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.palette;
import com.hypixel.hytale.protocol.packets.world.PaletteType;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
public enum PaletteTypeEnum {
EMPTY(PaletteType.Empty, () -> EmptySectionPalette.INSTANCE),
HALF_BYTE(PaletteType.HalfByte, HalfByteSectionPalette::new ),
BYTE(PaletteType.Byte, ByteSectionPalette::new ),
SHORT(PaletteType.Short, ShortSectionPalette::new );
private static final PaletteTypeEnum[] values = values();
@Nonnull
private final PaletteType paletteType;
private final Supplier<? extends ISectionPalette > constructor;
private final byte paletteId;
public static PaletteTypeEnum get (byte paletteId) {
return values[paletteId];
}
private <T extends ISectionPalette > PaletteTypeEnum(@Nonnull PaletteType paletteType, Supplier<T> constructor) {
this .paletteType = paletteType;
this .constructor = constructor;
this .paletteId = (byte )paletteType.ordinal();
}
@Nonnull
public PaletteType getPaletteType {
.paletteType;
}
Supplier<? > getConstructor() {
.constructor;
}
{
.paletteId;
}
}
com/hypixel/hytale/server/core/universe/world/chunk/section/palette/ShortSectionPalette.java
package com.hypixel.hytale.server.core.universe.world.chunk.section.palette;
import com.hypixel.hytale.protocol.packets.world.PaletteType;
import it.unimi.dsi.fastutil.bytes.Byte2IntMap;
import it.unimi.dsi.fastutil.ints.Int2ShortMap;
import it.unimi.dsi.fastutil.ints.Int2ShortOpenHashMap;
import it.unimi.dsi.fastutil.shorts.Short2IntMap;
import it.unimi.dsi.fastutil.shorts.Short2IntOpenHashMap;
import it.unimi.dsi.fastutil.shorts.Short2ShortMap;
import it.unimi.dsi.fastutil.shorts.Short2ShortOpenHashMap;
import java.util.BitSet;
import javax.annotation.Nonnull;
public class ShortSectionPalette extends AbstractShortSectionPalette {
private static final int KEY_MASK = 65535 ;
public static final int MAX_SIZE = 65536 ;
public static final int DEMOTE_SIZE = 251 ;
public ShortSectionPalette () {
super (new short ['耀' ]);
}
public {
(externalToInternal, internalToExternal, internalIdSet, internalIdCount, blocks);
}
{
( [ ], data, unique, count);
}
PaletteType {
PaletteType.Short;
}
{
.blocks[idx];
}
{
.blocks[idx] = s;
}
{
.count() <= ;
}
ByteSectionPalette {
ByteSectionPalette.fromShortPalette( );
}
ISectionPalette {
( );
}
{
(internalId & ) == internalId;
}
ShortSectionPalette {
();
();
(section.internalToExternal.size());
();
(Byte2IntMap.Entry entry : section.internalToExternal.byte2IntEntrySet()) {
( )(entry.getByteKey() & );
entry.getIntValue();
shortInternalToExternal.put(internal, external);
shortExternalToInternal.put(external, internal);
shortInternalIdSet.set(internal);
shortInternalIdCount.put(internal, section.internalIdCount.get(entry.getByteKey()));
}
[] shortBlocks = [ ];
( ; i < ; ++i) {
shortBlocks[i] = ( )(section.blocks[i] & );
}
(shortExternalToInternal, shortInternalToExternal, shortInternalIdSet, shortInternalIdCount, shortBlocks);
}
}
com/hypixel/hytale/server/core/universe/world/chunk/state/TickableBlockState.java
package com.hypixel.hytale.server.core.universe.world.chunk.state;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import javax.annotation.Nullable;
public interface TickableBlockState {
void tick (float var1, int var2, ArchetypeChunk<ChunkStore> var3, Store<ChunkStore> var4, CommandBuffer<ChunkStore> var5) ;
Vector3i getPosition () ;
Vector3i getBlockPosition () ;
@Nullable
WorldChunk getChunk () ;
void invalidate () ;
}
com/hypixel/hytale/server/core/universe/world/chunk/systems/ChunkSystems.java
package com.hypixel.hytale.server.core.universe.world.chunk.systems;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.NonTicking;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.dependency.Order;
import com.hypixel.hytale.component.dependency.RootDependency;
import com.hypixel.hytale.component.dependency.SystemDependency;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.HolderSystem;
import com.hypixel.hytale.component.system.RefChangeSystem;
import com.hypixel.hytale.component.system.RefSystem;
import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
import com.hypixel.hytale.component.system.tick.RunWhenPausedSystem;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.protocol.CachedPacket;
import com.hypixel.hytale.protocol.packets.world.ServerSetBlock;
import com.hypixel.hytale.protocol.packets.world.ServerSetBlocks;
import com.hypixel.hytale.protocol.packets.world.SetBlockCmd;
import com.hypixel.hytale.protocol.packets.world.SetChunk;
import com.hypixel.hytale.server.core.modules.entity.player.ChunkTracker;
com.hypixel.hytale.server.core.modules.migrations.ChunkColumnMigrationSystem;
com.hypixel.hytale.server.core.universe.PlayerRef;
com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn;
com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
com.hypixel.hytale.server.core.universe.world.chunk.section.ChunkSection;
com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
it.unimi.dsi.fastutil.ints.IntIterator;
it.unimi.dsi.fastutil.ints.IntOpenHashSet;
it.unimi.dsi.fastutil.objects.ObjectArrayList;
java.util.Arrays;
java.util.Collection;
java.util.Set;
java.util.concurrent.CompletableFuture;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
HytaleLogger.forEnclosingClass();
;
{
}
{
Query<ChunkStore> QUERY = Query.<ChunkStore>and(WorldChunk.getComponentType(), Query.not(ChunkColumn.getComponentType()));
{
}
{
Holder[] sectionHolders = [ ];
( ; i < sectionHolders.length; ++i) {
sectionHolders[i] = ChunkStore.REGISTRY.newHolder();
}
holder.addComponent(ChunkColumn.getComponentType(), (sectionHolders));
}
{
}
Query<ChunkStore> {
QUERY;
}
Set<Dependency<ChunkStore>> {
RootDependency.firstSet();
}
}
<ChunkStore> {
Query<ChunkStore> QUERY = Query.<ChunkStore>and(ChunkColumn.getComponentType(), WorldChunk.getComponentType());
Set<Dependency<ChunkStore>> DEPENDENCIES;
{
}
{
(ChunkColumn)commandBuffer.getComponent(ref, ChunkColumn.getComponentType());
chunk != ;
(WorldChunk)commandBuffer.getComponent(ref, WorldChunk.getComponentType());
worldChunk != ;
Ref<ChunkStore>[] sections = chunk.getSections();
Holder<ChunkStore>[] sectionHolders = chunk.takeSectionHolders();
commandBuffer.getArchetype(ref).contains(ChunkStore.REGISTRY.getNonTickingComponentType());
(sectionHolders != && sectionHolders.length > && sectionHolders[ ] != ) {
( ; i < sectionHolders.length; ++i) {
(isNonTicking) {
sectionHolders[i].ensureComponent(ChunkStore.REGISTRY.getNonTickingComponentType());
} {
sectionHolders[i].tryRemoveComponent(ChunkStore.REGISTRY.getNonTickingComponentType());
}
(ChunkSection)sectionHolders[i].getComponent(ChunkSection.getComponentType());
(section == ) {
sectionHolders[i].addComponent(ChunkSection.getComponentType(), (ref, worldChunk.getX(), i, worldChunk.getZ()));
} {
section.load(ref, worldChunk.getX(), i, worldChunk.getZ());
}
}
commandBuffer.addEntities(sectionHolders, , sections, , sections.length, AddReason.LOAD);
}
( ; i < sections.length; ++i) {
(sections[i] == ) {
Holder<ChunkStore> newSection = ChunkStore.REGISTRY.newHolder();
(isNonTicking) {
newSection.ensureComponent(ChunkStore.REGISTRY.getNonTickingComponentType());
} {
newSection.tryRemoveComponent(ChunkStore.REGISTRY.getNonTickingComponentType());
}
newSection.addComponent(ChunkSection.getComponentType(), (ref, worldChunk.getX(), i, worldChunk.getZ()));
sections[i] = commandBuffer.addEntity(newSection, AddReason.SPAWN);
}
}
}
{
(ChunkColumn)commandBuffer.getComponent(ref, ChunkColumn.getComponentType());
chunk != ;
Ref<ChunkStore>[] sections = chunk.getSections();
Holder<ChunkStore>[] holders = [sections.length];
( ; i < sections.length; ++i) {
Ref<ChunkStore> section = sections[i];
holders[i] = ChunkStore.REGISTRY.newHolder();
commandBuffer.removeEntity(section, holders[i], reason);
}
chunk.putSectionHolders(holders);
Arrays.fill(sections, (Object) );
}
Query<ChunkStore> {
QUERY;
}
Set<Dependency<ChunkStore>> {
DEPENDENCIES;
}
{
DEPENDENCIES = Set.of( (Order.AFTER, OnNewChunk.class));
}
}
<ChunkStore, NonTicking<ChunkStore>> {
Archetype<ChunkStore> archetype = Archetype.of(WorldChunk.getComponentType(), ChunkColumn.getComponentType());
{
}
ComponentType<ChunkStore, NonTicking<ChunkStore>> {
ChunkStore.REGISTRY.getNonTickingComponentType();
}
{
(ChunkColumn)commandBuffer.getComponent(ref, ChunkColumn.getComponentType());
column != ;
Ref<ChunkStore>[] sections = column.getSections();
( ; i < sections.length; ++i) {
Ref<ChunkStore> section = sections[i];
commandBuffer.ensureComponent(section, ChunkStore.REGISTRY.getNonTickingComponentType());
}
}
{
}
{
(ChunkColumn)commandBuffer.getComponent(ref, ChunkColumn.getComponentType());
column != ;
Ref<ChunkStore>[] sections = column.getSections();
( ; i < sections.length; ++i) {
Ref<ChunkStore> section = sections[i];
commandBuffer.tryRemoveComponent(section, ChunkStore.REGISTRY.getNonTickingComponentType());
}
}
Query<ChunkStore> {
.archetype;
}
}
<ChunkStore> {
Query<ChunkStore> QUERY = Query.<ChunkStore>and(ChunkSection.getComponentType(), Query.not(BlockSection.getComponentType()));
{
}
{
holder.ensureComponent(BlockSection.getComponentType());
}
{
}
Query<ChunkStore> {
QUERY;
}
Set<Dependency<ChunkStore>> {
RootDependency.firstSet();
}
}
<ChunkStore> {
{
}
{
(BlockSection)holder.getComponent(BlockSection.getComponentType());
section != ;
section.loaded = ;
}
{
}
Query<ChunkStore> {
BlockSection.getComponentType();
}
}
<ChunkStore> <ChunkStore> {
Query<ChunkStore> QUERY = Query.<ChunkStore>and(ChunkSection.getComponentType(), BlockSection.getComponentType());
{
}
{
EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount);
}
{
(BlockSection)archetypeChunk.getComponent(index, BlockSection.getComponentType());
blockSection != ;
blockSection.getAndClearChangedPositions();
(!changes.isEmpty()) {
(ChunkSection)archetypeChunk.getComponent(index, ChunkSection.getComponentType());
section != ;
Collection<PlayerRef> players = ((ChunkStore)store.getExternalData()).getWorld().getPlayerRefs();
(players.isEmpty()) {
changes.clear();
} {
ChunkUtil.indexChunk(section.getX(), section.getZ());
(changes.size() >= ) {
ObjectArrayList<PlayerRef> playersCopy = <PlayerRef>(players);
CompletableFuture<CachedPacket<SetChunk>> set = blockSection.getCachedChunkPacket(section.getX(), section.getY(), section.getZ());
set.thenAccept((s) -> {
(PlayerRef player : playersCopy) {
Ref<EntityStore> ref = player.getReference();
(ref != ) {
player.getChunkTracker();
(tracker != && tracker.isLoaded(chunkIndex)) {
player.getPacketHandler().writeNoCache(s);
}
}
}
}).exceptionally((throwable) -> {
(throwable != ) {
((HytaleLogger.Api)ChunkSystems.LOGGER.at(Level.SEVERE).withCause(throwable)).log( );
}
;
});
changes.clear();
} {
(changes.size() == ) {
changes.iterator().nextInt();
ChunkUtil.minBlock(section.getX()) + ChunkUtil.xFromIndex(change);
ChunkUtil.minBlock(section.getY()) + ChunkUtil.yFromIndex(change);
ChunkUtil.minBlock(section.getZ()) + ChunkUtil.zFromIndex(change);
blockSection.get(change);
blockSection.getFiller(change);
blockSection.getRotationIndex(change);
(x, y, z, blockId, ( )filler, ( )rotation);
(PlayerRef player : players) {
Ref<EntityStore> ref = player.getReference();
(ref != ) {
player.getChunkTracker();
(tracker != && tracker.isLoaded(chunkIndex)) {
player.getPacketHandler().writeNoCache(packet);
}
}
}
} {
SetBlockCmd[] cmds = [changes.size()];
changes.intIterator();
change;
blockId;
filler;
rotation;
( ; iter.hasNext(); cmds[i++] = (( )change, blockId, ( )filler, ( )rotation)) {
change = iter.nextInt();
blockId = blockSection.get(change);
filler = blockSection.getFiller(change);
rotation = blockSection.getRotationIndex(change);
}
(section.getX(), section.getY(), section.getZ(), cmds);
(PlayerRef player : players) {
Ref<EntityStore> ref = player.getReference();
(ref != ) {
player.getChunkTracker();
(tracker != && tracker.isLoaded(chunkIndex)) {
player.getPacketHandler().writeNoCache(packet);
}
}
}
}
changes.clear();
}
}
}
}
Query<ChunkStore> {
QUERY;
}
Set<Dependency<ChunkStore>> {
RootDependency.lastSet();
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/SetTickingCommand.java
package com.hypixel.hytale.server.core.universe.world.commands;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class SetTickingCommand extends AbstractWorldCommand {
@Nonnull
private final RequiredArg<Boolean> tickingArg;
public SetTickingCommand () {
super ("setticking" , "server.commands.setticking.desc" );
this .tickingArg = this .withRequiredArg("ticking" , "server.commands.setticking.ticking.desc" , ArgTypes.BOOLEAN);
}
protected void execute (@Nonnull CommandContext context, @Nonnull World world, @Nonnull Store<EntityStore> store) {
boolean isTicking = (Boolean)this .tickingArg.get(context);
world.setTicking(isTicking);
context.sendMessage(Message.translation( ).param( , isTicking).param( , world.getName()));
}
}
com/hypixel/hytale/server/core/universe/world/commands/WorldSettingsCommand.java
package com.hypixel.hytale.server.core.universe.world.commands;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.shape.Box2D;
import com.hypixel.hytale.math.vector.Vector2d;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgumentType;
import com.hypixel.hytale.server.core.command.system.arguments.types.EnumArgumentType;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldConfig;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.server.core.universe.world.storage.provider.IChunkStorageProvider;
import com.hypixel.hytale.server.core.universe.world.worldgen.provider.IWorldGenProvider;
import com.hypixel.hytale.server.core.universe.world.worldmap.provider.IWorldMapProvider;
import java.util.Objects;
import java.util.function.BiConsumer;
import java.util.function.Function;
import javax.annotation.Nonnull;
public class WorldSettingsCommand extends AbstractCommandCollection {
();
{
( , );
.addAliases( []{ });
.generateSubCommand( , , , ArgTypes.STRING, , (worldConfig) -> (String)IWorldGenProvider.CODEC.getIdFor(worldConfig.getWorldGenProvider().getClass()), (worldConfig, path) -> worldConfig.setWorldGenProvider((IWorldGenProvider)((BuilderCodec)IWorldGenProvider.CODEC.getCodecFor(path)).getDefaultValue()));
.generateSubCommand( , , , ArgTypes.STRING, , (worldConfig) -> (String)IWorldMapProvider.CODEC.getIdFor(worldConfig.getWorldMapProvider().getClass()), (worldConfig, path) -> worldConfig.setWorldMapProvider((IWorldMapProvider)((BuilderCodec)IWorldMapProvider.CODEC.getCodecFor(path)).getDefaultValue()));
.generateSubCommand( , , , ArgTypes.STRING, , (worldConfig) -> (String)IChunkStorageProvider.CODEC.getIdFor(worldConfig.getChunkStorageProvider().getClass()), (worldConfig, path) -> worldConfig.setChunkStorageProvider((IChunkStorageProvider)((BuilderCodec)IChunkStorageProvider.CODEC.getCodecFor(path)).getDefaultValue()));
.generateSubCommand( , , , ArgTypes.BOOLEAN, , WorldConfig::isTicking, WorldConfig::setTicking);
.generateSubCommand( , , , ArgTypes.BOOLEAN, , WorldConfig::isBlockTicking, WorldConfig::setBlockTicking);
.generateSubCommand( , , , ArgTypes.BOOLEAN, , WorldConfig::isPvpEnabled, WorldConfig::setPvpEnabled);
.generateSubCommand( , , , ArgTypes.BOOLEAN, , WorldConfig::isGameTimePaused, WorldConfig::setGameTimePaused);
.generateSubCommand( , , , ArgTypes.BOOLEAN, , WorldConfig::isSpawningNPC, WorldConfig::setSpawningNPC);
.generateSubCommand( , , , ArgTypes.BOOLEAN, , WorldConfig::isSpawnMarkersEnabled, WorldConfig::setIsSpawnMarkersEnabled);
.generateSubCommand( , , , ArgTypes.BOOLEAN, , WorldConfig::isAllNPCFrozen, WorldConfig::setIsAllNPCFrozen);
.generateSubCommand( , , , ArgTypes.BOOLEAN, , World::isCompassUpdating, WorldConfig::isCompassUpdating, World::setCompassUpdating);
.generateSubCommand( , , , ArgTypes.BOOLEAN, , WorldConfig::isSavingPlayers, WorldConfig::setSavingPlayers);
.generateSubCommand( , , , ArgTypes.BOOLEAN, , WorldConfig::canSaveChunks, WorldConfig::setCanSaveChunks);
.generateSubCommand( , , , ArgTypes.BOOLEAN, , WorldConfig::canUnloadChunks, WorldConfig::setCanUnloadChunks);
.generateSubCommand( , , , ( , GameMode.class), , WorldConfig::getGameMode, WorldConfig::setGameMode);
.generateSubCommand( , , , ArgTypes.STRING, , WorldConfig::getGameplayConfig, WorldConfig::setGameplayConfig);
.addSubCommand( ( , , , (w) -> w.getWorldConfig().getChunkConfig().getPregenerateRegion(), (wc) -> wc.getChunkConfig().getPregenerateRegion(), (w, v) -> {
w.getWorldConfig();
worldConfig.getChunkConfig().setPregenerateRegion(v);
worldConfig.markChanged();
}));
.addSubCommand( ( , , , (w) -> w.getWorldConfig().getChunkConfig().getKeepLoadedRegion(), (wc) -> wc.getChunkConfig().getKeepLoadedRegion(), (w, v) -> {
w.getWorldConfig();
worldConfig.getChunkConfig().setKeepLoadedRegion(v);
worldConfig.markChanged();
}));
}
<T> {
.generateSubCommand(command, description, arg, argumentType, display, (world) -> getter.apply(world.getWorldConfig()), getter, (world, v) -> setter.accept(world.getWorldConfig(), v));
}
<T> {
.addSubCommand( (command, description, arg, argumentType, display, getter, defaultGetter, setter, .defaultWorldConfig));
}
<T> {
ArgumentType<T> argumentType;
String display;
Function<World, T> getter;
Function<WorldConfig, T> defaultGetter;
BiConsumer<World, T> setter;
WorldConfig defaultWorldConfig;
{
(name, description);
.argumentType = argumentType;
.display = display;
.getter = getter;
.defaultGetter = defaultGetter;
.setter = setter;
.defaultWorldConfig = defaultWorldConfig;
.addSubCommand( ());
.addSubCommand( ());
}
{
(T) .getter.apply(world);
context.sendMessage(Message.translation( ).param( , .display).param( , world.getName()).param( , currentValue.toString()));
}
{
RequiredArg<T> valueArg;
{
( , );
.valueArg = .withRequiredArg( , , WorldSettingsSubCommand. .argumentType);
}
{
(T)WorldSettingsSubCommand. .getter.apply(world);
(T)context.get( .valueArg);
WorldSettingsSubCommand. .setter.accept(world, newValue);
world.getWorldConfig().markChanged();
context.sendMessage(Message.translation( ).param( , WorldSettingsSubCommand. .display).param( , world.getName()).param( , ).param( , newValue.toString()).param( , currentValue.toString()));
}
}
{
{
( , );
}
{
(T)WorldSettingsSubCommand. .getter.apply(world);
(T)WorldSettingsSubCommand. .defaultGetter.apply(WorldSettingsSubCommand. .defaultWorldConfig);
WorldSettingsSubCommand. .setter.accept(world, newValue);
world.getWorldConfig().markChanged();
context.sendMessage(Message.translation( ).param( , WorldSettingsSubCommand. .display).param( , world.getName()).param( , ).param( , newValue.toString()).param( , currentValue.toString()));
}
}
}
{
String display;
Function<World, Box2D> getter;
Function<WorldConfig, Box2D> defaultGetter;
BiConsumer<World, Box2D> setter;
WorldConfig defaultWorldConfig;
{
(name, description);
.display = display;
.getter = getter;
.defaultGetter = defaultGetter;
.setter = setter;
.defaultWorldConfig = ();
.addSubCommand( ());
.addSubCommand( ());
}
{
(Box2D) .getter.apply(world);
context.sendMessage(Message.translation( ).param( , .display).param( , world.getName()).param( , Objects.toString(currentValue)));
}
{
RequiredArg<Double> minXArg;
RequiredArg<Double> minZArg;
RequiredArg<Double> maxXArg;
RequiredArg<Double> maxZArg;
{
( , );
.minXArg = .withRequiredArg( , , ArgTypes.DOUBLE);
.minZArg = .withRequiredArg( , , ArgTypes.DOUBLE);
.maxXArg = .withRequiredArg( , , ArgTypes.DOUBLE);
.maxZArg = .withRequiredArg( , , ArgTypes.DOUBLE);
}
{
(Box2D)WorldSettingsBox2DCommand. .getter.apply(world);
( ((Double)context.get( .minXArg), (Double)context.get( .minZArg)), ((Double)context.get( .maxXArg), (Double)context.get( .maxZArg)));
WorldSettingsBox2DCommand. .setter.accept(world, newValue);
world.getWorldConfig().markChanged();
context.sendMessage(Message.translation( ).param( , WorldSettingsBox2DCommand. .display).param( , world.getName()).param( , ).param( , Objects.toString(newValue)).param( , Objects.toString(currentValue)));
}
}
{
{
( , );
}
{
(Box2D)WorldSettingsBox2DCommand. .getter.apply(world);
(Box2D)WorldSettingsBox2DCommand. .defaultGetter.apply(WorldSettingsBox2DCommand. .defaultWorldConfig);
WorldSettingsBox2DCommand. .setter.accept(world, newValue);
world.getWorldConfig().markChanged();
context.sendMessage(Message.translation( ).param( , WorldSettingsBox2DCommand. .display).param( , world.getName()).param( , ).param( , Objects.toString(newValue)).param( , Objects.toString(currentValue)));
}
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;
import com.hypixel.hytale.server.core.universe.world.commands.block.bulk.BlockBulkCommand;
public class BlockCommand extends AbstractCommandCollection {
public BlockCommand () {
super ("block" , "server.commands.block.desc" );
this .setPermissionGroup(GameMode.Creative);
this .addAliases(new String []{"blocks" });
this .addSubCommand(new BlockSetCommand ());
this .addSubCommand(new BlockSetTickingCommand ());
this .addSubCommand(new BlockGetCommand ());
this .addSubCommand(new BlockGetStateCommand ());
this .addSubCommand(new BlockRowCommand ());
this .addSubCommand(new BlockBulkCommand ());
this .addSubCommand(new BlockInspectPhysicsCommand ());
this .addSubCommand( ());
.addSubCommand( ());
.addSubCommand( ());
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockGetCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
public class BlockGetCommand extends SimpleBlockCommand {
public BlockGetCommand () {
super ("get" , "server.commands.block.get.desc" );
}
protected void executeWithBlock (@Nonnull CommandContext context, @Nonnull WorldChunk chunk, int x, int y, int z) {
CommandSender sender = context.sender();
int blockId = chunk.getBlock(x, y, z);
BlockType blockType = (BlockType)BlockType.getAssetMap().getAsset(blockId);
int support = chunk.getSupportValue(x, y, z);
sender.sendMessage(Message.translation("server.commands.block.get.info" ).param("x" , x).param("y" , y).param( , z).param( , blockType.getId().toString()).param( , blockId).param( , support));
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockGetStateCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import javax.annotation.Nonnull;
public class BlockGetStateCommand extends SimpleBlockCommand {
public BlockGetStateCommand () {
super ("getstate" , "server.commands.block.getstate.desc" );
}
protected void executeWithBlock (@Nonnull CommandContext context, @Nonnull WorldChunk chunk, int x, int y, int z) {
CommandSender sender = context.sender();
Ref<ChunkStore> ref = chunk.getBlockComponentEntity(x, y, z);
if (ref != null ) {
StringBuilder stateString = new ();
Archetype<ChunkStore> archetype = ref.getStore().getArchetype(ref);
( archetype.getMinIndex(); i < archetype.length(); ++i) {
ComponentType<ChunkStore, ? <ChunkStore>> c = archetype.get(i);
(c != ) {
stateString.append(c.getTypeClass().getSimpleName()).append( ).append(ref.getStore().getComponent(ref, c)).append( );
}
}
sender.sendMessage(Message.translation( ).param( , x).param( , y).param( , z).param( , stateString.toString()));
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockInspectFillerCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.shape.Box;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.modules.debug.DebugUtils;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.server.core.util.FillerBlockUtil;
import javax.annotation.Nonnull;
public class BlockInspectFillerCommand {
Message.translation( );
Message.translation( );
{
( , );
.setPermissionGroup((GameMode) );
}
{
(TransformComponent)store.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
MathUtil.floor(position.getX());
MathUtil.floor(position.getZ());
MathUtil.floor(position.getY());
ChunkUtil.chunkCoordinate(x);
ChunkUtil.chunkCoordinate(y);
ChunkUtil.chunkCoordinate(z);
CompletableFutureUtil._catch(world.getChunkStore().getChunkSectionReferenceAsync(chunkX, chunkY, chunkZ).thenAcceptAsync((chunk) -> {
Store<ChunkStore> chunkStore = chunk.getStore();
(BlockSection)chunkStore.getComponent(chunk, BlockSection.getComponentType());
(blockSection == ) {
playerRef.sendMessage(MESSAGE_COMMANDS_BLOCK_INSPECT_FILLER_NO_BLOCKS);
} {
BlockTypeAssetMap<String, BlockType> blockTypeMap = BlockType.getAssetMap();
IndexedLookupTableAssetMap<String, BlockBoundingBoxes> hitboxMap = BlockBoundingBoxes.getAssetMap();
(( )ChunkUtil.minBlock(chunkX), ( )ChunkUtil.minBlock(chunkY), ( )ChunkUtil.minBlock(chunkZ));
( ; idx < ; ++idx) {
blockSection.get(idx);
blockTypeMap.getAsset(blockId);
(blockType != ) {
hitboxMap.getAsset(blockType.getHitboxTypeIndex());
(hitbox != && hitbox.protrudesUnitBox()) {
blockSection.getFiller(idx);
ChunkUtil.xFromIndex(idx);
ChunkUtil.yFromIndex(idx);
ChunkUtil.zFromIndex(idx);
(( )bx, ( )by, ( )bz);
pos.add( , , );
pos.add(offset);
blockSection.getRotationIndex(idx);
BlockBoundingBoxes. hitbox.get(rotation);
FillerBlockUtil.unpackX(filler);
FillerBlockUtil.unpackY(filler);
FillerBlockUtil.unpackZ(filler);
rotatedHitbox.getBoundingBox();
( )boundingBox.min.x;
( )boundingBox.min.y;
( )boundingBox.min.z;
(( )minX - boundingBox.min.x > ) {
--minX;
}
(( )minY - boundingBox.min.y > ) {
--minY;
}
(( )minZ - boundingBox.min.z > ) {
--minZ;
}
( )boundingBox.max.x;
( )boundingBox.max.y;
( )boundingBox.max.z;
(boundingBox.max.x - ( )maxX > ) {
++maxX;
}
(boundingBox.max.y - ( )maxY > ) {
++maxY;
}
(boundingBox.max.z - ( )maxZ > ) {
++maxZ;
}
();
colour.x = ( )(fillerX - minX) / ( )(maxX - minX);
colour.y = ( )(fillerY - minY) / ( )(maxY - minY);
colour.z = ( )(fillerZ - minZ) / ( )(maxZ - minZ);
DebugUtils.addCube(((ChunkStore)chunkStore.getExternalData()).getWorld(), pos, colour, , );
}
}
}
playerRef.sendMessage(MESSAGE_COMMANDS_BLOCK_INSPECT_FILLER_DONE);
}
}, world));
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockInspectPhysicsCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.blocktype.component.BlockPhysics;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.modules.debug.DebugUtils;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class BlockInspectPhysicsCommand extends AbstractPlayerCommand {
@Nonnull
private static final Message Message.translation( );
Message.translation( );
.withFlagArg( , );
{
( , );
.setPermissionGroup((GameMode) );
}
{
(TransformComponent)store.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
(Boolean) .ALL.get(context);
MathUtil.floor(position.getX());
MathUtil.floor(position.getZ());
MathUtil.floor(position.getY());
ChunkUtil.chunkCoordinate(x);
ChunkUtil.chunkCoordinate(y);
ChunkUtil.chunkCoordinate(z);
CompletableFutureUtil._catch(world.getChunkStore().getChunkSectionReferenceAsync(chunkX, chunkY, chunkZ).thenAcceptAsync((chunk) -> {
Store<ChunkStore> chunkStore = chunk.getStore();
(BlockPhysics)chunkStore.getComponent(chunk, BlockPhysics.getComponentType());
(blockPhysics == ) {
playerRef.sendMessage(MESSAGE_COMMANDS_BLOCK_INSPECT_PHYS_NO_BLOCKS);
} {
(( )ChunkUtil.minBlock(chunkX), ( )ChunkUtil.minBlock(chunkY), ( )ChunkUtil.minBlock(chunkZ));
( ; idx < ; ++idx) {
blockPhysics.get(idx);
(supportValue != || all) {
ChunkUtil.xFromIndex(idx);
ChunkUtil.yFromIndex(idx);
ChunkUtil.zFromIndex(idx);
(( )bx, ( )by, ( )bz);
pos.add( , , );
pos.add(offset);
Vector3f colour;
(supportValue == ) {
colour = ( , , );
} {
world.getBlockType(pos.toVector3i());
(!block.hasSupport()) {
(supportValue == ) {
;
}
colour = ( , , );
} (block.getMaxSupportDistance() != ) {
( )supportValue / ( )block.getMaxSupportDistance();
colour = (len, , - len);
} {
colour = ( , , );
}
}
DebugUtils.addCube(((ChunkStore)chunkStore.getExternalData()).getWorld(), pos, colour, , );
}
}
playerRef.sendMessage(MESSAGE_COMMANDS_BLOCK_INSPECT_PHYS_DONE);
}
}, world));
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockInspectRotationCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.modules.debug.DebugUtils;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class BlockInspectRotationCommand extends AbstractPlayerCommand {
@Nonnull
Message.translation( );
Message.translation( );
{
( , );
.setPermissionGroup((GameMode) );
}
{
(TransformComponent)store.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
MathUtil.floor(position.getX());
MathUtil.floor(position.getZ());
MathUtil.floor(position.getY());
ChunkUtil.chunkCoordinate(x);
ChunkUtil.chunkCoordinate(y);
ChunkUtil.chunkCoordinate(z);
CompletableFutureUtil._catch(world.getChunkStore().getChunkSectionReferenceAsync(chunkX, chunkY, chunkZ).thenAcceptAsync((chunk) -> {
Store<ChunkStore> chunkStore = chunk.getStore();
(BlockSection)chunkStore.getComponent(chunk, BlockSection.getComponentType());
(blockSection == ) {
playerRef.sendMessage(MESSAGE_COMMANDS_BLOCK_INSPECT_ROTATION_NO_BLOCKS);
} {
BlockTypeAssetMap<String, BlockType> blockTypeMap = BlockType.getAssetMap();
(( )ChunkUtil.minBlock(chunkX), ( )ChunkUtil.minBlock(chunkY), ( )ChunkUtil.minBlock(chunkZ));
( ; idx < ; ++idx) {
blockSection.get(idx);
blockTypeMap.getAsset(blockId);
(blockType != ) {
ChunkUtil.xFromIndex(idx);
ChunkUtil.yFromIndex(idx);
ChunkUtil.zFromIndex(idx);
(( )bx, ( )by, ( )bz);
pos.add( , , );
pos.add(offset);
blockSection.getRotation(idx);
(rotation.index() != ) {
();
colour.x = ( )rotation.yaw().ordinal() / (( )Rotation.VALUES.length - );
colour.y = ( )rotation.pitch().ordinal() / (( )Rotation.VALUES.length - );
colour.z = ( )rotation.roll().ordinal() / (( )Rotation.VALUES.length - );
DebugUtils.addCube(((ChunkStore)chunkStore.getExternalData()).getWorld(), pos, colour, , );
}
}
}
playerRef.sendMessage(MESSAGE_COMMANDS_BLOCK_INSPECT_ROTATION_DONE);
}
}, world));
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockRowCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.common.util.StringUtil;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.Axis;
import com.hypixel.hytale.math.shape.Box;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandUtil;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.server.core.util.WildcardMatch;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
java.util.Comparator;
java.util.List;
javax.annotation.Nonnull;
{
RequiredArg<String> queryArg;
;
{
( , );
.queryArg = .withRequiredArg( , , ArgTypes.STRING);
}
{
(TransformComponent)store.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
(HeadRotation)store.getComponent(ref, HeadRotation.getComponentType());
headRotationComponent != ;
transformComponent.getPosition();
getDominantCardinal(headRotationComponent.getDirection());
(String)context.get( .queryArg);
List<BlockType> blockTypes = .findBlockTypes(query);
(blockTypes.isEmpty()) {
playerRef.sendMessage(Message.translation( ).param( , query));
List<String> fuzzyMatches = StringUtil.<String>sortByFuzzyDistance(query, BlockType.getAssetMap().getAssetMap().keySet(), CommandUtil.RECOMMEND_COUNT);
(!fuzzyMatches.isEmpty()) {
playerRef.sendMessage(Message.translation( ).param( , fuzzyMatches.toString()));
}
} (blockTypes.size() >= ) {
playerRef.sendMessage(Message.translation( ).param( , ));
} {
.spawnBlocksRow(world, playerPos, axisDirection, blockTypes);
}
}
{
IndexedLookupTableAssetMap<String, BlockBoundingBoxes> boundingBoxes = BlockBoundingBoxes.getAssetMap();
getAxis(direction);
;
( ; x < blockTypes.size(); x += step) {
;
( ; i < step; ++i) {
(BlockType)blockTypes.get(i + x);
((BlockBoundingBoxes)boundingBoxes.getAsset(blockType.getHitboxTypeIndex())).get( ).getBoundingBox();
Math.ceil(boundingBox.dimension(axis));
distance += Math.floor(dimension) + ;
origin.clone().add(direction.clone().scale(distance)).add(Rotation.Ninety.rotateY(direction, ()).scale(x / step * )).toVector3i();
ChunkUtil.indexChunkFromBlock(blockPos.x, blockPos.z);
world.getChunkAsync(chunkIndex).thenAccept((chunk) -> {
;
chunk.setBlock(blockPos.x, blockPos.y, blockPos.z, blockType, );
});
}
}
}
Vector3i {
Math.abs(direction.x);
Math.abs(direction.y);
Math.abs(direction.z);
(ax > ay && ax > az) {
(( )Math.signum(direction.x), , );
} {
ay > az ? ( , ( )Math.signum(direction.y), ) : ( , , ( )Math.signum(direction.z));
}
}
Axis {
(direction.x != ) {
Axis.X;
} {
direction.z != ? Axis.Z : Axis.Y;
}
}
List<BlockType> {
List<BlockType> results = <BlockType>();
BlockTypeAssetMap<String, BlockType> blockTypeAssets = BlockType.getAssetMap();
(String blockName : blockTypeAssets.getAssetMap().keySet()) {
(WildcardMatch.test(blockName, wildcardQuery)) {
(BlockType)blockTypeAssets.getAsset(blockName);
results.add(blockType);
}
}
results = results.stream().sorted(Comparator.comparing(BlockType::getId)).toList();
results;
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockSelectCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.shape.Box;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockFlipType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.VariantRotation;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.DefaultArg;
import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg;
import com.hypixel.hytale.server.core.command.system.arguments.system.OptionalArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.arguments.types.EnumArgumentType;
import com.hypixel.hytale.server.core.command.system.arguments.types.SingleArgumentType;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.command.system.exceptions.GeneralCommandException;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.prefab.selection.SelectionManager;
import com.hypixel.hytale.server.core.prefab.selection.SelectionProvider;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
com.hypixel.hytale.server.core.util.FillerBlockUtil;
java.util.Collections;
java.util.List;
java.util.Map;
java.util.Map.Entry;
java.util.regex.Pattern;
java.util.stream.Stream;
javax.annotation.Nonnull;
{
SingleArgumentType<BlockFlipType> BLOCK_FLIP_TYPE = <BlockFlipType>( , BlockFlipType.class);
SingleArgumentType<VariantRotation> VARIANT_ROTATION = <VariantRotation>( , VariantRotation.class);
Message.translation( );
Message.translation( );
OptionalArg<String> regexArg;
FlagArg allFlag;
OptionalArg<String> sortArg;
OptionalArg<BlockFlipType> flipTypeArg;
OptionalArg<VariantRotation> variantRotationArg;
DefaultArg<Integer> paddingArg;
OptionalArg<String> groundArg;
{
( , );
.regexArg = .withOptionalArg( , , ArgTypes.STRING);
.allFlag = .withFlagArg( , );
.sortArg = .withOptionalArg( , , ArgTypes.STRING);
.flipTypeArg = .withOptionalArg( , , BLOCK_FLIP_TYPE);
.variantRotationArg = .withOptionalArg( , , VARIANT_ROTATION);
.paddingArg = .withDefaultArg( , , ArgTypes.INTEGER, , );
.groundArg = .withOptionalArg( , , ArgTypes.STRING);
}
{
(Player)store.getComponent(ref, Player.getComponentType());
playerComponent != ;
SelectionManager.getSelectionProvider();
(selectionProvider == ) {
context.sendMessage(MESSAGE_COMMANDS_BLOCK_SELECT_NO_SELECTION_PROVIDER);
} {
.regexArg.provided(context) ? Pattern.compile((String) .regexArg.get(context)) : ;
Stream<Map.Entry<String, BlockType>> stream = BlockType.getAssetMap().getAssetMap().entrySet().parallelStream().filter((e) -> !((BlockType)e.getValue()).isUnknown()).filter((e) -> pattern == || pattern.matcher((CharSequence)e.getKey()).matches());
(!(Boolean) .allFlag.get(context)) {
stream = stream.filter((e) -> !((BlockType)e.getValue()).isState());
}
( .flipTypeArg.provided(context)) {
(BlockFlipType) .flipTypeArg.get(context);
stream = stream.filter((e) -> ((BlockType)e.getValue()).getFlipType() == flipType);
}
( .variantRotationArg.provided(context)) {
(VariantRotation) .variantRotationArg.get(context);
stream = stream.filter((e) -> ((BlockType)e.getValue()).getVariantRotation() == variantRotation);
}
( .sortArg.provided(context)) {
(String) .sortArg.get(context);
(sort.isEmpty()) {
stream = stream.sorted(Entry.comparingByKey());
} {
(String sortType : sort.split( )) {
Stream var10000;
(sortType) {
-> var10000 = stream.sorted(Entry.comparingByKey());
-> var10000 = stream.sorted(Entry.comparingByKey());
-> var10000 = stream.sorted(Collections.reverseOrder());
-> (Message.translation( ).param( , sortType));
}
stream = var10000;
}
}
}
List<Map.Entry<String, BlockBoundingBoxes>> blocks = stream.map((e) -> Map.entry((String)e.getKey(), (BlockBoundingBoxes)BlockBoundingBoxes.getAssetMap().getAsset(((BlockType)e.getValue()).getHitboxTypeIndex()))).toList();
context.sendMessage(Message.translation( ).param( , blocks.size()));
();
(Map.Entry<String, BlockBoundingBoxes> block : blocks) {
largestBox.union(((BlockBoundingBoxes)block.getValue()).get( ).getBoundingBox());
}
(Integer) .paddingArg.get(context);
MathUtil.ceil(Math.sqrt(( )blocks.size())) + ;
MathUtil.ceil(largestBox.width()) + paddingSize;
MathUtil.ceil(largestBox.depth()) + paddingSize;
strideX / ;
strideZ / ;
largestBox.height();
String groundBlock;
( .groundArg.provided(context)) {
groundBlock = (String) .groundArg.get(context);
} {
;
(BlockType.getAssetMap().getAsset( ) != ) {
groundBlock = ;
} {
groundBlock = ;
}
}
selectionProvider.computeSelectionCopy(ref, playerComponent, (selection) -> {
BlockTypeAssetMap<String, BlockType> blockTypeAssetMap = BlockType.getAssetMap();
blockTypeAssetMap.getIndex(groundBlock);
( -paddingSize; x < sqrt * strideX; ++x) {
( -paddingSize; z < sqrt * strideZ; ++z) {
selection.addBlockAtWorldPos(x, , z, groundId, , , );
( ; ( )y < height; ++y) {
selection.addBlockAtWorldPos(x, y, z, , , , );
}
}
}
( ; i < blocks.size(); ++i) {
Map.Entry<String, BlockBoundingBoxes> entry = (Map.Entry)blocks.get(i);
BlockBoundingBoxes. ((BlockBoundingBoxes)entry.getValue()).get( );
rotatedBoxes.getBoundingBox();
i % sqrt * strideX + halfStrideX + MathUtil.floor(boundingBox.middleX());
i / sqrt * strideZ + halfStrideZ + MathUtil.floor(boundingBox.middleZ());
blockTypeAssetMap.getIndex((String)entry.getKey());
selection.addBlockAtWorldPos(x, , z, blockId, , , );
(((BlockBoundingBoxes)entry.getValue()).protrudesUnitBox()) {
FillerBlockUtil.forEachFillerBlock(rotatedBoxes, (x1, y1, z1) -> {
(x1 != || y1 != || z1 != ) {
FillerBlockUtil.pack(x1, y1, z1);
selection.addBlockAtWorldPos(x + x1, + y1, z + z1, blockId, , filler, );
}
});
}
}
context.sendMessage(MESSAGE_COMMANDS_BLOCK_SELECT_DONE);
}, store);
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockSetCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
public class BlockSetCommand extends SimpleBlockCommand {
private final RequiredArg<BlockType> blockArg;
public BlockSetCommand () {
super ("set" , "server.commands.block.set.desc" );
this .blockArg = this .withRequiredArg("block" , "server.commands.block.set.arg.block" , ArgTypes.BLOCK_TYPE_ASSET);
this .setPermissionGroup(GameMode.Creative);
}
protected void executeWithBlock (@Nonnull CommandContext context, @Nonnull WorldChunk chunk, int x, int y, int z) {
CommandSender sender context.sender();
(BlockType)context.get( .blockArg);
chunk.setBlock(x, y, z, blockType);
sender.sendMessage(Message.translation( ).param( , x).param( , y).param( , z).param( , blockType.getId().toString()));
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockSetStateCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
public class BlockSetStateCommand extends SimpleBlockCommand {
private final RequiredArg<String> stateArg;
public BlockSetStateCommand () {
super ("setstate" , "" );
this .stateArg = this .withRequiredArg("state" , "" , ArgTypes.STRING);
}
protected void executeWithBlock (@Nonnull CommandContext context, @Nonnull WorldChunk chunk, int x, int y, int z) {
int blockId = chunk.getBlock(x, y, z);
BlockType blockType = (BlockType)BlockType.getAssetMap().getAsset(blockId);
String state = (String)context.get( .stateArg);
chunk.setBlockInteractionState(x, y, z, blockType, state, );
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/BlockSetTickingCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
public class BlockSetTickingCommand extends SimpleBlockCommand {
public BlockSetTickingCommand () {
super ("setticking" , "server.commands.block.setticking.desc" );
this .setPermissionGroup((GameMode)null );
}
protected void executeWithBlock (@Nonnull CommandContext context, @Nonnull WorldChunk chunk, int x, int y, int z) {
CommandSender sender = context.sender();
chunk.setTicking(x, y, z, true );
sender.sendMessage(Message.translation("server.commands.block.setticking.success" ).param("x" , x).param("y" , y).param("z" , z));
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/SimpleBlockCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.arguments.types.RelativeIntPosition;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public abstract class SimpleBlockCommand extends AbstractWorldCommand {
@Nonnull
private static final Message MESSAGE_COMMANDS_ERROR_EXCEPTION = Message.translation("server.commands.error.exception" );
@Nonnull
private final RequiredArg<RelativeIntPosition> coordsArg;
public {
(name, description);
.coordsArg = .withRequiredArg( , , ArgTypes.RELATIVE_BLOCK_POSITION);
}
{
context.sender();
(RelativeIntPosition)context.get( .coordsArg);
coords.getBlockPosition(context, store);
blockPos.x;
blockPos.y;
blockPos.z;
ChunkUtil.indexChunkFromBlock(x, z);
world.getChunkAsync(chunkIndex).thenAcceptAsync((chunk) -> .executeWithBlock(context, chunk, x, y, z), world).exceptionally((t) -> {
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.SEVERE).withCause(t)).log( );
sender.sendMessage(MESSAGE_COMMANDS_ERROR_EXCEPTION);
;
});
}
;
}
com/hypixel/hytale/server/core/universe/world/commands/block/bulk/BlockBulkCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block.bulk;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;
public class BlockBulkCommand extends AbstractCommandCollection {
public BlockBulkCommand () {
super ("bulk" , "server.commands.block.bulk.desc" );
this .setPermissionGroup((GameMode)null );
this .addSubCommand(new BlockBulkFindCommand ());
this .addSubCommand(new BlockBulkFindHereCommand ());
this .addSubCommand(new BlockBulkReplaceCommand ());
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/bulk/BlockBulkFindCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block.bulk;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.iterator.SpiralIterator;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.arguments.types.IntCoord;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntLists;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
public {
Message.translation( );
Message.translation( );
RequiredArg<IntCoord> chunkXArg;
RequiredArg<IntCoord> chunkZArg;
RequiredArg<String> blockTypeArg;
RequiredArg<Integer> countArg;
RequiredArg<Integer> timeoutArg;
{
( , , );
.chunkXArg = .withRequiredArg( , , ArgTypes.RELATIVE_INT_COORD);
.chunkZArg = .withRequiredArg( , , ArgTypes.RELATIVE_INT_COORD);
.blockTypeArg = .withRequiredArg( , , ArgTypes.BLOCK_TYPE_KEY);
.countArg = .withRequiredArg( , , ArgTypes.INTEGER);
.timeoutArg = .withRequiredArg( , , ArgTypes.INTEGER);
}
{
context.sender();
(IntCoord) .chunkXArg.get(context);
(IntCoord) .chunkZArg.get(context);
;
;
(context.isPlayer()) {
Ref<EntityStore> playerRef = context.senderAsPlayerRef();
(playerRef != ) {
(TransformComponent)store.getComponent(playerRef, TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
baseChunkX = MathUtil.floor(playerPos.getX()) >> ;
baseChunkZ = MathUtil.floor(playerPos.getZ()) >> ;
}
}
relChunkX.resolveXZ(baseChunkX);
relChunkZ.resolveXZ(baseChunkZ);
(String) .blockTypeArg.get(context);
BlockType.getAssetMap().getIndex(blockTypeKey);
IntLists.singleton(blockId);
(Integer) .countArg.get(context);
(Integer) .timeoutArg.get(context);
CompletableFuture.runAsync(() -> {
System.nanoTime();
;
[] found = []{ };
();
world.getChunkStore();
(originChunkX, originChunkZ, SpiralIterator.MAX_RADIUS);
label34:
(iterator.hasNext()) {
iterator.next();
(BlockChunk)chunkComponentStore.getChunkReferenceAsync(key).thenApplyAsync((chunkRef) -> (BlockChunk)chunkComponentStore.getStore().getComponent(chunkRef, BlockChunk.getComponentType()), world).join();
( ; sectionIndex < ; ++sectionIndex) {
blockChunk.getSectionAtIndex(sectionIndex);
(section.contains(blockId)) {
ChunkUtil.xOfChunkIndex(key);
ChunkUtil.zOfChunkIndex(key);
section.find(idAsList, temp, (blockIndex) -> {
(found[ ] < count) {
found[ ]++;
chunkX << | ChunkUtil.xFromIndex(blockIndex);
sectionIndex << | ChunkUtil.yFromIndex(blockIndex);
chunkZ << | ChunkUtil.zFromIndex(blockIndex);
sender.sendMessage(Message.translation( ).param( , x).param( , y).param( , z));
}
});
(found[ ] >= count) {
label34;
}
temp.clear();
}
}
++tested;
(tested % == ) {
sender.sendMessage(Message.translation( ).param( , tested));
}
System.nanoTime() - start;
(diff > TimeUnit.SECONDS.toNanos(( )timeout)) {
sender.sendMessage(MESSAGE_COMMANDS_BLOCK_FIND_TIME_OUT);
;
}
}
sender.sendMessage(MESSAGE_COMMANDS_BLOCK_FIND_DONE);
});
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/bulk/BlockBulkFindHereCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block.bulk;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.iterator.SpiralIterator;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.DefaultArg;
import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Nonnull;
public {
.withFlagArg( , );
RequiredArg<String> blockTypeArg;
DefaultArg<Integer> radiusArg;
{
( , );
.blockTypeArg = .withRequiredArg( , , ArgTypes.BLOCK_TYPE_KEY);
.radiusArg = .withDefaultArg( , , ArgTypes.INTEGER, , );
}
{
(String) .blockTypeArg.get(context);
BlockType.getAssetMap().getIndex(blockTypeKey);
BlockBulkReplaceCommand.getBlockIdList(blockId);
(Integer) .radiusArg.get(context);
(Boolean) .printNameArg.get(context);
(TransformComponent)store.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
MathUtil.floor(playerPos.getX()) >> ;
MathUtil.floor(playerPos.getZ()) >> ;
CompletableFuture.runAsync(() -> {
System.nanoTime();
();
world.getChunkStore();
();
(originChunkX, originChunkZ, radius);
(iterator.hasNext()) {
iterator.next();
(BlockChunk)chunkComponentStore.getChunkReferenceAsync(key).thenApplyAsync((chunkRef) -> (BlockChunk)chunkComponentStore.getStore().getComponent(chunkRef, BlockChunk.getComponentType()), world).join();
( ; sectionIndex < ; ++sectionIndex) {
blockChunk.getSectionAtIndex(sectionIndex);
(section.containsAny(blockIdList)) {
section.find(blockIdList, temp, (blockIndex) -> found.getAndIncrement());
temp.clear();
}
}
}
System.nanoTime() - start;
(BlockType)BlockType.getAssetMap().getAsset(blockId);
printBlockName ? + findBlock.getId() : ;
playerRef.sendMessage(Message.translation( + found.get() + blockName + + TimeUnit.NANOSECONDS.toSeconds(diff) + ));
});
}
}
com/hypixel/hytale/server/core/universe/world/commands/block/bulk/BlockBulkReplaceCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.block.bulk;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.iterator.SpiralIterator;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.VariantRotation;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import java.util.concurrent.CompletableFuture;
java.util.concurrent.TimeUnit;
java.util.concurrent.atomic.AtomicInteger;
javax.annotation.Nonnull;
{
RequiredArg<String> findArg;
RequiredArg<String> replaceArg;
RequiredArg<Integer> radiusArg;
{
( , );
.findArg = .withRequiredArg( , , ArgTypes.BLOCK_TYPE_KEY);
.replaceArg = .withRequiredArg( , , ArgTypes.BLOCK_TYPE_KEY);
.radiusArg = .withRequiredArg( , , ArgTypes.INTEGER);
}
{
(TransformComponent)store.getComponent(ref, TransformComponent.getComponentType());
transformComponent != ;
(String) .findArg.get(context);
(String) .replaceArg.get(context);
BlockType.getAssetMap().getIndex(findBlockTypeKey);
BlockType.getAssetMap().getIndex(replaceBlockTypeKey);
getBlockIdList(findBlockId);
getBlockIdList(replaceBlockId);
(Integer) .radiusArg.get(context);
transformComponent.getPosition();
MathUtil.floor(playerPos.getX()) >> ;
MathUtil.floor(playerPos.getZ()) >> ;
CompletableFuture.runAsync(() -> {
System.nanoTime();
();
world.getChunkStore();
();
(originChunkX, originChunkZ, radius);
(iterator.hasNext()) {
iterator.next();
(BlockChunk)chunkComponentStore.getChunkReferenceAsync(key).thenApplyAsync((chunkRef) -> (BlockChunk)chunkComponentStore.getStore().getComponent(chunkRef, BlockChunk.getComponentType()), world).join();
( ; sectionIndex < ; ++sectionIndex) {
blockChunk.getSectionAtIndex(sectionIndex);
(section.containsAny(findBlockIdList)) {
ChunkUtil.xOfChunkIndex(key);
ChunkUtil.zOfChunkIndex(key);
section.find(findBlockIdList, temp, (blockIndex) -> {
chunkX << | ChunkUtil.xFromIndex(blockIndex);
sectionIndex << | ChunkUtil.yFromIndex(blockIndex);
chunkZ << | ChunkUtil.zFromIndex(blockIndex);
CompletableFutureUtil._catch(world.getChunkAsync(ChunkUtil.indexChunkFromBlock(x, z))).thenAccept((chunk) -> {
chunk.getBlock(x, y, z);
findBlockIdList.indexOf(foundBlock);
chunk.setBlock(x, y, z, replaceBlockIdList.getInt(replaceIndex));
replaced.getAndIncrement();
});
});
}
}
}
System.nanoTime() - start;
replaced.get();
playerRef.sendMessage(Message.translation( + var10001 + + TimeUnit.NANOSECONDS.toSeconds(diff) + ));
});
}
IntList {
();
(BlockType)BlockType.getAssetMap().getAsset(blockId);
(findBlock.getVariantRotation().equals(VariantRotation.NESW)) {
blockIdList = createNESWRotationLists(findBlock, blockIdList);
} {
blockIdList.add(blockId);
}
blockIdList;
}
IntList {
RotationTuple[] rotations = block.getVariantRotation().getRotations();
block.getId();
blockIdList.add(BlockType.getAssetMap().getIndex(blockName));
(RotationTuple rp : rotations) {
blockName + + rp.yaw().getDegrees();
blockIdList.add(BlockType.getAssetMap().getIndex(newBlockRotation));
}
blockIdList;
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/WorldAddCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.arguments.system.DefaultArg;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.worldgen.provider.IWorldGenProvider;
import java.util.Objects;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public class WorldAddCommand extends CommandBase {
@Nonnull
private final RequiredArg<String> nameArg;
@Nonnull
private final DefaultArg<String> genArg;
@Nonnull
private final DefaultArg<String> storageArg;
public WorldAddCommand () {
super ("add" , "server.commands.addworld.desc" );
.nameArg = .withRequiredArg( , , ArgTypes.STRING);
.genArg = .withDefaultArg( , , ArgTypes.STRING, , );
.storageArg = .withDefaultArg( , , ArgTypes.STRING, , );
}
{
context.sender();
(String)context.get( .nameArg);
(Universe.get().getWorld(name) != ) {
sender.sendMessage(Message.translation( ).param( , name));
} (Universe.get().isWorldLoadable(name)) {
sender.sendMessage(Message.translation( ).param( , name));
} {
(String)context.get( .genArg);
(String)context.get( .storageArg);
(generatorType != && ! .equals(generatorType)) {
BuilderCodec<? > providerCodec = (BuilderCodec)IWorldGenProvider.CODEC.getCodecFor(generatorType);
(providerCodec == ) {
( + generatorType + );
}
}
CompletableFutureUtil._catch(Universe.get().addWorld(name, generatorType, chunkStorageType).thenRun(() -> sender.sendMessage(Message.translation( ).param( , name).param( , (String)Objects.requireNonNullElse(generatorType, )).param( , (String)Objects.requireNonNullElse(chunkStorageType, )))).exceptionally((throwable) -> {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(throwable)).log( , name);
sender.sendMessage(Message.translation( ).param( , name).param( , throwable.getCause() != ? throwable.getCause().getMessage() : throwable.getMessage()));
;
}));
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/WorldCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;
import com.hypixel.hytale.server.core.universe.world.commands.WorldSettingsCommand;
import com.hypixel.hytale.server.core.universe.world.commands.world.perf.WorldPerfCommand;
import com.hypixel.hytale.server.core.universe.world.commands.world.tps.WorldTpsCommand;
import com.hypixel.hytale.server.core.universe.world.commands.worldconfig.WorldConfigCommand;
import com.hypixel.hytale.server.core.universe.world.commands.worldconfig.WorldPauseCommand;
public class WorldCommand extends AbstractCommandCollection {
public WorldCommand () {
super ("world" , "server.commands.world.desc" );
this .addAliases(new String []{"worlds" });
this .addSubCommand(new WorldListCommand ());
this .addSubCommand(new WorldRemoveCommand ());
this .addSubCommand(new WorldPruneCommand ());
this .addSubCommand(new WorldLoadCommand ());
this .addSubCommand(new WorldAddCommand ());
this .addSubCommand(new ());
.addSubCommand( ());
.addSubCommand( ());
.addSubCommand( ());
.addSubCommand( ());
.addSubCommand( ());
.addSubCommand( ());
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/WorldListCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.util.message.MessageFormat;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
public class WorldListCommand extends CommandBase {
public WorldListCommand () {
super ("list" , "server.commands.worlds.desc" );
this .addAliases(new String []{"ls" });
}
protected void executeSync (@Nonnull CommandContext context) {
Set<Message> worlds = (Set)Universe.get().getWorlds().keySet().stream().map(Message::raw).collect(Collectors.toSet());
Message message = MessageFormat.list(Message.translation("server.commands.worlds.header" ), worlds);
context.sender().sendMessage(message);
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/WorldLoadCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import com.hypixel.hytale.server.core.universe.Universe;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public class WorldLoadCommand extends CommandBase {
@Nonnull
private final RequiredArg<String> nameArg;
public WorldLoadCommand () {
super ("load" , "server.commands.loadworld.desc" );
this .nameArg = this .withRequiredArg("name" , "server.commands.loadworld.arg.name.desc" , ArgTypes.STRING);
}
protected void executeSync (@Nonnull CommandContext context) {
CommandSender sender = context.sender();
(String)context.get( .nameArg);
(Universe.get().getWorld(name) != ) {
sender.sendMessage(Message.translation( ).param( , name));
} (!Universe.get().isWorldLoadable(name)) {
sender.sendMessage(Message.translation( ).param( , name));
} {
CompletableFutureUtil._catch(Universe.get().loadWorld(name).thenRun(() -> sender.sendMessage(Message.translation( ).param( , name))).exceptionally((throwable) -> {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(throwable)).log( , name);
sender.sendMessage(Message.translation( ).param( , name).param( , throwable.getCause() != ? throwable.getCause().getMessage() : throwable.getMessage()));
;
}));
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/WorldPruneCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public class WorldPruneCommand extends AbstractAsyncCommand {
@Nonnull
private static final Message MESSAGE_COMMANDS_WORLD_PRUNE_NONE_TO_PRUNE = Message.translation("server.commands.world.prune.noneToPrune" );
@Nonnull
private static final Message MESSAGE_COMMANDS_WORLD_PRUNE_PRUNE_ERROR = Message.translation("server.commands.world.prune.pruneError" );
public WorldPruneCommand () {
super ("prune" , , );
}
CompletableFuture<Void> {
context.sender();
Universe.get().getDefaultWorld();
Map<String, World> worlds = Universe.get().getWorlds();
Set<String> toRemove = ();
worlds.forEach((worldKey, world) -> {
(world != defaultWorld && world.getPlayerCount() == ) {
toRemove.add(worldKey);
world.getWorldConfig().setDeleteOnRemove( );
}
});
(toRemove.isEmpty()) {
sender.sendMessage(MESSAGE_COMMANDS_WORLD_PRUNE_NONE_TO_PRUNE);
CompletableFuture.completedFuture((Object) );
} {
CompletableFuture.runAsync(() -> {
toRemove.forEach((worldKey) -> {
{
Universe.get().removeWorld(worldKey);
removed ? : ;
sender.sendMessage(Message.translation(msgKey).param( , worldKey));
} (Throwable t) {
sender.sendMessage(MESSAGE_COMMANDS_WORLD_PRUNE_PRUNE_ERROR);
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.SEVERE).withCause(t)).log( + worldKey);
}
});
sender.sendMessage(Message.translation( ).param( , toRemove.size()));
});
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/WorldRemoveCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import com.hypixel.hytale.server.core.universe.Universe;
import javax.annotation.Nonnull;
public class WorldRemoveCommand extends CommandBase {
public static final Message MESSAGE_UNIVERSE_REMOVE_WORLD_NOT_FOUND = Message.translation("server.universe.removeworld.notFound" );
public static final Message MESSAGE_UNIVERSE_REMOVE_WORLD_ONLY_ONE_WORLD_LOADED = Message.translation("server.universe.removeworld.onlyOneWorldLoaded" );
public static final Message MESSAGE_UNIVERSE_REMOVE_WORLD_CHANGE_DEFAULT_WORLD = Message.translation("server.universe.removeworld.changeDefaultWorld" );
@Nonnull
private final RequiredArg<String> nameArg;
{
( , );
.nameArg = .withRequiredArg( , , ArgTypes.STRING);
.addAliases( []{ });
}
{
context.sender();
(String)context.get( .nameArg);
(Universe.get().getWorld(name) == ) {
sender.sendMessage(MESSAGE_UNIVERSE_REMOVE_WORLD_NOT_FOUND);
} (Universe.get().getWorlds().size() == ) {
sender.sendMessage(MESSAGE_UNIVERSE_REMOVE_WORLD_ONLY_ONE_WORLD_LOADED);
} (name.equalsIgnoreCase(HytaleServer.get().getConfig().getDefaults().getWorld())) {
sender.sendMessage(MESSAGE_UNIVERSE_REMOVE_WORLD_CHANGE_DEFAULT_WORLD);
} {
Universe.get().removeWorld(name);
sender.sendMessage(Message.translation( ).param( , name));
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/WorldSaveCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg;
import com.hypixel.hytale.server.core.command.system.arguments.system.OptionalArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.system.WorldConfigSaveSystem;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.component.ChunkSavingSystems;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public class WorldSaveCommand extends AbstractAsyncCommand {
@Nonnull
private static final Message MESSAGE_COMMANDS_WORLD_SAVE_NO_WORLD_SPECIFIED = Message.translation("server.commands.world.save.noWorldSpecified" );
@Nonnull
private static final Message MESSAGE_COMMANDS_WORLD_SAVE_SAVING_ALL = Message.translation("server.commands.world.save.savingAll" );
@Nonnull
private Message.translation( );
OptionalArg<World> worldArg;
FlagArg saveAllFlag;
{
( , , );
.worldArg = .withOptionalArg( , , ArgTypes.WORLD);
.saveAllFlag = .withFlagArg( , );
}
CompletableFuture<Void> {
((Boolean) .saveAllFlag.get(context)) {
.saveAllWorlds(context);
} (! .worldArg.provided(context)) {
context.sendMessage(MESSAGE_COMMANDS_WORLD_SAVE_NO_WORLD_SPECIFIED);
CompletableFuture.completedFuture((Object) );
} {
(World) .worldArg.getProcessed(context);
context.sendMessage(Message.translation( ).param( , world.getName()));
CompletableFuture.runAsync(() -> saveWorld(world), world).thenRun(() -> context.sendMessage(Message.translation( ).param( , world.getName())));
}
}
CompletableFuture<Void> {
context.sendMessage(MESSAGE_COMMANDS_WORLD_SAVE_SAVING_ALL);
CompletableFuture[] completableFutures = (CompletableFuture[])Universe.get().getWorlds().values().stream().map((world) -> CompletableFuture.runAsync(() -> saveWorld(world), world)).toArray((x$ ) -> [x$ ]);
CompletableFuture.allOf(completableFutures).thenRun(() -> context.sendMessage(MESSAGE_COMMANDS_WORLD_SAVE_SAVING_ALL_DONE));
}
CompletableFuture<Void> {
CompletableFuture.allOf(WorldConfigSaveSystem.saveWorldConfigAndResources(world), ChunkSavingSystems.saveChunksInWorld(world.getChunkStore().getStore()));
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/WorldSetDefaultCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
import com.hypixel.hytale.server.core.universe.Universe;
import javax.annotation.Nonnull;
public class WorldSetDefaultCommand extends CommandBase {
@Nonnull
private final RequiredArg<String> nameArg;
public WorldSetDefaultCommand () {
super ("setdefault" , "server.commands.world.setdefault.desc" );
this .nameArg = this .withRequiredArg("name" , "server.commands.world.setdefault.arg.name.desc" , ArgTypes.STRING);
}
protected void executeSync (@Nonnull CommandContext context) {
CommandSender sender = context.sender();
String worldName = (String)context.get( .nameArg);
(Universe.get().getWorld(worldName) == ) {
sender.sendMessage(Message.translation( ).param( , worldName));
} {
HytaleServer.get().getConfig().getDefaults().setWorld(worldName);
sender.sendMessage(Message.translation( ).param( , worldName));
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/perf/WorldPerfCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world.perf;
import com.hypixel.hytale.common.util.FormatUtil;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.metrics.metric.HistoricMetric;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
public class WorldPerfCommand extends AbstractWorldCommand {
public static final double PRECISION = 1000.0 ;
@Nonnull
private final FlagArg allFlag = this .withFlagArg("all" , "server.commands.world.perf.all.desc" );
@Nonnull
private final FlagArg deltaFlag = this .withFlagArg( , );
{
( , );
.addSubCommand( ());
.addSubCommand( ());
}
{
world.getBufferedTickLengthMetricSet();
[] periods = historicMetric.getPeriodsNanos();
world.getTickStepNanos();
Message.empty();
.deltaFlag.provided(context);
.allFlag.provided(context);
(context.sender() Player) {
( ; i < periods.length; ++i) {
FormatUtil.timeUnitToString(periods[i], TimeUnit.NANOSECONDS, );
historicMetric.getAverage(i);
historicMetric.calculateMin(i);
historicMetric.calculateMax(i);
(showDelta) {
FormatUtil.simpleTimeUnitFormat(min, average, max, TimeUnit.NANOSECONDS, TimeUnit.MILLISECONDS, );
.repeat(Math.max( , - value.length()));
msg.insert(Message.translation( ).param( , length).param( , padding).param( , value).insert( ));
} {
msg.insert(Message.translation( ).param( , length).param( , FormatUtil.simpleFormat(min, average, max, (d1) -> tpsFromDelta(d1, ( )tickStepNanos), )).insert( ));
}
}
} {
FormatUtil.simpleTimeUnitFormat(( )tickStepNanos, TimeUnit.NANOSECONDS, );
msg.insert(Message.translation( ).param( , tickLimitFormatted).insert( ));
( ; i < periods.length; ++i) {
FormatUtil.timeUnitToString(periods[i], TimeUnit.NANOSECONDS, );
historicMetric.getAverage(i);
historicMetric.calculateMin(i);
historicMetric.calculateMax(i);
(showDelta) {
FormatUtil.simpleTimeUnitFormat(min, average, max, TimeUnit.NANOSECONDS, TimeUnit.MILLISECONDS, );
.repeat(Math.max( , - value.length()));
msg.insert(Message.translation( ).param( , length).param( , padding).param( , value).insert( ));
} {
msg.insert(Message.translation( ).param( , length).param( , tpsFromDelta(max, ( )tickStepNanos)).param( , tpsFromDelta(average, ( )tickStepNanos)).param( , tpsFromDelta(min, ( )tickStepNanos)).insert( ));
}
(showAll) {
msg.insert(Message.translation( ).param( , length).param( , min).param( , ( )average).param( , max).insert( ));
}
}
}
context.sendMessage(msg);
}
{
delta;
(delta < min) {
adjustedDelta = min;
}
( )Math.round( / ( )adjustedDelta * * ) / ;
}
{
delta;
(delta < ( )min) {
adjustedDelta = ( )min;
}
( )Math.round( / adjustedDelta * * ) / ;
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/perf/WorldPerfGraphCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world.perf;
import com.hypixel.hytale.common.util.FormatUtil;
import com.hypixel.hytale.common.util.StringUtil;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.metrics.metric.HistoricMetric;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.DefaultArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
public class WorldPerfGraphCommand extends AbstractWorldCommand {
@Nonnull
private final DefaultArg<Integer> widthArg;
@Nonnull
private final DefaultArg<Integer> heightArg;
public WorldPerfGraphCommand () {
super ("graph" , "server.commands.world.perf.graph.desc" );
this .widthArg = this .withDefaultArg("width" , "server.commands.world.perf.graph.width.desc" , ArgTypes.INTEGER, , );
.heightArg = .withDefaultArg( , , ArgTypes.INTEGER, , );
}
{
(Integer) .widthArg.get(context);
(Integer) .heightArg.get(context);
System.nanoTime();
Message.empty();
world.getBufferedTickLengthMetricSet();
[] periods = historicMetric.getPeriodsNanos();
( ; i < periods.length; ++i) {
periods[i];
[] historyTimestamps = historicMetric.getTimestamps(i);
[] historyValues = historicMetric.getValues(i);
FormatUtil.timeUnitToString(period, TimeUnit.NANOSECONDS, );
msg.insert(Message.translation( ).param( , historyLengthFormatted));
();
StringUtil.generateGraph(sb, width, height, startNano - period, startNano, , ( )world.getTps(), (value) -> String.valueOf(MathUtil.round(value, )), historyTimestamps.length, (ii) -> historyTimestamps[ii], (ii) -> WorldPerfCommand.tpsFromDelta(historyValues[ii], ( )world.getTickStepNanos()));
msg.insert(sb.toString()).insert( );
}
context.sendMessage(msg);
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/perf/WorldPerfResetCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world.perf;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class WorldPerfResetCommand extends AbstractWorldCommand {
@Nonnull
private static final Message MESSAGE_COMMANDS_WORLD_PERF_RESET_ALL = Message.translation("server.commands.world.perf.reset.all" );
private final FlagArg allFlag = this .withFlagArg("all" , "server.commands.world.perf.reset.all.desc" );
public WorldPerfResetCommand () {
super ("reset" , "server.commands.world.perf.reset.desc" );
}
protected void execute {
( .allFlag.provided(context)) {
Universe.get().getWorlds().forEach((name, w) -> w.clearMetrics());
context.sendMessage(MESSAGE_COMMANDS_WORLD_PERF_RESET_ALL);
} {
world.clearMetrics();
context.sendMessage(Message.translation( ).param( , world.getName()));
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/tps/WorldTpsCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world.tps;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class WorldTpsCommand extends AbstractWorldCommand {
@Nonnull
private static final Message MESSAGE_COMMANDS_WORLD_TPS_SET_SUCCESS = Message.translation("server.commands.world.tps.set.success" );
@Nonnull
private static final Message MESSAGE_COMMANDS_WORLD_TPS_SET_INVALID = Message.translation("server.commands.world.tps.set.invalid" );
@Nonnull
private final RequiredArg<Integer> tickRateArg;
public WorldTpsCommand () {
super ("tps" , );
.tickRateArg = .withRequiredArg( , , ArgTypes.TICK_RATE);
.addAliases( []{ });
.addSubCommand( ());
}
{
(Integer) .tickRateArg.get(context);
(newTickRate > && newTickRate <= ) {
world.setTps(newTickRate);
/ ( )newTickRate;
context.sendMessage(MESSAGE_COMMANDS_WORLD_TPS_SET_SUCCESS.param( , world.getName()).param( , newTickRate).param( , String.format( , newMs)));
} {
context.sendMessage(MESSAGE_COMMANDS_WORLD_TPS_SET_INVALID.param( , newTickRate));
}
}
}
com/hypixel/hytale/server/core/universe/world/commands/world/tps/WorldTpsResetCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.world.tps;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class WorldTpsResetCommand extends AbstractWorldCommand {
public WorldTpsResetCommand () {
super ("reset" , "server.commands.world.tps.reset.desc" );
}
protected void execute (@Nonnull CommandContext context, @Nonnull World world, @Nonnull Store<EntityStore> store) {
int defaultTps = 30 ;
world.setTps(30 );
double defaultMs = 33.333333333333336 ;
context.sendMessage(Message.translation("server.commands.world.tps.reset.success" ).param("worldName" , world.getName()).param("tps" , 30 ).param("ms" , String.format("%.2f" , )));
}
}
com/hypixel/hytale/server/core/universe/world/commands/worldconfig/WorldConfigCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.worldconfig;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;
public class WorldConfigCommand extends AbstractCommandCollection {
public WorldConfigCommand () {
super ("config" , "server.commands.world.config.desc" );
this .addSubCommand(new WorldConfigPauseTimeCommand ());
this .addSubCommand(new WorldConfigSeedCommand ());
this .addSubCommand(new WorldConfigSetPvpCommand ());
this .addSubCommand(new WorldConfigSetSpawnCommand ());
}
}
com/hypixel/hytale/server/core/universe/world/commands/worldconfig/WorldConfigPauseTimeCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.worldconfig;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.modules.time.WorldTimeResource;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldConfig;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class WorldConfigPauseTimeCommand extends AbstractWorldCommand {
public WorldConfigPauseTimeCommand () {
super ("pausetime" , "server.commands.pausetime.desc" );
}
protected void execute (@Nonnull CommandContext context, @Nonnull World world, @Nonnull Store<EntityStore> store) {
pauseTime(context.sender(), world, store);
}
public static void pauseTime (@Nonnull CommandSender commandSender, @Nonnull World world, @Nonnull Store<EntityStore> store) {
WorldTimeResource (WorldTimeResource)store.getResource(WorldTimeResource.getResourceType());
!world.getWorldConfig().isGameTimePaused();
world.getWorldConfig();
worldConfig.setGameTimePaused(timePause);
worldConfig.markChanged();
Message.translation(timePause ? : );
commandSender.sendMessage(Message.translation( ).param( , timePausedMessage).param( , world.getName()).param( , worldTimeResource.getGameTime().toString()));
}
}
com/hypixel/hytale/server/core/universe/world/commands/worldconfig/WorldConfigSeedCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.worldconfig;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class WorldConfigSeedCommand extends AbstractWorldCommand {
public WorldConfigSeedCommand () {
super ("seed" , "server.commands.seed.desc" );
}
protected void execute (@Nonnull CommandContext context, @Nonnull World world, @Nonnull Store<EntityStore> store) {
context.sendMessage(Message.translation("server.universe.seed.info" ).param("seed" , world.getWorldConfig().getSeed()));
}
}
com/hypixel/hytale/server/core/universe/world/commands/worldconfig/WorldConfigSetPvpCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.worldconfig;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldConfig;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.server.core.util.message.MessageFormat;
import javax.annotation.Nonnull;
public class WorldConfigSetPvpCommand extends AbstractWorldCommand {
@Nonnull
private final RequiredArg<Boolean> stateArg;
public WorldConfigSetPvpCommand () {
super ("pvp" , "server.commands.setpvp.desc" );
this .stateArg = this .withRequiredArg("enabled" , "server.commands.world.config.setpvp.stateArg.desc" , ArgTypes.BOOLEAN);
}
protected void execute (@Nonnull CommandContext context, @Nonnull World world, @Nonnull Store<EntityStore> store) {
.stateArg.provided(context) ? (Boolean) .stateArg.get(context) : !world.getWorldConfig().isPvpEnabled();
world.getWorldConfig();
worldConfig.setPvpEnabled(isPvpEnabled);
worldConfig.markChanged();
context.sendMessage(Message.translation( ).param( , MessageFormat.enabled(isPvpEnabled)).param( , world.getName()));
}
}
com/hypixel/hytale/server/core/universe/world/commands/worldconfig/WorldConfigSetSpawnCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.worldconfig;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.DefaultArg;
import com.hypixel.hytale.server.core.command.system.arguments.system.OptionalArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.arguments.types.RelativeDoublePosition;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.command.system.exceptions.GeneralCommandException;
import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldConfig;
import com.hypixel.hytale.server.core.universe.world.spawn.GlobalSpawnProvider;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.text.DecimalFormat;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public class WorldConfigSetSpawnCommand extends AbstractWorldCommand {
@Nonnull
private ( );
Message.translation( );
OptionalArg<RelativeDoublePosition> positionArg;
DefaultArg<Vector3f> rotationArg;
{
( , );
.positionArg = .withOptionalArg( , , ArgTypes.RELATIVE_POSITION);
.rotationArg = .withDefaultArg( , , ArgTypes.ROTATION, Vector3f.FORWARD, );
.addSubCommand( ());
}
{
Vector3d position;
( .positionArg.provided(context)) {
(RelativeDoublePosition) .positionArg.get(context);
position = relativePosition.getRelativePosition(context, world, store);
} {
(!context.isPlayer()) {
(MESSAGE_COMMANDS_ERROR_PROVIDE_POSITION);
}
Ref<EntityStore> playerRef = context.senderAsPlayerRef();
(playerRef == || !playerRef.isValid()) {
(MESSAGE_COMMANDS_ERROR_PROVIDE_POSITION);
}
(TransformComponent)store.getComponent(playerRef, TransformComponent.getComponentType());
transformComponent != ;
position = transformComponent.getPosition().clone();
}
Vector3f rotation;
( .rotationArg.provided(context)) {
rotation = (Vector3f) .rotationArg.get(context);
} (context.isPlayer()) {
Ref<EntityStore> playerRef = context.senderAsPlayerRef();
(playerRef != && playerRef.isValid()) {
(HeadRotation)store.getComponent(playerRef, HeadRotation.getComponentType());
headRotationComponent != ;
rotation = headRotationComponent.getRotation();
} {
rotation = (Vector3f) .rotationArg.get(context);
}
} {
rotation = (Vector3f) .rotationArg.get(context);
}
(position, rotation);
world.getWorldConfig();
worldConfig.setSpawnProvider( (transform));
worldConfig.markChanged();
world.getLogger().at(Level.INFO).log( , worldConfig.getSpawnProvider());
context.sendMessage(Message.translation( ).param( , DECIMAL.format(position.getX())).param( , DECIMAL.format(position.getY())).param( , DECIMAL.format(position.getZ())).param( , DECIMAL.format(( )rotation.getX())).param( , DECIMAL.format(( )rotation.getY())).param( , DECIMAL.format(( )rotation.getZ())));
}
}
com/hypixel/hytale/server/core/universe/world/commands/worldconfig/WorldConfigSetSpawnDefaultCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.worldconfig;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.spawn.ISpawnProvider;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public class WorldConfigSetSpawnDefaultCommand extends AbstractWorldCommand {
@Nonnull
private static final Message MESSAGE_UNIVERSE_SET_SPAWN_DEFAULT = Message.translation("server.universe.setspawn.default" );
public WorldConfigSetSpawnDefaultCommand () {
super ("default" , "server.commands.world.config.setspawn.default.desc" );
}
protected void execute (@Nonnull CommandContext context, @Nonnull World world, @Nonnull Store<EntityStore> store) {
world.getWorldConfig().setSpawnProvider((ISpawnProvider)null );
world.getLogger().at(Level.INFO).log("Set spawn provider to: %s" , world.getWorldConfig().getSpawnProvider());
context.sendMessage(MESSAGE_UNIVERSE_SET_SPAWN_DEFAULT);
}
}
com/hypixel/hytale/server/core/universe/world/commands/worldconfig/WorldPauseCommand.java
package com.hypixel.hytale.server.core.universe.world.commands.worldconfig;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.Constants;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class WorldPauseCommand extends AbstractWorldCommand {
@Nonnull
private static final Message MESSAGE_COMMANDS_PAUSE_TOO_MANY_PLAYERS = Message.translation("server.commands.pause.tooManyPlayers" );
public WorldPauseCommand () {
super ("pause" , "server.commands.pause.desc" );
}
protected void execute (@Nonnull CommandContext context, @Nonnull World world, @Nonnull Store<EntityStore> store) {
if (world.getPlayerCount() == 1 && Constants.SINGLEPLAYER) {
world.setPaused(!world.isPaused());
context.sendMessage(Message.translation("server.commands.pause.updated" ).param("state" , Message.translation(world.isPaused() ? : )));
} {
context.sendMessage(MESSAGE_COMMANDS_PAUSE_TOO_MANY_PLAYERS);
}
}
}
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.math.vector.Vector3i;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
public class ConnectedBlockFaceTags {
public static final BuilderCodec<ConnectedBlockFaceTags> CODEC;
public static final ConnectedBlockFaceTags EMPTY;
@Nonnull
private final Map<Vector3i, HashSet<String>> blockFaceTags = new Object2ObjectOpenHashMap <Vector3i, HashSet<String>>();
public ConnectedBlockFaceTags () {
}
public boolean contains (Vector3i direction, String blockFaceTag) {
return this .blockFaceTags.containsKey(direction) && ((HashSet)this .blockFaceTags.get(direction)).contains(blockFaceTag);
}
@Nonnull
public Map<Vector3i, HashSet<String>> {
.blockFaceTags;
}
Set<String> {
.blockFaceTags.containsKey(direction) ? (Set) .blockFaceTags.get(direction) : Collections.emptySet();
}
Set<Vector3i> {
.blockFaceTags.keySet();
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ConnectedBlockFaceTags.class, ConnectedBlockFaceTags:: ).append( ( , (Codec.STRING, (x$ ) -> [x$ ]), ), (o, tags) -> {
HashSet<String> strings = (tags.length);
strings.addAll(Arrays.asList(tags));
o.blockFaceTags.put(Vector3i.NORTH, strings);
}, (o) -> o.blockFaceTags.containsKey(Vector3i.NORTH) ? (String[])((HashSet)o.blockFaceTags.get(Vector3i.NORTH)).toArray((x$ ) -> [x$ ]) : [ ]).add()).append( ( , (Codec.STRING, (x$ ) -> [x$ ]), ), (o, tags) -> {
HashSet<String> strings = (tags.length);
strings.addAll(Arrays.asList(tags));
o.blockFaceTags.put(Vector3i.EAST, strings);
}, (o) -> o.blockFaceTags.containsKey(Vector3i.EAST) ? (String[])((HashSet)o.blockFaceTags.get(Vector3i.EAST)).toArray((x$ ) -> [x$ ]) : [ ]).add()).append( ( , (Codec.STRING, (x$ ) -> [x$ ]), ), (o, tags) -> {
HashSet<String> strings = (tags.length);
strings.addAll(Arrays.asList(tags));
o.blockFaceTags.put(Vector3i.SOUTH, strings);
}, (o) -> o.blockFaceTags.containsKey(Vector3i.SOUTH) ? (String[])((HashSet)o.blockFaceTags.get(Vector3i.SOUTH)).toArray((x$ ) -> [x$ ]) : [ ]).add()).append( ( , (Codec.STRING, (x$ ) -> [x$ ]), ), (o, tags) -> {
HashSet<String> strings = (tags.length);
strings.addAll(Arrays.asList(tags));
o.blockFaceTags.put(Vector3i.WEST, strings);
}, (o) -> o.blockFaceTags.containsKey(Vector3i.WEST) ? (String[])((HashSet)o.blockFaceTags.get(Vector3i.WEST)).toArray((x$ ) -> [x$ ]) : [ ]).add()).append( ( , (Codec.STRING, (x$ ) -> [x$ ]), ), (o, tags) -> {
HashSet<String> strings = (tags.length);
strings.addAll(Arrays.asList(tags));
o.blockFaceTags.put(Vector3i.UP, strings);
}, (o) -> o.blockFaceTags.containsKey(Vector3i.UP) ? (String[])((HashSet)o.blockFaceTags.get(Vector3i.UP)).toArray((x$ ) -> [x$ ]) : [ ]).add()).append( ( , (Codec.STRING, (x$ ) -> [x$ ]), ), (o, tags) -> {
HashSet<String> strings = (tags.length);
strings.addAll(Arrays.asList(tags));
o.blockFaceTags.put(Vector3i.DOWN, strings);
}, (o) -> o.blockFaceTags.containsKey(Vector3i.DOWN) ? (String[])((HashSet)o.blockFaceTags.get(Vector3i.DOWN)).toArray((x$ ) -> [x$ ]) : [ ]).add()).build();
EMPTY = ();
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockPatternRule.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.EnumCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.codec.codecs.set.SetCodec;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.buildertool.config.BlockTypeListAsset;
import com.hypixel.hytale.server.core.prefab.selection.mask.BlockPattern;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ConnectedBlockPatternRule {
public static final BuilderCodec<ConnectedBlockPatternRule> CODEC;
private IncludeOrExclude includeOrExclude;
private Vector3i relativePosition;
private final HashSet<String> blockTypes;
@Nullable
private BlockTypeListAsset[] blockTypeListAssets;
private Set<BlockPattern.BlockEntry> shapeBlockTypeKeys;
private ConnectedBlockFaceTags faceTags;
private AdjacentSide[] placementNormals;
public ConnectedBlockPatternRule () {
this .relativePosition = Vector3i.ZERO;
this .blockTypes = ();
.shapeBlockTypeKeys = Collections.emptySet();
.faceTags = ConnectedBlockFaceTags.EMPTY;
}
Vector3i {
.relativePosition;
}
HashSet<String> {
.blockTypes;
}
Set<BlockPattern.BlockEntry> getShapeBlockTypeKeys() {
.shapeBlockTypeKeys;
}
ConnectedBlockFaceTags {
.faceTags;
}
BlockTypeListAsset[] getBlockTypeListAssets() {
.blockTypeListAssets;
}
AdjacentSide[] getPlacementNormals() {
.placementNormals;
}
{
.includeOrExclude == ConnectedBlockPatternRule.IncludeOrExclude.INCLUDE;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ConnectedBlockPatternRule.class, ConnectedBlockPatternRule:: ).append( ( , Vector3i.CODEC, ), (o, relativePosition) -> o.relativePosition = relativePosition, (o) -> o.relativePosition).add()).append( ( , (IncludeOrExclude.class), ), (o, allowOrExclude) -> o.includeOrExclude = allowOrExclude, (o) -> o.includeOrExclude).add()).append( ( , ( (AdjacentSide.class), (x$ ) -> [x$ ]), ), (o, placementNormals) -> o.placementNormals = placementNormals, (o) -> o.placementNormals).add()).documentation( )).append( ( , ConnectedBlockFaceTags.CODEC, ), (o, faceTags) -> o.faceTags = faceTags, (o) -> o.faceTags).add()).append( ( , (BlockPattern.BlockEntry.CODEC, HashSet:: , )), (o, blockTypesAllowed) -> o.shapeBlockTypeKeys = blockTypesAllowed, (o) -> o.shapeBlockTypeKeys).add()).append( ( , (Codec.STRING, (x$ ) -> [x$ ])), (o, blockTypesAllowed) -> {
(blockTypesAllowed != ) {
Collections.addAll(o.blockTypes, blockTypesAllowed);
}
}, (o) -> o.blockTypes != ? (String[])o.blockTypes.toArray((x$ ) -> [x$ ]) : ).add()).append( ( , Codec.STRING_ARRAY), (o, blockTypeListAssetsAllowed) -> {
(blockTypeListAssetsAllowed != ) {
o.blockTypeListAssets = [blockTypeListAssetsAllowed.length];
( ; i < blockTypeListAssetsAllowed.length; ++i) {
o.blockTypeListAssets[i] = (BlockTypeListAsset)BlockTypeListAsset.getAssetMap().getAsset(blockTypeListAssetsAllowed[i]);
(o.blockTypeListAssets[i] == ) {
System.out.println( + blockTypeListAssetsAllowed[i] + );
}
}
}
}, (o) -> {
(o.blockTypeListAssets == ) {
;
} {
String[] assetIds = [o.blockTypeListAssets.length];
( ; i < o.blockTypeListAssets.length; ++i) {
assetIds[i] = o.blockTypeListAssets[i].getId();
}
assetIds;
}
}).add()).build();
}
{
Up(Vector3i.UP),
Down(Vector3i.DOWN),
North(Vector3i.NORTH),
East(Vector3i.EAST),
South(Vector3i.SOUTH),
West(Vector3i.WEST);
Vector3i relativePosition;
{
.relativePosition = side;
}
}
{
INCLUDE,
EXCLUDE;
{
}
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockRuleSet.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.codec.lookup.CodecMapCodec;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.universe.world.World;
import java.util.Optional;
import javax.annotation.Nullable;
public abstract class ConnectedBlockRuleSet {
public static final CodecMapCodec<ConnectedBlockRuleSet> CODEC = new CodecMapCodec <ConnectedBlockRuleSet>("Type" );
public ConnectedBlockRuleSet () {
}
public abstract boolean onlyUpdateOnPlacement () ;
public abstract Optional<ConnectedBlocksUtil.ConnectedBlockResult> getConnectedBlockType(World var1, Vector3i var2, BlockType var3, int var4, Vector3i var5, boolean var6);
public void updateCachedBlockTypes (BlockType blockType, BlockTypeAssetMap<String, BlockType> assetMap) {
}
@Nullable
public com.hypixel.hytale.protocol.ConnectedBlockRuleSet toPacket (BlockTypeAssetMap<String, BlockType> assetMap) {
return ;
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlockShape.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
public class ConnectedBlockShape {
public static final BuilderCodec<ConnectedBlockShape> CODEC;
private CustomTemplateConnectedBlockPattern[] patternsToMatchAnyOf;
private ConnectedBlockFaceTags faceTags;
public ConnectedBlockShape () {
}
public CustomTemplateConnectedBlockPattern[] getPatternsToMatchAnyOf() {
return this .patternsToMatchAnyOf;
}
public ConnectedBlockFaceTags getFaceTags () {
return this .faceTags;
}
static {
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ConnectedBlockShape.class, ConnectedBlockShape::new ).append(new KeyedCodec ("PatternsToMatchAnyOf" , new ArrayCodec (CustomTemplateConnectedBlockPattern.CODEC, (x$0 ) -> new CustomTemplateConnectedBlockPattern [x$0 ]), true ), (o, patternsToMatchAnyOf) -> o.patternsToMatchAnyOf = patternsToMatchAnyOf, (o) -> o.patternsToMatchAnyOf).add()).append(new KeyedCodec ("FaceTags" , ConnectedBlockFaceTags.CODEC, ), (o, faceTags) -> o.faceTags = faceTags, (o) -> o.faceTags).add()).build();
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlocksModule.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.assetstore.AssetRegistry;
import com.hypixel.hytale.assetstore.event.LoadedAssetsEvent;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.DefaultAssetMap;
import com.hypixel.hytale.common.plugin.PluginManifest;
import com.hypixel.hytale.server.core.asset.HytaleAssetStore;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.server.core.modules.interaction.InteractionModule;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
import com.hypixel.hytale.server.core.universe.world.connectedblocks.builtin.RoofConnectedBlockRuleSet;
import com.hypixel.hytale.server.core.universe.world.connectedblocks.builtin.StairConnectedBlockRuleSet;
import javax.annotation.Nonnull;
public class ConnectedBlocksModule extends JavaPlugin {
public static final PluginManifest MANIFEST = PluginManifest.corePlugin(ConnectedBlocksModule.class).depends(EntityModule.class).depends(InteractionModule.class).build();
private static ConnectedBlocksModule instance;
public static ConnectedBlocksModule get () {
return instance;
}
public {
(init);
instance = ;
}
{
AssetRegistry.register(((HytaleAssetStore.Builder)((HytaleAssetStore.Builder)((HytaleAssetStore.Builder)HytaleAssetStore.builder(CustomConnectedBlockTemplateAsset.class, ()).setPath( )).setKeyFunction(CustomConnectedBlockTemplateAsset::getId)).setCodec(CustomConnectedBlockTemplateAsset.CODEC)).build());
.getEventRegistry().register((Class)LoadedAssetsEvent.class, BlockType.class, ConnectedBlocksModule::onBlockTypesChanged);
CustomTemplateConnectedBlockPattern.CODEC.register((String) , CustomConnectedBlockPattern.class, CustomConnectedBlockPattern.CODEC);
ConnectedBlockRuleSet.CODEC.register((String) , CustomTemplateConnectedBlockRuleSet.class, CustomTemplateConnectedBlockRuleSet.CODEC);
ConnectedBlockRuleSet.CODEC.register((String) , StairConnectedBlockRuleSet.class, StairConnectedBlockRuleSet.CODEC);
ConnectedBlockRuleSet.CODEC.register((String) , RoofConnectedBlockRuleSet.class, RoofConnectedBlockRuleSet.CODEC);
}
{
(BlockType blockType : event.getLoadedAssets().values()) {
blockType.getConnectedBlockRuleSet();
(ruleSet != ) {
ruleSet.updateCachedBlockTypes(blockType, event.getAssetMap());
}
}
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/ConnectedBlocksUtil.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.util.FillerBlockUtil;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIntPair;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Queue;
import java.util.Set;
import javax.annotation.Nonnull;
public class ConnectedBlocksUtil {
private static final int MAX_UPDATE_DEPTH = 3 ;
public ConnectedBlocksUtil () {
}
public static void {
(blockPosition);
(BlockType)BlockType.getAssetMap().getAsset(blockTypeId);
(blockType != ) {
blockChunkComponent.getSectionAtBlockY(blockPosition.y);
sectionAtY.getFiller(blockPosition.x, blockPosition.y, blockPosition.z);
;
(blockType.getConnectedBlockRuleSet() != && filler == ) {
blockTypeRotation.index();
Optional<ConnectedBlockResult> foundPattern = getDesiredConnectedBlockType(worldChunkComponent.getWorld(), coordinate, blockType, rotationIndex, placementNormal, );
(foundPattern.isPresent() && (!((ConnectedBlockResult)foundPattern.get()).blockTypeKey().equals(blockType.getId()) || ((ConnectedBlockResult)foundPattern.get()).rotationIndex != rotationIndex)) {
(ConnectedBlockResult)foundPattern.get();
BlockType.getAssetMap().getIndex(result.blockTypeKey());
result.rotationIndex();
worldChunkComponent.setBlock(coordinate.x, coordinate.y, coordinate.z, id, (BlockType)BlockType.getAssetMap().getAsset(id), rotation, , settings);
}
}
updateNeighborsWithDepth(worldChunkComponent, coordinate, placementNormal, settings);
}
}
{
{
}
Queue<QueueEntry> queue = ();
Set<Vector3i> visited = <Vector3i>();
queue.add( ( (startCoordinate), ));
label67:
(!queue.isEmpty()) {
(QueueEntry)queue.poll();
entry.coordinate;
entry.depth;
Map<Vector3i, ConnectedBlockResult> desiredChanges = <Vector3i, ConnectedBlockResult>();
notifyNeighborsAndCollectChanges(worldChunkComponent.getWorld(), coordinate, desiredChanges, placementNormal);
desiredChanges.entrySet().iterator();
( ) {
Vector3i location;
ConnectedBlockResult connectedBlockResult;
WorldChunk newWorldChunk;
( ) {
(!var10.hasNext()) {
label67;
}
Map.Entry<Vector3i, ConnectedBlockResult> result = (Map.Entry)var10.next();
location = (Vector3i)result.getKey();
connectedBlockResult = (ConnectedBlockResult)result.getValue();
(visited.add(location.clone()) && (location.x != coordinate.x || location.y != coordinate.y || location.z != coordinate.z)) {
newWorldChunk = worldChunkComponent;
ChunkUtil.indexChunkFromBlock(location.x, location.z);
(chunkIndex == worldChunkComponent.getIndex()) {
;
}
newWorldChunk = worldChunkComponent.getWorld().getChunkIfLoaded(chunkIndex);
(newWorldChunk != ) {
;
}
}
}
BlockType.getAssetMap().getIndex(connectedBlockResult.blockTypeKey());
(BlockType)BlockType.getAssetMap().getAsset(blockId);
newWorldChunk.setBlock(location.x, location.y, location.z, blockId, block, connectedBlockResult.rotationIndex(), , settings);
(Map.Entry<Vector3i, ObjectIntPair<String>> additionalEntry : connectedBlockResult.getAdditionalConnectedBlocks().entrySet()) {
(Vector3i)additionalEntry.getKey();
ObjectIntPair<String> blockData = (ObjectIntPair)additionalEntry.getValue();
( (location)).add(offset);
newWorldChunk;
ChunkUtil.indexChunkFromBlock(additionalLocation.x, additionalLocation.z);
(additionalChunkIndex != newWorldChunk.getIndex()) {
additionalChunk = worldChunkComponent.getWorld().getChunkIfLoaded(additionalChunkIndex);
(additionalChunk == ) {
;
}
}
BlockType.getAssetMap().getIndex((String)blockData.first());
(BlockType)BlockType.getAssetMap().getAsset(additionalBlockId);
(additionalBlock != ) {
additionalChunk.setBlock(additionalLocation.x, additionalLocation.y, additionalLocation.z, additionalBlockId, additionalBlock, blockData.rightInt(), , settings);
}
}
(depth + < ) {
queue.add( (location.clone(), depth + ));
}
}
}
}
{
origin.clone();
ChunkUtil.indexChunkFromBlock(origin.x, origin.z);
world.getChunkIfLoaded(chunkIndex);
( - ; x1 <= ; ++x1) {
( - ; z1 <= ; ++z1) {
( - ; y1 <= ; ++y1) {
(x1 != || y1 != || z1 != ) {
coordinate.assign(origin).add(x1, y1, z1);
(coordinate.y >= && coordinate.y < && !desiredChanges.containsKey(coordinate)) {
ChunkUtil.indexChunkFromBlock(coordinate.x, coordinate.z);
(neighborChunkIndex != chunkIndex) {
chunkIndex = neighborChunkIndex;
chunk = world.getChunkIfLoaded(neighborChunkIndex);
}
(chunk != ) {
chunk.getBlockChunk();
(blockChunk != ) {
blockChunk.getSectionAtBlockY(coordinate.y);
(blockSection != ) {
blockSection.get(coordinate.x, coordinate.y, coordinate.z);
(BlockType)BlockType.getAssetMap().getAsset(neighborBlockId);
(neighborBlockType != ) {
neighborBlockType.getConnectedBlockRuleSet();
(ruleSet != && !ruleSet.onlyUpdateOnPlacement()) {
blockSection.getFiller(coordinate.x, coordinate.y, coordinate.z);
blockSection.getRotationIndex(coordinate.x, coordinate.y, coordinate.z);
(filler != ) {
coordinate.x - FillerBlockUtil.unpackX(filler);
coordinate.y - FillerBlockUtil.unpackY(filler);
coordinate.z - FillerBlockUtil.unpackZ(filler);
coordinate.assign(originX, originY, originZ);
}
Optional<ConnectedBlockResult> output = getDesiredConnectedBlockType(world, coordinate, neighborBlockType, existingRotation, placementNormal, );
(output.isPresent() && (!neighborBlockType.getId().equals(((ConnectedBlockResult)output.get()).blockTypeKey()) || ((ConnectedBlockResult)output.get()).rotationIndex != existingRotation)) {
desiredChanges.put(coordinate.clone(), (ConnectedBlockResult)output.get());
}
}
}
}
}
}
}
}
}
}
}
}
Optional<ConnectedBlockResult> {
currentBlockType.getConnectedBlockRuleSet();
ruleSet == ? Optional.empty() : ruleSet.getConnectedBlockType(world, coordinate, currentBlockType, currentRotation, placementNormal, isPlacement);
}
{
String blockTypeKey;
rotationIndex;
Map<Vector3i, ObjectIntPair<String>> additionalConnectedBlocks = <Vector3i, ObjectIntPair<String>>();
{
.blockTypeKey = blockTypeKey;
.rotationIndex = rotationIndex;
}
String {
.blockTypeKey;
}
{
.rotationIndex;
}
Map<Vector3i, ObjectIntPair<String>> {
.additionalConnectedBlocks;
}
{
.additionalConnectedBlocks.put(offset, ObjectIntPair.of(blockTypeKey, rotationIndex));
}
{
(obj == ) {
;
} (obj != && obj.getClass() == .getClass()) {
(ConnectedBlockResult)obj;
Objects.equals( .blockTypeKey, that.blockTypeKey) && .rotationIndex == that.rotationIndex && Objects.equals( .additionalConnectedBlocks, that.additionalConnectedBlocks);
} {
;
}
}
{
Objects.hash( []{ .blockTypeKey, .rotationIndex, .additionalConnectedBlocks});
}
String {
.blockTypeKey;
+ var10000 + + .rotationIndex + + String.valueOf( .additionalConnectedBlocks) + ;
}
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockPattern.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.codec.codecs.simple.BooleanCodec;
import com.hypixel.hytale.math.Axis;
import com.hypixel.hytale.math.block.BlockUtil;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockFlipType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.asset.type.buildertool.config.BlockTypeListAsset;
import com.hypixel.hytale.server.core.prefab.selection.mask.BlockPattern;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import it.unimi.dsi.fastutil.Pair;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import javax.annotation.Nonnull;
public class CustomConnectedBlockPattern extends CustomTemplateConnectedBlockPattern {
public static BuilderCodec<CustomConnectedBlockPattern> CODEC;
Random random;
;
PatternRotationDefinition patternRotationDefinition;
ConnectedBlockPatternRule[] rulesToMatch;
Rotation yawToApplyAddReplacedBlockType;
requireFaceTagsMatchingRoll;
onlyOnUpdate;
onlyOnPlacement;
{
.patternRotationDefinition = PatternRotationDefinition.DEFAULT;
}
{
(!rule.getFaceTags().getDirections().isEmpty()) {
(BlockType)BlockType.getAssetMap().getAsset(blockToTest);
checkingBlockType.getConnectedBlockRuleSet();
(!(checkingRuleSet CustomTemplateConnectedBlockRuleSet)) {
!rule.isInclude();
}
(CustomTemplateConnectedBlockRuleSet)checkingRuleSet;
BlockType.getAssetMap().getIndex(blockToTest);
checkingConnectedBlockRuleSet.getShapesForBlockType(index);
checkingConnectedBlockRuleSet.getShapeTemplateAsset();
(checkingTemplateAsset == ) {
!rule.isInclude();
}
(String shapeName : shapeNames) {
(template.connectsToOtherMaterials || placedRuleset.getShapeNameToBlockPatternMap().equals(checkingConnectedBlockRuleSet.getShapeNameToBlockPatternMap())) {
(ConnectedBlockShape)checkingTemplateAsset.connectedBlockShapes.get(shapeName);
Map<Vector3i, HashSet<String>> ruleFaceTags = rule.getFaceTags().getBlockFaceTags();
(Map.Entry<Vector3i, HashSet<String>> ruleFaceTag : ruleFaceTags.entrySet()) {
Rotation.rotate(((Vector3i)ruleFaceTag.getKey()).clone(), Rotation.None.subtract(rotationToCheckUnrotated.yaw()), Rotation.None);
(String faceTag : (HashSet)ruleFaceTag.getValue()) {
blockToCheckConnectedBlockShape.getFaceTags() != && blockToCheckConnectedBlockShape.getFaceTags().contains(adjustedDirectionOfPattern, faceTag);
(containsFaceTag) {
rule.isInclude();
}
}
}
}
}
}
(!rule.getShapeBlockTypeKeys().isEmpty()) {
(BlockType)BlockType.getAssetMap().getAsset(blockToTest);
checkingBlockType.getConnectedBlockRuleSet();
(!(checkingRuleSet CustomTemplateConnectedBlockRuleSet)) {
!rule.isInclude();
}
(CustomTemplateConnectedBlockRuleSet)checkingRuleSet;
BlockType.getAssetMap().getIndex(blockToTest);
(String shapeName : checkingConnectedBlockRuleSet.getShapesForBlockType(index)) {
((template.connectsToOtherMaterials || placedRuleset.getShapeNameToBlockPatternMap().equals(checkingConnectedBlockRuleSet.getShapeNameToBlockPatternMap())) && rule.getShapeBlockTypeKeys().contains( .BlockEntry(shapeName, rotationToCheckUnrotated.index(), fillerToCheckUnrotated))) {
rule.isInclude();
}
}
}
(!rule.getBlockTypes().isEmpty() && rule.getBlockTypes().contains(blockToTest)) {
rule.isInclude();
} {
(rule.getBlockTypeListAssets() != ) {
(BlockTypeListAsset blockTypeListAsset : rule.getBlockTypeListAssets()) {
(blockTypeListAsset.getBlockTypeKeys().contains(blockToTest)) {
rule.isInclude();
}
}
}
!rule.isInclude();
}
}
Optional<ConnectedBlocksUtil.ConnectedBlockResult> getConnectedBlockTypeKey(String shapeName, World world, Vector3i coordinate, CustomTemplateConnectedBlockRuleSet connectedBlockRuleset, BlockType blockType, rotation, Vector3i placementNormal, isPlacement) {
((!isPlacement || ! .onlyOnUpdate) && (isPlacement || ! .onlyOnPlacement)) {
connectedBlockRuleset.getShapeTemplateAsset();
(shapeTemplate == ) {
Optional.empty();
} {
();
(Rotation.None, Rotation.None, Rotation.None);
(Rotation.None, Rotation.None, Rotation.None);
List<Pair<Rotation, PatternRotationDefinition.MirrorAxis>> rotations = .patternRotationDefinition.getRotations();
label100:
( ; i < rotations.size(); ++i) {
Pair<Rotation, PatternRotationDefinition.MirrorAxis> patternTransform = (Pair)rotations.get(i);
totalRotation.assign(patternTransform.first(), Rotation.None, Rotation.None);
( .transformRulesToOrientation) {
RotationTuple.get(rotation);
tempRotation.assign(rotationTuple.yaw(), rotationTuple.pitch(), rotationTuple.roll());
totalRotation.add(tempRotation);
}
label97:
(ConnectedBlockPatternRule ruleToMatch : .rulesToMatch) {
coordinateToTest.assign(ruleToMatch.getRelativePosition());
((PatternRotationDefinition.MirrorAxis)patternTransform.second()) {
X -> coordinateToTest.setX(-coordinateToTest.getX());
Z -> coordinateToTest.setZ(-coordinateToTest.getZ());
}
(ruleToMatch.getPlacementNormals() != ) {
(ConnectedBlockPatternRule.AdjacentSide normal : ruleToMatch.getPlacementNormals()) {
(normal.relativePosition.equals(placementNormal)) {
label97;
}
}
Optional.empty();
} {
coordinateToTest = Rotation.rotate(coordinateToTest, totalRotation.rotationYaw, totalRotation.rotationPitch, totalRotation.rotationRoll);
coordinateToTest.add(coordinate);
world.getChunkIfLoaded(ChunkUtil.indexChunkFromBlock(coordinateToTest.x, coordinateToTest.z));
(chunkIfLoaded == ) {
Optional.empty();
}
chunkIfLoaded.getBlockType(coordinateToTest).getId();
chunkIfLoaded.getRotation(coordinateToTest.x, coordinateToTest.y, coordinateToTest.z);
tempRotation.assign(rotationToCheckUnrotated);
tempRotation.subtract(totalRotation);
chunkIfLoaded.getFiller(coordinateToTest.x, coordinateToTest.y, coordinateToTest.z);
fillerToCheckUnrotated = tempRotation.rotationPitch.subtract(rotationToCheckUnrotated.pitch()).rotateX(fillerToCheckUnrotated);
fillerToCheckUnrotated = tempRotation.rotationYaw.subtract(rotationToCheckUnrotated.yaw()).rotateY(fillerToCheckUnrotated);
fillerToCheckUnrotated = tempRotation.rotationRoll.subtract(rotationToCheckUnrotated.roll()).rotateY(fillerToCheckUnrotated);
rotationToCheckUnrotated = RotationTuple.of(tempRotation.rotationYaw, tempRotation.rotationPitch, tempRotation.rotationRoll);
(BlockType)BlockType.getAssetMap().getAsset(blockToCheckUnrotated);
(patternTransform.second() != PatternRotationDefinition.MirrorAxis.NONE) {
blockTypeToCheckUnrotated.getFlipType().flipYaw(rotationToCheckUnrotated.yaw(), patternTransform.second() == PatternRotationDefinition.MirrorAxis.X ? Axis.X : Axis.Z);
fillerToCheckUnrotated = newYawMirrored.subtract(rotationToCheckUnrotated.yaw()).rotateY(fillerToCheckUnrotated);
rotationToCheckUnrotated = RotationTuple.of(newYawMirrored, rotationToCheckUnrotated.pitch(), rotationToCheckUnrotated.roll());
}
checkPatternRuleAgainstBlockType(connectedBlockRuleset, shapeTemplate, blockType.getId(), ruleToMatch, blockToCheckUnrotated, rotationToCheckUnrotated, fillerToCheckUnrotated);
(!patternMatches) {
label100;
}
}
}
(BlockPattern)connectedBlockRuleset.getShapeNameToBlockPatternMap().get(shapeName);
(resultBlockPattern == ) {
Optional.empty();
}
random.setSeed(BlockUtil.pack(coordinate));
BlockPattern. resultBlockPattern.nextBlockTypeKey(random);
(resultBlockTypeKey == ) {
Optional.empty();
}
(BlockType)BlockType.getAssetMap().getAsset(resultBlockTypeKey.blockTypeKey());
(baseBlockTypeForFlip == ) {
Optional.empty();
}
baseBlockTypeForFlip.getFlipType();
RotationTuple.get(resultBlockTypeKey.rotation());
resultRotation = RotationTuple.of(resultRotation.yaw().add( .yawToApplyAddReplacedBlockType), resultRotation.pitch(), resultRotation.roll());
(patternTransform.second() != PatternRotationDefinition.MirrorAxis.NONE) {
flipType.flipYaw(resultRotation.yaw(), patternTransform.second() == PatternRotationDefinition.MirrorAxis.X ? Axis.X : Axis.Z);
resultRotation = RotationTuple.of(newYawMirrored, resultRotation.pitch(), resultRotation.roll());
}
resultRotation = RotationTuple.of(resultRotation.yaw().add(totalRotation.rotationYaw), resultRotation.pitch().add(totalRotation.rotationPitch), resultRotation.roll().add(totalRotation.rotationRoll));
(resultRotation.pitch().equals(Rotation.OneEighty) && flipType.equals(BlockFlipType.ORTHOGONAL)) {
resultRotation = RotationTuple.of(resultRotation.yaw().subtract(Rotation.Ninety), resultRotation.pitch(), resultRotation.roll());
}
Optional.of( .ConnectedBlockResult(resultBlockTypeKey.blockTypeKey(), resultRotation.index()));
}
Optional.empty();
}
} {
Optional.empty();
}
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(CustomConnectedBlockPattern.class, CustomConnectedBlockPattern:: ).append( ( , Codec.BOOLEAN, ), (o, transformRulesToPlacedOrientation) -> o.transformRulesToOrientation = transformRulesToPlacedOrientation, (o) -> o.transformRulesToOrientation).documentation( ).add()).append( ( , Rotation.CODEC, ), (o, yawToApplyAddReplacedBlockType) -> o.yawToApplyAddReplacedBlockType = yawToApplyAddReplacedBlockType, (o) -> o.yawToApplyAddReplacedBlockType).documentation( ).add()).append( ( , Codec.BOOLEAN, ), (o, requireFaceTagsMatchingRoll) -> o.requireFaceTagsMatchingRoll = requireFaceTagsMatchingRoll, (o) -> o.requireFaceTagsMatchingRoll).documentation( ).add()).append( ( , PatternRotationDefinition.CODEC, ), (o, patternRotations) -> o.patternRotationDefinition = patternRotations, (o) -> o.patternRotationDefinition).documentation( ).add()).append( ( , (ConnectedBlockPatternRule.CODEC, (x$ ) -> [x$ ]), ), (o, matchingPatterns) -> o.rulesToMatch = matchingPatterns, (o) -> o.rulesToMatch).documentation( ).add()).append( ( , (), ), (o, onlyOnPlacement) -> o.onlyOnPlacement = onlyOnPlacement, (o) -> o.onlyOnPlacement).documentation( ).add()).append( ( , (), ), (o, onlyOnUpdate) -> o.onlyOnUpdate = onlyOnUpdate, (o) -> o.onlyOnUpdate).documentation( ).add()).build();
random = ();
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomConnectedBlockTemplateAsset.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.assetstore.AssetExtraInfo;
import com.hypixel.hytale.assetstore.AssetKeyValidator;
import com.hypixel.hytale.assetstore.AssetRegistry;
import com.hypixel.hytale.assetstore.AssetStore;
import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec;
import com.hypixel.hytale.assetstore.map.DefaultAssetMap;
import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.codecs.map.MapCodec;
import com.hypixel.hytale.codec.validation.ValidatorCache;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.prefab.selection.mask.BlockPattern;
import com.hypixel.hytale.server.core.universe.world.World;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nonnull;
public class CustomConnectedBlockTemplateAsset implements JsonAssetWithMap <String, DefaultAssetMap<String, CustomConnectedBlockTemplateAsset>> {
public static final AssetBuilderCodec<String, CustomConnectedBlockTemplateAsset> CODEC;
public static final ValidatorCache<String> VALIDATOR_CACHE;
private static AssetStore<String, CustomConnectedBlockTemplateAsset, DefaultAssetMap<String, CustomConnectedBlockTemplateAsset>> ASSET_STORE;
String id;
AssetExtraInfo.Data data;
;
dontUpdateAfterInitialPlacement;
String defaultShapeName;
Map<String, ConnectedBlockShape> connectedBlockShapes;
{
}
AssetStore<String, CustomConnectedBlockTemplateAsset, DefaultAssetMap<String, CustomConnectedBlockTemplateAsset>> {
(ASSET_STORE == ) {
ASSET_STORE = AssetRegistry.<String, CustomConnectedBlockTemplateAsset, DefaultAssetMap<String, CustomConnectedBlockTemplateAsset>>getAssetStore(CustomConnectedBlockTemplateAsset.class);
}
ASSET_STORE;
}
DefaultAssetMap<String, CustomConnectedBlockTemplateAsset> {
(DefaultAssetMap)getAssetStore().getAssetMap();
}
Optional<ConnectedBlocksUtil.ConnectedBlockResult> getConnectedBlockType(World world, Vector3i coordinate, CustomTemplateConnectedBlockRuleSet ruleSet, BlockType blockType, rotation, Vector3i placementNormal, useDefaultShapeIfNoMatch, isPlacement) {
(Map.Entry<String, ConnectedBlockShape> entry : .connectedBlockShapes.entrySet()) {
(ConnectedBlockShape)entry.getValue();
(connectedBlockShape != ) {
CustomTemplateConnectedBlockPattern[] patterns = connectedBlockShape.getPatternsToMatchAnyOf();
(patterns != ) {
(CustomTemplateConnectedBlockPattern connectedBlockPattern : patterns) {
Optional<ConnectedBlocksUtil.ConnectedBlockResult> blockRotationIfMatchedOptional = connectedBlockPattern.getConnectedBlockTypeKey((String)entry.getKey(), world, coordinate, ruleSet, blockType, rotation, placementNormal, isPlacement);
(!blockRotationIfMatchedOptional.isEmpty()) {
blockRotationIfMatchedOptional;
}
}
}
}
}
(useDefaultShapeIfNoMatch) {
(BlockPattern)ruleSet.getShapeNameToBlockPatternMap().get( .defaultShapeName);
(defaultShapeBlockPattern == ) {
Optional.empty();
} {
BlockPattern. defaultShapeBlockPattern.nextBlockTypeKey(ThreadLocalRandom.current());
Optional.of( .ConnectedBlockResult(defaultBlock.blockTypeKey(), rotation));
}
} {
Optional.empty();
}
}
{
.dontUpdateAfterInitialPlacement;
}
String {
.id;
}
{
CODEC = ((AssetBuilderCodec.Builder)((AssetBuilderCodec.Builder)((AssetBuilderCodec.Builder)((AssetBuilderCodec.Builder)AssetBuilderCodec.builder(CustomConnectedBlockTemplateAsset.class, CustomConnectedBlockTemplateAsset:: , Codec.STRING, (builder, id) -> builder.id = id, (builder) -> builder.id, (builder, data) -> builder.data = data, (builder) -> builder.data).append( ( , Codec.BOOLEAN, ), (o, dontUpdateAfterInitialPlacement) -> o.dontUpdateAfterInitialPlacement = dontUpdateAfterInitialPlacement, (o) -> o.dontUpdateAfterInitialPlacement).documentation( ).add()).append( ( , Codec.BOOLEAN, ), (o, connectsToOtherMaterials) -> o.connectsToOtherMaterials = connectsToOtherMaterials, (o) -> o.connectsToOtherMaterials).documentation( ).add()).append( ( , Codec.STRING, ), (o, defaultShapeName) -> o.defaultShapeName = defaultShapeName, (o) -> o.defaultShapeName).add()).append( ( , (ConnectedBlockShape.CODEC, HashMap:: ), ), (o, connectedBlockShapes) -> o.connectedBlockShapes = connectedBlockShapes, (o) -> o.connectedBlockShapes).add()).build();
VALIDATOR_CACHE = <String>( (CustomConnectedBlockTemplateAsset::getAssetStore));
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomTemplateConnectedBlockPattern.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.codec.lookup.CodecMapCodec;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.universe.world.World;
import java.util.Optional;
import javax.annotation.Nonnull;
public abstract class CustomTemplateConnectedBlockPattern {
public static final CodecMapCodec<CustomTemplateConnectedBlockPattern> CODEC = new CodecMapCodec <CustomTemplateConnectedBlockPattern>("Type" );
public CustomTemplateConnectedBlockPattern () {
}
public abstract Optional<ConnectedBlocksUtil.ConnectedBlockResult> getConnectedBlockTypeKey(String var1, @Nonnull World var2, @Nonnull Vector3i var3, @Nonnull CustomTemplateConnectedBlockRuleSet var4, @Nonnull BlockType var5, int var6, @Nonnull Vector3i var7, boolean var8);
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/CustomTemplateConnectedBlockRuleSet.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.map.MapCodec;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.prefab.selection.mask.BlockPattern;
import com.hypixel.hytale.server.core.universe.world.World;
import it.unimi.dsi.fastutil.ints.Int2ObjectFunction;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nullable;
public class CustomTemplateConnectedBlockRuleSet extends ConnectedBlockRuleSet {
public static final BuilderCodec<CustomTemplateConnectedBlockRuleSet> CODEC;
private String shapeAssetId;
private Map<String, BlockPattern> shapeNameToBlockPatternMap = new Object2ObjectOpenHashMap <String, BlockPattern>();
private final Int2ObjectMap<Set<String>> shapesPerBlockType = <Set<String>>();
{
}
Map<String, BlockPattern> {
.shapeNameToBlockPatternMap;
}
{
.updateCachedBlockTypes(blockType, assetMap);
(Map.Entry<String, BlockPattern> entry : .shapeNameToBlockPatternMap.entrySet()) {
(String)entry.getKey();
(BlockPattern)entry.getValue();
Integer[] var7 = blockPattern.getResolvedKeys();
var7.length;
( ; var9 < var8; ++var9) {
var7[var9];
Set<String> shapes = (Set) .shapesPerBlockType.computeIfAbsent(resolvedKey, (Int2ObjectFunction)((k) -> ()));
shapes.add(name);
}
}
}
Set<String> {
.shapesPerBlockType.getOrDefault(blockTypeKey, Set.of());
}
CustomConnectedBlockTemplateAsset {
(CustomConnectedBlockTemplateAsset)CustomConnectedBlockTemplateAsset.getAssetMap().getAsset( .shapeAssetId);
}
{
.getShapeTemplateAsset();
templateAsset != && templateAsset.isDontUpdateAfterInitialPlacement();
}
Optional<ConnectedBlocksUtil.ConnectedBlockResult> getConnectedBlockType(World world, Vector3i testedCoordinate, BlockType blockType, rotation, Vector3i placementNormal, isPlacement) {
.getShapeTemplateAsset();
shapeTemplateAsset == ? Optional.empty() : shapeTemplateAsset.getConnectedBlockType(world, testedCoordinate, , blockType, rotation, placementNormal, , isPlacement);
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(CustomTemplateConnectedBlockRuleSet.class, CustomTemplateConnectedBlockRuleSet:: ).append( ( , Codec.STRING), (ruleSet, shapeAssetId) -> ruleSet.shapeAssetId = shapeAssetId, (ruleSet) -> ruleSet.shapeAssetId).addValidator(CustomConnectedBlockTemplateAsset.VALIDATOR_CACHE.getValidator()).documentation( ).add()).append( ( , (BlockPattern.CODEC, HashMap:: ), ), (material, shapeNameToBlockPatternMap) -> material.shapeNameToBlockPatternMap = shapeNameToBlockPatternMap, (material) -> material.shapeNameToBlockPatternMap).documentation( ).add()).build();
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/PatternRotationDefinition.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import it.unimi.dsi.fastutil.Pair;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
public class PatternRotationDefinition {
public static final BuilderCodec<PatternRotationDefinition> CODEC;
@Nonnull
public static PatternRotationDefinition DEFAULT;
private boolean isCardinallyRotatable;
private boolean isMirrorZ;
private boolean isMirrorX;
public static final List<Pair<Rotation, MirrorAxis>> ROTATIONS;
public PatternRotationDefinition () {
}
@Nonnull
public List<Pair<Rotation, MirrorAxis>> getRotations () {
return new AbstractList <Pair<Rotation, MirrorAxis>>() {
[] enabledIndexes = .computeEnabled();
[] computeEnabled() {
();
idx.add( );
(PatternRotationDefinition. .isCardinallyRotatable) {
idx.addAll(IntList.of( , , ));
}
(PatternRotationDefinition. .isMirrorX) {
idx.add( );
(PatternRotationDefinition. .isCardinallyRotatable) {
idx.addAll(IntList.of( , , ));
}
}
(PatternRotationDefinition. .isMirrorZ) {
idx.add( );
(PatternRotationDefinition. .isCardinallyRotatable) {
idx.addAll(IntList.of( , , ));
}
}
idx.toIntArray();
}
Pair<Rotation, MirrorAxis> {
(Pair)PatternRotationDefinition.ROTATIONS.get( .enabledIndexes[i]);
}
{
.enabledIndexes.length;
}
};
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(PatternRotationDefinition.class, PatternRotationDefinition:: ).append( ( , Codec.BOOLEAN, ), (o, isCardinallyRotatable) -> o.isCardinallyRotatable = isCardinallyRotatable, (o) -> o.isCardinallyRotatable).add()).append( ( , Codec.BOOLEAN, ), (o, isMirrorZ) -> o.isMirrorZ = isMirrorZ, (o) -> o.isMirrorZ).add()).append( ( , Codec.BOOLEAN, ), (o, isMirrorX) -> o.isMirrorX = isMirrorX, (o) -> o.isMirrorX).add()).build();
DEFAULT = ();
ROTATIONS = ();
(MirrorAxis mirrorAxis : PatternRotationDefinition.MirrorAxis.values()) {
(Rotation value : Rotation.VALUES) {
ROTATIONS.add(Pair.of(value, mirrorAxis));
}
}
}
{
NONE,
X,
Z;
{
}
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/Rotation3D.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import javax.annotation.Nonnull;
@Deprecated(
forRemoval = true
)
public class Rotation3D {
public Rotation rotationYaw;
public Rotation rotationPitch;
public Rotation rotationRoll;
public Rotation3D (Rotation rotationYaw, Rotation rotationPitch, Rotation rotationRoll) {
this .rotationYaw = rotationYaw;
this .rotationPitch = rotationPitch;
this .rotationRoll = rotationRoll;
}
public void assign (Rotation yaw, Rotation pitch, Rotation roll) {
this .rotationYaw = yaw;
this .rotationPitch = pitch;
this .rotationRoll = roll;
}
public void assign (@Nonnull RotationTuple rotation) {
this .assign(rotation.yaw(), rotation.pitch(), rotation.roll());
}
public void add (@Nonnull Rotation3D toAdd) {
this .rotationYaw = .rotationYaw.add(toAdd.rotationYaw);
.rotationPitch = .rotationPitch.add(toAdd.rotationPitch);
.rotationRoll = .rotationRoll.add(toAdd.rotationRoll);
}
{
.rotationYaw = .rotationYaw.subtract(toSubtract.rotationYaw);
.rotationPitch = .rotationPitch.subtract(toSubtract.rotationPitch);
.rotationRoll = .rotationRoll.subtract(toSubtract.rotationRoll);
}
{
.assign(Rotation.None.subtract( .rotationYaw), Rotation.None.subtract( .rotationPitch), Rotation.None.subtract( .rotationRoll));
}
Rotation3D {
(( ) .rotationPitch.getDegrees(), ( ) .rotationYaw.getDegrees(), ( ) .rotationRoll.getDegrees());
vector3f = Rotation.rotate(vector3f, rotationYawToRotate, rotationPitchToRotate, rotationRollToRotate);
.assign(Rotation.closestOfDegrees(vector3f.y), Rotation.closestOfDegrees(vector3f.x), Rotation.closestOfDegrees(vector3f.z));
;
}
{
.rotateSelfBy(rotation.rotationYaw, rotation.rotationPitch, rotation.rotationRoll);
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/ConnectedBlockOutput.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks.builtin;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
public class ConnectedBlockOutput {
public static final BuilderCodec<ConnectedBlockOutput> CODEC;
protected String state;
protected String blockTypeKey;
protected ConnectedBlockOutput () {
}
public int resolve (BlockType baseBlockType, BlockTypeAssetMap<String, BlockType> assetMap) {
String blockTypeKey = this .blockTypeKey;
if (blockTypeKey == null ) {
blockTypeKey = baseBlockType.getId();
}
BlockType blockType = (BlockType)assetMap.getAsset(blockTypeKey);
if (blockType == null ) {
return -1 ;
} else {
if (this .state != null ) {
String baseKey = blockType.getDefaultStateKey();
baseKey == ? blockType : (BlockType)BlockType.getAssetMap().getAsset(baseKey);
( .equals( .state)) {
blockTypeKey = baseBlock.getId();
} {
blockTypeKey = baseBlock.getBlockKeyForState( .state);
}
(blockTypeKey == ) {
- ;
}
}
assetMap.getIndex(blockTypeKey);
(index == - ) {
- ;
} {
.blockTypeKey = blockTypeKey;
index;
}
}
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ConnectedBlockOutput.class, ConnectedBlockOutput:: ).append( ( , Codec.STRING), (output, state) -> output.state = state, (output) -> output.state).documentation( ).add()).append( ( , Codec.STRING), (output, blockTypeKey) -> output.blockTypeKey = blockTypeKey, (output) -> output.blockTypeKey).documentation( ).add()).build();
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/RoofConnectedBlockRuleSet.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks.builtin;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.simple.IntegerCodec;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.ConnectedBlockRuleSetType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockFace;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockFaceSupport;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.connectedblocks.ConnectedBlockRuleSet;
import com.hypixel.hytale.server.core.universe.world.connectedblocks.ConnectedBlocksUtil;
import com.hypixel.hytale.server.core.util.FillerBlockUtil;
import it.unimi.dsi.fastutil.objects.ObjectIntPair;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
public class RoofConnectedBlockRuleSet extends ConnectedBlockRuleSet implements {
BuilderCodec<RoofConnectedBlockRuleSet> CODEC;
StairConnectedBlockRuleSet regular;
StairConnectedBlockRuleSet hollow;
ConnectedBlockOutput topper;
String materialName;
;
{
}
StairConnectedBlockRuleSet.StairType {
RotationTuple.get(rotation);
currentRotation.yaw();
currentRotation.pitch();
currentPitch != Rotation.None;
(upsideDown) {
currentYaw = currentYaw.flip();
}
();
StairConnectedBlockRuleSet. StairConnectedBlockRuleSet.StairType.STRAIGHT;
StairConnectedBlockRuleSet. StairConnectedBlockRuleSet.getInvertedCornerConnection(world, currentRuleSet, coordinate, mutablePos, currentYaw, upsideDown);
(frontConnection != ) {
isWidthFulfilled(world, coordinate, mutablePos, frontConnection, currentYaw, blockId, rotation, width);
(valid) {
resultingStair = frontConnection.getStairType( );
}
}
StairConnectedBlockRuleSet. StairConnectedBlockRuleSet.getCornerConnection(world, currentRuleSet, coordinate, mutablePos, rotation, currentYaw, upsideDown, width);
(backConnection != ) {
isWidthFulfilled(world, coordinate, mutablePos, backConnection, currentYaw, blockId, rotation, width);
(valid) {
resultingStair = backConnection.getStairType( );
}
}
(resultingStair == StairConnectedBlockRuleSet.StairType.STRAIGHT) {
( (coordinate)).add( , , );
StairConnectedBlockRuleSet. getValleyConnection(world, coordinate, aboveCoordinate, currentRuleSet, currentRotation, mutablePos, , blockId, rotation, width);
(resultingConnection != ) {
resultingStair = resultingConnection.getStairType( );
}
}
(resultingStair == StairConnectedBlockRuleSet.StairType.STRAIGHT) {
( (coordinate)).add( , - , );
StairConnectedBlockRuleSet. getValleyConnection(world, coordinate, belowCoordinate, currentRuleSet, currentRotation, mutablePos, , blockId, rotation, width);
(resultingConnection != ) {
resultingStair = resultingConnection.getStairType( );
}
}
(upsideDown) {
StairConnectedBlockRuleSet.StairType var10000;
(resultingStair) {
CORNER_LEFT -> var10000 = StairConnectedBlockRuleSet.StairType.CORNER_RIGHT;
CORNER_RIGHT -> var10000 = StairConnectedBlockRuleSet.StairType.CORNER_LEFT;
INVERTED_CORNER_LEFT -> var10000 = StairConnectedBlockRuleSet.StairType.INVERTED_CORNER_RIGHT;
INVERTED_CORNER_RIGHT -> var10000 = StairConnectedBlockRuleSet.StairType.INVERTED_CORNER_LEFT;
-> var10000 = resultingStair;
}
resultingStair = var10000;
}
resultingStair;
}
{
;
( ; i < width - ; ++i) {
mutablePos.assign(backConnection == StairConnectedBlockRuleSet.StairConnection.CORNER_LEFT ? Vector3i.WEST : Vector3i.EAST).scale(i + );
currentYaw.rotateY(mutablePos, mutablePos);
FillerBlockUtil.pack(mutablePos.x, mutablePos.y, mutablePos.z);
mutablePos.add(coordinate.x, coordinate.y, coordinate.z);
world.getChunkIfLoaded(ChunkUtil.indexChunkFromBlock(mutablePos.x, mutablePos.z));
(chunk != ) {
chunk.getRotationIndex(mutablePos.x, mutablePos.y, mutablePos.z);
chunk.getFiller(mutablePos.x, mutablePos.y, mutablePos.z);
chunk.getBlock(mutablePos);
((otherFiller != || otherBlockId != blockId || otherRotation != rotation) && (otherFiller != requiredFiller || otherBlockId != blockId || otherRotation != rotation)) {
valid = ;
;
}
}
}
valid;
}
StairConnectedBlockRuleSet.StairConnection {
rotation.yaw();
mutablePos.assign(reverse ? Vector3i.SOUTH : Vector3i.NORTH).scale(width);
yaw.rotateY(mutablePos, mutablePos);
mutablePos.add(checkCoordinate.x, checkCoordinate.y, checkCoordinate.z);
ObjectIntPair<StairConnectedBlockRuleSet.StairType> backStair = StairConnectedBlockRuleSet.getStairData(world, mutablePos, currentRuleSet.getMaterialName());
(backStair == ) {
;
} {
reverse ? isTopperConnectionCompatible(rotation, backStair, Rotation.None) : isValleyConnectionCompatible(rotation, backStair, Rotation.None, );
(!backConnection) {
;
} {
mutablePos.assign(reverse ? Vector3i.EAST : Vector3i.WEST).scale(width);
yaw.rotateY(mutablePos, mutablePos);
mutablePos.add(checkCoordinate.x, checkCoordinate.y, checkCoordinate.z);
ObjectIntPair<StairConnectedBlockRuleSet.StairType> leftStair = StairConnectedBlockRuleSet.getStairData(world, mutablePos, currentRuleSet.getMaterialName());
mutablePos.assign(reverse ? Vector3i.WEST : Vector3i.EAST).scale(width);
yaw.rotateY(mutablePos, mutablePos);
mutablePos.add(checkCoordinate.x, checkCoordinate.y, checkCoordinate.z);
ObjectIntPair<StairConnectedBlockRuleSet.StairType> rightStair = StairConnectedBlockRuleSet.getStairData(world, mutablePos, currentRuleSet.getMaterialName());
reverse ? isTopperConnectionCompatible(rotation, leftStair, Rotation.Ninety) : isValleyConnectionCompatible(rotation, leftStair, Rotation.Ninety, );
reverse ? isTopperConnectionCompatible(rotation, rightStair, Rotation.TwoSeventy) : isValleyConnectionCompatible(rotation, rightStair, Rotation.TwoSeventy, );
(leftConnection == rightConnection) {
;
} {
StairConnectedBlockRuleSet. leftConnection ? StairConnectedBlockRuleSet.StairConnection.CORNER_LEFT : StairConnectedBlockRuleSet.StairConnection.CORNER_RIGHT;
!isWidthFulfilled(world, placementCoordinate, mutablePos, connection, yaw, blockId, blockRotation, width) ? : connection;
}
}
}
}
{
isValleyConnectionCompatible(rotation, otherStair, yawOffset, );
}
{
rotation.yaw();
Vector3i[] directions = []{Vector3i.NORTH, Vector3i.SOUTH, Vector3i.EAST, Vector3i.WEST};
Rotation[] yawOffsets = []{Rotation.OneEighty, Rotation.None, Rotation.Ninety, Rotation.TwoSeventy};
( ; i < directions.length; ++i) {
mutablePos.assign(directions[i]);
yaw.rotateY(mutablePos, mutablePos);
mutablePos.add(coordinate.x, coordinate.y, coordinate.z);
ObjectIntPair<StairConnectedBlockRuleSet.StairType> stair = StairConnectedBlockRuleSet.getStairData(world, mutablePos, currentRuleSet.getMaterialName());
(stair == || !isTopperConnectionCompatible(rotation, stair, yawOffsets[i])) {
;
}
}
;
}
{
rotation.yaw().add(yawOffset);
(otherStair == ) {
;
} {
RotationTuple.get(otherStair.rightInt());
StairConnectedBlockRuleSet. (StairConnectedBlockRuleSet.StairType)otherStair.first();
(stairRotation.pitch() != rotation.pitch()) {
;
} (inverted && otherStairType.isCorner()) {
;
} (!inverted && otherStairType.isInvertedCorner()) {
;
} {
stairRotation.yaw() == targetYaw || otherStairType == StairConnectedBlockRuleSet.StairConnection.CORNER_RIGHT.getStairType(inverted) && stairRotation.yaw() == targetYaw.add(Rotation.Ninety) || otherStairType == StairConnectedBlockRuleSet.StairConnection.CORNER_LEFT.getStairType(inverted) && stairRotation.yaw() == targetYaw.add(Rotation.TwoSeventy);
}
}
}
{
;
}
Optional<ConnectedBlocksUtil.ConnectedBlockResult> getConnectedBlockType(World world, Vector3i coordinate, BlockType blockType, rotation, Vector3i placementNormal, isPlacement) {
world.getChunkIfLoaded(ChunkUtil.indexChunkFromBlock(coordinate.x, coordinate.z));
(chunk == ) {
Optional.empty();
} {
chunk.getBlock(coordinate.x, coordinate.y - , coordinate.z);
(BlockType)BlockType.getAssetMap().getAsset(belowBlockId);
chunk.getRotationIndex(coordinate.x, coordinate.y - , coordinate.z);
;
(belowBlockType != ) {
Map<BlockFace, BlockFaceSupport[]> supporting = belowBlockType.getSupporting(belowBlockRotation);
(supporting != ) {
BlockFaceSupport[] support = (BlockFaceSupport[])supporting.get(BlockFace.UP);
hollow = support == ;
}
}
BlockType.getAssetMap().getIndex(blockType.getId());
StairConnectedBlockRuleSet. getConnectedBlockStairType(world, coordinate, , blockId, rotation, .width);
( .topper != && stairType == StairConnectedBlockRuleSet.StairType.STRAIGHT) {
( (coordinate)).add( , - , );
RotationTuple.get(rotation);
currentRotation = RotationTuple.of(Rotation.None, currentRotation.pitch(), currentRotation.roll());
();
canBeTopper(world, belowCoordinate, , currentRotation, mutablePos);
(topper) {
(BlockType)BlockType.getAssetMap().getAsset( .topper.blockTypeKey);
(topperBlockType != ) {
Optional.of( .ConnectedBlockResult(topperBlockType.getId(), rotation));
}
}
}
( .hollow != && hollow) {
.hollow.getStairBlockType(stairType);
(hollowBlockType != ) {
Optional.of( .ConnectedBlockResult(hollowBlockType.getId(), rotation));
}
}
.regular.getStairBlockType(stairType);
(regularBlockType != ) {
ConnectedBlocksUtil. .ConnectedBlockResult(regularBlockType.getId(), rotation);
( .regular != && .width > ) {
StairConnectedBlockRuleSet. .regular.getStairType(BlockType.getAssetMap().getIndex(blockType.getId()));
(existingStairType != && existingStairType != StairConnectedBlockRuleSet.StairType.STRAIGHT) {
existingStairType.isLeft() ? -( .width - ) : (existingStairType.isRight() ? .width - : );
stairType.isLeft() ? -( .width - ) : (stairType.isRight() ? .width - : );
(newWidth != previousWidth) {
();
RotationTuple.get(rotation).yaw();
mutablePos.assign(Vector3i.EAST).scale(previousWidth);
currentYaw.rotateY(mutablePos, mutablePos);
result.addAdditionalBlock(mutablePos, regularBlockType.getId(), rotation);
}
}
}
Optional.of(result);
} {
Optional.empty();
}
}
}
{
( .regular != ) {
.regular.updateCachedBlockTypes(baseBlockType, assetMap);
}
( .hollow != ) {
.hollow.updateCachedBlockTypes(baseBlockType, assetMap);
}
( .topper != ) {
.topper.resolve(baseBlockType, assetMap);
}
}
StairConnectedBlockRuleSet.StairType {
StairConnectedBlockRuleSet. .regular.getStairType(blockId);
(regularStairType != ) {
regularStairType;
} {
.hollow != ? .hollow.getStairType(blockId) : ;
}
}
String {
.materialName;
}
com.hypixel.hytale.protocol.ConnectedBlockRuleSet {
com.hypixel.hytale.protocol. .hypixel.hytale.protocol.ConnectedBlockRuleSet();
packet.type = ConnectedBlockRuleSetType.Roof;
com.hypixel.hytale.protocol. .hypixel.hytale.protocol.RoofConnectedBlockRuleSet();
( .regular != ) {
roofPacket.regular = .regular.toProtocol(assetMap);
}
( .hollow != ) {
roofPacket.hollow = .hollow.toProtocol(assetMap);
}
( .topper != ) {
roofPacket.topperBlockId = assetMap.getIndex( .topper.blockTypeKey);
} {
roofPacket.topperBlockId = - ;
}
roofPacket.width = .width;
roofPacket.materialName = .materialName;
packet.roof = roofPacket;
packet;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(RoofConnectedBlockRuleSet.class, RoofConnectedBlockRuleSet:: ).append( ( , StairConnectedBlockRuleSet.CODEC), (ruleSet, output) -> ruleSet.regular = output, (ruleSet) -> ruleSet.regular).addValidator(Validators.nonNull()).add()).append( ( , StairConnectedBlockRuleSet.CODEC), (ruleSet, output) -> ruleSet.hollow = output, (ruleSet) -> ruleSet.hollow).add()).append( ( , ConnectedBlockOutput.CODEC), (ruleSet, output) -> ruleSet.topper = output, (ruleSet) -> ruleSet.topper).add()).append( ( , ()), (ruleSet, output) -> ruleSet.width = output, (ruleSet) -> ruleSet.width).add()).append( ( , Codec.STRING), (ruleSet, materialName) -> ruleSet.materialName = materialName, (ruleSet) -> ruleSet.materialName).add()).build();
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/StairConnectedBlockRuleSet.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks.builtin;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.ConnectedBlockRuleSetType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.connectedblocks.ConnectedBlockRuleSet;
import com.hypixel.hytale.server.core.universe.world.connectedblocks.ConnectedBlocksUtil;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIntImmutablePair;
import it.unimi.dsi.fastutil.objects.ObjectIntPair;
import java.util.Optional;
import javax.annotation.Nullable;
public class StairConnectedBlockRuleSet extends ConnectedBlockRuleSet implements StairLikeConnectedBlockRuleSet {
;
BuilderCodec<StairConnectedBlockRuleSet> CODEC;
ConnectedBlockOutput straight;
ConnectedBlockOutput cornerLeft;
ConnectedBlockOutput cornerRight;
ConnectedBlockOutput invertedCornerLeft;
ConnectedBlockOutput invertedCornerRight;
;
Int2ObjectMap<StairType> blockIdToStairType;
Object2IntMap<StairType> stairTypeToBlockId;
{
}
{
;
}
{
assetMap.getIndex(baseBlockType.getId());
Int2ObjectMap<StairType> blockIdToStairType = <StairType>();
Object2IntMap<StairType> stairTypeToBlockId = <StairType>();
stairTypeToBlockId.defaultReturnValue(baseIndex);
ConnectedBlockOutput[] outputs = []{ .straight, .cornerLeft, .cornerRight, .invertedCornerLeft, .invertedCornerRight};
StairType[] stairTypes = StairConnectedBlockRuleSet.StairType.VALUES;
( ; i < outputs.length; ++i) {
outputs[i];
(output != ) {
output.resolve(baseBlockType, assetMap);
(index != - ) {
blockIdToStairType.put(index, stairTypes[i]);
stairTypeToBlockId.put(stairTypes[i], index);
}
}
}
.blockIdToStairType = blockIdToStairType;
.stairTypeToBlockId = stairTypeToBlockId;
}
ObjectIntPair<StairType> {
world.getChunkIfLoaded(ChunkUtil.indexChunkFromBlock(coordinate.x, coordinate.z));
(chunk == ) {
;
} {
chunk.getFiller(coordinate.x, coordinate.y, coordinate.z);
(filler != ) {
;
} {
chunk.getBlock(coordinate);
(BlockType)BlockType.getAssetMap().getAsset(blockId);
(blockType == ) {
;
} {
blockType.getConnectedBlockRuleSet();
(ruleSet StairLikeConnectedBlockRuleSet) {
(StairLikeConnectedBlockRuleSet)ruleSet;
stairRuleSet.getMaterialName();
(requiredMaterialName != && otherMaterialName != && !requiredMaterialName.equals(otherMaterialName)) {
;
} {
stairRuleSet.getStairType(blockId);
(stairType == ) {
;
} {
chunk.getRotationIndex(coordinate.x, coordinate.y, coordinate.z);
<StairType>(stairType, rotation);
}
}
} {
;
}
}
}
}
}
StairType {
(StairType) .blockIdToStairType.get(blockId);
}
String {
.materialName;
}
BlockType {
( .stairTypeToBlockId == ) {
;
} {
.stairTypeToBlockId.getInt(stairType);
(BlockType)BlockType.getAssetMap().getAsset(resultingBlockTypeIndex);
}
}
Optional<ConnectedBlocksUtil.ConnectedBlockResult> getConnectedBlockType(World world, Vector3i coordinate, BlockType currentBlockType, rotation, Vector3i placementNormal, isPlacement) {
RotationTuple.get(rotation);
currentRotation.yaw();
currentRotation.pitch();
currentPitch != Rotation.None;
(upsideDown) {
currentYaw = currentYaw.flip();
}
();
StairConnectedBlockRuleSet.StairType.STRAIGHT;
getInvertedCornerConnection(world, , coordinate, mutablePos, currentYaw, upsideDown);
(frontConnection != ) {
resultingStair = frontConnection.getStairType( );
}
getCornerConnection(world, , coordinate, mutablePos, rotation, currentYaw, upsideDown, );
(backConnection != ) {
resultingStair = backConnection.getStairType( );
}
(upsideDown) {
StairType var10000;
(resultingStair.ordinal()) {
-> var10000 = StairConnectedBlockRuleSet.StairType.CORNER_RIGHT;
-> var10000 = StairConnectedBlockRuleSet.StairType.CORNER_LEFT;
-> var10000 = StairConnectedBlockRuleSet.StairType.INVERTED_CORNER_RIGHT;
-> var10000 = StairConnectedBlockRuleSet.StairType.INVERTED_CORNER_LEFT;
-> var10000 = resultingStair;
}
resultingStair = var10000;
}
.stairTypeToBlockId.getInt(resultingStair);
(BlockType)BlockType.getAssetMap().getAsset(resultingBlockTypeIndex);
(resultingBlockType == ) {
Optional.empty();
} {
resultingBlockType.getId();
Optional.of( .ConnectedBlockResult(resultingBlockTypeKey, rotation));
}
}
StairConnection {
;
mutablePos.assign(Vector3i.NORTH).scale(width);
currentYaw.rotateY(mutablePos, mutablePos);
mutablePos.add(coordinate.x, coordinate.y, coordinate.z);
ObjectIntPair<StairType> backStair = getStairData(world, mutablePos, currentRuleSet.getMaterialName());
(backStair == && width > ) {
mutablePos.assign(Vector3i.NORTH).scale(width + );
currentYaw.rotateY(mutablePos, mutablePos);
mutablePos.add(coordinate.x, coordinate.y, coordinate.z);
backStair = getStairData(world, mutablePos, currentRuleSet.getMaterialName());
(backStair != && backStair.first() == StairConnectedBlockRuleSet.StairType.STRAIGHT) {
backStair = ;
}
}
(backStair != ) {
(StairType)backStair.left();
RotationTuple.get(backStair.rightInt());
otherStairRotation.yaw();
otherStairRotation.pitch() != Rotation.None;
(otherUpsideDown) {
otherYaw = otherYaw.flip();
}
(canConnectTo(currentYaw, otherYaw, upsideDown, otherUpsideDown)) {
mutablePos.assign(Vector3i.SOUTH);
otherYaw.rotateY(mutablePos, mutablePos);
mutablePos.add(coordinate.x, coordinate.y, coordinate.z);
ObjectIntPair<StairType> sidewaysStair = getStairData(world, mutablePos, currentRuleSet.getMaterialName());
(sidewaysStair == || sidewaysStair.rightInt() != rotation) {
backConnection = getConnection(currentYaw, otherYaw, otherStairType, );
}
}
}
backConnection;
}
StairConnection {
;
mutablePos.assign(Vector3i.SOUTH);
currentYaw.rotateY(mutablePos, mutablePos);
mutablePos.add(coordinate.x, coordinate.y, coordinate.z);
ObjectIntPair<StairType> frontStair = getStairData(world, mutablePos, currentRuleSet.getMaterialName());
(frontStair != ) {
(StairType)frontStair.left();
RotationTuple.get(frontStair.rightInt());
otherStairRotation.yaw();
otherStairRotation.pitch() != Rotation.None;
(otherUpsideDown) {
otherYaw = otherYaw.flip();
}
(canConnectTo(currentYaw, otherYaw, upsideDown, otherUpsideDown)) {
frontConnection = getConnection(currentYaw, otherYaw, otherStairType, );
}
}
frontConnection;
}
{
otherUpsideDown == upsideDown && otherYaw != currentYaw && otherYaw.add(Rotation.OneEighty) != currentYaw;
}
StairConnection {
(otherYaw == currentYaw.add(Rotation.Ninety) && otherStairType != StairConnectedBlockRuleSet.StairType.invertedCorner(inverted) && otherStairType != StairConnectedBlockRuleSet.StairType.corner(!inverted)) {
StairConnectedBlockRuleSet.StairConnection.CORNER_LEFT;
} {
otherYaw == currentYaw.subtract(Rotation.Ninety) && otherStairType != StairConnectedBlockRuleSet.StairType.invertedCorner(!inverted) && otherStairType != StairConnectedBlockRuleSet.StairType.corner(inverted) ? StairConnectedBlockRuleSet.StairConnection.CORNER_RIGHT : ;
}
}
com.hypixel.hytale.protocol.ConnectedBlockRuleSet {
com.hypixel.hytale.protocol. .hypixel.hytale.protocol.ConnectedBlockRuleSet();
packet.type = ConnectedBlockRuleSetType.Stair;
packet.stair = .toProtocol(assetMap);
packet;
}
com.hypixel.hytale.protocol.StairConnectedBlockRuleSet {
com.hypixel.hytale.protocol. .hypixel.hytale.protocol.StairConnectedBlockRuleSet();
stairPacket.straightBlockId = .getBlockIdForStairType(StairConnectedBlockRuleSet.StairType.STRAIGHT, assetMap);
stairPacket.cornerLeftBlockId = .getBlockIdForStairType(StairConnectedBlockRuleSet.StairType.CORNER_LEFT, assetMap);
stairPacket.cornerRightBlockId = .getBlockIdForStairType(StairConnectedBlockRuleSet.StairType.CORNER_RIGHT, assetMap);
stairPacket.invertedCornerLeftBlockId = .getBlockIdForStairType(StairConnectedBlockRuleSet.StairType.INVERTED_CORNER_LEFT, assetMap);
stairPacket.invertedCornerRightBlockId = .getBlockIdForStairType(StairConnectedBlockRuleSet.StairType.INVERTED_CORNER_RIGHT, assetMap);
stairPacket.materialName = .materialName;
stairPacket;
}
{
.getStairBlockType(stairType);
blockType == ? - : assetMap.getIndex(blockType.getId());
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(StairConnectedBlockRuleSet.class, StairConnectedBlockRuleSet:: ).append( ( , ConnectedBlockOutput.CODEC), (ruleSet, output) -> ruleSet.straight = output, (ruleSet) -> ruleSet.straight).addValidator(Validators.nonNull()).add()).append( ( , ConnectedBlockOutput.CODEC), (ruleSet, output) -> ruleSet.cornerLeft = output, (ruleSet) -> ruleSet.cornerLeft).addValidator(Validators.nonNull()).add()).append( ( , ConnectedBlockOutput.CODEC), (ruleSet, output) -> ruleSet.cornerRight = output, (ruleSet) -> ruleSet.cornerRight).addValidator(Validators.nonNull()).add()).append( ( , ConnectedBlockOutput.CODEC), (ruleSet, output) -> ruleSet.invertedCornerLeft = output, (ruleSet) -> ruleSet.invertedCornerLeft).add()).append( ( , ConnectedBlockOutput.CODEC), (ruleSet, output) -> ruleSet.invertedCornerRight = output, (ruleSet) -> ruleSet.invertedCornerRight).add()).append( ( , Codec.STRING), (ruleSet, materialName) -> ruleSet.materialName = materialName, (ruleSet) -> ruleSet.materialName).add()).build();
}
{
CORNER_LEFT,
CORNER_RIGHT;
{
}
StairType {
StairType var10000;
( .ordinal()) {
-> var10000 = inverted ? StairConnectedBlockRuleSet.StairType.INVERTED_CORNER_LEFT : StairConnectedBlockRuleSet.StairType.CORNER_LEFT;
-> var10000 = inverted ? StairConnectedBlockRuleSet.StairType.INVERTED_CORNER_RIGHT : StairConnectedBlockRuleSet.StairType.CORNER_RIGHT;
-> ((String) , (Throwable) );
}
var10000;
}
}
{
STRAIGHT,
CORNER_LEFT,
CORNER_RIGHT,
INVERTED_CORNER_LEFT,
INVERTED_CORNER_RIGHT;
StairType[] VALUES = values();
{
}
StairType {
right ? CORNER_RIGHT : CORNER_LEFT;
}
StairType {
right ? INVERTED_CORNER_RIGHT : INVERTED_CORNER_LEFT;
}
{
== CORNER_LEFT || == CORNER_RIGHT;
}
{
== INVERTED_CORNER_LEFT || == INVERTED_CORNER_RIGHT;
}
{
== CORNER_LEFT || == INVERTED_CORNER_LEFT;
}
{
== CORNER_RIGHT || == INVERTED_CORNER_RIGHT;
}
}
}
com/hypixel/hytale/server/core/universe/world/connectedblocks/builtin/StairLikeConnectedBlockRuleSet.java
package com.hypixel.hytale.server.core.universe.world.connectedblocks.builtin;
import javax.annotation.Nullable;
public interface StairLikeConnectedBlockRuleSet {
StairConnectedBlockRuleSet.StairType getStairType (int var1) ;
@Nullable
String getMaterialName () ;
}
com/hypixel/hytale/server/core/universe/world/events/AddWorldEvent.java
package com.hypixel.hytale.server.core.universe.world.events;
import com.hypixel.hytale.event.ICancellable;
import com.hypixel.hytale.server.core.universe.world.World;
import javax.annotation.Nonnull;
public class AddWorldEvent extends WorldEvent implements ICancellable {
private boolean cancelled = false ;
public AddWorldEvent (@Nonnull World world) {
super (world);
}
@Nonnull
public String toString () {
boolean var10000 = this .cancelled;
return "AddWorldEvent{cancelled=" + var10000 + "} " + super .toString();
}
public boolean isCancelled () {
return this .cancelled;
}
public void setCancelled (boolean cancelled) {
this .cancelled = cancelled;
}
}
com/hypixel/hytale/server/core/universe/world/events/AllWorldsLoadedEvent.java
package com.hypixel.hytale.server.core.universe.world.events;
import com.hypixel.hytale.event.IEvent;
import javax.annotation.Nonnull;
public class AllWorldsLoadedEvent implements IEvent <Void> {
public AllWorldsLoadedEvent () {
}
@Nonnull
public String toString () {
return "AllWorldsLoadedEvent{}" ;
}
}
com/hypixel/hytale/server/core/universe/world/events/ChunkEvent.java
package com.hypixel.hytale.server.core.universe.world.events;
import com.hypixel.hytale.event.IEvent;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
public abstract class ChunkEvent implements IEvent <String> {
@Nonnull
private final WorldChunk chunk;
public ChunkEvent (@Nonnull WorldChunk chunk) {
this .chunk = chunk;
}
public WorldChunk getChunk () {
return this .chunk;
}
@Nonnull
public String toString () {
return "ChunkEvent{chunk=" + String.valueOf(this .chunk) + "}" ;
}
}
com/hypixel/hytale/server/core/universe/world/events/ChunkPreLoadProcessEvent.java
package com.hypixel.hytale.server.core.universe.world.events;
import com.hypixel.hytale.common.util.FormatUtil;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.event.IProcessedEvent;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public class ChunkPreLoadProcessEvent extends ChunkEvent implements IProcessedEvent {
private final boolean newlyGenerated;
private long lastDispatchNanos;
private boolean didLog;
@Nonnull
private final Holder<ChunkStore> holder;
public ChunkPreLoadProcessEvent (@Nonnull Holder<ChunkStore> holder, @Nonnull WorldChunk chunk, boolean newlyGenerated, long lastDispatchNanos) {
super (chunk);
this .newlyGenerated = newlyGenerated;
this .lastDispatchNanos = lastDispatchNanos;
this .holder = holder;
}
public boolean isNewlyGenerated () {
.newlyGenerated;
}
Holder<ChunkStore> {
.holder;
}
{
System.nanoTime();
end - .lastDispatchNanos;
.lastDispatchNanos = end;
(diff > ( ) .getChunk().getWorld().getTickStepNanos()) {
.getChunk().getWorld();
(world.consumeGCHasRun()) {
world.getLogger().at(Level.SEVERE).log(String.format( , FormatUtil.nanosToString(diff)), .getChunk(), hookName);
} {
world.getLogger().at(Level.SEVERE).log(String.format( , FormatUtil.nanosToString(diff)), .getChunk(), hookName);
}
.didLog = ;
}
}
{
.didLog;
}
String {
.newlyGenerated;
+ var10000 + + .lastDispatchNanos + + .didLog + + .toString();
}
}
com/hypixel/hytale/server/core/universe/world/events/RemoveWorldEvent.java
package com.hypixel.hytale.server.core.universe.world.events;
import com.hypixel.hytale.event.ICancellable;
import com.hypixel.hytale.server.core.universe.world.World;
import javax.annotation.Nonnull;
public class RemoveWorldEvent extends WorldEvent implements ICancellable {
private boolean cancelled;
@Nonnull
private final RemovalReason removalReason;
public RemoveWorldEvent (@Nonnull World world, @Nonnull RemovalReason removalReason) {
super (world);
this .removalReason = removalReason;
}
@Nonnull
public RemovalReason getRemovalReason () {
return this .removalReason;
}
public boolean isCancelled () {
return this .removalReason == RemoveWorldEvent.RemovalReason.EXCEPTIONAL ? false : this .cancelled;
}
public void setCancelled (boolean cancelled) {
this .cancelled = cancelled;
}
@Nonnull
String {
.cancelled;
+ var10000 + + .toString();
}
{
GENERAL,
EXCEPTIONAL;
{
}
}
}
com/hypixel/hytale/server/core/universe/world/events/StartWorldEvent.java
package com.hypixel.hytale.server.core.universe.world.events;
import com.hypixel.hytale.server.core.universe.world.World;
import javax.annotation.Nonnull;
public class StartWorldEvent extends WorldEvent {
public StartWorldEvent (@Nonnull World world) {
super (world);
}
@Nonnull
public String toString () {
return "StartWorldEvent{} " + super .toString();
}
}
com/hypixel/hytale/server/core/universe/world/events/WorldEvent.java
package com.hypixel.hytale.server.core.universe.world.events;
import com.hypixel.hytale.event.IEvent;
import com.hypixel.hytale.server.core.universe.world.World;
import javax.annotation.Nonnull;
public abstract class WorldEvent implements IEvent <String> {
@Nonnull
private final World world;
public WorldEvent (@Nonnull World world) {
this .world = world;
}
@Nonnull
public World getWorld () {
return this .world;
}
@Nonnull
public String toString () {
return "WorldEvent{world=" + String.valueOf(this .world) + "}" ;
}
}
com/hypixel/hytale/server/core/universe/world/events/ecs/ChunkSaveEvent.java
package com.hypixel.hytale.server.core.universe.world.events.ecs;
import com.hypixel.hytale.component.system.CancellableEcsEvent;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
public class ChunkSaveEvent extends CancellableEcsEvent {
@Nonnull
private final WorldChunk chunk;
public ChunkSaveEvent (@Nonnull WorldChunk chunk) {
this .chunk = chunk;
}
@Nonnull
public WorldChunk getChunk () {
return this .chunk;
}
}
com/hypixel/hytale/server/core/universe/world/events/ecs/ChunkUnloadEvent.java
package com.hypixel.hytale.server.core.universe.world.events.ecs;
import com.hypixel.hytale.component.system.CancellableEcsEvent;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
public class ChunkUnloadEvent extends CancellableEcsEvent {
@Nonnull
private final WorldChunk chunk;
private boolean resetKeepAlive = true ;
public ChunkUnloadEvent (@Nonnull WorldChunk chunk) {
this .chunk = chunk;
}
@Nonnull
public WorldChunk getChunk () {
return this .chunk;
}
public void setResetKeepAlive (boolean willResetKeepAlive) {
this .resetKeepAlive = willResetKeepAlive;
}
public boolean willResetKeepAlive () {
return this .resetKeepAlive;
}
}
com/hypixel/hytale/server/core/universe/world/events/ecs/MoonPhaseChangeEvent.java
package com.hypixel.hytale.server.core.universe.world.events.ecs;
import com.hypixel.hytale.component.system.EcsEvent;
public class MoonPhaseChangeEvent extends EcsEvent {
private final int newMoonPhase;
public MoonPhaseChangeEvent (int newMoonPhase) {
this .newMoonPhase = newMoonPhase;
}
public int getNewMoonPhase () {
return this .newMoonPhase;
}
}
com/hypixel/hytale/server/core/universe/world/lighting/CalculationResult.java
package com.hypixel.hytale.server.core.universe.world.lighting;
public enum CalculationResult {
NOT_LOADED,
DONE,
INVALIDATED,
WAITING_FOR_NEIGHBOUR;
private CalculationResult () {
}
}
com/hypixel/hytale/server/core/universe/world/lighting/ChunkLightingManager.java
package com.hypixel.hytale.server.core.universe.world.lighting;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import it.unimi.dsi.fastutil.objects.ObjectArrayFIFOQueue;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Semaphore;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public class ChunkLightingManager implements Runnable {
@Nonnull
private final HytaleLogger logger;
@Nonnull
private final Thread thread;
@Nonnull
private final World world;
private final Semaphore semaphore = new Semaphore (1 );
private final Set<Vector3i> set = ConcurrentHashMap.newKeySet();
ObjectArrayFIFOQueue<Vector3i> queue = <Vector3i>();
LightCalculation lightCalculation;
{
.logger = HytaleLogger.get( + world.getName() + );
.thread = ( , + world.getName());
.thread.setDaemon( );
.world = world;
.lightCalculation = ( );
}
HytaleLogger {
.logger;
}
World {
.world;
}
{
.lightCalculation = lightCalculation;
}
LightCalculation {
.lightCalculation;
}
{
.thread.start();
}
{
{
;
;
(! .thread.isInterrupted()) {
.semaphore.drainPermits();
Vector3i pos;
( .queue) {
pos = .queue.isEmpty() ? : (Vector3i) .queue.dequeue();
}
(pos != ) {
.process(pos);
}
Thread. ();
currentSize;
( .queue) {
currentSize = .queue.size();
}
(currentSize != lastSize) {
count = ;
lastSize = currentSize;
} (count <= currentSize) {
++count;
} {
.semaphore.acquire();
}
}
} (InterruptedException var9) {
Thread.currentThread().interrupt();
}
}
{
{
( .lightCalculation.calculateLight(chunkPosition)) {
NOT_LOADED:
WAITING_FOR_NEIGHBOUR:
DONE:
.set.remove(chunkPosition);
;
INVALIDATED:
( .queue) {
.queue.enqueue(chunkPosition);
}
}
} (Exception e) {
((HytaleLogger.Api) .logger.at(Level.WARNING).withCause(e)).log( , chunkPosition);
.set.remove(chunkPosition);
}
}
{
( .thread.isAlive()) {
.thread.interrupt();
;
} {
;
}
}
{
{
;
( .thread.isAlive()) {
.thread.interrupt();
.thread.join(( )( .world.getTickStepNanos() / ));
i += .world.getTickStepNanos() / ;
(i > ) {
();
(StackTraceElement traceElement : .thread.getStackTrace()) {
sb.append( ).append(traceElement).append( );
}
HytaleLogger.getLogger().at(Level.SEVERE).log( , .thread, sb.toString());
.thread.stop();
;
}
}
} (InterruptedException var7) {
Thread.currentThread().interrupt();
}
}
{
.lightCalculation.init(worldChunk);
}
{
( .set.add(chunkPosition)) {
( .queue) {
.queue.enqueue(chunkPosition);
}
.semaphore.release( );
}
}
{
(chunkX, , chunkZ);
( ; chunkY < ; ++chunkY) {
chunkPos.setY(chunkY);
( .isQueued(chunkPos)) {
;
}
}
;
}
{
.set.contains(chunkPosition);
}
{
( .queue) {
.queue.size();
}
}
{
.lightCalculation.invalidateLightAtBlock(worldChunk, blockX, blockY, blockZ, blockType, oldHeight, newHeight);
}
{
.lightCalculation.invalidateLightInChunkSections(worldChunk, , );
}
{
.lightCalculation.invalidateLightInChunkSections(worldChunk, sectionIndex, sectionIndex + );
}
{
.lightCalculation.invalidateLightInChunkSections(worldChunk, sectionIndexFrom, sectionIndexTo);
}
{
.world.getChunkStore().getStore().forEachEntityParallel(WorldChunk.getComponentType(), (index, archetypeChunk, storeCommandBuffer) -> {
(WorldChunk)archetypeChunk.getComponent(index, WorldChunk.getComponentType());
( ; y < ; ++y) {
chunk.getBlockChunk().getSectionAtIndex(y);
section.invalidateLocalLight();
(BlockChunk.SEND_LOCAL_LIGHTING_DATA || BlockChunk.SEND_GLOBAL_LIGHTING_DATA) {
chunk.getBlockChunk().invalidateChunkSection(y);
}
}
});
.world.getChunkStore().getChunkIndexes().forEach((index) -> {
ChunkUtil.xOfChunkIndex(index);
ChunkUtil.zOfChunkIndex(index);
( ; y < ; ++y) {
.addToQueue( (x, y, z));
}
});
}
}
com/hypixel/hytale/server/core/universe/world/lighting/FloodLightCalculation.java
package com.hypixel.hytale.server.core.universe.world.lighting;
import com.hypixel.hytale.common.util.FormatUtil;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector2i;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.metrics.metric.AverageCollector;
import com.hypixel.hytale.protocol.ColorLight;
import com.hypixel.hytale.protocol.Opacity;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.fluid.Fluid;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.accessor.LocalCachedChunkAccessor;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.chunk.section.ChunkLightData;
import com.hypixel.hytale.server.core.universe.world.chunk.section.ChunkLightDataBuilder;
import com.hypixel.hytale.server.core.universe.world.chunk.section.FluidSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
import it.unimi.dsi.fastutil.ints.IntIterator;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
java.util.concurrent.atomic.AtomicLong;
java.util.function.IntBinaryOperator;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
ChunkLightingManager chunkLightingManager;
();
();
();
();
BlockSection[][] fromSections;
{
.fromSections = [][]{ [Vector3i.BLOCK_SIDES.length], [Vector3i.BLOCK_EDGES.length], [Vector3i.BLOCK_CORNERS.length]};
.chunkLightingManager = chunkLightingManager;
}
{
.chunkLightingManager.getWorld().debugAssertInTickingThread();
chunk.getX();
chunk.getZ();
.initChunk(chunk, x, z);
.initNeighbours(x, z);
}
{
.chunkLightingManager.getWorld().getChunkIfInMemory(ChunkUtil.indexChunk(x, z));
(chunk != ) {
.initChunk(chunk, x, z);
}
}
{
( ; y < ; ++y) {
.initSection(chunk, x, y, z);
}
}
{
.initChunk(x - , z - );
.initChunk(x - , z + );
.initChunk(x + , z - );
.initChunk(x + , z + );
.initChunk(x - , z);
.initChunk(x + , z);
.initChunk(x, z - );
.initChunk(x, z + );
}
{
chunk.getBlockChunk().getSectionAtIndex(y);
(!section.hasLocalLight()) {
.chunkLightingManager.getLogger().at(Level.FINEST).log( , x, y, z);
} {
(section.hasGlobalLight()) {
;
}
.chunkLightingManager.getLogger().at(Level.FINEST).log( , x, y, z);
}
.chunkLightingManager.addToQueue( (x, y, z));
}
{
.initNeighbourSections(accessor, chunkX - , chunkY, chunkZ - );
.initNeighbourSections(accessor, chunkX - , chunkY, chunkZ + );
.initNeighbourSections(accessor, chunkX + , chunkY, chunkZ - );
.initNeighbourSections(accessor, chunkX + , chunkY, chunkZ + );
.initNeighbourSections(accessor, chunkX - , chunkY, chunkZ);
.initNeighbourSections(accessor, chunkX + , chunkY, chunkZ);
.initNeighbourSections(accessor, chunkX, chunkY, chunkZ - );
.initNeighbourSections(accessor, chunkX, chunkY, chunkZ + );
}
{
accessor.getChunkIfInMemory(x, z);
(chunk != ) {
(y < ) {
.initSection(chunk, x, y + , z);
}
(y > ) {
.initSection(chunk, x, y - , z);
}
}
}
CalculationResult {
chunkPosition.x;
chunkPosition.y;
chunkPosition.z;
.chunkLightingManager.getWorld().getChunkIfInMemory(ChunkUtil.indexChunk(chunkX, chunkZ));
(worldChunk == ) {
CalculationResult.NOT_LOADED;
} {
worldChunk.chunkLightTiming;
.chunkLightingManager.getLogger().at(Level.FINE).isEnabled();
LocalCachedChunkAccessor.atChunkCoords( .chunkLightingManager.getWorld(), chunkX, chunkZ, );
accessor.overwrite(worldChunk);
Objects.requireNonNull(accessor);
CompletableFuture.runAsync(accessor::cacheChunksInRadius, .chunkLightingManager.getWorld()).join();
worldChunk.getBlockChunk().getSectionAtIndex(chunkY);
(FluidSection)CompletableFuture.supplyAsync(() -> {
Ref<ChunkStore> section = .chunkLightingManager.getWorld().getChunkStore().getChunkSectionReference(chunkX, chunkY, chunkZ);
section == ? : (FluidSection)section.getStore().getComponent(section, FluidSection.getComponentType());
}, .chunkLightingManager.getWorld()).join();
(fluidSection == ) {
CalculationResult.NOT_LOADED;
} (toSection.hasLocalLight() && toSection.hasGlobalLight()) {
.initNeighbours(accessor, chunkX, chunkY, chunkZ);
CalculationResult.DONE;
} {
(!toSection.hasLocalLight()) {
.updateLocalLight(accessor, worldChunk, chunkX, chunkY, chunkZ, toSection, fluidSection, chunkLightTiming, fineLoggable);
(localLightResult) {
NOT_LOADED:
INVALIDATED:
WAITING_FOR_NEIGHBOUR:
localLightResult;
DONE:
:
.initNeighbours(accessor, chunkX, chunkY, chunkZ);
}
}
(!toSection.hasGlobalLight()) {
.updateGlobalLight(accessor, worldChunk, chunkX, chunkY, chunkZ, toSection, chunkLightTiming, fineLoggable);
(globalLightResult) {
NOT_LOADED:
INVALIDATED:
WAITING_FOR_NEIGHBOUR:
globalLightResult;
DONE:
}
}
(fineLoggable) {
chunkLightTiming.get();
chunkDiff != ;
( ; i < ; ++i) {
worldChunk.getBlockChunk().getSectionAtIndex(i);
done = done && section.hasLocalLight() && section.hasGlobalLight();
}
(done) {
.avgChunk.add(( )chunkDiff);
.chunkLightingManager.getLogger().at(Level.FINE).log( , FormatUtil.nanosToString(chunkDiff), chunkX, chunkZ, FormatUtil.nanosToString(( ) .avgChunk.get()));
}
}
(BlockChunk.SEND_LOCAL_LIGHTING_DATA || BlockChunk.SEND_GLOBAL_LIGHTING_DATA) {
worldChunk.getBlockChunk().invalidateChunkSection(chunkY);
}
CalculationResult.DONE;
}
}
}
CalculationResult {
System.nanoTime();
toSection.isSolidAir() && fluidSection.isEmpty();
ChunkLightDataBuilder localLight;
(solidAir) {
localLight = .floodEmptyChunkSection(worldChunk, toSection.getLocalChangeCounter(), chunkY);
} {
localLight = .floodChunkSection(worldChunk, toSection, fluidSection, chunkY);
}
toSection.setLocalLight(localLight);
worldChunk.markNeedsSaving();
(fineLoggable) {
System.nanoTime();
end - start;
(solidAir) {
.emptyAvg.add(( )diff);
} {
.blocksAvg.add(( )diff);
}
chunkLightTiming.addAndGet(diff);
.chunkLightingManager.getLogger().at(Level.FINER).log( , FormatUtil.nanosToString(diff), chunkX, chunkY, chunkZ, solidAir ? : , FormatUtil.nanosToString(( )(solidAir ? .emptyAvg.get() : .blocksAvg.get())));
}
(!toSection.hasLocalLight()) {
.chunkLightingManager.getLogger().at(Level.FINEST).log( , chunkX, chunkY, chunkZ, toSection.getLocalChangeCounter(), toSection.getLocalLight().getChangeId());
CalculationResult.INVALIDATED;
} {
CalculationResult.DONE;
}
}
CalculationResult {
System.nanoTime();
( .testNeighboursForLocalLight(accessor, worldChunk, chunkX, chunkY, chunkZ)) {
CalculationResult.WAITING_FOR_NEIGHBOUR;
} {
(toSection.getLocalLight(), toSection.getGlobalChangeCounter());
( );
.propagateSides(toSection, globalLight, bitSetQueue);
.propagateEdges(toSection, globalLight, bitSetQueue);
.propagateCorners(toSection, globalLight, bitSetQueue);
.propagateLight(bitSetQueue, toSection, globalLight);
toSection.setGlobalLight(globalLight);
worldChunk.markNeedsSaving();
(fineLoggable) {
System.nanoTime();
end - start;
chunkLightTiming.addAndGet(diff);
.borderAvg.add(( )diff);
.chunkLightingManager.getLogger().at(Level.FINER).log( + FormatUtil.nanosToString(diff) + + chunkX + + chunkY + + chunkZ + + FormatUtil.nanosToString(( ) .borderAvg.get()));
}
(!toSection.hasGlobalLight()) {
.chunkLightingManager.getLogger().at(Level.FINEST).log( , chunkX, chunkY, chunkZ, toSection.getGlobalChangeCounter(), toSection.getGlobalLight().getChangeId());
CalculationResult.INVALIDATED;
} {
CalculationResult.DONE;
}
}
}
{
worldChunk.getX();
blockY >> ;
worldChunk.getZ();
oldHeight >> ;
newHeight >> ;
Math.max(MathUtil.minValue(oldHeightChunk, newHeightChunk, chunkY), );
MathUtil.maxValue(oldHeightChunk, newHeightChunk, chunkY) + ;
.invalidateLightInChunkSections(worldChunk, from, to);
.chunkLightingManager.getLogger().at(Level.FINER).log( , blockX, blockY, blockZ, blockType.getId(), chunkX, chunkY, chunkZ);
handled;
}
{
worldChunk.getX();
worldChunk.getZ();
.chunkLightingManager.getWorld();
LocalCachedChunkAccessor.atChunkCoords(world, chunkX, chunkZ, );
accessor.overwrite(worldChunk);
(!world.isInThread()) {
Objects.requireNonNull(accessor);
CompletableFuture.runAsync(accessor::cacheChunksInRadius, world).join();
} {
accessor.cacheChunksInRadius();
}
( chunkX - ; x <= chunkX + ; ++x) {
( chunkZ - ; z <= chunkZ + ; ++z) {
accessor.getChunkIfInMemory(x, z);
(worldChunkTemp != ) {
( sectionIndexTo - ; y >= sectionIndexFrom; --y) {
worldChunkTemp.getBlockChunk().getSectionAtIndex(y);
(worldChunkTemp == worldChunk) {
section.invalidateLocalLight();
} {
section.invalidateGlobalLight();
}
(BlockChunk.SEND_LOCAL_LIGHTING_DATA || BlockChunk.SEND_GLOBAL_LIGHTING_DATA) {
worldChunkTemp.getBlockChunk().invalidateChunkSection(y);
}
}
}
}
}
( chunkX - ; x <= chunkX + ; ++x) {
( chunkZ - ; z <= chunkZ + ; ++z) {
accessor.getChunkIfInMemory(x, z);
(worldChunkTemp != ) {
( sectionIndexTo - ; y >= sectionIndexFrom; --y) {
.chunkLightingManager.addToQueue( (x, y, z));
}
}
}
}
;
}
ChunkLightDataBuilder {
chunkY * ;
(changeCounter);
( );
( ; x < ; ++x) {
( ; z < ; ++z) {
ChunkUtil.indexColumn(x, z);
worldChunk.getHeight(column);
(sectionY > height) {
( ; y < ; ++y) {
light.setLight(ChunkUtil.indexBlockFromColumn(column, y), , ( ) );
}
bitSetQueue.set(column);
}
}
}
(bitSetQueue.cardinality() < ) {
( );
;
( ) {
bitSetQueue.nextSetBit(counter);
(column == - ) {
(bitSetQueue.isEmpty()) {
changedColumns.iterator();
(iterator.hasNext()) {
iterator.nextInt();
light.getLight(column, );
( ; y < ; ++y) {
light.setLight(ChunkUtil.indexBlockFromColumn(column, y), , skyLight);
}
}
;
}
counter = ;
} {
bitSetQueue.clear(column);
counter = column;
ChunkUtil.xFromColumn(column);
ChunkUtil.zFromColumn(column);
light.getLight(column, );
( )(skyLight - );
(propagatedValue >= ) {
(Vector2i side : Vector2i.DIRECTIONS) {
x + side.x;
z + side.y;
(nx >= && nx < && nz >= && nz < ) {
ChunkUtil.indexColumn(nx, nz);
light.getLight(neighbourColumn, );
(neighbourSkyLight < propagatedValue) {
light.setLight(neighbourColumn, , propagatedValue);
changedColumns.add(neighbourColumn);
(propagatedValue > ) {
bitSetQueue.set(neighbourColumn);
}
}
}
}
}
}
}
}
light;
}
ChunkLightDataBuilder {
chunkY * ;
(toSection.getLocalChangeCounter());
( );
( ; x < ; ++x) {
( ; z < ; ++z) {
ChunkUtil.indexColumn(x, z);
worldChunk.getHeight(column);
( ; y < ; ++y) {
ChunkUtil.indexBlockFromColumn(column, y);
.getSkyValue(worldChunk, chunkY, x, y, z, sectionY, height);
( )(skyValue << );
toSection.get(blockIndex);
(BlockType)BlockType.getAssetMap().getAsset(blockId);
blockType.getLight();
fluidSection.getFluidId(blockIndex);
(Fluid)Fluid.getAssetMap().getAsset(fluidId);
fluid.getLight();
(blockTypeLight != && fluidLight != ) {
lightValue = ChunkLightData.combineLightValues(( )Math.max(blockTypeLight.red, fluidLight.red), ( )Math.max(blockTypeLight.green, fluidLight.green), ( )Math.max(blockTypeLight.blue, fluidLight.blue), skyValue);
} (fluidLight != ) {
lightValue = ChunkLightData.combineLightValues(fluidLight.red, fluidLight.green, fluidLight.blue, skyValue);
} (blockTypeLight != ) {
lightValue = ChunkLightData.combineLightValues(blockTypeLight.red, blockTypeLight.green, blockTypeLight.blue, skyValue);
}
(lightValue != ) {
toLight.setLightRaw(blockIndex, lightValue);
bitSetQueue.set(blockIndex);
}
}
}
}
.propagateLight(bitSetQueue, toSection, toLight);
toLight;
}
{
sectionY + blockY;
originY >= height;
( )(hasSky ? : );
}
{
;
( ) {
bitSetQueue.nextSetBit(counter);
(blockIndex == - ) {
(bitSetQueue.isEmpty()) {
;
}
counter = ;
} {
bitSetQueue.clear(blockIndex);
counter = blockIndex;
(BlockType)BlockType.getAssetMap().getAsset(section.get(blockIndex));
fromBlockType.getOpacity();
(fromOpacity != Opacity.Solid) {
light.getLightRaw(blockIndex);
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
(redLight >= || greenLight >= || blueLight >= || skyLight >= ) {
( )(redLight - );
( )(greenLight - );
( )(blueLight - );
( )(skyLight - );
(fromOpacity == Opacity.Semitransparent || fromOpacity == Opacity.Cutout) {
--propagatedRedValue;
--propagatedGreenValue;
--propagatedBlueValue;
--propagatedSkyValue;
}
(propagatedRedValue >= || propagatedGreenValue >= || propagatedBlueValue >= || propagatedSkyValue >= ) {
ChunkUtil.xFromIndex(blockIndex);
ChunkUtil.yFromIndex(blockIndex);
ChunkUtil.zFromIndex(blockIndex);
(Vector3i side : Vector3i.BLOCK_SIDES) {
x + side.x;
(nx >= && nx < ) {
y + side.y;
(ny >= && ny < ) {
z + side.z;
(nz >= && nz < ) {
ChunkUtil.indexBlock(nx, ny, nz);
.propagateLight(bitSetQueue, propagatedRedValue, propagatedGreenValue, propagatedBlueValue, propagatedSkyValue, section, light, neighbourBlock);
}
}
}
}
}
}
}
}
}
}
{
Vector3i[][] blockParts = Vector3i.BLOCK_PARTS;
( ; partType < .fromSections.length; ++partType) {
BlockSection[] partSections = .fromSections[partType];
Arrays.fill(partSections, (Object) );
Vector3i[] directions = blockParts[partType];
( ; i < directions.length; ++i) {
directions[i];
chunkX + side.x;
chunkY + side.y;
chunkZ + side.z;
(ny >= && ny < ) {
(nx == chunkX && nz == chunkZ) {
worldChunk.getBlockChunk().getSectionAtIndex(ny);
(!fromSection.hasLocalLight()) {
;
}
partSections[i] = fromSection;
} {
accessor.getChunkIfInMemory(nx, nz);
(neighbourChunk == ) {
;
}
neighbourChunk.getBlockChunk().getSectionAtIndex(ny);
(!fromSection.hasLocalLight()) {
;
}
partSections[i] = fromSection;
}
}
}
}
;
}
{
BlockSection[] fromSectionsSides = .fromSections[ ];
;
.propagateSide(bitSetQueue, fromSectionsSides[i++], toSection, globalLight, (a, b) -> ChunkUtil.indexBlock(a, , b), (a, b) -> ChunkUtil.indexBlock(a, , b));
.propagateSide(bitSetQueue, fromSectionsSides[i++], toSection, globalLight, (a, b) -> ChunkUtil.indexBlock(a, , b), (a, b) -> ChunkUtil.indexBlock(a, , b));
.propagateSide(bitSetQueue, fromSectionsSides[i++], toSection, globalLight, (a, b) -> ChunkUtil.indexBlock(a, b, ), (a, b) -> ChunkUtil.indexBlock(a, b, ));
.propagateSide(bitSetQueue, fromSectionsSides[i++], toSection, globalLight, (a, b) -> ChunkUtil.indexBlock(a, b, ), (a, b) -> ChunkUtil.indexBlock(a, b, ));
.propagateSide(bitSetQueue, fromSectionsSides[i++], toSection, globalLight, (a, b) -> ChunkUtil.indexBlock( , a, b), (a, b) -> ChunkUtil.indexBlock( , a, b));
.propagateSide(bitSetQueue, fromSectionsSides[i++], toSection, globalLight, (a, b) -> ChunkUtil.indexBlock( , a, b), (a, b) -> ChunkUtil.indexBlock( , a, b));
}
{
(fromSection != ) {
fromSection.getLocalLight();
( ; a < ; ++a) {
( ; b < ; ++b) {
fromIndex.applyAsInt(a, b);
toIndex.applyAsInt(a, b);
(BlockType)BlockType.getAssetMap().getAsset(fromSection.get(fromBlockIndex));
fromBlockType.getOpacity();
(fromOpacity != Opacity.Solid) {
fromLight.getLightRaw(fromBlockIndex);
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
(redLight >= || greenLight >= || blueLight >= || skyLight >= ) {
( )(redLight - );
( )(greenLight - );
( )(blueLight - );
( )(skyLight - );
(fromOpacity == Opacity.Semitransparent || fromOpacity == Opacity.Cutout) {
--propagatedRedValue;
--propagatedGreenValue;
--propagatedBlueValue;
--propagatedSkyValue;
}
(propagatedRedValue >= || propagatedGreenValue >= || propagatedBlueValue >= || propagatedSkyValue >= ) {
.propagateLight(bitSetQueue, propagatedRedValue, propagatedGreenValue, propagatedBlueValue, propagatedSkyValue, toSection, toLight, toBlockIndex);
}
}
}
}
}
}
}
{
BlockSection[] fromSectionsEdges = .fromSections[ ];
;
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock(a, , ), (a) -> ChunkUtil.indexBlock(a, , ));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock(a, , ), (a) -> ChunkUtil.indexBlock(a, , ));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock(a, , ), (a) -> ChunkUtil.indexBlock(a, , ));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock(a, , ), (a) -> ChunkUtil.indexBlock(a, , ));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock( , , a), (a) -> ChunkUtil.indexBlock( , , a));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock( , , a), (a) -> ChunkUtil.indexBlock( , , a));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock( , , a), (a) -> ChunkUtil.indexBlock( , , a));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock( , , a), (a) -> ChunkUtil.indexBlock( , , a));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock( , a, ), (a) -> ChunkUtil.indexBlock( , a, ));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock( , a, ), (a) -> ChunkUtil.indexBlock( , a, ));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock( , a, ), (a) -> ChunkUtil.indexBlock( , a, ));
.propagateEdge(bitSetQueue, fromSectionsEdges[i++], toSection, globalLight, (a) -> ChunkUtil.indexBlock( , a, ), (a) -> ChunkUtil.indexBlock( , a, ));
}
{
(fromSection != ) {
fromSection.getLocalLight();
( ; a < ; ++a) {
fromIndex.applyAsInt(a);
toIndex.applyAsInt(a);
(BlockType)BlockType.getAssetMap().getAsset(fromSection.get(fromBlockIndex));
fromBlockType.getOpacity();
(fromOpacity != Opacity.Solid) {
fromLight.getLightRaw(fromBlockIndex);
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
(redLight >= || greenLight >= || blueLight >= || skyLight >= ) {
( )(redLight - );
( )(greenLight - );
( )(blueLight - );
( )(skyLight - );
(fromOpacity == Opacity.Semitransparent || fromOpacity == Opacity.Cutout) {
--propagatedRedValue;
--propagatedGreenValue;
--propagatedBlueValue;
--propagatedSkyValue;
}
(propagatedRedValue >= || propagatedGreenValue >= || propagatedBlueValue >= || propagatedSkyValue >= ) {
.propagateLight(bitSetQueue, propagatedRedValue, propagatedGreenValue, propagatedBlueValue, propagatedSkyValue, toSection, toLight, toBlockIndex);
}
}
}
}
}
}
{
BlockSection[] fromSectionsCorners = .fromSections[ ];
;
.propagateCorner(bitSetQueue, fromSectionsCorners[i++], toSection, globalLight, ChunkUtil.indexBlock( , , ), ChunkUtil.indexBlock( , , ));
.propagateCorner(bitSetQueue, fromSectionsCorners[i++], toSection, globalLight, ChunkUtil.indexBlock( , , ), ChunkUtil.indexBlock( , , ));
.propagateCorner(bitSetQueue, fromSectionsCorners[i++], toSection, globalLight, ChunkUtil.indexBlock( , , ), ChunkUtil.indexBlock( , , ));
.propagateCorner(bitSetQueue, fromSectionsCorners[i++], toSection, globalLight, ChunkUtil.indexBlock( , , ), ChunkUtil.indexBlock( , , ));
.propagateCorner(bitSetQueue, fromSectionsCorners[i++], toSection, globalLight, ChunkUtil.indexBlock( , , ), ChunkUtil.indexBlock( , , ));
.propagateCorner(bitSetQueue, fromSectionsCorners[i++], toSection, globalLight, ChunkUtil.indexBlock( , , ), ChunkUtil.indexBlock( , , ));
.propagateCorner(bitSetQueue, fromSectionsCorners[i++], toSection, globalLight, ChunkUtil.indexBlock( , , ), ChunkUtil.indexBlock( , , ));
.propagateCorner(bitSetQueue, fromSectionsCorners[i++], toSection, globalLight, ChunkUtil.indexBlock( , , ), ChunkUtil.indexBlock( , , ));
}
{
(fromSection != ) {
fromSection.getLocalLight();
(BlockType)BlockType.getAssetMap().getAsset(fromSection.get(fromBlockIndex));
fromBlockType.getOpacity();
(fromOpacity != Opacity.Solid) {
fromLight.getLightRaw(fromBlockIndex);
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
ChunkLightData.getLightValue(lightValue, );
(redLight >= || greenLight >= || blueLight >= || skyLight >= ) {
( )(redLight - );
( )(greenLight - );
( )(blueLight - );
( )(skyLight - );
(fromOpacity == Opacity.Semitransparent || fromOpacity == Opacity.Cutout) {
--propagatedRedValue;
--propagatedGreenValue;
--propagatedBlueValue;
--propagatedSkyValue;
}
(propagatedRedValue >= || propagatedGreenValue >= || propagatedBlueValue >= || propagatedSkyValue >= ) {
.propagateLight(bitSetQueue, propagatedRedValue, propagatedGreenValue, propagatedBlueValue, propagatedSkyValue, toSection, toLight, toBlockIndex);
}
}
}
}
}
{
(BlockType)BlockType.getAssetMap().getAsset(toSection.get(toBlockIndex));
toBlockType.getOpacity();
(toOpacity == Opacity.Cutout) {
--propagatedRedValue;
--propagatedGreenValue;
--propagatedBlueValue;
--propagatedSkyValue;
}
(propagatedRedValue >= || propagatedGreenValue >= || propagatedBlueValue >= || propagatedSkyValue >= ) {
toLight.getLightRaw(toBlockIndex);
ChunkLightData.getLightValue(oldLightValue, );
ChunkLightData.getLightValue(oldLightValue, );
ChunkLightData.getLightValue(oldLightValue, );
ChunkLightData.getLightValue(oldLightValue, );
(neighbourRedLight < propagatedRedValue) {
neighbourRedLight = propagatedRedValue;
}
(neighbourGreenLight < propagatedGreenValue) {
neighbourGreenLight = propagatedGreenValue;
}
(neighbourBlueLight < propagatedBlueValue) {
neighbourBlueLight = propagatedBlueValue;
}
(neighbourSkyLight < propagatedSkyValue) {
neighbourSkyLight = propagatedSkyValue;
}
( )((neighbourRedLight & ) << );
newLightValue = ( )(newLightValue | (neighbourGreenLight & ) << );
newLightValue = ( )(newLightValue | (neighbourBlueLight & ) << );
newLightValue = ( )(newLightValue | (neighbourSkyLight & ) << );
toLight.setLightRaw(toBlockIndex, newLightValue);
(newLightValue != oldLightValue && (propagatedRedValue > || propagatedGreenValue > || propagatedBlueValue > || propagatedSkyValue > )) {
bitSetQueue.set(toBlockIndex);
}
}
}
}
com/hypixel/hytale/server/core/universe/world/lighting/FullBrightLightCalculation.java
package com.hypixel.hytale.server.core.universe.world.lighting;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.chunk.section.ChunkLightDataBuilder;
import javax.annotation.Nonnull;
public class FullBrightLightCalculation implements LightCalculation {
private final ChunkLightingManager chunkLightingManager;
private LightCalculation delegate;
public FullBrightLightCalculation (ChunkLightingManager chunkLightingManager, LightCalculation delegate) {
this .chunkLightingManager = chunkLightingManager;
this .delegate = delegate;
}
public void init (@Nonnull WorldChunk worldChunk) {
this .delegate.init(worldChunk);
}
@Nonnull
public CalculationResult calculateLight (@Nonnull Vector3i chunkPosition) {
CalculationResult result = this .delegate.calculateLight(chunkPosition);
(result == CalculationResult.DONE) {
.chunkLightingManager.getWorld().getChunkIfInMemory(ChunkUtil.indexChunk(chunkPosition.x, chunkPosition.z));
(worldChunk == ) {
CalculationResult.NOT_LOADED;
}
.setFullBright(worldChunk, chunkPosition.y);
}
result;
}
{
.delegate.invalidateLightAtBlock(worldChunk, blockX, blockY, blockZ, blockType, oldHeight, newHeight);
(handled) {
.setFullBright(worldChunk, blockY >> );
}
handled;
}
{
.delegate.invalidateLightInChunkSections(worldChunk, sectionIndexFrom, sectionIndexTo);
(handled) {
( sectionIndexTo - ; y >= sectionIndexFrom; --y) {
.setFullBright(worldChunk, y);
}
}
handled;
}
{
worldChunk.getBlockChunk().getSectionAtIndex(chunkY);
(section.getGlobalChangeCounter());
( ; i < ; ++i) {
light.setSkyLight(i, ( ) );
}
section.setGlobalLight(light);
(BlockChunk.SEND_LOCAL_LIGHTING_DATA || BlockChunk.SEND_GLOBAL_LIGHTING_DATA) {
worldChunk.getBlockChunk().invalidateChunkSection(chunkY);
}
}
}
com/hypixel/hytale/server/core/universe/world/lighting/LightCalculation.java
package com.hypixel.hytale.server.core.universe.world.lighting;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import javax.annotation.Nonnull;
public interface LightCalculation {
void init (@Nonnull WorldChunk var1) ;
@Nonnull
CalculationResult calculateLight (@Nonnull Vector3i var1) ;
boolean invalidateLightAtBlock (@Nonnull WorldChunk var1, int var2, int var3, int var4, @Nonnull BlockType var5, int var6, int var7) ;
boolean invalidateLightInChunkSections (@Nonnull WorldChunk var1, int var2, int var3) ;
}
com/hypixel/hytale/server/core/universe/world/map/WorldMap.java
package com.hypixel.hytale.server.core.universe.world.map;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.packets.worldmap.ContextMenuItem;
import com.hypixel.hytale.protocol.packets.worldmap.MapChunk;
import com.hypixel.hytale.protocol.packets.worldmap.MapImage;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.protocol.packets.worldmap.UpdateWorldMap;
import com.hypixel.hytale.server.core.io.NetworkSerializable;
import com.hypixel.hytale.server.core.util.PositionUtil;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.util.Map;
import javax.annotation.Nonnull;
public class WorldMap implements NetworkSerializable <UpdateWorldMap> {
private final Map<String, MapMarker> pointsOfInterest = new Object2ObjectOpenHashMap <String, MapMarker>();
@Nonnull
private final Long2ObjectMap<MapImage> chunks;
private UpdateWorldMap packet;
public WorldMap (int chunks) {
this .chunks = new <MapImage>(chunks);
}
Map<String, MapMarker> {
.pointsOfInterest;
}
Long2ObjectMap<MapImage> {
.chunks;
}
{
.addPointOfInterest(id, name, markerType, (pos));
}
{
.addPointOfInterest(id, name, markerType, (pos));
}
{
(MapMarker) .pointsOfInterest.putIfAbsent(id, (id, name, markerType, PositionUtil.toTransformPacket(transform), (ContextMenuItem[]) ));
(old != ) {
( + id + );
}
}
UpdateWorldMap {
( .packet != ) {
.packet;
} {
MapChunk[] mapChunks = [ .chunks.size()];
;
(Long2ObjectMap.Entry<MapImage> entry : .chunks.long2ObjectEntrySet()) {
entry.getLongKey();
ChunkUtil.xOfChunkIndex(index);
ChunkUtil.zOfChunkIndex(index);
mapChunks[i++] = (chunkX, chunkZ, (MapImage)entry.getValue());
}
.packet = (mapChunks, (MapMarker[]) .pointsOfInterest.values().toArray((x$ ) -> [x$ ]), (String[]) );
}
}
String {
String.valueOf( .pointsOfInterest);
+ var10000 + + String.valueOf( .chunks) + ;
}
}
package com.hypixel.hytale.server.core.universe.world.meta;
import com.google.common.flogger.StackSize;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.lookup.ACodecMapCodec;
import com.hypixel.hytale.codec.lookup.CodecMapCodec;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.StateData;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.meta.state.exceptions.NoSuchBlockStateException;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonDocument;
<ChunkStore> {
HytaleLogger.forEnclosingClass();
CodecMapCodec<BlockState> CODEC = <BlockState>( );
BuilderCodec<BlockState> BASE_CODEC;
KeyedCodec<String> TYPE_STRUCTURE;
;
;
( );
WorldChunk chunk;
Vector3i position;
Ref<ChunkStore> reference;
{
}
{
( .reference != && .reference.isValid()) {
String.valueOf( .reference);
( + var10002 + + String.valueOf(reference));
} {
.reference = reference;
}
}
Ref<ChunkStore> {
.reference;
}
{
( .reference != && .reference.isValid()) {
( );
} {
.chunk = ;
}
}
{
;
}
{
}
{
(! .initialized.get()) {
(String.valueOf( ));
}
}
{
ChunkUtil.indexBlockInColumn( .position.x, .position.y, .position.z);
}
{
.chunk = chunk;
(position != ) {
position.assign(position.getX() & , position.getY(), position.getZ() & );
(position.equals(Vector3i.ZERO)) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withStackTrace(StackSize.FULL)).log( , );
}
.position = position;
}
}
{
position.assign(position.getX() & , position.getY(), position.getZ() & );
(position.equals(Vector3i.ZERO)) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withStackTrace(StackSize.FULL)).log( , );
}
.position = position;
}
Vector3i {
.position.clone();
}
Vector3i {
.position;
}
{
.position = ;
}
{
.chunk.getX() << | .position.getX();
}
{
.position.y;
}
{
.chunk.getZ() << | .position.getZ();
}
Vector3i {
( .getBlockX(), .getBlockY(), .getBlockZ());
}
Vector3d {
.getBlockType();
( , , );
blockType.getBlockCenter( .getRotationIndex(), blockCenter);
blockCenter.add(( ) .getBlockX(), ( ) .getBlockY(), ( ) .getBlockZ());
}
WorldChunk {
.chunk;
}
BlockType {
.getChunk().getBlockType( .position);
}
{
.getChunk().getRotationIndex( .position.x, .position.y, .position.z);
}
{
}
{
.getChunk().markNeedsSaving();
}
BsonDocument {
CODEC.encode( ).asDocument();
}
Component<ChunkStore> {
CODEC.encode( , (ExtraInfo)ExtraInfo.THREAD_LOCAL.get()).asDocument();
(Component)CODEC.decode(document, (ExtraInfo)ExtraInfo.THREAD_LOCAL.get());
}
Holder<ChunkStore> {
( .reference != && .reference.isValid() && .chunk != ) {
Holder<ChunkStore> holder = ChunkStore.REGISTRY.newHolder();
Store<ChunkStore> componentStore = .chunk.getWorld().getChunkStore().getStore();
Archetype<ChunkStore> archetype = componentStore.getArchetype( .reference);
( archetype.getMinIndex(); i < archetype.length(); ++i) {
archetype.get(i);
(componentType != ) {
holder.addComponent(componentType, componentStore.getComponent( .reference, componentType));
}
}
holder;
} {
Holder<ChunkStore> holder = ChunkStore.REGISTRY.newHolder();
ComponentType<ChunkStore, ? > componentType = BlockStateModule.get().getComponentType( .getClass());
(componentType == ) {
( + String.valueOf( ));
} {
holder.addComponent(componentType, );
holder;
}
}
}
BlockState NoSuchBlockStateException {
load(doc, chunk, pos, chunk.getBlockType(pos.getX(), pos.getY(), pos.getZ()));
}
BlockState NoSuchBlockStateException {
BlockState blockState;
{
blockState = (BlockState)CODEC.decode(doc);
} (ACodecMapCodec.UnknownIdException e) {
(e);
}
blockState.setPosition(chunk, pos);
(chunk != ) {
(!blockState.initialize(blockType)) {
;
}
blockState.initialized.set( );
}
blockState;
}
BlockState {
worldChunk.getBlockType(x, y, z);
(blockType != && !blockType.isUnknown()) {
blockType.getState();
(state != && state.getId() != ) {
(x, y, z);
BlockStateModule.get().createBlockState(state.getId(), worldChunk, position, blockType);
(blockState != ) {
worldChunk.setState(x, y, z, blockState);
}
blockState;
} {
;
}
} {
;
}
}
BlockState {
(reference == ) {
;
} {
ComponentType<ChunkStore, BlockState> componentType = findComponentType(componentAccessor.getArchetype(reference), BlockState.class);
componentType == ? : (BlockState)componentAccessor.getComponent(reference, componentType);
}
}
BlockState {
ComponentType<ChunkStore, BlockState> componentType = findComponentType(archetypeChunk.getArchetype(), BlockState.class);
componentType == ? : (BlockState)archetypeChunk.getComponent(index, componentType);
}
BlockState {
ComponentType<ChunkStore, BlockState> componentType = findComponentType(holder.getArchetype(), BlockState.class);
componentType == ? : (BlockState)holder.getComponent(componentType);
}
<C <ChunkStore>, T > ComponentType<ChunkStore, T> {
( archetype.getMinIndex(); i < archetype.length(); ++i) {
ComponentType<ChunkStore, ? <ChunkStore>> componentType = archetype.get(i);
(componentType != && entityClass.isAssignableFrom(componentType.getTypeClass())) {
componentType;
}
}
;
}
{
BASE_CODEC = ((BuilderCodec.Builder)BuilderCodec.abstractBuilder(BlockState.class).addField( ( , Vector3i.CODEC), (entity, o) -> entity.position = o, (entity) -> entity.position != && !Vector3i.ZERO.equals(entity.position) ? entity.position : )).build();
TYPE_STRUCTURE = <String>( , Codec.STRING);
}
}
package com.hypixel.hytale.server.core.universe.world.meta;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.common.plugin.PluginManifest;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.DisableProcessingAssert;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.dependency.RootDependency;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.spatial.KDTree;
import com.hypixel.hytale.component.spatial.SpatialResource;
import com.hypixel.hytale.component.system.HolderSystem;
import com.hypixel.hytale.component.system.MetricSystem;
import com.hypixel.hytale.component.system.RefSystem;
import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.metrics.MetricResults;
import com.hypixel.hytale.metrics.MetricsRegistry;
import com.hypixel.hytale.protocol.Packet;
com.hypixel.hytale.server.core.HytaleServer;
com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
com.hypixel.hytale.server.core.asset.type.blocktype.config.StateData;
com.hypixel.hytale.server.core.modules.block.BlockModule;
com.hypixel.hytale.server.core.modules.block.system.ItemContainerStateSpatialSystem;
com.hypixel.hytale.server.core.plugin.JavaPlugin;
com.hypixel.hytale.server.core.plugin.JavaPluginInit;
com.hypixel.hytale.server.core.plugin.PluginState;
com.hypixel.hytale.server.core.universe.PlayerRef;
com.hypixel.hytale.server.core.universe.world.World;
com.hypixel.hytale.server.core.universe.world.chunk.ChunkFlag;
com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
com.hypixel.hytale.server.core.universe.world.chunk.state.TickableBlockState;
com.hypixel.hytale.server.core.universe.world.meta.state.DestroyableBlockState;
com.hypixel.hytale.server.core.universe.world.meta.state.ItemContainerState;
com.hypixel.hytale.server.core.universe.world.meta.state.SendableBlockState;
com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
java.util.List;
java.util.Map;
java.util.Set;
java.util.concurrent.ConcurrentHashMap;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
org.bson.BsonDocument;
{
PluginManifest.corePlugin(BlockStateModule.class).depends(BlockModule.class).build();
BlockStateModule instance;
Map<Class<? >, ComponentType<ChunkStore, ? >> classToComponentType = ();
ResourceType<ChunkStore, SpatialResource<Ref<ChunkStore>, ChunkStore>> itemContainerSpatialResourceType;
BlockStateModule {
instance;
}
ResourceType<ChunkStore, SpatialResource<Ref<ChunkStore>, ChunkStore>> {
.itemContainerSpatialResourceType;
}
{
(init);
instance = ;
}
{
.registerBlockState(ItemContainerState.class, , ItemContainerState.CODEC, ItemContainerState.ItemContainerStateData.class, ItemContainerState.ItemContainerStateData.CODEC);
.itemContainerSpatialResourceType = .getChunkStoreRegistry().registerSpatialResource(() -> (Ref::isValid));
.getChunkStoreRegistry().registerSystem( ( .itemContainerSpatialResourceType));
.getChunkStoreRegistry().registerSystem( ());
}
<T > BlockStateRegistration {
.registerBlockState(clazz, key, codec, (Class) , (Codec) );
}
<T , D > BlockStateRegistration {
( .isDisabled()) {
;
} {
BlockState.CODEC.register(key, clazz, codec);
(dataCodec != ) {
StateData.CODEC.register(key, dataClass, dataCodec);
}
ComponentType<ChunkStore, T> componentType;
(codec != ) {
componentType = .getChunkStoreRegistry().registerComponent(clazz, key, (BuilderCodec)codec);
} {
componentType = .getChunkStoreRegistry().registerComponent(clazz, () -> {
( );
});
}
.classToComponentType.put(clazz, componentType);
.getChunkStoreRegistry().registerSystem( (componentType), );
.getChunkStoreRegistry().registerSystem( (componentType), );
.getChunkStoreRegistry().registerSystem( (componentType), );
(TickableBlockState.class.isAssignableFrom(clazz)) {
.getChunkStoreRegistry().registerSystem( (componentType), );
}
(SendableBlockState.class.isAssignableFrom(clazz)) {
.getChunkStoreRegistry().registerSystem( (componentType), );
.getChunkStoreRegistry().registerSystem( (componentType), );
}
(clazz, () -> .getState() == PluginState.ENABLED, () -> .unregisterBlockState(clazz, dataClass));
}
}
<T , D > {
(!HytaleServer.get().isShuttingDown()) {
BlockState.CODEC.remove(clazz);
ChunkStore.REGISTRY.unregisterComponent((ComponentType) .classToComponentType.remove(clazz));
(dataClass != ) {
StateData.CODEC.remove(dataClass);
}
}
}
<T > T {
(String)BlockState.CODEC.getIdFor(clazz);
(T) .createBlockState(id, chunk, pos, blockType);
}
BlockState {
Codec<? > codec = BlockState.CODEC.getCodecFor(key);
(codec == ) {
.getLogger().at(Level.WARNING).log( , key);
;
} {
codec.decode( ());
(blockState == ) {
.getLogger().at(Level.WARNING).log( , key);
;
} {
blockState.setPosition(chunk, pos);
(!blockState.initialize(blockType)) {
;
} {
blockState.initialized.set( );
blockState;
}
}
}
}
<T > ComponentType<ChunkStore, T> {
( .isDisabled()) {
;
} {
entityClass == ? : (ComponentType) .classToComponentType.get(entityClass);
}
}
<T > <ChunkStore> {
ComponentType<ChunkStore, T> componentType;
{
.componentType = componentType;
}
Query<ChunkStore> {
.componentType;
}
{
}
{
(T)(holder.getComponent( .componentType));
(reason) {
REMOVE:
(blockState DestroyableBlockState) {
((DestroyableBlockState)blockState).onDestroy();
}
blockState.unloadFromWorld();
;
UNLOAD:
blockState.onUnload();
blockState.unloadFromWorld();
}
}
String {
+ String.valueOf( .componentType) + ;
}
}
<T > <ChunkStore> {
HytaleLogger.forEnclosingClass();
ComponentType<ChunkStore, T> componentType;
{
.componentType = componentType;
}
Query<ChunkStore> {
.componentType;
}
{
(T)(store.getComponent(ref, .componentType));
blockState.getIndex();
blockState.getChunk();
(chunk == ) {
blockState.getBlockPosition();
MathUtil.floor(( )position.getX()) >> ;
MathUtil.floor(( )position.getZ()) >> ;
((ChunkStore)store.getExternalData()).getWorld();
world.getChunkIfInMemory(ChunkUtil.indexChunk(chunkX, chunkZ));
(worldChunk != && !worldChunk.not(ChunkFlag.INIT)) {
(worldChunk.not(ChunkFlag.TICKING)) {
commandBuffer.run((_store) -> {
Holder<ChunkStore> holder = _store.removeEntity(ref, RemoveReason.UNLOAD);
worldChunk.getBlockComponentChunk().addEntityHolder(index, holder);
});
}
ChunkUtil.xFromBlockInColumn(index);
ChunkUtil.yFromBlockInColumn(index);
ChunkUtil.zFromBlockInColumn(index);
blockState.setPosition(worldChunk, (x, y, z));
}
}
((BlockState)blockState).setReference(ref);
(!blockState.initialized.get()) {
(!blockState.initialize(blockState.getChunk().getBlockType(blockState.getPosition()))) {
LOGGER.at(Level.WARNING).log( , blockState, blockState.getPosition(), chunk);
commandBuffer.removeEntity(ref, RemoveReason.REMOVE);
} {
blockState.initialized.set( );
}
}
}
{
}
String {
+ String.valueOf( .componentType) + ;
}
}
<T > <ChunkStore> {
HytaleLogger.forEnclosingClass();
ComponentType<ChunkStore, T> componentType;
Query<ChunkStore> query;
{
.componentType = componentType;
.query = Query.<ChunkStore>and(componentType, BlockModule.BlockStateInfo.getComponentType());
}
Query<ChunkStore> {
.query;
}
Set<Dependency<ChunkStore>> {
RootDependency.firstSet();
}
{
(T)(archetypeChunk.getComponent(index, .componentType));
blockStateComponent != ;
BlockModule. (BlockModule.BlockStateInfo)archetypeChunk.getComponent(index, BlockModule.BlockStateInfo.getComponentType());
blockStateInfoComponent != ;
{
(!blockStateComponent.initialized.get()) {
blockStateComponent.initialized.set( );
(blockStateComponent.getReference() == || !blockStateComponent.getReference().isValid()) {
((BlockState)blockStateComponent).setReference(archetypeChunk.getReferenceTo(index));
}
((ChunkStore)store.getExternalData()).getWorld();
Store<ChunkStore> chunkStore = world.getChunkStore().getStore();
(WorldChunk)chunkStore.getComponent(blockStateInfoComponent.getChunkRef(), WorldChunk.getComponentType());
worldChunkComponent != ;
ChunkUtil.xFromBlockInColumn(blockStateInfoComponent.getIndex());
ChunkUtil.yFromBlockInColumn(blockStateInfoComponent.getIndex());
ChunkUtil.zFromBlockInColumn(blockStateInfoComponent.getIndex());
blockStateComponent.setPosition(worldChunkComponent, (x, y, z));
worldChunkComponent.getBlock(x, y, z);
(BlockType)BlockType.getAssetMap().getAsset(blockIndex);
(!blockStateComponent.initialize(blockType)) {
LOGGER.at(Level.SEVERE).log( , blockStateComponent);
commandBuffer.removeEntity(archetypeChunk.getReferenceTo(index), RemoveReason.REMOVE);
}
}
} (Exception throwable) {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(throwable)).log( , blockStateComponent);
commandBuffer.removeEntity(archetypeChunk.getReferenceTo(index), RemoveReason.REMOVE);
}
}
String {
+ String.valueOf( .componentType) + ;
}
}
<T > <ChunkStore> , MetricSystem<ChunkStore> {
HytaleLogger.forEnclosingClass();
MetricsRegistry<LegacyTickingBlockStateSystem<?>> METRICS_REGISTRY;
ComponentType<ChunkStore, T> componentType;
{
.componentType = componentType;
}
Query<ChunkStore> {
.componentType;
}
{
(T)(archetypeChunk.getComponent(index, .componentType));
{
((TickableBlockState)blockState).tick(dt, index, archetypeChunk, store, commandBuffer);
} (Throwable throwable) {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(throwable)).log( , blockState);
commandBuffer.removeEntity(archetypeChunk.getReferenceTo(index), RemoveReason.REMOVE);
}
}
MetricResults {
METRICS_REGISTRY.toMetricResults( );
}
String {
+ String.valueOf( .componentType) + ;
}
{
METRICS_REGISTRY = ( ()).register( , (o) -> o.componentType.getTypeClass().toString(), Codec.STRING);
}
}
<T > .LoadPacketDataQuerySystem {
ComponentType<ChunkStore, T> componentType;
{
.componentType = componentType;
}
Query<ChunkStore> {
.componentType;
}
{
(SendableBlockState)BlockState.getBlockState(index, archetypeChunk);
(state.canPlayerSee(player)) {
state.sendTo(results);
}
}
String {
+ String.valueOf( .componentType) + ;
}
}
<T > .UnloadPacketDataQuerySystem {
ComponentType<ChunkStore, T> componentType;
{
.componentType = componentType;
}
Query<ChunkStore> {
.componentType;
}
{
(SendableBlockState)BlockState.getBlockState(index, archetypeChunk);
(state.canPlayerSee(player)) {
state.unloadFrom(results);
}
}
String {
+ String.valueOf( .componentType) + ;
}
}
<ChunkStore> {
Query<ChunkStore> query = BlockStateModule.get().getComponentType(ItemContainerState.class);
{
}
Query<ChunkStore> {
query;
}
{
((BlockModule.BlockStateInfoNeedRebuild)((ChunkStore)commandBuffer.getExternalData()).getWorld().getChunkStore().getStore().getResource(BlockModule.BlockStateInfoNeedRebuild.getResourceType())).markAsNeedRebuild();
}
{
((BlockModule.BlockStateInfoNeedRebuild)((ChunkStore)commandBuffer.getExternalData()).getWorld().getChunkStore().getStore().getResource(BlockModule.BlockStateInfoNeedRebuild.getResourceType())).markAsNeedRebuild();
}
String {
;
}
}
}
package com.hypixel.hytale.server.core.universe.world.meta;
import com.hypixel.hytale.registry.Registration;
import java.util.function.BooleanSupplier;
import javax.annotation.Nonnull;
public class BlockStateRegistration extends Registration {
private final Class<? extends BlockState > blockStateClass;
public BlockStateRegistration (Class<? extends BlockState> blockStateClass, BooleanSupplier isEnabled, Runnable unregister) {
super (isEnabled, unregister);
this .blockStateClass = blockStateClass;
}
public BlockStateRegistration (@Nonnull BlockStateRegistration registration, BooleanSupplier isEnabled, Runnable unregister) {
super (isEnabled, unregister);
this .blockStateClass = registration.blockStateClass;
}
public Class<? extends BlockState > getBlockStateClass() {
return this .blockStateClass;
}
@Nonnull
public String toString () {
String var10000 = String.valueOf(this .blockStateClass);
return "BlockStateRegistration{blockStateClass=" + var10000 + ", " + .toString() + ;
}
}
package com.hypixel.hytale.server.core.universe.world.meta;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.function.consumer.BooleanConsumer;
import com.hypixel.hytale.registry.Registry;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.StateData;
import java.util.List;
import java.util.function.BooleanSupplier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockStateRegistry extends Registry <BlockStateRegistration> {
public BlockStateRegistry (@Nonnull List<BooleanConsumer> registrations, BooleanSupplier precondition, String preconditionMessage) {
super (registrations, precondition, preconditionMessage, BlockStateRegistration::new );
}
@Nullable
public <T extends BlockState > BlockStateRegistration registerBlockState (@Nonnull Class<T> clazz, @Nonnull String key, Codec<T> codec) {
this .checkPrecondition();
return (BlockStateRegistration)this .register(BlockStateModule.get().registerBlockState(clazz, key, codec));
}
@Nullable
public <T extends BlockState , D extends StateData > BlockStateRegistration registerBlockState {
.checkPrecondition();
(BlockStateRegistration) .register(BlockStateModule.get().registerBlockState(clazz, key, codec, dataClass, dataCodec));
}
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.RefSystem;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.Direction;
import com.hypixel.hytale.protocol.Position;
import com.hypixel.hytale.protocol.Transform;
import com.hypixel.hytale.protocol.packets.worldmap.ContextMenuItem;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
import com.hypixel.hytale.server.core.modules.block.BlockModule;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
it.unimi.dsi.fastutil.longs.Long2ObjectMap;
javax.annotation.Nonnull;
javax.annotation.Nullable;
<ChunkStore> {
BuilderCodec<BlockMapMarker> CODEC;
String name;
String icon;
{
}
{
.name = name;
.icon = icon;
}
ComponentType<ChunkStore, BlockMapMarker> {
BlockModule.get().getBlockMapMarkerComponentType();
}
String {
.name;
}
String {
.icon;
}
Component<ChunkStore> {
( .name, .icon);
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(BlockMapMarker.class, BlockMapMarker:: ).append( ( , Codec.STRING), (o, v) -> o.name = v, (o) -> o.name).addValidator(Validators.nonNull()).add()).append( ( , Codec.STRING), (o, v) -> o.icon = v, (o) -> o.icon).addValidator(Validators.nonNull()).add()).build();
}
<ChunkStore> {
ComponentType<ChunkStore, BlockMapMarker> COMPONENT_TYPE = BlockMapMarker.getComponentType();
ResourceType<ChunkStore, BlockMapMarkersResource> BLOCK_MAP_MARKERS_RESOURCE_TYPE = BlockMapMarkersResource.getResourceType();
{
}
{
BlockModule. (BlockModule.BlockStateInfo)commandBuffer.getComponent(ref, BlockModule.BlockStateInfo.getComponentType());
blockInfo != ;
Ref<ChunkStore> chunkRef = blockInfo.getChunkRef();
(chunkRef.isValid()) {
(BlockChunk)commandBuffer.getComponent(chunkRef, BlockChunk.getComponentType());
blockChunk != ;
(BlockMapMarker)commandBuffer.getComponent(ref, COMPONENT_TYPE);
blockMapMarker != ;
(WorldChunk)commandBuffer.getComponent(chunkRef, WorldChunk.getComponentType());
(ChunkUtil.worldCoordFromLocalCoord(wc.getX(), ChunkUtil.xFromBlockInColumn(blockInfo.getIndex())), ChunkUtil.yFromBlockInColumn(blockInfo.getIndex()), ChunkUtil.worldCoordFromLocalCoord(wc.getZ(), ChunkUtil.zFromBlockInColumn(blockInfo.getIndex())));
(BlockMapMarkersResource)commandBuffer.getResource(BLOCK_MAP_MARKERS_RESOURCE_TYPE);
resource.addMarker(blockPosition, blockMapMarker.getName(), blockMapMarker.getIcon());
}
}
{
(reason == RemoveReason.REMOVE) {
BlockModule. (BlockModule.BlockStateInfo)commandBuffer.getComponent(ref, BlockModule.BlockStateInfo.getComponentType());
blockInfo != ;
Ref<ChunkStore> chunkRef = blockInfo.getChunkRef();
(chunkRef.isValid()) {
(WorldChunk)commandBuffer.getComponent(chunkRef, WorldChunk.getComponentType());
(ChunkUtil.worldCoordFromLocalCoord(wc.getX(), ChunkUtil.xFromBlockInColumn(blockInfo.getIndex())), ChunkUtil.yFromBlockInColumn(blockInfo.getIndex()), ChunkUtil.worldCoordFromLocalCoord(wc.getZ(), ChunkUtil.zFromBlockInColumn(blockInfo.getIndex())));
(BlockMapMarkersResource)commandBuffer.getResource(BLOCK_MAP_MARKERS_RESOURCE_TYPE);
resource.removeMarker(blockPosition);
}
}
}
Query<ChunkStore> {
COMPONENT_TYPE;
}
}
.MarkerProvider {
();
{
}
{
(BlockMapMarkersResource)world.getChunkStore().getStore().getResource(BlockMapMarkersResource.getResourceType());
Long2ObjectMap<BlockMapMarkersResource.BlockMapMarkerData> markers = resource.getMarkers();
(BlockMapMarkersResource.BlockMapMarkerData markerData : markers.values()) {
markerData.getPosition();
();
transform.position = (( )(( )position.getX() + ), ( )position.getY(), ( )(( )position.getZ() + ));
transform.orientation = ( , , );
(markerData.getMarkerId(), markerData.getName(), markerData.getIcon(), transform, (ContextMenuItem[]) );
tracker.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, marker);
}
}
}
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.map.MapCodec;
import com.hypixel.hytale.component.Resource;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.math.block.BlockUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.modules.block.BlockModule;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Nonnull;
public class BlockMapMarkersResource implements Resource <ChunkStore> {
public static final BuilderCodec<BlockMapMarkersResource> CODEC;
private Long2ObjectMap<BlockMapMarkerData> markers = new Long2ObjectOpenHashMap <BlockMapMarkerData>();
public BlockMapMarkersResource () {
}
public BlockMapMarkersResource (Long2ObjectMap<BlockMapMarkerData> markers) {
this .markers = markers;
}
public static ResourceType<ChunkStore, BlockMapMarkersResource> {
BlockModule.get().getBlockMapMarkersResourceType();
}
Long2ObjectMap<BlockMapMarkerData> {
.markers;
}
{
BlockUtil.pack(position);
.markers.put(key, (position, name, icon, UUID.randomUUID().toString()));
}
{
BlockUtil.pack(position);
.markers.remove(key);
}
Resource<ChunkStore> {
( ( .markers));
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(BlockMapMarkersResource.class, BlockMapMarkersResource:: ).append( ( , (BlockMapMarkersResource.BlockMapMarkerData.CODEC, HashMap:: ), ), (o, markersMap) -> {
(markersMap != ) {
(Map.Entry<String, BlockMapMarkerData> entry : markersMap.entrySet()) {
o.markers.put(Long.valueOf((String)entry.getKey()), (BlockMapMarkerData)entry.getValue());
}
}
}, (o) -> {
HashMap<String, BlockMapMarkerData> returnMap = (o.markers.size());
(Map.Entry<Long, BlockMapMarkerData> entry : o.markers.entrySet()) {
returnMap.put(String.valueOf(entry.getKey()), (BlockMapMarkerData)entry.getValue());
}
returnMap;
}).add()).build();
}
{
BuilderCodec<BlockMapMarkerData> CODEC;
Vector3i position;
String name;
String icon;
String markerId;
{
}
{
.position = position;
.name = name;
.icon = icon;
.markerId = markerId;
}
Vector3i {
.position;
}
String {
.name;
}
String {
.icon;
}
String {
.markerId;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(BlockMapMarkerData.class, BlockMapMarkerData:: ).append( ( , Vector3i.CODEC), (o, v) -> o.position = v, (o) -> o.position).add()).append( ( , Codec.STRING), (o, v) -> o.name = v, (o) -> o.name).add()).append( ( , Codec.STRING), (o, v) -> o.icon = v, (o) -> o.icon).add()).append( ( , Codec.STRING), (o, v) -> o.markerId = v, (o) -> o.markerId).add()).build();
}
}
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public interface BreakValidatedBlockState {
boolean canDestroy (@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) ;
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
@Deprecated
public interface DestroyableBlockState {
void onDestroy () ;
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
import com.hypixel.hytale.server.core.inventory.container.ItemContainer;
public interface ItemContainerBlockState {
ItemContainer getItemContainer () ;
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.event.EventPriority;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.StateData;
import com.hypixel.hytale.server.core.entity.entities.player.windows.ContainerBlockWindow;
import com.hypixel.hytale.server.core.entity.entities.player.windows.WindowManager;
import com.hypixel.hytale.server.core.inventory.ItemStack;
import com.hypixel.hytale.server.core.inventory.container.ItemContainer;
import com.hypixel.hytale.server.core.inventory.container.SimpleItemContainer;
import com.hypixel.hytale.server.core.modules.entity.item.ItemComponent;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.meta.BlockState;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
java.util.List;
java.util.Map;
java.util.UUID;
java.util.concurrent.ConcurrentHashMap;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
, DestroyableBlockState, MarkerBlockState {
Codec<ItemContainerState> CODEC;
Map<UUID, ContainerBlockWindow> windows = ();
custom;
;
String droplist;
SimpleItemContainer itemContainer;
WorldMapManager.MarkerReference marker;
{
}
{
(! .initialize(blockType)) {
;
} ( .custom) {
;
} {
;
blockType.getState();
(var4 ItemContainerStateData) {
(ItemContainerStateData)var4;
capacity = itemContainerStateData.getCapacity();
}
List<ItemStack> remainder = <ItemStack>();
.itemContainer = (SimpleItemContainer)ItemContainer.ensureContainerCapacity( .itemContainer, capacity, SimpleItemContainer:: , remainder);
.itemContainer.registerChangeEvent(EventPriority.LAST, ::onItemChange);
(!remainder.isEmpty()) {
.getChunk();
chunk.getWorld();
Store<EntityStore> store = world.getEntityStore().getStore();
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.WARNING).withCause( ())).log( , remainder.size(), blockType.getId(), chunk.getWorld().getName(), chunk, .getPosition());
.getBlockPosition();
Holder<EntityStore>[] itemEntityHolders = ItemComponent.generateItemDrops(store, remainder, blockPosition.toVector3d(), Vector3f.ZERO);
store.addEntities(itemEntityHolders, AddReason.SPAWN);
}
;
}
}
{
;
}
{
}
{
WindowManager.closeAndRemoveAll( .windows);
.getChunk();
chunk.getWorld();
Store<EntityStore> store = world.getEntityStore().getStore();
List<ItemStack> allItemStacks = .itemContainer.dropAllItemStacks();
.getBlockPosition().toVector3d().add( , , );
Holder<EntityStore>[] itemEntityHolders = ItemComponent.generateItemDrops(store, allItemStacks, dropPosition, Vector3f.ZERO);
(itemEntityHolders.length > ) {
world.execute(() -> store.addEntities(itemEntityHolders, AddReason.SPAWN));
}
( .marker != ) {
.marker.remove();
}
}
{
.custom = custom;
.markNeedsSave();
}
{
.allowViewing = allowViewing;
.markNeedsSave();
}
{
.allowViewing;
}
{
.itemContainer = itemContainer;
.markNeedsSave();
}
String {
.droplist;
}
{
.droplist = droplist;
.markNeedsSave();
}
{
.marker = marker;
.markNeedsSave();
}
Map<UUID, ContainerBlockWindow> {
.windows;
}
ItemContainer {
.itemContainer;
}
{
.markNeedsSave();
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(ItemContainerState.class, ItemContainerState:: , BlockState.BASE_CODEC).addField( ( , Codec.BOOLEAN), (state, o) -> state.custom = o, (state) -> state.custom)).addField( ( , Codec.BOOLEAN), (state, o) -> state.allowViewing = o, (state) -> state.allowViewing)).addField( ( , Codec.STRING), (state, o) -> state.droplist = o, (state) -> state.droplist)).addField( ( , WorldMapManager.MarkerReference.CODEC), (state, o) -> state.marker = o, (state) -> state.marker)).addField( ( , SimpleItemContainer.CODEC), (state, o) -> state.itemContainer = o, (state) -> state.itemContainer)).build();
}
{
BuilderCodec<ItemContainerStateData> CODEC;
;
{
}
{
.capacity;
}
String {
.capacity;
+ var10000 + + .toString();
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(ItemContainerStateData.class, ItemContainerStateData:: , StateData.DEFAULT_CODEC).appendInherited( ( , Codec.INTEGER), (t, i) -> t.capacity = i.shortValue(), (t) -> Integer.valueOf(t.capacity), (o, p) -> o.capacity = p.capacity).add()).build();
}
}
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.protocol.packets.interface_.CustomPageLifetime;
import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType;
import com.hypixel.hytale.protocol.packets.interface_.Page;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.entities.player.pages.InteractiveCustomUIPage;
import com.hypixel.hytale.server.core.modules.block.BlockModule;
import com.hypixel.hytale.server.core.ui.builder.EventData;
import com.hypixel.hytale.server.core.ui.builder.UICommandBuilder;
import com.hypixel.hytale.server.core.ui.builder.UIEventBuilder;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class LaunchPad implements Component <ChunkStore> {
private static final int ;
BuilderCodec<LaunchPad> CODEC;
velocityX;
velocityY;
velocityZ;
playersOnly;
ComponentType<ChunkStore, LaunchPad> {
BlockModule.get().getLaunchPadComponentType();
}
{
}
{
.velocityX = velocityX;
.velocityY = velocityY;
.velocityZ = velocityZ;
.playersOnly = playersOnly;
}
{
.velocityX;
}
{
.velocityY;
}
{
.velocityZ;
}
{
.playersOnly;
}
{
Math.max(Math.min(velocity, ), - );
}
String {
+ .velocityX + + .velocityY + + .velocityZ + + .playersOnly + ;
}
Component<ChunkStore> {
( .velocityX, .velocityY, .velocityZ, .playersOnly);
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(LaunchPad.class, LaunchPad:: ).append( ( , Codec.DOUBLE), (state, d) -> state.velocityX = d.floatValue(), (state) -> ( )state.velocityX).documentation( ).add()).append( ( , Codec.DOUBLE), (state, d) -> state.velocityY = d.floatValue(), (state) -> ( )state.velocityY).documentation( ).add()).append( ( , Codec.DOUBLE), (state, d) -> state.velocityZ = d.floatValue(), (state) -> ( )state.velocityZ).documentation( ).add()).append( ( , Codec.BOOLEAN), (state, b) -> state.playersOnly = b, (state) -> state.playersOnly).documentation( ).add()).build();
}
<LaunchPadSettingsPageEventData> {
Ref<ChunkStore> ref;
{
(playerRef, lifetime, LaunchPad.LaunchPadSettingsPage.LaunchPadSettingsPageEventData.CODEC);
.ref = ref;
}
{
commandBuilder.append( );
((EntityStore)store.getExternalData()).getWorld().getChunkStore();
(LaunchPad)chunkStore.getStore().getComponent( .ref, LaunchPad.getComponentType());
commandBuilder.set( , launchPadComponent.velocityX);
commandBuilder.set( , launchPadComponent.velocityY);
commandBuilder.set( , launchPadComponent.velocityZ);
commandBuilder.set( , launchPadComponent.playersOnly);
eventBuilder.addEventBinding(CustomUIEventBindingType.Activating, , ( ()).append( , ).append( , ).append( , ).append( , ));
}
{
((EntityStore)store.getExternalData()).getWorld().getChunkStore();
(LaunchPad)chunkStore.getStore().getComponent( .ref, LaunchPad.getComponentType());
launchPadComponent != ;
BlockModule. (BlockModule.BlockStateInfo)chunkStore.getStore().getComponent( .ref, BlockModule.BlockStateInfo.getComponentType());
blockStateInfoComponent != ;
launchPadComponent.velocityX = LaunchPad.clampVelocity(( )data.x);
launchPadComponent.velocityY = LaunchPad.clampVelocity(( )data.y);
launchPadComponent.velocityZ = LaunchPad.clampVelocity(( )data.z);
launchPadComponent.playersOnly = data.playersOnly;
(WorldChunk)chunkStore.getStore().getComponent(blockStateInfoComponent.getChunkRef(), WorldChunk.getComponentType());
worldChunkComponent != ;
worldChunkComponent.markNeedsSaving();
(Player)store.getComponent(ref, Player.getComponentType());
playerComponent != ;
playerComponent.getPageManager().setPage(ref, store, Page.None);
}
{
;
;
;
;
BuilderCodec<LaunchPadSettingsPageEventData> CODEC;
x;
y;
z;
playersOnly;
{
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(LaunchPadSettingsPageEventData.class, LaunchPadSettingsPageEventData:: ).addField( ( , Codec.DOUBLE), (entry, s) -> entry.x = s, (entry) -> entry.x)).addField( ( , Codec.DOUBLE), (entry, s) -> entry.y = s, (entry) -> entry.y)).addField( ( , Codec.DOUBLE), (entry, s) -> entry.z = s, (entry) -> entry.z)).addField( ( , Codec.BOOLEAN), (entry, s) -> entry.playersOnly = s, (entry) -> entry.playersOnly)).build();
}
}
}
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
public interface MarkerBlockState {
void setMarker (WorldMapManager.MarkerReference var1) ;
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.core.universe.world.meta.BlockState;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public interface PlacedByBlockState {
void placedBy (@Nonnull Ref<EntityStore> var1, @Nonnull String var2, @Nonnull BlockState var3, @Nonnull ComponentAccessor<EntityStore> var4) ;
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.RefSystem;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerRespawnPointData;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldData;
import com.hypixel.hytale.server.core.modules.block.BlockModule;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import java.util.UUID;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class <ChunkStore> {
BuilderCodec<RespawnBlock> CODEC;
UUID ownerUUID;
ComponentType<ChunkStore, RespawnBlock> {
BlockModule.get().getRespawnBlockComponentType();
}
{
}
{
.ownerUUID = ownerUUID;
}
UUID {
.ownerUUID;
}
{
.ownerUUID = ownerUUID;
}
Component<ChunkStore> {
( .ownerUUID);
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(RespawnBlock.class, RespawnBlock:: ).append( ( , Codec.UUID_BINARY), (respawnBlockState, uuid) -> respawnBlockState.ownerUUID = uuid, (respawnBlockState) -> respawnBlockState.ownerUUID).add()).build();
}
<ChunkStore> {
ComponentType<ChunkStore, RespawnBlock> COMPONENT_TYPE = RespawnBlock.getComponentType();
ComponentType<ChunkStore, BlockModule.BlockStateInfo> BLOCK_INFO_TYPE = BlockModule.BlockStateInfo.getComponentType();
Query<ChunkStore> QUERY;
{
}
{
}
{
(reason != RemoveReason.UNLOAD) {
(RespawnBlock)commandBuffer.getComponent(ref, COMPONENT_TYPE);
respawnState != ;
(respawnState.ownerUUID != ) {
BlockModule. (BlockModule.BlockStateInfo)commandBuffer.getComponent(ref, BLOCK_INFO_TYPE);
blockInfo != ;
Universe.get().getPlayer(respawnState.ownerUUID);
(playerRef == ) {
HytaleLogger.getLogger().at(Level.WARNING).log( );
} {
(Player)playerRef.getComponent(Player.getComponentType());
Ref<ChunkStore> chunkRef = blockInfo.getChunkRef();
(chunkRef != && chunkRef.isValid()) {
player.getPlayerConfigData().getPerWorldData(((ChunkStore)store.getExternalData()).getWorld().getName());
PlayerRespawnPointData[] respawnPoints = playerWorldData.getRespawnPoints();
(WorldChunk)commandBuffer.getComponent(chunkRef, WorldChunk.getComponentType());
(ChunkUtil.worldCoordFromLocalCoord(wc.getX(), ChunkUtil.xFromBlockInColumn(blockInfo.getIndex())), ChunkUtil.yFromBlockInColumn(blockInfo.getIndex()), ChunkUtil.worldCoordFromLocalCoord(wc.getZ(), ChunkUtil.zFromBlockInColumn(blockInfo.getIndex())));
( ; i < respawnPoints.length; ++i) {
respawnPoints[i];
(respawnPoint.getBlockPosition().equals(blockPosition)) {
playerWorldData.setRespawnPoints((PlayerRespawnPointData[])ArrayUtil.remove(respawnPoints, i));
;
}
}
}
}
}
}
}
Query<ChunkStore> {
QUERY;
}
{
QUERY = Query.<ChunkStore>and(COMPONENT_TYPE, BLOCK_INFO_TYPE);
}
}
}
package com.hypixel.hytale.server.core.universe.world.meta.state;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import java.util.List;
@Deprecated
public interface SendableBlockState {
void sendTo (List<Packet> var1) ;
void unloadFrom (List<Packet> var1) ;
default boolean canPlayerSee (PlayerRef player) {
return true ;
}
}
package com.hypixel.hytale.server.core.universe.world.meta.state.exceptions;
public class NoSuchBlockStateException extends Exception {
public NoSuchBlockStateException (String message) {
super (message);
}
public NoSuchBlockStateException (Throwable cause) {
super (cause);
}
}
com/hypixel/hytale/server/core/universe/world/npc/INonPlayerCharacter.java
package com.hypixel.hytale.server.core.universe.world.npc;
public interface INonPlayerCharacter {
String getNPCTypeId () ;
int getNPCTypeIndex () ;
}
com/hypixel/hytale/server/core/universe/world/path/IPath.java
package com.hypixel.hytale.server.core.universe.world.path;
import java.util.List;
import java.util.UUID;
import javax.annotation.Nullable;
public interface IPath <Waypoint extends IPathWaypoint > {
@Nullable
UUID getId () ;
@Nullable
String getName () ;
List<Waypoint> getPathWaypoints () ;
int length () ;
Waypoint get (int var1) ;
}
com/hypixel/hytale/server/core/universe/world/path/IPathWaypoint.java
package com.hypixel.hytale.server.core.universe.world.path;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public interface IPathWaypoint {
int getOrder () ;
Vector3d getWaypointPosition (@Nonnull ComponentAccessor<EntityStore> var1) ;
Vector3f getWaypointRotation (@Nonnull ComponentAccessor<EntityStore> var1) ;
double getPauseTime () ;
float getObservationAngle () ;
}
com/hypixel/hytale/server/core/universe/world/path/SimplePathWaypoint.java
package com.hypixel.hytale.server.core.universe.world.path;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class SimplePathWaypoint implements IPathWaypoint {
private int order;
private Transform transform;
public SimplePathWaypoint (int order, Transform transform) {
this .order = order;
this .transform = transform;
}
public int getOrder () {
return this .order;
}
@Nonnull
public Vector3d getWaypointPosition (@Nonnull ComponentAccessor<EntityStore> componentAccessor) {
return this .transform.getPosition();
}
@Nonnull
public Vector3f getWaypointRotation (@Nonnull ComponentAccessor<EntityStore> componentAccessor) {
return this .transform.getRotation();
}
public {
;
}
{
;
}
}
com/hypixel/hytale/server/core/universe/world/path/WorldPath.java
package com.hypixel.hytale.server.core.universe.world.path;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.math.vector.Transform;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import javax.annotation.Nonnull;
public class WorldPath implements IPath <SimplePathWaypoint> {
public static final BuilderCodec<WorldPath> CODEC;
protected UUID id;
protected String name;
protected List<Transform> waypoints = Collections.emptyList();
protected List<SimplePathWaypoint> simpleWaypoints;
protected WorldPath () {
}
public WorldPath (String name, List<Transform> waypoints) {
this .id = UUID.randomUUID();
this .name = name;
this .waypoints = waypoints;
}
public UUID getId () {
return this .id;
}
public String getName () {
.name;
}
List<SimplePathWaypoint> {
( .simpleWaypoints == || .simpleWaypoints.size() != .waypoints.size()) {
.simpleWaypoints = <SimplePathWaypoint>();
( ; i < .waypoints.size(); ++i) {
.simpleWaypoints.add( (i, (Transform) .waypoints.get(i)));
}
}
.simpleWaypoints = Collections.unmodifiableList( .simpleWaypoints);
.simpleWaypoints;
}
{
.waypoints.size();
}
SimplePathWaypoint {
List<SimplePathWaypoint> path = .getPathWaypoints();
(SimplePathWaypoint)path.get(index);
}
List<Transform> {
.waypoints;
}
String {
.name;
+ var10000 + + String.valueOf( .waypoints) + ;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(WorldPath.class, WorldPath:: ).addField( ( , Codec.UUID_BINARY), (worldPath, uuid) -> worldPath.id = uuid, (worldPath) -> worldPath.id)).addField( ( , Codec.STRING), (worldPath, s) -> worldPath.name = s, (worldPath) -> worldPath.name)).addField( ( , (Transform.CODEC, (x$ ) -> [x$ ])), (worldPath, wayPoints) -> worldPath.waypoints = List.of(wayPoints), (worldPath) -> (Transform[])worldPath.waypoints.toArray((x$ ) -> [x$ ]))).build();
}
}
com/hypixel/hytale/server/core/universe/world/path/WorldPathChangedEvent.java
package com.hypixel.hytale.server.core.universe.world.path;
import com.hypixel.hytale.event.IEvent;
import java.util.Objects;
import javax.annotation.Nonnull;
public class WorldPathChangedEvent implements IEvent <Void> {
private WorldPath worldPath;
public WorldPathChangedEvent (WorldPath worldPath) {
Objects.requireNonNull(worldPath, "World path must not be null in an event" );
this .worldPath = worldPath;
}
public WorldPath getWorldPath () {
return this .worldPath;
}
@Nonnull
public String toString () {
return "WorldPathChangedEvent{worldPath=" + String.valueOf(this .worldPath) + "}" ;
}
}
com/hypixel/hytale/server/core/universe/world/path/WorldPathConfig.java
package com.hypixel.hytale.server.core.universe.world.path;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.map.MapCodec;
import com.hypixel.hytale.codec.util.RawJsonReader;
import com.hypixel.hytale.event.IEventDispatcher;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.util.BsonUtil;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonValue;
public class WorldPathConfig {
public static final BuilderCodec<WorldPathConfig> CODEC;
protected Map<String, WorldPath> paths = new ConcurrentHashMap ();
public WorldPathConfig () {
}
public WorldPath getPath (String name) {
return (WorldPath) .paths.get(name);
}
Map<String, WorldPath> {
Collections.unmodifiableMap( .paths);
}
WorldPath {
Objects.requireNonNull(worldPath);
IEventDispatcher<WorldPathChangedEvent, WorldPathChangedEvent> dispatcher = HytaleServer.get().getEventBus().dispatchFor(WorldPathChangedEvent.class);
(dispatcher.hasListener()) {
dispatcher.dispatch( (worldPath));
}
(WorldPath) .paths.put(worldPath.getName(), worldPath);
}
WorldPath {
Objects.requireNonNull(path);
(WorldPath) .paths.remove(path);
}
CompletableFuture<Void> {
CODEC.encode( );
BsonUtil.writeDocument(world.getSavePath().resolve( ), bsonValue.asDocument());
}
CompletableFuture<WorldPathConfig> {
world.getSavePath().resolve( );
world.getSavePath().resolve( );
(Files.exists(oldPath, [ ]) && !Files.exists(path, [ ])) {
{
Files.move(oldPath, path);
} (IOException var4) {
}
}
CompletableFuture.supplyAsync(() -> {
(WorldPathConfig)RawJsonReader.readSyncWithBak(path, CODEC, HytaleLogger.getLogger());
config != ? config : ();
});
}
String {
+ String.valueOf( .paths) + ;
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(WorldPathConfig.class, WorldPathConfig:: ).addField( ( , (WorldPath.CODEC, ConcurrentHashMap:: , )), (config, paths) -> config.paths = paths, (config) -> config.paths)).build();
}
}
com/hypixel/hytale/server/core/universe/world/spawn/FitToHeightMapSpawnProvider.java
package com.hypixel.hytale.server.core.universe.world.spawn;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import java.util.UUID;
import javax.annotation.Nonnull;
public class FitToHeightMapSpawnProvider implements ISpawnProvider {
@Nonnull
public static BuilderCodec<FitToHeightMapSpawnProvider> CODEC;
private ISpawnProvider spawnProvider;
protected FitToHeightMapSpawnProvider () {
}
public FitToHeightMapSpawnProvider (@Nonnull ISpawnProvider spawnProvider) {
this .spawnProvider = spawnProvider;
}
@Nonnull
public Transform getSpawnPoint (@Nonnull World world, @Nonnull UUID uuid) {
Transform spawnPoint = this .spawnProvider.getSpawnPoint(world, uuid);
Vector3d position spawnPoint.getPosition();
(position.getY() < ) {
world.getNonTickingChunk(ChunkUtil.indexChunkFromBlock(position.getX(), position.getZ()));
(worldChunk != ) {
MathUtil.floor(position.getX());
MathUtil.floor(position.getZ());
position.setY(( )(worldChunk.getHeight(x, z) + ));
}
}
spawnPoint;
}
Transform[] getSpawnPoints() {
.spawnProvider.getSpawnPoints();
}
{
.spawnProvider.isWithinSpawnDistance(position, distance);
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(FitToHeightMapSpawnProvider.class, FitToHeightMapSpawnProvider:: ).documentation( )).append( ( , ISpawnProvider.CODEC), (o, i) -> o.spawnProvider = i, (o) -> o.spawnProvider).documentation( ).add()).build();
}
}
com/hypixel/hytale/server/core/universe/world/spawn/GlobalSpawnProvider.java
package com.hypixel.hytale.server.core.universe.world.spawn;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.universe.world.World;
import java.util.UUID;
import javax.annotation.Nonnull;
public class GlobalSpawnProvider implements ISpawnProvider {
@Nonnull
public static BuilderCodec<GlobalSpawnProvider> CODEC;
private Transform spawnPoint;
public GlobalSpawnProvider () {
}
public GlobalSpawnProvider (@Nonnull Transform spawnPoint) {
this .spawnPoint = spawnPoint;
}
public Transform getSpawnPoint (@Nonnull World world, @Nonnull UUID uuid) {
return this .spawnPoint.clone();
}
@Nonnull
public Transform[] getSpawnPoints() {
return new Transform []{this .spawnPoint};
}
public boolean isWithinSpawnDistance ( Vector3d position, distance) {
position.distanceSquaredTo( .spawnPoint.getPosition()) < distance * distance;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(GlobalSpawnProvider.class, GlobalSpawnProvider:: ).documentation( )).append( ( , Transform.CODEC_DEGREES), (o, i) -> o.spawnPoint = i, (o) -> o.spawnPoint).documentation( ).add()).build();
}
}
com/hypixel/hytale/server/core/universe/world/spawn/ISpawnProvider.java
package com.hypixel.hytale.server.core.universe.world.spawn;
import com.hypixel.hytale.codec.lookup.BuilderCodecMapCodec;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.entity.Entity;
import com.hypixel.hytale.server.core.entity.UUIDComponent;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import java.util.UUID;
import javax.annotation.Nonnull;
public interface ISpawnProvider {
@Nonnull
BuilderCodecMapCodec<ISpawnProvider> CODEC;
default Transform getSpawnPoint (@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) {
UUIDComponent uuidComponent = (UUIDComponent)componentAccessor.getComponent(ref, UUIDComponent.getComponentType());
if (!null .$assertionsDisabled && uuidComponent == null ) {
throw new AssertionError ();
} else {
World world = ((EntityStore)componentAccessor.getExternalData()).getWorld();
return this .getSpawnPoint(world, uuidComponent.getUuid());
}
}
Transform {
.getSpawnPoint(entity.getWorld(), entity.getUuid());
}
Transform ;
Transform[] getSpawnPoints();
;
{
( .$assertionsDisabled) {
}
CODEC = <ISpawnProvider>( );
}
}
com/hypixel/hytale/server/core/universe/world/spawn/IndividualSpawnProvider.java
package com.hypixel.hytale.server.core.universe.world.spawn;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.math.util.HashUtil;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.universe.world.World;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class IndividualSpawnProvider implements ISpawnProvider {
@Nonnull
public static BuilderCodec<IndividualSpawnProvider> CODEC;
private Transform[] spawnPoints;
public IndividualSpawnProvider () {
}
public IndividualSpawnProvider (@Nonnull Transform spawnPoint) {
this .spawnPoints = new Transform [1 ];
this .spawnPoints[0 ] = spawnPoint;
}
public IndividualSpawnProvider (@Nonnull Transform[] spawnPoints) {
this .spawnPoints = spawnPoints;
}
public Transform getSpawnPoint {
.spawnPoints[Math.abs(( )HashUtil.hashUuid(uuid)) % .spawnPoints.length].clone();
}
Transform[] getSpawnPoints() {
.spawnPoints;
}
Transform {
.spawnPoints.length == ? : .spawnPoints[ ];
}
{
distance * distance;
(Transform point : .spawnPoints) {
(position.distanceSquaredTo(point.getPosition()) < distanceSquared) {
;
}
}
;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(IndividualSpawnProvider.class, IndividualSpawnProvider:: ).documentation( )).append( ( , (Transform.CODEC, (x$ ) -> [x$ ])), (o, i) -> o.spawnPoints = i, (o) -> o.spawnPoints).documentation( ).add()).build();
}
}
com/hypixel/hytale/server/core/universe/world/storage/BufferChunkLoader.java
package com.hypixel.hytale.server.core.universe.world.storage;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.util.BsonUtil;
import java.nio.ByteBuffer;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import org.bson.BsonDocument;
public abstract class BufferChunkLoader implements IChunkLoader {
@Nonnull
private final Store<ChunkStore> store;
public BufferChunkLoader (@Nonnull Store<ChunkStore> store) {
Objects.requireNonNull(store);
this .store = store;
}
@Nonnull
public Store<ChunkStore> getStore () {
return this .store;
}
public abstract CompletableFuture<ByteBuffer> loadBuffer (int var1, int var2) ;
@Nonnull
public CompletableFuture<Holder<ChunkStore>> loadHolder (int x, int z) {
return .loadBuffer(x, z).thenApplyAsync((buffer) -> {
(buffer == ) {
;
} {
BsonUtil.readFromBuffer(buffer);
Holder<ChunkStore> holder = ChunkStore.REGISTRY.deserialize(bsonDocument);
(WorldChunk)holder.getComponent(WorldChunk.getComponentType());
worldChunkComponent != ;
worldChunkComponent.loadFromHolder(((ChunkStore) .store.getExternalData()).getWorld(), x, z, holder);
holder;
}
});
}
}
com/hypixel/hytale/server/core/universe/world/storage/BufferChunkSaver.java
package com.hypixel.hytale.server.core.universe.world.storage;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.util.BsonUtil;
import java.nio.ByteBuffer;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import org.bson.BsonDocument;
public abstract class BufferChunkSaver implements IChunkSaver {
@Nonnull
private final Store<ChunkStore> store;
protected BufferChunkSaver (@Nonnull Store<ChunkStore> store) {
Objects.requireNonNull(store);
this .store = store;
}
@Nonnull
public Store<ChunkStore> getStore () {
return this .store;
}
@Nonnull
public abstract CompletableFuture<Void> saveBuffer (int var1, int var2, @Nonnull ByteBuffer var3) ;
@Nonnull
public abstract CompletableFuture<Void> removeBuffer (int var1, int var2) ;
CompletableFuture<Void> {
ChunkStore.REGISTRY.serialize(holder);
ByteBuffer.wrap(BsonUtil.writeToBytes(document));
.saveBuffer(x, z, buffer);
}
CompletableFuture<Void> {
.removeBuffer(x, z);
}
}
com/hypixel/hytale/server/core/universe/world/storage/ChunkStore.java
package com.hypixel.hytale.server.core.universe.world.storage;
import com.hypixel.fastutil.longs.Long2ObjectConcurrentHashMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.store.CodecKey;
import com.hypixel.hytale.codec.store.CodecStore;
import com.hypixel.hytale.common.util.FormatUtil;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.IResourceStorage;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.SystemGroup;
import com.hypixel.hytale.component.SystemType;
import com.hypixel.hytale.component.system.StoreSystem;
import com.hypixel.hytale.component.system.data.EntityDataSystem;
import com.hypixel.hytale.event.IEventDispatcher;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.metrics.MetricProvider;
import com.hypixel.hytale.metrics.MetricsRegistry;
import com.hypixel.hytale.protocol.Packet;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldProvider;
com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn;
com.hypixel.hytale.server.core.universe.world.chunk.ChunkFlag;
com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
com.hypixel.hytale.server.core.universe.world.events.ChunkPreLoadProcessEvent;
com.hypixel.hytale.server.core.universe.world.storage.component.ChunkSavingSystems;
com.hypixel.hytale.server.core.universe.world.storage.component.ChunkUnloadingSystem;
com.hypixel.hytale.server.core.universe.world.storage.provider.IChunkStorageProvider;
com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedChunk;
com.hypixel.hytale.server.core.universe.world.worldgen.IWorldGen;
com.hypixel.hytale.sneakythrow.SneakyThrow;
it.unimi.dsi.fastutil.longs.Long2ObjectMap;
it.unimi.dsi.fastutil.longs.LongSet;
it.unimi.dsi.fastutil.longs.LongSets;
java.io.IOException;
java.util.Objects;
java.util.concurrent.CompletableFuture;
java.util.concurrent.TimeUnit;
java.util.concurrent.atomic.AtomicInteger;
java.util.concurrent.locks.StampedLock;
java.util.function.LongPredicate;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
HytaleLogger.forEnclosingClass();
MetricsRegistry<ChunkStore> METRICS_REGISTRY;
MAX_FAILURE_BACKOFF_NANOS;
FAILURE_BACKOFF_NANOS;
ComponentRegistry<ChunkStore> REGISTRY;
CodecKey<Holder<ChunkStore>> HOLDER_CODEC_KEY;
SystemType<ChunkStore, LoadPacketDataQuerySystem> LOAD_PACKETS_DATA_QUERY_SYSTEM_TYPE;
SystemType<ChunkStore, LoadFuturePacketDataQuerySystem> LOAD_FUTURE_PACKETS_DATA_QUERY_SYSTEM_TYPE;
SystemType<ChunkStore, UnloadPacketDataQuerySystem> UNLOAD_PACKETS_DATA_QUERY_SYSTEM_TYPE;
ResourceType<ChunkStore, ChunkUnloadingSystem.Data> UNLOAD_RESOURCE;
ResourceType<ChunkStore, ChunkSavingSystems.Data> SAVE_RESOURCE;
SystemGroup<ChunkStore> INIT_GROUP;
World world;
Long2ObjectConcurrentHashMap<ChunkLoadState> chunks;
Store<ChunkStore> store;
IChunkLoader loader;
IChunkSaver saver;
IWorldGen generator;
CompletableFuture<Void> generatorLoaded;
StampedLock generatorLock;
AtomicInteger totalGeneratedChunksCount;
AtomicInteger totalLoadedChunksCount;
{
.chunks = <ChunkLoadState>( , ChunkUtil.NOT_FOUND);
.generatorLoaded = ();
.generatorLock = ();
.totalGeneratedChunksCount = ();
.totalLoadedChunksCount = ();
.world = world;
}
World {
.world;
}
Store<ChunkStore> {
.store;
}
IChunkLoader {
.loader;
}
IChunkSaver {
.saver;
}
IWorldGen {
.generatorLock.readLock();
IWorldGen var3;
{
var3 = .generator;
} {
.generatorLock.unlockRead(readStamp);
}
var3;
}
{
.setGenerator((IWorldGen) );
}
{
.generatorLock.writeLock();
{
( .generator != ) {
.generator.shutdown();
}
.totalGeneratedChunksCount.set( );
.generator = generator;
(generator != ) {
.generatorLoaded.complete((Object) );
.generatorLoaded = ();
}
} {
.generatorLock.unlockWrite(writeStamp);
}
}
LongSet {
LongSets.unmodifiable( .chunks.keySet());
}
{
.chunks.size();
}
{
.totalGeneratedChunksCount.get();
}
{
.totalLoadedChunksCount.get();
}
{
.store = REGISTRY.addStore( , resourceStorage, (store) -> .store = store);
}
{
System.nanoTime();
hasLoadingChunks;
{
.world.consumeTaskQueue();
Thread. ();
hasLoadingChunks = ;
(Long2ObjectMap.Entry<ChunkLoadState> entry : .chunks.long2ObjectEntrySet()) {
(ChunkLoadState)entry.getValue();
chunkState.lock.readLock();
{
CompletableFuture<Ref<ChunkStore>> future = chunkState.future;
(future != && !future.isDone()) {
hasLoadingChunks = ;
;
}
} {
chunkState.lock.unlockRead(stamp);
}
}
} (hasLoadingChunks && System.nanoTime() - start <= );
.world.consumeTaskQueue();
}
{
.store.shutdown();
.chunks.clear();
}
Ref<ChunkStore> {
.world.debugAssertInTickingThread();
(WorldChunk)holder.getComponent(WorldChunk.getComponentType());
worldChunkComponent != ;
.chunks.get(worldChunkComponent.getIndex());
(chunkState == ) {
( );
} {
Ref<ChunkStore> oldReference = ;
chunkState.lock.writeLock();
{
(chunkState.future == ) {
( );
}
(chunkState.reference != ) {
oldReference = chunkState.reference;
chunkState.reference = ;
}
} {
chunkState.lock.unlockWrite(stamp);
}
(oldReference != ) {
(WorldChunk) .store.getComponent(oldReference, WorldChunk.getComponentType());
oldWorldChunkComponent != ;
oldWorldChunkComponent.setFlag(ChunkFlag.TICKING, );
.store.removeEntity(oldReference, RemoveReason.REMOVE);
.world.getNotificationHandler().updateChunk(worldChunkComponent.getIndex());
}
oldReference = .store.addEntity(holder, AddReason.SPAWN);
(oldReference == ) {
( );
} {
worldChunkComponent.setReference(oldReference);
stamp = chunkState.lock.writeLock();
Ref var17;
{
chunkState.reference = oldReference;
chunkState.flags = ;
chunkState.future = ;
chunkState.throwable = ;
chunkState.failedWhen = ;
chunkState.failedCounter = ;
var17 = oldReference;
} {
chunkState.lock.unlockWrite(stamp);
}
var17;
}
}
}
{
.world.debugAssertInTickingThread();
(WorldChunk) .store.getComponent(reference, WorldChunk.getComponentType());
worldChunkComponent != ;
worldChunkComponent.getIndex();
.chunks.get(index);
chunkState.lock.readLock();
{
worldChunkComponent.setFlag(ChunkFlag.TICKING, );
.store.removeEntity(reference, reason);
(chunkState.future != ) {
chunkState.reference = ;
} {
.chunks.remove(index, chunkState);
}
} {
chunkState.lock.unlockRead(stamp);
}
}
Ref<ChunkStore> {
.chunks.get(index);
(chunkState == ) {
;
} {
chunkState.lock.tryOptimisticRead();
Ref<ChunkStore> reference = chunkState.reference;
(chunkState.lock.validate(stamp)) {
reference;
} {
stamp = chunkState.lock.readLock();
Ref var7;
{
var7 = chunkState.reference;
} {
chunkState.lock.unlockRead(stamp);
}
var7;
}
}
}
Ref<ChunkStore> {
Ref<ChunkStore> ref = .getChunkReference(ChunkUtil.indexChunk(x, z));
(ref == ) {
;
} {
(ChunkColumn) .store.getComponent(ref, ChunkColumn.getComponentType());
chunkColumnComponent == ? : chunkColumnComponent.getSection(y);
}
}
Ref<ChunkStore> {
Ref<ChunkStore> ref = .getChunkReference(ChunkUtil.indexChunk(x, z));
(ref == ) {
;
} {
(ChunkColumn)commandBuffer.getComponent(ref, ChunkColumn.getComponentType());
chunkColumnComponent == ? : chunkColumnComponent.getSection(y);
}
}
CompletableFuture<Ref<ChunkStore>> {
y >= && y < ? .getChunkReferenceAsync(ChunkUtil.indexChunk(x, z)).thenApplyAsync((ref) -> {
(ref != && ref.isValid()) {
Store<ChunkStore> store = ref.getStore();
(ChunkColumn)store.getComponent(ref, ChunkColumn.getComponentType());
chunkColumnComponent == ? : chunkColumnComponent.getSection(y);
} {
;
}
}, ((ChunkStore) .store.getExternalData()).getWorld()) : CompletableFuture.failedFuture( ( + y));
}
<T <ChunkStore>> T {
Ref<ChunkStore> reference = .getChunkReference(index);
(T)(reference != && reference.isValid() ? .store.getComponent(reference, componentType) : );
}
CompletableFuture<Ref<ChunkStore>> {
.getChunkReferenceAsync(index, );
}
CompletableFuture<Ref<ChunkStore>> {
( .store.isShutdown()) {
CompletableFuture.completedFuture((Object) );
} {
ChunkLoadState chunkState;
((flags & ) == ) {
chunkState = .chunks.get(index);
(chunkState == ) {
CompletableFuture.completedFuture((Object) );
}
chunkState.lock.readLock();
{
((flags & ) == || (chunkState.flags & ) != ) {
(chunkState.reference != ) {
CompletableFuture.completedFuture(chunkState.reference);
var30;
}
(chunkState.future == ) {
CompletableFuture.completedFuture((Object) );
var29;
}
chunkState.future;
var7;
}
} {
chunkState.lock.unlockRead(stamp);
}
} {
chunkState = .chunks.computeIfAbsent(index, (l) -> ());
}
chunkState.lock.writeLock();
(chunkState.future == && chunkState.reference != && (flags & ) == ) {
Ref<ChunkStore> reference = chunkState.reference;
((flags & ) == ) {
chunkState.lock.unlockWrite(stamp);
CompletableFuture.completedFuture(reference);
} ( .world.isInThread() && (flags & - ) == ) {
chunkState.lock.unlockWrite(stamp);
(WorldChunk) .store.getComponent(reference, WorldChunk.getComponentType());
worldChunkComponent != ;
worldChunkComponent.setFlag(ChunkFlag.TICKING, );
CompletableFuture.completedFuture(reference);
} {
chunkState.lock.unlockWrite(stamp);
CompletableFuture.supplyAsync(() -> {
(WorldChunk) .store.getComponent(reference, WorldChunk.getComponentType());
worldChunkComponent != ;
worldChunkComponent.setFlag(ChunkFlag.TICKING, );
reference;
}, .world);
}
} {
{
(chunkState.throwable != ) {
System.nanoTime() - chunkState.failedWhen;
chunkState.failedCounter;
(nanosSince < Math.min(MAX_FAILURE_BACKOFF_NANOS, ( )(count * count) * FAILURE_BACKOFF_NANOS)) {
CompletableFuture.failedFuture( ( , chunkState.throwable));
var38;
}
chunkState.throwable = ;
chunkState.failedWhen = ;
}
chunkState.future == ;
(isNew) {
chunkState.flags = flags;
}
ChunkUtil.xOfChunkIndex(index);
ChunkUtil.zOfChunkIndex(index);
((isNew || (chunkState.flags & ) != ) && (flags & ) == ) {
(chunkState.future == ) {
chunkState.future = .loader.loadHolder(x, z).thenApplyAsync((holder) -> {
(holder != && ! .store.isShutdown()) {
.totalLoadedChunksCount.getAndIncrement();
.preLoadChunkAsync(index, holder, );
} {
;
}
}).thenApplyAsync( ::postLoadChunk, .world).exceptionally((throwable) -> {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(throwable)).log( , x, z);
chunkState.fail(throwable);
SneakyThrow.sneakyThrow(throwable);
});
} {
chunkState.flags &= - ;
chunkState.future = chunkState.future.thenCompose((reference) -> reference != ? CompletableFuture.completedFuture(reference) : .loader.loadHolder(x, z).thenApplyAsync((holder) -> {
(holder != && ! .store.isShutdown()) {
.totalLoadedChunksCount.getAndIncrement();
.preLoadChunkAsync(index, holder, );
} {
;
}
}).thenApplyAsync( ::postLoadChunk, .world).exceptionally((throwable) -> {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(throwable)).log( , x, z);
chunkState.fail(throwable);
SneakyThrow.sneakyThrow(throwable);
}));
}
}
((isNew || (chunkState.flags & ) != ) && (flags & ) == ) {
( ) .world.getWorldConfig().getSeed();
(chunkState.future == ) {
.generatorLock.readLock();
CompletableFuture<GeneratedChunk> future;
{
( .generator == ) {
future = .generatorLoaded.thenCompose((aVoid) -> .generator.generate(seed, index, x, z, (flags & ) != ? ::isChunkStillNeeded : ));
} {
future = .generator.generate(seed, index, x, z, (flags & ) != ? ::isChunkStillNeeded : );
}
} {
.generatorLock.unlockRead(readStamp);
}
chunkState.future = future.thenApplyAsync((generatedChunk) -> {
(generatedChunk != && ! .store.isShutdown()) {
.totalGeneratedChunksCount.getAndIncrement();
.preLoadChunkAsync(index, generatedChunk.toHolder( .world), );
} {
;
}
}).thenApplyAsync( ::postLoadChunk, .world).exceptionally((throwable) -> {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(throwable)).log( , x, z);
chunkState.fail(throwable);
SneakyThrow.sneakyThrow(throwable);
});
} {
chunkState.flags &= - ;
chunkState.future = chunkState.future.thenCompose((reference) -> {
(reference != ) {
CompletableFuture.completedFuture(reference);
} {
.generatorLock.readLock();
CompletableFuture<GeneratedChunk> future;
{
( .generator == ) {
future = .generatorLoaded.thenCompose((aVoid) -> .generator.generate(seed, index, x, z, (LongPredicate) ));
} {
future = .generator.generate(seed, index, x, z, (LongPredicate) );
}
} {
.generatorLock.unlockRead(readStamp);
}
future.thenApplyAsync((generatedChunk) -> {
(generatedChunk != && ! .store.isShutdown()) {
.totalGeneratedChunksCount.getAndIncrement();
.preLoadChunkAsync(index, generatedChunk.toHolder( .world), );
} {
;
}
}).thenApplyAsync( ::postLoadChunk, .world).exceptionally((throwable) -> {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(throwable)).log( , x, z);
chunkState.fail(throwable);
SneakyThrow.sneakyThrow(throwable);
});
}
});
}
}
((isNew || (chunkState.flags & ) == ) && (flags & ) != ) {
chunkState.flags |= ;
(chunkState.future != ) {
chunkState.future = chunkState.future.thenApplyAsync((reference) -> {
(reference != ) {
(WorldChunk) .store.getComponent(reference, WorldChunk.getComponentType());
worldChunkComponent != ;
worldChunkComponent.setFlag(ChunkFlag.TICKING, );
}
reference;
}, .world).exceptionally((throwable) -> {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(throwable)).log( , x, z);
chunkState.fail(throwable);
SneakyThrow.sneakyThrow(throwable);
});
}
}
(chunkState.future == ) {
CompletableFuture.completedFuture((Object) );
var37;
} {
chunkState.future;
var36;
}
} {
chunkState.lock.unlockWrite(stamp);
}
}
}
}
{
(PlayerRef playerRef : .world.getPlayerRefs()) {
(playerRef.getChunkTracker().shouldBeVisible(index)) {
;
}
}
;
}
{
.chunks.get(index);
(chunkState == ) {
;
} {
chunkState.lock.readLock();
var8;
{
(chunkState.throwable != ) {
System.nanoTime() - chunkState.failedWhen;
chunkState.failedCounter;
nanosSince < Math.min(maxFailureBackoffNanos, ( )(count * count) * FAILURE_BACKOFF_NANOS);
var11;
}
var8 = ;
} {
chunkState.lock.unlockRead(stamp);
}
var8;
}
}
Holder<ChunkStore> {
(WorldChunk)holder.getComponent(WorldChunk.getComponentType());
(worldChunkComponent == ) {
(String.format( , ChunkUtil.xOfChunkIndex(index), ChunkUtil.zOfChunkIndex(index)));
} (worldChunkComponent.getIndex() != index) {
(String.format( , worldChunkComponent.getX(), worldChunkComponent.getZ(), ChunkUtil.xOfChunkIndex(index), ChunkUtil.zOfChunkIndex(index)));
} {
(BlockChunk)holder.getComponent(BlockChunk.getComponentType());
(blockChunk == ) {
(String.format( , ChunkUtil.xOfChunkIndex(index), ChunkUtil.zOfChunkIndex(index)));
} {
blockChunk.loadFromHolder(holder);
worldChunkComponent.setFlag(ChunkFlag.NEWLY_GENERATED, newlyGenerated);
worldChunkComponent.setLightingUpdatesEnabled( );
(newlyGenerated && .world.getWorldConfig().shouldSaveNewChunks()) {
worldChunkComponent.markNeedsSaving();
}
{
System.nanoTime();
IEventDispatcher<ChunkPreLoadProcessEvent, ChunkPreLoadProcessEvent> dispatcher = HytaleServer.get().getEventBus().dispatchFor(ChunkPreLoadProcessEvent.class, .world.getName());
(dispatcher.hasListener()) {
dispatcher.dispatch( (holder, worldChunkComponent, newlyGenerated, start));
(!event.didLog()) {
System.nanoTime();
end - start;
(diff > ( ) .world.getTickStepNanos()) {
LOGGER.at(Level.SEVERE).log( , FormatUtil.nanosToString(diff), .world.consumeGCHasRun(), worldChunkComponent);
}
}
}
} {
worldChunkComponent.setLightingUpdatesEnabled( );
}
holder;
}
}
}
Ref<ChunkStore> {
.world.debugAssertInTickingThread();
(holder != && ! .store.isShutdown()) {
System.nanoTime();
(WorldChunk)holder.getComponent(WorldChunk.getComponentType());
worldChunkComponent != ;
worldChunkComponent.setFlag(ChunkFlag.START_INIT, );
(worldChunkComponent.is(ChunkFlag.TICKING)) {
holder.tryRemoveComponent(REGISTRY.getNonTickingComponentType());
} {
holder.ensureComponent(REGISTRY.getNonTickingComponentType());
}
Ref<ChunkStore> reference = .add(holder);
worldChunkComponent.initFlags();
.world.getChunkLighting().init(worldChunkComponent);
System.nanoTime();
end - start;
(diff > ( ) .world.getTickStepNanos()) {
LOGGER.at(Level.SEVERE).log( , FormatUtil.nanosToString(diff), .world.consumeGCHasRun(), worldChunkComponent);
}
reference;
} {
;
}
}
{
METRICS_REGISTRY = ( ()).register( , ChunkStore::getStore, Store.METRICS_REGISTRY).register( , MetricProvider.maybe(ChunkStore::getLoader)).register( , MetricProvider.maybe(ChunkStore::getSaver)).register( , MetricProvider.maybe(ChunkStore::getGenerator)).register( , (chunkComponentStore) -> ( )chunkComponentStore.totalGeneratedChunksCount.get(), Codec.LONG).register( , (chunkComponentStore) -> ( )chunkComponentStore.totalLoadedChunksCount.get(), Codec.LONG);
MAX_FAILURE_BACKOFF_NANOS = TimeUnit.SECONDS.toNanos( );
FAILURE_BACKOFF_NANOS = TimeUnit.MILLISECONDS.toNanos( );
REGISTRY = <ChunkStore>();
HOLDER_CODEC_KEY = <Holder<ChunkStore>>( );
CodecStore.STATIC;
HOLDER_CODEC_KEY;
REGISTRY;
Objects.requireNonNull(var10002);
var10000.putCodecSupplier(var10001, var10002::getEntityCodec);
LOAD_PACKETS_DATA_QUERY_SYSTEM_TYPE = REGISTRY.registerSystemType(LoadPacketDataQuerySystem.class);
LOAD_FUTURE_PACKETS_DATA_QUERY_SYSTEM_TYPE = REGISTRY.registerSystemType(LoadFuturePacketDataQuerySystem.class);
UNLOAD_PACKETS_DATA_QUERY_SYSTEM_TYPE = REGISTRY.registerSystemType(UnloadPacketDataQuerySystem.class);
UNLOAD_RESOURCE = REGISTRY.registerResource(ChunkUnloadingSystem.Data.class, ChunkUnloadingSystem.Data:: );
SAVE_RESOURCE = REGISTRY.registerResource(ChunkSavingSystems.Data.class, ChunkSavingSystems.Data:: );
INIT_GROUP = REGISTRY.registerSystemGroup();
REGISTRY.registerSystem( ());
REGISTRY.registerSystem( ());
REGISTRY.registerSystem( .WorldRemoved());
REGISTRY.registerSystem( .Ticking());
}
{
();
;
CompletableFuture<Ref<ChunkStore>> future;
Ref<ChunkStore> reference;
Throwable throwable;
failedWhen;
failedCounter;
{
}
{
.lock.writeLock();
{
.flags = ;
.future = ;
.throwable = throwable;
.failedWhen = System.nanoTime();
++ .failedCounter;
} {
.lock.unlockWrite(stamp);
}
}
}
<ChunkStore, PlayerRef, Packet> {
{
}
}
<ChunkStore, PlayerRef, CompletableFuture<Packet>> {
{
}
}
<ChunkStore, PlayerRef, Packet> {
{
}
}
<ChunkStore> {
{
}
SystemGroup<ChunkStore> {
ChunkStore.INIT_GROUP;
}
{
store.getExternalData();
data.getWorld();
world.getWorldConfig().getChunkStorageProvider();
{
data.loader = chunkStorageProvider.getLoader(store);
data.saver = chunkStorageProvider.getSaver(store);
} (IOException e) {
SneakyThrow.sneakyThrow(e);
}
}
{
store.getExternalData();
{
(data.loader != ) {
data.loader;
data.loader = ;
oldLoader.close();
}
(data.saver != ) {
data.saver;
data.saver = ;
oldSaver.close();
}
} (IOException e) {
((HytaleLogger.Api)ChunkStore.LOGGER.at(Level.SEVERE).withCause(e)).log( );
}
}
}
}
com/hypixel/hytale/server/core/universe/world/storage/EntityStore.java
package com.hypixel.hytale.server.core.universe.world.storage;
import com.hypixel.hytale.codec.store.CodecKey;
import com.hypixel.hytale.codec.store.CodecStore;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.IResourceStorage;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.SystemGroup;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.RefSystem;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.metrics.MetricsRegistry;
import com.hypixel.hytale.server.core.entity.UUIDComponent;
import com.hypixel.hytale.server.core.modules.entity.tracker.NetworkId;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldProvider;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class {
MetricsRegistry<EntityStore> METRICS_REGISTRY;
ComponentRegistry<EntityStore> REGISTRY;
CodecKey<Holder<EntityStore>> HOLDER_CODEC_KEY;
SystemGroup<EntityStore> SEND_PACKET_GROUP;
( );
World world;
Store<EntityStore> store;
Map<UUID, Ref<EntityStore>> entitiesByUuid = ();
Int2ObjectMap<Ref<EntityStore>> networkIdToRef = <Ref<EntityStore>>();
{
.world = world;
}
{
.store = REGISTRY.addStore( , resourceStorage, (store) -> .store = store);
}
{
.store.shutdown();
.entitiesByUuid.clear();
}
Store<EntityStore> {
.store;
}
Ref<EntityStore> {
(Ref) .entitiesByUuid.get(uuid);
}
Ref<EntityStore> {
(Ref) .networkIdToRef.get(networkId);
}
{
.networkIdCounter.getAndIncrement();
}
World {
.world;
}
{
METRICS_REGISTRY = ( ()).register( , EntityStore::getStore, Store.METRICS_REGISTRY);
REGISTRY = <EntityStore>();
HOLDER_CODEC_KEY = <Holder<EntityStore>>( );
CodecStore.STATIC;
HOLDER_CODEC_KEY;
REGISTRY;
Objects.requireNonNull(var10002);
var10000.putCodecSupplier(var10001, var10002::getEntityCodec);
SEND_PACKET_GROUP = REGISTRY.registerSystemGroup();
}
<EntityStore> {
HytaleLogger.forEnclosingClass();
{
}
Query<EntityStore> {
UUIDComponent.getComponentType();
}
{
(UUIDComponent)commandBuffer.getComponent(ref, UUIDComponent.getComponentType());
uuidComponent != ;
Ref<EntityStore> currentRef = (Ref)(store.getExternalData()).entitiesByUuid.putIfAbsent(uuidComponent.getUuid(), ref);
(currentRef != ) {
LOGGER.at(Level.WARNING).log( , uuidComponent.getUuid());
commandBuffer.removeEntity(ref, RemoveReason.REMOVE);
}
}
{
(UUIDComponent)commandBuffer.getComponent(ref, UUIDComponent.getComponentType());
uuidComponent != ;
(store.getExternalData()).entitiesByUuid.remove(uuidComponent.getUuid(), ref);
}
}
<EntityStore> {
{
}
Query<EntityStore> {
NetworkId.getComponentType();
}
{
store.getExternalData();
(NetworkId)commandBuffer.getComponent(ref, NetworkId.getComponentType());
networkIdComponent != ;
networkIdComponent.getId();
(entityStore.networkIdToRef.putIfAbsent(networkId, ref) != ) {
networkId = entityStore.takeNextNetworkId();
commandBuffer.putComponent(ref, NetworkId.getComponentType(), (networkId));
entityStore.networkIdToRef.put(networkId, ref);
}
}
{
store.getExternalData();
(NetworkId)commandBuffer.getComponent(ref, NetworkId.getComponentType());
networkIdComponent != ;
entityStore.networkIdToRef.remove(networkIdComponent.getId(), ref);
}
}
}
com/hypixel/hytale/server/core/universe/world/storage/GetChunkFlags.java
package com.hypixel.hytale.server.core.universe.world.storage;
public class GetChunkFlags {
public static final int NONE = 0 ;
public static final int NO_LOAD = 1 ;
public static final int NO_GENERATE = 2 ;
public static final int SET_TICKING = 4 ;
public static final int BYPASS_LOADED = 8 ;
public static final int POLL_STILL_NEEDED = 16 ;
public static final int NO_SET_TICKING_SYNC = -2147483648 ;
public {
}
}
com/hypixel/hytale/server/core/universe/world/storage/IChunkLoader.java
package com.hypixel.hytale.server.core.universe.world.storage;
import com.hypixel.hytale.component.Holder;
import it.unimi.dsi.fastutil.longs.LongSet;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public interface IChunkLoader extends Closeable {
@Nonnull
CompletableFuture<Holder<ChunkStore>> loadHolder (int var1, int var2) ;
@Nonnull
LongSet getIndexes () throws IOException;
}
com/hypixel/hytale/server/core/universe/world/storage/IChunkSaver.java
package com.hypixel.hytale.server.core.universe.world.storage;
import com.hypixel.hytale.component.Holder;
import it.unimi.dsi.fastutil.longs.LongSet;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public interface IChunkSaver extends Closeable {
@Nonnull
CompletableFuture<Void> saveHolder (int var1, int var2, @Nonnull Holder<ChunkStore> var3) ;
@Nonnull
CompletableFuture<Void> removeHolder (int var1, int var2) ;
@Nonnull
LongSet getIndexes () throws IOException;
void flush () throws IOException;
}
com/hypixel/hytale/server/core/universe/world/storage/component/ChunkSavingSystems.java
package com.hypixel.hytale.server.core.universe.world.storage.component;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Resource;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.dependency.Order;
import com.hypixel.hytale.component.dependency.RootDependency;
import com.hypixel.hytale.component.dependency.SystemDependency;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.StoreSystem;
import com.hypixel.hytale.component.system.tick.RunWhenPausedSystem;
import com.hypixel.hytale.component.system.tick.TickingSystem;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.HytaleServer;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.ChunkFlag;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.events.ecs.ChunkSaveEvent;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkSaver;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
java.util.concurrent.ConcurrentLinkedDeque;
java.util.concurrent.ForkJoinPool;
java.util.concurrent.atomic.AtomicInteger;
java.util.function.BiConsumer;
java.util.function.Function;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
HytaleLogger.forEnclosingClass();
ComponentType<ChunkStore, WorldChunk> WORLD_CHUNK_COMPONENT_TYPE = WorldChunk.getComponentType();
Query<ChunkStore> QUERY;
{
}
CompletableFuture<Void> {
((ChunkStore)store.getExternalData()).getWorld().getLogger();
(Data)store.getResource(ChunkStore.SAVE_RESOURCE);
logger.at(Level.INFO).log( );
store.forEachChunk(QUERY, (BiConsumer)((archetypeChunk, b) -> {
( ; index < archetypeChunk.size(); ++index) {
tryQueue(index, archetypeChunk, b.getStore());
}
}));
logger.at(Level.INFO).log( );
Ref<ChunkStore> reference;
((reference = data.poll()) != ) {
saveChunk(reference, data, , store);
}
logger.at(Level.INFO).log( );
data.waitForSavingChunks();
}
{
(WorldChunk)archetypeChunk.getComponent(index, WORLD_CHUNK_COMPONENT_TYPE);
worldChunkComponent != ;
(worldChunkComponent.getNeedsSaving() && !worldChunkComponent.isSaving()) {
Ref<ChunkStore> chunkRef = archetypeChunk.getReferenceTo(index);
(worldChunkComponent);
store.invoke(chunkRef, event);
(!event.isCancelled()) {
((Data)store.getResource(ChunkStore.SAVE_RESOURCE)).push(chunkRef);
}
}
}
{
Store<ChunkStore> store = commandBuffer.getStore();
(Data)store.getResource(ChunkStore.SAVE_RESOURCE);
( ; index < archetypeChunk.size(); ++index) {
(WorldChunk)archetypeChunk.getComponent(index, WORLD_CHUNK_COMPONENT_TYPE);
worldChunkComponent != ;
(worldChunkComponent.getNeedsSaving() && !worldChunkComponent.isSaving()) {
Ref<ChunkStore> chunkRef = archetypeChunk.getReferenceTo(index);
(worldChunkComponent);
store.invoke(chunkRef, event);
(!event.isCancelled()) {
data.push(chunkRef);
}
}
}
}
{
(!reference.isValid()) {
LOGGER.at(Level.FINEST).log( );
} {
data.toSaveTotal.getAndIncrement();
(WorldChunk)store.getComponent(reference, WORLD_CHUNK_COMPONENT_TYPE);
worldChunkComponent != ;
Holder<ChunkStore> holder = worldChunkComponent.toHolder();
store.getExternalData();
chunkStore.getWorld();
chunkStore.getSaver();
CompletableFuture<Void> future = saver.saveHolder(worldChunkComponent.getX(), worldChunkComponent.getZ(), holder).whenComplete((aVoid, throwable) -> {
(throwable != ) {
((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(throwable)).log( , worldChunkComponent.getX(), worldChunkComponent.getZ());
} {
worldChunkComponent.setFlag(ChunkFlag.ON_DISK, );
LOGGER.at(Level.FINEST).log( , worldChunkComponent.getX(), worldChunkComponent.getZ());
}
});
data.chunkSavingFutures.add(future);
(report) {
future.thenRunAsync(() -> HytaleServer.get().reportSaveProgress(world, data.savedCount.incrementAndGet(), data.toSaveTotal.get() + data.queue.size()));
}
worldChunkComponent.consumeNeedsSaving();
}
}
{
QUERY = Query.<ChunkStore>and(WORLD_CHUNK_COMPONENT_TYPE, Query.not(ChunkStore.REGISTRY.getNonSerializedComponentType()));
}
<ChunkStore> {
Set<Dependency<ChunkStore>> dependencies;
{
.dependencies = Set.of( (Order.AFTER, ChunkStore.ChunkLoaderSaverSetupSystem.class));
}
Set<Dependency<ChunkStore>> {
.dependencies;
}
{
}
{
((ChunkStore)store.getExternalData()).getWorld();
world.getLogger().at(Level.INFO).log( );
world.getChunkStore().shutdownGenerator();
(!world.getWorldConfig().canSaveChunks()) {
world.getLogger().at(Level.INFO).log( );
} {
world.getLogger().at(Level.INFO).log( );
(Data)store.getResource(ChunkStore.SAVE_RESOURCE);
data.savedCount.set( );
data.toSaveTotal.set( );
ChunkSavingSystems.saveChunksInWorld(store).join();
world.getLogger().at(Level.INFO).log( );
}
}
}
<ChunkStore> <ChunkStore> {
{
}
Set<Dependency<ChunkStore>> {
RootDependency.lastSet();
}
{
(Data)store.getResource(ChunkStore.SAVE_RESOURCE);
(data.isSaving && ((ChunkStore)store.getExternalData()).getWorld().getWorldConfig().canSaveChunks()) {
data.chunkSavingFutures.removeIf(CompletableFuture::isDone);
(data.checkTimer(dt)) {
store.forEachChunk(ChunkSavingSystems.QUERY, ChunkSavingSystems::tryQueueSync);
}
((ChunkStore)store.getExternalData()).getWorld();
((ChunkStore)store.getExternalData()).getSaver();
ForkJoinPool.commonPool().getParallelism();
( ; i < parallelSaves; ++i) {
Ref<ChunkStore> reference = data.poll();
(reference == ) {
;
}
(!reference.isValid()) {
ChunkSavingSystems.LOGGER.at(Level.FINEST).log( );
;
}
(WorldChunk)store.getComponent(reference, ChunkSavingSystems.WORLD_CHUNK_COMPONENT_TYPE);
chunk.setSaving( );
Holder<ChunkStore> holder = store.copySerializableEntity(reference);
data.toSaveTotal.getAndIncrement();
data.chunkSavingFutures.add(CompletableFuture.supplyAsync(() -> saver.saveHolder(chunk.getX(), chunk.getZ(), holder)).thenCompose(Function.identity()).whenCompleteAsync((aVoid, throwable) -> {
(throwable != ) {
((HytaleLogger.Api)ChunkSavingSystems.LOGGER.at(Level.SEVERE).withCause(throwable)).log( , chunk.getX(), chunk.getZ());
} {
chunk.setFlag(ChunkFlag.ON_DISK, );
ChunkSavingSystems.LOGGER.at(Level.FINEST).log( , chunk.getX(), chunk.getZ());
}
chunk.consumeNeedsSaving();
chunk.setSaving( );
}, world));
}
}
}
}
<ChunkStore> {
;
Set<Ref<ChunkStore>> set = ConcurrentHashMap.newKeySet();
Deque<Ref<ChunkStore>> queue = ();
List<CompletableFuture<Void>> chunkSavingFutures = <CompletableFuture<Void>>();
time;
;
();
();
{
.time = ;
}
{
.time = time;
}
Resource<ChunkStore> {
( .time);
}
{
.queue.clear();
.set.clear();
}
{
( .set.add(reference)) {
.queue.push(reference);
}
}
Ref<ChunkStore> {
Ref<ChunkStore> reference = (Ref) .queue.poll();
(reference == ) {
;
} {
.set.remove(reference);
reference;
}
}
{
.time -= dt;
( .time <= ) {
.time += ;
;
} {
;
}
}
CompletableFuture<Void> {
CompletableFuture.allOf((CompletableFuture[]) .chunkSavingFutures.toArray((x$ ) -> [x$ ]));
}
}
}
com/hypixel/hytale/server/core/universe/world/storage/component/ChunkUnloadingSystem.java
package com.hypixel.hytale.server.core.universe.world.storage.component;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Resource;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.system.tick.RunWhenPausedSystem;
import com.hypixel.hytale.component.system.tick.TickingSystem;
import com.hypixel.hytale.math.shape.Box2D;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.server.core.modules.entity.player.ChunkTracker;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.ChunkFlag;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.events.ecs.ChunkUnloadEvent;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.List;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public class ChunkUnloadingSystem extends TickingSystem <ChunkStore> implements RunWhenPausedSystem <ChunkStore> {
public static final ;
;
;
;
{
}
{
(Data)store.getResource(ChunkStore.UNLOAD_RESOURCE);
((ChunkStore)store.getExternalData()).getWorld();
(!world.getWorldConfig().canUnloadChunks()) {
-- .ticksUntilUnloadingReminder;
( .ticksUntilUnloadingReminder <= ) {
world.getLogger().at(Level.INFO).log( );
.ticksUntilUnloadingReminder = ;
}
} {
;
- ( )Runtime.getRuntime().freeMemory() / ( )Runtime.getRuntime().maxMemory();
(percentOfRAMUsed > ) {
(percentOfRAMUsed - ) / ;
pollCount = Math.max(MathUtil.ceil(desperatePercent * ), );
}
dataResource.pollCount = pollCount;
(dataResource.tick(dt)) {
dataResource.chunkTrackers.clear();
world.getEntityStore().getStore().forEachChunk(ChunkTracker.getComponentType(), ChunkUnloadingSystem::collectTrackers);
store.forEachEntityParallel(WorldChunk.getComponentType(), ChunkUnloadingSystem::tryUnload);
}
}
}
{
Store<ChunkStore> store = commandBuffer.getStore();
((ChunkStore)store.getExternalData()).getWorld();
(WorldChunk)archetypeChunk.getComponent(index, WorldChunk.getComponentType());
worldChunkComponent != ;
(Data)commandBuffer.getResource(ChunkStore.UNLOAD_RESOURCE);
ChunkTracker. getChunkVisibility(dataResource.chunkTrackers, worldChunkComponent.getIndex());
(chunkVisibility == ChunkTracker.ChunkVisibility.HOT) {
worldChunkComponent.resetKeepAlive();
worldChunkComponent.resetActiveTimer();
} {
world.getWorldConfig().getChunkConfig().getKeepLoadedRegion();
worldChunkComponent.shouldKeepLoaded() || keepLoaded != && isChunkInBox(keepLoaded, worldChunkComponent.getX(), worldChunkComponent.getZ());
dataResource.pollCount;
(chunkVisibility != ChunkTracker.ChunkVisibility.COLD && !worldChunkComponent.getNeedsSaving() && !shouldKeepLoaded) {
(worldChunkComponent.pollKeepAlive(pollCount) <= ) {
Ref<ChunkStore> chunkRef = archetypeChunk.getReferenceTo(index);
(worldChunkComponent);
commandBuffer.invoke(chunkRef, event);
(event.isCancelled()) {
(event.willResetKeepAlive()) {
worldChunkComponent.resetKeepAlive();
}
} {
commandBuffer.run((s) -> ((ChunkStore)s.getExternalData()).remove(chunkRef, RemoveReason.UNLOAD));
}
}
} {
worldChunkComponent.resetKeepAlive();
(worldChunkComponent.is(ChunkFlag.TICKING) && worldChunkComponent.pollActiveTimer(pollCount) <= ) {
commandBuffer.run((s) -> worldChunkComponent.setFlag(ChunkFlag.TICKING, ));
}
}
}
}
ChunkTracker.ChunkVisibility {
;
(ChunkTracker chunkTracker : playerChunkTrackers) {
(chunkTracker.getChunkVisibility(chunkIndex)) {
NONE:
:
;
HOT:
ChunkTracker.ChunkVisibility.HOT;
COLD:
isVisible = ;
}
}
isVisible ? ChunkTracker.ChunkVisibility.COLD : ChunkTracker.ChunkVisibility.NONE;
}
{
ChunkUtil.minBlock(x);
ChunkUtil.minBlock(z);
ChunkUtil.maxBlock(x);
ChunkUtil.maxBlock(z);
( )maxX >= box.min.x && ( )minX <= box.max.x && ( )maxZ >= box.min.y && ( )minZ <= box.max.y;
}
{
Store<ChunkStore> chunkStore = ((EntityStore)commandBuffer.getExternalData()).getWorld().getChunkStore().getStore();
(Data)chunkStore.getResource(ChunkStore.UNLOAD_RESOURCE);
( ; index < archetypeChunk.size(); ++index) {
(ChunkTracker)archetypeChunk.getComponent(index, ChunkTracker.getComponentType());
dataResource.chunkTrackers.add(chunkTracker);
}
}
<ChunkStore> {
;
time;
;
List<ChunkTracker> chunkTrackers = <ChunkTracker>();
{
.time = ;
}
{
.time = time;
}
Resource<ChunkStore> {
( .time);
}
{
.time -= dt;
( .time <= ) {
.time += ;
;
} {
;
}
}
}
}
com/hypixel/hytale/server/core/universe/world/storage/provider/DefaultChunkStorageProvider.java
package com.hypixel.hytale.server.core.universe.world.storage.provider;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkLoader;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkSaver;
import java.io.IOException;
import javax.annotation.Nonnull;
public class DefaultChunkStorageProvider implements IChunkStorageProvider {
@Nonnull
public static final DefaultChunkStorageProvider INSTANCE = new DefaultChunkStorageProvider ();
public static final String ID = "Hytale" ;
@Nonnull
public static final BuilderCodec<DefaultChunkStorageProvider> CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(DefaultChunkStorageProvider.class, () -> INSTANCE).documentation("Selects the default recommended storage as decided by the server." )).build();
@Nonnull
public static final IChunkStorageProvider DEFAULT = ();
{
}
IChunkLoader IOException {
DEFAULT.getLoader(store);
}
IChunkSaver IOException {
DEFAULT.getSaver(store);
}
String {
+ String.valueOf(DEFAULT) + ;
}
}
com/hypixel/hytale/server/core/universe/world/storage/provider/EmptyChunkStorageProvider.java
package com.hypixel.hytale.server.core.universe.world.storage.provider;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkLoader;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkSaver;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.longs.LongSets;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public class EmptyChunkStorageProvider implements IChunkStorageProvider {
public static final String ID = "Empty" ;
@Nonnull
public static final EmptyChunkStorageProvider INSTANCE = new EmptyChunkStorageProvider ();
@Nonnull
public static final BuilderCodec<EmptyChunkStorageProvider> CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(EmptyChunkStorageProvider.class, () -> INSTANCE).documentation("A chunk storage provider that discards any chunks to save and will always fail to find chunks." )).build();
@Nonnull
public ();
();
{
}
IChunkLoader {
EMPTY_CHUNK_LOADER;
}
IChunkSaver {
EMPTY_CHUNK_SAVER;
}
String {
;
}
{
{
}
{
}
CompletableFuture<Holder<ChunkStore>> {
CompletableFuture.completedFuture((Object) );
}
LongSet {
LongSets.EMPTY_SET;
}
}
{
{
}
{
}
CompletableFuture<Void> {
CompletableFuture.completedFuture((Object) );
}
CompletableFuture<Void> {
CompletableFuture.completedFuture((Object) );
}
LongSet {
LongSets.EMPTY_SET;
}
{
}
}
}
com/hypixel/hytale/server/core/universe/world/storage/provider/IChunkStorageProvider.java
package com.hypixel.hytale.server.core.universe.world.storage.provider;
import com.hypixel.hytale.codec.lookup.BuilderCodecMapCodec;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkLoader;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkSaver;
import java.io.IOException;
import javax.annotation.Nonnull;
public interface IChunkStorageProvider {
@Nonnull
BuilderCodecMapCodec<IChunkStorageProvider> CODEC = new BuilderCodecMapCodec <IChunkStorageProvider>("Type" , true );
@Nonnull
IChunkLoader getLoader (@Nonnull Store<ChunkStore> var1) throws IOException;
@Nonnull
IChunkSaver getSaver (@Nonnull Store<ChunkStore> var1) throws IOException;
}
com/hypixel/hytale/server/core/universe/world/storage/provider/IndexedStorageChunkStorageProvider.java
package com.hypixel.hytale.server.core.universe.world.storage.provider;
import com.hypixel.fastutil.longs.Long2ObjectConcurrentHashMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.component.Resource;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.SystemGroup;
import com.hypixel.hytale.component.system.StoreSystem;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.metrics.MetricProvider;
import com.hypixel.hytale.metrics.MetricResults;
import com.hypixel.hytale.metrics.MetricsRegistry;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.BufferChunkLoader;
import com.hypixel.hytale.server.core.universe.world.storage.BufferChunkSaver;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkLoader;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkSaver;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import com.hypixel.hytale.sneakythrow.supplier.ThrowableSupplier;
import com.hypixel.hytale.storage.IndexedStorageFile;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntListIterator;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
it.unimi.dsi.fastutil.longs.LongSet;
it.unimi.dsi.fastutil.longs.LongSets;
java.io.Closeable;
java.io.FileNotFoundException;
java.io.IOException;
java.nio.ByteBuffer;
java.nio.file.FileAlreadyExistsException;
java.nio.file.Files;
java.nio.file.LinkOption;
java.nio.file.Path;
java.nio.file.StandardOpenOption;
java.util.Iterator;
java.util.concurrent.CompletableFuture;
java.util.stream.Stream;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
;
BuilderCodec<IndexedStorageChunkStorageProvider> CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(IndexedStorageChunkStorageProvider.class, IndexedStorageChunkStorageProvider:: ).documentation( )).build();
{
}
IChunkLoader {
(store);
}
IChunkSaver {
(store);
}
String {
;
}
String {
regionX + + regionZ + ;
}
{
String[] split = fileName.split( );
(split.length != ) {
( );
} (! .equals(split[ ])) {
( );
} (! .equals(split[ ])) {
( );
} {
Integer.parseInt(split[ ]);
Integer.parseInt(split[ ]);
ChunkUtil.indexChunk(regionX, regionZ);
}
}
{
{
(store);
}
IOException {
((IndexedStorageCache) .getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType())).close();
}
CompletableFuture<ByteBuffer> {
x >> ;
z >> ;
x & ;
z & ;
ChunkUtil.indexColumn(localX, localZ);
(IndexedStorageCache) .getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType());
CompletableFuture.supplyAsync(SneakyThrow.sneakySupplier((ThrowableSupplier)(() -> {
indexedStorageCache.getOrTryOpen(regionX, regionZ);
chunks == ? : chunks.readBlob(index);
})));
}
LongSet IOException {
((IndexedStorageCache) .getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType())).getIndexes();
}
MetricResults {
((ChunkStore) .getStore().getExternalData()).getSaver() IndexedStorageChunkSaver ? : ((IndexedStorageCache) .getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType())).toMetricResults();
}
}
{
{
(store);
}
IOException {
(IndexedStorageCache) .getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType());
indexedStorageCache.close();
}
CompletableFuture<Void> {
x >> ;
z >> ;
x & ;
z & ;
ChunkUtil.indexColumn(localX, localZ);
(IndexedStorageCache) .getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType());
CompletableFuture.runAsync(SneakyThrow.sneakyRunnable(() -> {
indexedStorageCache.getOrCreate(regionX, regionZ);
chunks.writeBlob(index, buffer);
}));
}
CompletableFuture<Void> {
x >> ;
z >> ;
x & ;
z & ;
ChunkUtil.indexColumn(localX, localZ);
(IndexedStorageCache) .getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType());
CompletableFuture.runAsync(SneakyThrow.sneakyRunnable(() -> {
indexedStorageCache.getOrTryOpen(regionX, regionZ);
(chunks != ) {
chunks.removeBlob(index);
}
}));
}
LongSet IOException {
((IndexedStorageCache) .getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType())).getIndexes();
}
IOException {
((IndexedStorageCache) .getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType())).flush();
}
MetricResults {
((IndexedStorageCache) .getStore().getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType())).toMetricResults();
}
}
, MetricProvider, Resource<ChunkStore> {
MetricsRegistry<IndexedStorageCache> METRICS_REGISTRY;
Long2ObjectConcurrentHashMap<IndexedStorageFile> cache;
Path path;
{
.cache = <IndexedStorageFile>( , ChunkUtil.NOT_FOUND);
}
ResourceType<ChunkStore, IndexedStorageCache> {
Universe.get().getIndexedStorageCacheResourceType();
}
Long2ObjectConcurrentHashMap<IndexedStorageFile> {
.cache;
}
IOException {
;
Iterator<IndexedStorageFile> iterator = .cache.values().iterator();
(iterator.hasNext()) {
{
((IndexedStorageFile)iterator.next()).close();
iterator.remove();
} (Exception e) {
(exception == ) {
exception = ( );
}
exception.addSuppressed(e);
}
}
(exception != ) {
exception;
}
}
IndexedStorageFile {
.cache.computeIfAbsent(ChunkUtil.indexChunk(regionX, regionZ), (k) -> {
.path.resolve(IndexedStorageChunkStorageProvider.toFileName(regionX, regionZ));
(!Files.exists(regionFile, [ ])) {
;
} {
{
IndexedStorageFile.open(regionFile, StandardOpenOption.READ, StandardOpenOption.WRITE);
} (FileNotFoundException var7) {
;
} (IOException e) {
SneakyThrow.sneakyThrow(e);
}
}
});
}
IndexedStorageFile {
.cache.computeIfAbsent(ChunkUtil.indexChunk(regionX, regionZ), (k) -> {
{
(!Files.exists( .path, [ ])) {
{
Files.createDirectory( .path);
} (FileAlreadyExistsException var6) {
}
}
.path.resolve(IndexedStorageChunkStorageProvider.toFileName(regionX, regionZ));
IndexedStorageFile.open(regionFile, StandardOpenOption.CREATE, StandardOpenOption.READ, StandardOpenOption.WRITE);
} (IOException e) {
SneakyThrow.sneakyThrow(e);
}
});
}
LongSet IOException {
(!Files.exists( .path, [ ])) {
LongSets.EMPTY_SET;
} {
();
Stream<Path> stream = Files.list( .path);
{
stream.forEach((path) -> {
(!Files.isDirectory(path, [ ])) {
regionIndex;
{
regionIndex = IndexedStorageChunkStorageProvider.fromFileName(path.getFileName().toString());
} (IllegalArgumentException var15) {
;
}
ChunkUtil.xOfChunkIndex(regionIndex);
ChunkUtil.zOfChunkIndex(regionIndex);
.getOrTryOpen(regionX, regionZ);
(regionFile != ) {
regionFile.keys();
blobIndexes.iterator();
(iterator.hasNext()) {
iterator.nextInt();
ChunkUtil.xFromColumn(blobIndex);
ChunkUtil.zFromColumn(blobIndex);
regionX << | localX;
regionZ << | localZ;
chunkIndexes.add(ChunkUtil.indexChunk(chunkX, chunkZ));
}
}
}
});
} (Throwable var6) {
(stream != ) {
{
stream.close();
} (Throwable var5) {
var6.addSuppressed(var5);
}
}
var6;
}
(stream != ) {
stream.close();
}
chunkIndexes;
}
}
IOException {
;
(IndexedStorageFile indexedStorageFile : .cache.values()) {
{
indexedStorageFile.force( );
} (Exception e) {
(exception == ) {
exception = ( );
}
exception.addSuppressed(e);
}
}
(exception != ) {
exception;
}
}
MetricResults {
METRICS_REGISTRY.toMetricResults( );
}
Resource<ChunkStore> {
();
}
{
METRICS_REGISTRY = ( ()).register( , (cache) -> (CacheEntryMetricData[])cache.cache.long2ObjectEntrySet().stream().map(CacheEntryMetricData:: ).toArray((x$ ) -> [x$ ]), (IndexedStorageChunkStorageProvider.IndexedStorageCache.CacheEntryMetricData.CODEC, (x$ ) -> [x$ ]));
}
{
Codec<CacheEntryMetricData> CODEC;
key;
IndexedStorageFile value;
{
}
{
.key = entry.getLongKey();
.value = (IndexedStorageFile)entry.getValue();
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(CacheEntryMetricData.class, CacheEntryMetricData:: ).append( ( , Codec.LONG), (entry, o) -> entry.key = o, (entry) -> entry.key).add()).append( ( , IndexedStorageFile.METRICS_REGISTRY), (entry, o) -> entry.value = o, (entry) -> entry.value).add()).build();
}
}
}
<ChunkStore> {
{
}
SystemGroup<ChunkStore> {
ChunkStore.INIT_GROUP;
}
{
((ChunkStore)store.getExternalData()).getWorld();
((IndexedStorageCache)store.getResource(IndexedStorageChunkStorageProvider.IndexedStorageCache.getResourceType())).path = world.getSavePath().resolve( );
}
{
}
}
}
com/hypixel/hytale/server/core/universe/world/storage/provider/MigrationChunkStorageProvider.java
package com.hypixel.hytale.server.core.universe.world.storage.provider;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkLoader;
import com.hypixel.hytale.server.core.universe.world.storage.IChunkSaver;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import javax.annotation.Nonnull;
public class MigrationChunkStorageProvider implements IChunkStorageProvider {
public static final String ID = "Migration" ;
@Nonnull
public static final BuilderCodec<MigrationChunkStorageProvider> CODEC;
private IChunkStorageProvider[] from;
private IChunkStorageProvider to;
public MigrationChunkStorageProvider () {
}
{
.from = from;
.to = to;
}
IChunkLoader IOException {
IChunkLoader[] loaders = [ .from.length];
( ; i < .from.length; ++i) {
loaders[i] = .from[i].getLoader(store);
}
(loaders);
}
IChunkSaver IOException {
.to.getSaver(store);
}
String {
Arrays.toString( .from);
+ var10000 + + String.valueOf( .to) + ;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(MigrationChunkStorageProvider.class, MigrationChunkStorageProvider:: ).documentation( )).append( ( , (IChunkStorageProvider.CODEC, (x$ ) -> [x$ ])), (migration, o) -> migration.from = o, (migration) -> migration.from).documentation( ).add()).append( ( , IChunkStorageProvider.CODEC), (migration, o) -> migration.to = o, (migration) -> migration.to).documentation( ).add()).build();
}
{
IChunkLoader[] loaders;
{
.loaders = loaders;
}
IOException {
;
(IChunkLoader loader : .loaders) {
{
loader.close();
} (Exception e) {
(exception == ) {
exception = ( );
}
exception.addSuppressed(e);
}
}
(exception != ) {
exception;
}
}
CompletableFuture<Holder<ChunkStore>> {
CompletableFuture<Holder<ChunkStore>> future = .loaders[ ].loadHolder(x, z);
( ; i < .loaders.length; ++i) {
.loaders[i];
future = future.handle((worldChunk, throwable) -> {
(throwable != ) {
loader.loadHolder(x, z).exceptionally((throwable1) -> {
throwable1.addSuppressed(throwable);
SneakyThrow.sneakyThrow(throwable1);
});
} {
worldChunk == ? loader.loadHolder(x, z) : future;
}
}).thenCompose(Function.identity());
}
future;
}
LongSet IOException {
();
(IChunkLoader loader : .loaders) {
indexes.addAll(loader.getIndexes());
}
indexes;
}
}
}
com/hypixel/hytale/server/core/universe/world/storage/resources/DefaultResourceStorageProvider.java
package com.hypixel.hytale.server.core.universe.world.storage.resources;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.IResourceStorage;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldProvider;
import javax.annotation.Nonnull;
public class DefaultResourceStorageProvider implements IResourceStorageProvider {
public static final DefaultResourceStorageProvider INSTANCE = new DefaultResourceStorageProvider ();
public static final String ID = "Hytale" ;
public static final BuilderCodec<DefaultResourceStorageProvider> CODEC = BuilderCodec.builder(DefaultResourceStorageProvider.class, () -> INSTANCE).build();
public static final DiskResourceStorageProvider DEFAULT = new DiskResourceStorageProvider ();
public DefaultResourceStorageProvider () {
}
@Nonnull
public <T extends > IResourceStorage {
DEFAULT.getResourceStorage(world);
}
String {
;
}
}
com/hypixel/hytale/server/core/universe/world/storage/resources/DiskResourceStorageProvider.java
package com.hypixel.hytale.server.core.universe.world.storage.resources;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.util.RawJsonReader;
import com.hypixel.hytale.component.ComponentRegistry;
import com.hypixel.hytale.component.IResourceStorage;
import com.hypixel.hytale.component.Resource;
import com.hypixel.hytale.component.ResourceType;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.server.core.Options;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldProvider;
import com.hypixel.hytale.server.core.util.BsonUtil;
import com.hypixel.hytale.server.core.util.io.FileUtil;
import com.hypixel.hytale.sneakythrow.SneakyThrow;
import com.hypixel.hytale.sneakythrow.supplier.ThrowableSupplier;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import org.bson.BsonDocument;
public class DiskResourceStorageProvider implements {
;
BuilderCodec<DiskResourceStorageProvider> CODEC;
;
{
}
String {
.path;
}
<T > IResourceStorage {
(world.getSavePath().resolve( .path));
}
String {
+ .path + ;
}
{
world.getSavePath().resolve( );
resourcesPath.resolve( );
(Files.exists(chunkStorePath, [ ])) {
{
FileUtil.moveDirectoryContents(chunkStorePath, resourcesPath, StandardCopyOption.REPLACE_EXISTING);
FileUtil.deleteDirectory(chunkStorePath);
} (IOException e) {
( , e);
}
}
resourcesPath.resolve( );
(Files.exists(entityStorePath, [ ])) {
{
FileUtil.moveDirectoryContents(entityStorePath, resourcesPath, StandardCopyOption.REPLACE_EXISTING);
FileUtil.deleteDirectory(entityStorePath);
} (IOException e) {
( , e);
}
}
}
{
CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(DiskResourceStorageProvider.class, DiskResourceStorageProvider:: ).append( ( , Codec.STRING), (o, s) -> o.path = s, (o) -> o.path).add()).build();
}
{
HytaleLogger.forEnclosingClass();
;
Path path;
{
.path = path;
(!Options.getOptionSet().has(Options.BARE)) {
{
Files.createDirectories(path);
} (IOException e) {
( , e);
}
}
}
<T <ECS_TYPE>, ECS_TYPE> CompletableFuture<T> {
BuilderCodec<T> codec = data.<T>getResourceCodec(resourceType);
codec == ? CompletableFuture.completedFuture(data.createResource(resourceType)) : CompletableFuture.supplyAsync(SneakyThrow.sneakySupplier((ThrowableSupplier)(() -> {
data.getResourceId(resourceType);
.path.resolve(id + );
BasicFileAttributes attributes;
{
attributes = Files.readAttributes(file, BasicFileAttributes.class);
} (IOException var9) {
LOGGER.at(Level.FINE).log( , file);
data.createResource(resourceType);
}
(attributes.size() == ) {
LOGGER.at(Level.WARNING).log( , file);
data.createResource(resourceType);
} {
{
(T)((Resource)RawJsonReader.readSync(file, codec, LOGGER));
resource != ? resource : data.createResource(resourceType);
} (IOException e) {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause(e)).log( , file);
data.createResource(resourceType);
}
}
})));
}
<T <ECS_TYPE>, ECS_TYPE> CompletableFuture<Void> {
BuilderCodec<T> codec = data.<T>getResourceCodec(resourceType);
(codec == ) {
CompletableFuture.completedFuture((Object) );
} {
data.getResourceId(resourceType);
.path.resolve(id + );
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
codec.encode(resource, extraInfo).asDocument();
extraInfo.getValidationResults().logOrThrowValidatorExceptions(LOGGER);
BsonUtil.writeDocument(file, document);
}
}
<T <ECS_TYPE>, ECS_TYPE> CompletableFuture<Void> {
data.getResourceId(resourceType);
(id == ) {
CompletableFuture.completedFuture((Object) );
} {
.path.resolve(id + );
{
Files.deleteIfExists(file);
CompletableFuture.completedFuture((Object) );
} (IOException e) {
CompletableFuture.failedFuture(e);
}
}
}
}
}
com/hypixel/hytale/server/core/universe/world/storage/resources/EmptyResourceStorageProvider.java
package com.hypixel.hytale.server.core.universe.world.storage.resources;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.EmptyResourceStorage;
import com.hypixel.hytale.component.IResourceStorage;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldProvider;
import javax.annotation.Nonnull;
public class EmptyResourceStorageProvider implements IResourceStorageProvider {
public static final EmptyResourceStorageProvider INSTANCE = new EmptyResourceStorageProvider ();
public static final String ID = "Empty" ;
public static final BuilderCodec<EmptyResourceStorageProvider> CODEC = BuilderCodec.builder(EmptyResourceStorageProvider.class, () -> INSTANCE).build();
public EmptyResourceStorageProvider () {
}
@Nonnull
public <T extends WorldProvider > IResourceStorage getResourceStorage (@Nonnull World world) {
return EmptyResourceStorage.get();
}
@Nonnull
String {
;
}
}
com/hypixel/hytale/server/core/universe/world/storage/resources/IResourceStorageProvider.java
package com.hypixel.hytale.server.core.universe.world.storage.resources;
import com.hypixel.hytale.codec.lookup.BuilderCodecMapCodec;
import com.hypixel.hytale.component.IResourceStorage;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldProvider;
import javax.annotation.Nonnull;
public interface IResourceStorageProvider {
@Nonnull
BuilderCodecMapCodec<IResourceStorageProvider> CODEC = new BuilderCodecMapCodec <IResourceStorageProvider>("Type" , true );
<T extends WorldProvider > IResourceStorage getResourceStorage (@Nonnull World var1) ;
}
com/hypixel/hytale/server/core/universe/world/system/WorldPregenerateSystem.java
package com.hypixel.hytale.server.core.universe.world.system;
import com.hypixel.hytale.common.util.FormatUtil;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.dependency.Order;
import com.hypixel.hytale.component.dependency.SystemGroupDependency;
import com.hypixel.hytale.component.system.StoreSystem;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.shape.Box2D;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import javax.annotation.Nonnull;
public class WorldPregenerateSystem extends StoreSystem <ChunkStore> {
private static final Set<Dependency<ChunkStore>> DEPENDENCIES;
public WorldPregenerateSystem () {
}
@Nonnull
public Set<Dependency<ChunkStore>> getDependencies () {
DEPENDENCIES;
}
{
((ChunkStore)store.getExternalData()).getWorld();
world.getWorldConfig().getChunkConfig().getPregenerateRegion();
(region != ) {
world.getLogger().at(Level.INFO).log( , region);
System.nanoTime();
MathUtil.floor(region.min.x);
MathUtil.floor(region.min.y);
MathUtil.floor(region.max.x);
MathUtil.floor(region.max.y);
List<CompletableFuture<Ref<ChunkStore>>> futures = <CompletableFuture<Ref<ChunkStore>>>();
( lowX; x <= highX; x += ) {
( lowZ; z <= highZ; z += ) {
futures.add(world.getChunkStore().getChunkReferenceAsync(ChunkUtil.indexChunkFromBlock(x, z)));
}
}
futures.size();
();
futures.forEach((f) -> f.whenComplete((worldChunk, throwable) -> {
(throwable != ) {
((HytaleLogger.Api)world.getLogger().at(Level.SEVERE).withCause(throwable)).log( );
}
(done.incrementAndGet() == allFutures) {
System.nanoTime();
world.getLogger().at(Level.INFO).log( , allFutures, FormatUtil.nanosToString(end - start));
}
}));
}
}
{
}
{
DEPENDENCIES = Set.of( (Order.AFTER, ChunkStore.INIT_GROUP));
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedBlockChunk.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.protocol.Opacity;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.environment.EnvironmentChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.palette.IntBytePalette;
import com.hypixel.hytale.server.core.universe.world.chunk.palette.ShortBytePalette;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class GeneratedBlockChunk {
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
protected long index;
protected int x;
protected int z;
protected final IntBytePalette tint;
protected final EnvironmentChunk environments;
protected final GeneratedChunkSection[] chunkSections;
public {
( , , );
}
{
(index, x, z, (), (), [ ]);
}
{
.index = index;
.x = x;
.z = z;
.tint = tint;
.environments = environments;
.chunkSections = chunkSections;
}
{
.index;
}
{
.x;
}
{
.z;
}
{
.index = index;
.x = x;
.z = z;
}
{
;
( ) {
--y;
(y <= ) {
;
}
.getSection(y);
(section == ) {
y = ChunkUtil.indexSection(y) * ;
(y == ) {
;
}
} {
section.getBlock(x, y, z);
(BlockType)BlockType.getAssetMap().getAsset(blockId);
(blockId != && type != && type.getOpacity() != Opacity.Transparent) {
;
}
}
}
y;
}
ShortBytePalette {
();
( ; x < ; ++x) {
( ; z < ; ++z) {
height.set(x, z, ( ) .getHeight(x, z));
}
}
height;
}
GeneratedChunkSection {
ChunkUtil.indexSection(y);
index >= && index < .chunkSections.length ? .chunkSections[index] : ;
}
{
.tint.get(x, z);
}
{
.tint.set(x, z, tint);
}
{
.environments.set(x, y, z, environment);
}
{
.environments.setColumn(x, z, environment);
}
{
.environments.get(x, y, z);
}
{
(y >= && y < ) {
.getSection(y);
section == ? : section.getRotationIndex(x, y, z);
} {
;
}
}
{
(y >= && y < ) {
.getSection(y);
section == ? : section.getBlock(x, y, z);
} {
;
}
}
{
(y >= && y < ) {
.getSection(y);
ChunkUtil.indexSection(y);
(section == ) {
(blockId == ) {
;
}
section = .initialize(sectionIndex);
}
section.setBlock(x, y, z, blockId, rotation, filler);
} {
((HytaleLogger.Api)LOGGER.at(Level.INFO).withCause( ())).log( , x, y, z, blockId);
}
}
GeneratedChunkSection {
.chunkSections[section] = ();
}
{
ChunkUtil.indexSection(y);
(index >= && index < .chunkSections.length) {
.chunkSections[index] = ;
}
}
BlockChunk {
( ; y < .chunkSections.length; ++y) {
.chunkSections[y];
(chunkSection != ) {
sectionHolders[y].putComponent(BlockSection.getComponentType(), chunkSection.toChunkSection());
}
}
.generateHeight();
.environments.trim();
( .x, .z, height, .tint, .environments);
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedBlockStateChunk.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockComponentChunk;
import com.hypixel.hytale.server.core.universe.world.meta.BlockState;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class GeneratedBlockStateChunk {
private final Int2ObjectMap<Holder<ChunkStore>> mapping = new Int2ObjectOpenHashMap <Holder<ChunkStore>>();
public GeneratedBlockStateChunk () {
}
public Holder<ChunkStore> getState (int x, int y, int z) {
return (Holder)this .mapping.get(ChunkUtil.indexBlockInColumn(x, y, z));
}
public void setState (int x, int y, int z, @Nullable Holder<ChunkStore> state) {
int index = ChunkUtil.indexBlockInColumn(x, y, z);
(state == ) {
.mapping.remove(index);
} {
BlockState.getBlockState(state);
(blockState != ) {
blockState.setPosition( (x, y, z));
}
.mapping.put(index, state);
}
}
BlockComponentChunk {
( .mapping, ());
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedChunk.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
import com.hypixel.hytale.common.collection.Flags;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockComponentChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn;
import com.hypixel.hytale.server.core.universe.world.chunk.ChunkFlag;
import com.hypixel.hytale.server.core.universe.world.chunk.EntityChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import javax.annotation.Nonnull;
public class GeneratedChunk {
private final GeneratedBlockChunk generatedBlockChunk;
private final GeneratedBlockStateChunk generatedBlockStateChunk;
private final GeneratedEntityChunk generatedEntityChunk;
private final Holder<ChunkStore>[] sections;
public GeneratedChunk () {
this (new GeneratedBlockChunk (), new GeneratedBlockStateChunk (), new GeneratedEntityChunk (), makeSections());
}
public GeneratedChunk (GeneratedBlockChunk generatedBlockChunk, GeneratedBlockStateChunk generatedBlockStateChunk, GeneratedEntityChunk generatedEntityChunk, Holder<ChunkStore>[] sections) {
.generatedBlockChunk = generatedBlockChunk;
.generatedBlockStateChunk = generatedBlockStateChunk;
.generatedEntityChunk = generatedEntityChunk;
.sections = sections;
}
GeneratedBlockChunk {
.generatedBlockChunk;
}
GeneratedBlockStateChunk {
.generatedBlockStateChunk;
}
GeneratedEntityChunk {
.generatedEntityChunk;
}
Holder<ChunkStore>[] getSections() {
.sections;
}
Holder<ChunkStore> {
.generatedBlockChunk.toBlockChunk( .sections);
.generatedBlockStateChunk.toBlockComponentChunk();
.generatedEntityChunk.toEntityChunk();
(world, (ChunkFlag.NEWLY_GENERATED), blockChunk, blockComponentChunk, entityChunk);
Holder<ChunkStore> holder = worldChunk.toHolder();
holder.putComponent(ChunkColumn.getComponentType(), ( .sections));
holder;
}
Holder<ChunkStore> {
.toWorldChunk(world);
}
Holder<ChunkStore>[] makeSections() {
Holder<ChunkStore>[] holders = [ ];
( ; i < holders.length; ++i) {
holders[i] = ChunkStore.REGISTRY.newHolder();
}
holders;
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedChunkSection.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
import com.hypixel.hytale.server.core.universe.world.chunk.section.palette.EmptySectionPalette;
import com.hypixel.hytale.server.core.universe.world.chunk.section.palette.ISectionPalette;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.IntArrays;
import java.util.Arrays;
import javax.annotation.Nonnull;
public class GeneratedChunkSection {
@Nonnull
private final int [] data = new int ['耀' ];
@Nonnull
private final int [] temp = new int ['耀' ];
private ISectionPalette fillers;
private ISectionPalette rotations;
public GeneratedChunkSection () {
this .fillers = EmptySectionPalette.INSTANCE;
this .rotations = EmptySectionPalette.INSTANCE;
}
public int getRotationIndex (int x, int y, int z) {
return this .getRotationIndex(ChunkUtil.indexBlock(x, y, z));
}
{
.rotations.get(index);
}
{
.getBlock(ChunkUtil.indexBlock(x, y, z));
}
{
.fillers.get(ChunkUtil.indexBlock(x, y, z));
}
{
.data[index];
}
{
.setBlock(ChunkUtil.indexBlock(x, y, z), block, rotation, filler);
}
{
.data[index] = block;
ISectionPalette. .fillers.set(index, filler);
(result == ISectionPalette.SetResult.REQUIRES_PROMOTE) {
.fillers = .fillers.promote();
.fillers.set(index, filler);
} (result == ISectionPalette.SetResult.ADDED_OR_REMOVED && .fillers.shouldDemote()) {
.fillers = .fillers.demote();
}
result = .rotations.set(index, rotation);
(result == ISectionPalette.SetResult.REQUIRES_PROMOTE) {
.rotations = .rotations.promote();
.rotations.set(index, rotation);
} (result == ISectionPalette.SetResult.ADDED_OR_REMOVED && .rotations.shouldDemote()) {
.rotations = .rotations.demote();
}
}
[] getData() {
.data;
}
{
Arrays.fill( .data, );
}
{
( ; i < .data.length; ++i) {
( .data[i] != ) {
;
}
}
;
}
BlockSection {
System.arraycopy( .data, , .temp, , );
IntArrays.unstableSort( .temp);
;
( ; i < ; ++i) {
( .temp[i] != .temp[i - ]) {
.temp[count++] = .temp[i];
}
}
(ISectionPalette.from( .data, .temp, count), .fillers, .rotations);
}
{
( ; i < ; ++i) {
buf.writeInt( .data[i]);
}
}
{
[] blocks = [ ];
( ; i < blocks.length; ++i) {
blocks[i] = buf.readInt();
}
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/GeneratedEntityChunk.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.modules.entity.component.FromWorldGen;
import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.prefab.PrefabRotation;
import com.hypixel.hytale.server.core.universe.world.chunk.EntityChunk;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class GeneratedEntityChunk {
private final List<EntityWrapperEntry> entities;
public GeneratedEntityChunk () {
this (new ObjectArrayList ());
}
protected GeneratedEntityChunk (List<EntityWrapperEntry> entities) {
this .entities = entities;
}
public List<EntityWrapperEntry> getEntities () {
return this .entities;
}
public void {
.entities.forEach(consumer);
}
{
(entityHolders != && entityHolders.length > ) {
.entities.add( (offset, rotation, entityHolders, objectId));
}
}
EntityChunk {
();
(EntityWrapperEntry entry : .entities) {
(entry.worldgenId());
(Holder<EntityStore> entityHolder : entry.entityHolders()) {
(TransformComponent)entityHolder.getComponent(TransformComponent.getComponentType());
transformComponent != ;
entry.rotation().rotate(transformComponent.getPosition().subtract( , , ));
transformComponent.getPosition().add( , , );
(HeadRotation)entityHolder.getComponent(HeadRotation.getComponentType());
(headRotationComponent != ) {
headRotationComponent.getRotation().addYaw(-entry.rotation().getYaw());
}
transformComponent.getRotation().addYaw(-entry.rotation().getYaw());
transformComponent.getPosition().add(entry.offset());
entityHolder.putComponent(FromWorldGen.getComponentType(), fromWorldGen);
entityChunk.storeEntityHolder(entityHolder);
}
}
entityChunk;
}
{
String {
String.valueOf( .offset);
+ var10000 + + String.valueOf( .rotation) + + Arrays.toString( .entityHolders) + ;
}
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/IBenchmarkableWorldGen.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
public interface IBenchmarkableWorldGen extends IWorldGen {
IWorldGenBenchmark getBenchmark () ;
}
com/hypixel/hytale/server/core/universe/world/worldgen/IWorldGen.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.server.core.universe.world.spawn.FitToHeightMapSpawnProvider;
import com.hypixel.hytale.server.core.universe.world.spawn.ISpawnProvider;
import com.hypixel.hytale.server.core.universe.world.spawn.IndividualSpawnProvider;
import java.util.concurrent.CompletableFuture;
import java.util.function.LongPredicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public interface IWorldGen {
@Nullable
WorldGenTimingsCollector getTimings () ;
CompletableFuture<GeneratedChunk> generate (int var1, long var2, int var4, int var5, LongPredicate var6) ;
@Deprecated
Transform[] getSpawnPoints(int var1);
@Nonnull
default ISpawnProvider getDefaultSpawnProvider (int seed) {
return new FitToHeightMapSpawnProvider (new IndividualSpawnProvider (this .getSpawnPoints(seed)));
}
default void shutdown () {
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/IWorldGenBenchmark.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
import java.util.concurrent.CompletableFuture;
public interface IWorldGenBenchmark {
void start () ;
void stop () ;
CompletableFuture<String> buildReport () ;
}
com/hypixel/hytale/server/core/universe/world/worldgen/ValidatableWorldGen.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
public interface ValidatableWorldGen {
boolean validate () ;
}
com/hypixel/hytale/server/core/universe/world/worldgen/WorldGenLoadException.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
import com.hypixel.hytale.common.util.ExceptionUtil;
import java.util.Objects;
import javax.annotation.Nonnull;
public class WorldGenLoadException extends Exception {
public WorldGenLoadException (@Nonnull String message) {
super ((String)Objects.requireNonNull(message));
}
public WorldGenLoadException (@Nonnull String message, Throwable cause) {
super ((String)Objects.requireNonNull(message), cause);
}
@Nonnull
public String getTraceMessage () {
return this .getTraceMessage(", " );
}
@Nonnull
public String getTraceMessage (@Nonnull String joiner) {
return ExceptionUtil.combineMessages(this , joiner);
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/WorldGenTimingsCollector.java
package com.hypixel.hytale.server.core.universe.world.worldgen;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.metrics.MetricsRegistry;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicLongArray;
import javax.annotation.Nonnull;
public class WorldGenTimingsCollector {
public static final MetricsRegistry<WorldGenTimingsCollector> METRICS_REGISTRY;
private static final double NANOS_TO_SECONDS = 1.0E-9 ;
private static final int WARMUP = 100 ;
private static final double WARMUP_VALUE = -1.0 / 0.0 ;
private static final int CHUNKS = 0 ;
private static final int ZONE_BIOME_RESULT = ;
;
;
;
;
();
( );
( );
ThreadPoolExecutor threadPoolExecutor;
{
.threadPoolExecutor = threadPoolExecutor;
}
{
.chunkCounter.incrementAndGet() > ? .addAndGet( , nanos) : - / ;
}
{
.chunkCounter.get() > ? .addAndGet( , nanos) : - / ;
}
{
.chunkCounter.get() > ? .addAndGet( , nanos) : - / ;
}
{
.chunkCounter.get() > ? .addAndGet( , nanos) : - / ;
}
{
.chunkCounter.get() > ? .addAndGet( , nanos) : - / ;
}
{
.chunkCounter.get() > ? .addAndGet( , nanos) : - / ;
}
{
- / ;
}
{
.get( );
}
{
.get( );
}
{
.get( );
}
{
.get( );
}
{
.get( );
}
{
.chunkCounter.get();
}
{
.get( );
}
{
.threadPoolExecutor.getQueue().size();
}
{
.threadPoolExecutor.getActiveCount();
}
String {
String.format( , .getChunkCounter(), .zoneBiomeResult(), .prepare(), .blocksGeneration(), .caveGeneration(), .prefabGeneration());
}
{
.times.get(index);
.counts.get(index);
getAvgSeconds(sum, count);
}
{
.times.addAndGet(index, nanos);
.counts.incrementAndGet(index);
getAvgSeconds(sum, count);
}
{
count == ? : ( )nanos * / ( )count;
}
{
METRICS_REGISTRY = ( ()).register( , (worldGenTimingsCollector) -> worldGenTimingsCollector.chunkCounter.get(), Codec.LONG).register( , (worldGenTimingsCollector) -> worldGenTimingsCollector.getChunkTime(), Codec.DOUBLE).register( , (worldGenTimingsCollector) -> worldGenTimingsCollector.zoneBiomeResult(), Codec.DOUBLE).register( , (worldGenTimingsCollector) -> worldGenTimingsCollector.prepare(), Codec.DOUBLE).register( , (worldGenTimingsCollector) -> worldGenTimingsCollector.blocksGeneration(), Codec.DOUBLE).register( , (worldGenTimingsCollector) -> worldGenTimingsCollector.caveGeneration(), Codec.DOUBLE).register( , (worldGenTimingsCollector) -> worldGenTimingsCollector.prefabGeneration(), Codec.DOUBLE).register( , WorldGenTimingsCollector::getQueueLength, Codec.INTEGER).register( , WorldGenTimingsCollector::getGeneratingCount, Codec.INTEGER);
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/provider/DummyWorldGenProvider.java
package com.hypixel.hytale.server.core.universe.world.worldgen.provider;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedBlockChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedBlockStateChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedEntityChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.IWorldGen;
import com.hypixel.hytale.server.core.universe.world.worldgen.WorldGenTimingsCollector;
import java.util.concurrent.CompletableFuture;
import java.util.function.LongPredicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class DummyWorldGenProvider implements IWorldGenProvider {
public static final String ID = "Dummy" ;
public static final BuilderCodec<DummyWorldGenProvider> CODEC = ((BuilderCodec.Builder)BuilderCodec.builder(DummyWorldGenProvider.class, DummyWorldGenProvider::new ).documentation("A dummy world generation provider that places a single layer of unknown blocks in each chunk." )).build();
public DummyWorldGenProvider () {
}
@Nonnull
public IWorldGen {
();
}
String {
;
}
{
{
}
WorldGenTimingsCollector {
;
}
Transform[] getSpawnPoints( seed) {
[]{ ( , , )};
}
CompletableFuture<GeneratedChunk> {
(index, cx, cz);
( ; x < ; ++x) {
( ; z < ; ++z) {
chunk.setBlock(x, , z, , , );
}
}
CompletableFuture.completedFuture( (chunk, (), (), GeneratedChunk.makeSections()));
}
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/provider/FlatWorldGenProvider.java
package com.hypixel.hytale.server.core.universe.world.worldgen.provider;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.codec.validation.validator.RangeRefValidator;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.protocol.Color;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.environment.config.Environment;
import com.hypixel.hytale.server.core.asset.util.ColorParseUtil;
import com.hypixel.hytale.server.core.codec.ProtocolCodecs;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedBlockChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedBlockStateChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedEntityChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.IWorldGen;
import com.hypixel.hytale.server.core.universe.world.worldgen.WorldGenLoadException;
import com.hypixel.hytale.server.core.universe.world.worldgen.WorldGenTimingsCollector;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.function.LongPredicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class FlatWorldGenProvider implements IWorldGenProvider {
;
BuilderCodec<FlatWorldGenProvider> CODEC;
Color DEFAULT_TINT;
Color tint;
Layer[] layers;
{
.tint = DEFAULT_TINT;
.layers = []{ ( , , Environment.UNKNOWN.getId(), )};
}
{
.tint = DEFAULT_TINT;
.tint = tint;
.layers = layers;
}
IWorldGen WorldGenLoadException {
ColorParseUtil.colorToARGBInt( .tint);
(Layer layer : .layers) {
(layer.from >= layer.to) {
( + String.valueOf(layer));
}
layer.from = Math.max(layer.from, );
layer.to = Math.min(layer.to, );
(layer.environment != ) {
Environment.getAssetMap().getIndex(layer.environment);
(index == - ) {
( + layer.environment);
}
layer.environmentId = index;
} {
layer.environmentId = ;
}
(layer.blockType != ) {
BlockType.getAssetMap().getIndex(layer.blockType);
(index == - ) {
( + layer.blockType);
}
layer.blockId = index;
} {
layer.blockId = ;
}
}
( .layers, tintId);
}
String {
String.valueOf( .tint);
+ var10000 + + Arrays.toString( .layers) + ;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(FlatWorldGenProvider.class, FlatWorldGenProvider:: ).documentation( )).append( ( , ProtocolCodecs.COLOR), (config, o) -> config.tint = o, (config) -> config.tint).documentation( ).add()).append( ( , (FlatWorldGenProvider.Layer.CODEC, (x$ ) -> [x$ ])), (config, o) -> config.layers = o, (config) -> config.layers).documentation( ).addValidator(Validators.nonNull()).add()).build();
DEFAULT_TINT = (( ) , ( )- , ( ) );
}
{
Layer[] layers;
tintId;
{
.layers = layers;
.tintId = tintId;
}
WorldGenTimingsCollector {
;
}
Transform[] getSpawnPoints( seed) {
[]{ ( , , )};
}
CompletableFuture<GeneratedChunk> {
(index, cx, cz);
( ; x < ; ++x) {
( ; z < ; ++z) {
generatedBlockChunk.setTint(x, z, .tintId);
}
}
(Layer layer : .layers) {
( ; x < ; ++x) {
( ; z < ; ++z) {
( layer.from; y < layer.to; ++y) {
generatedBlockChunk.setBlock(x, y, z, layer.blockId, , );
generatedBlockChunk.setEnvironment(x, y, z, layer.environmentId);
}
generatedBlockChunk.setTint(x, z, .tintId);
}
}
}
CompletableFuture.completedFuture( (generatedBlockChunk, (), (), GeneratedChunk.makeSections()));
}
}
{
BuilderCodec<Layer> CODEC;
- ;
;
String environment;
String blockType;
environmentId;
blockId;
{
}
{
.from = from;
.to = to;
.environment = environment;
.blockType = blockType;
}
String {
+ .from + + .to + + .environment + + .blockType + ;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(Layer.class, Layer:: ).documentation( )).append( ( , Codec.INTEGER), (layer, i) -> layer.from = i, (layer) -> layer.from).documentation( ).add()).append( ( , Codec.INTEGER), (layer, i) -> layer.to = i, (layer) -> layer.to).documentation( ).addValidator( ( , (String) , )).add()).append( ( , Codec.STRING), (layer, s) -> layer.blockType = s, (layer) -> layer.blockType).documentation( ).addValidator(BlockType.VALIDATOR_CACHE.getValidator()).add()).append( ( , Codec.STRING), (layer, s) -> layer.environment = s, (layer) -> layer.environment).documentation( ).addValidator(Environment.VALIDATOR_CACHE.getValidator()).add()).build();
}
}
}
com/hypixel/hytale/server/core/universe/world/worldgen/provider/IWorldGenProvider.java
package com.hypixel.hytale.server.core.universe.world.worldgen.provider;
import com.hypixel.hytale.codec.lookup.BuilderCodecMapCodec;
import com.hypixel.hytale.server.core.universe.world.worldgen.IWorldGen;
import com.hypixel.hytale.server.core.universe.world.worldgen.WorldGenLoadException;
public interface IWorldGenProvider {
BuilderCodecMapCodec<IWorldGenProvider> CODEC = new BuilderCodecMapCodec <IWorldGenProvider>("Type" , true );
IWorldGen getGenerator () throws WorldGenLoadException;
}
com/hypixel/hytale/server/core/universe/world/worldgen/provider/VoidWorldGenProvider.java
package com.hypixel.hytale.server.core.universe.world.worldgen.provider;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.protocol.Color;
import com.hypixel.hytale.server.core.asset.type.environment.config.Environment;
import com.hypixel.hytale.server.core.asset.util.ColorParseUtil;
import com.hypixel.hytale.server.core.codec.ProtocolCodecs;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedBlockChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedBlockStateChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.GeneratedEntityChunk;
import com.hypixel.hytale.server.core.universe.world.worldgen.IWorldGen;
import com.hypixel.hytale.server.core.universe.world.worldgen.WorldGenLoadException;
import com.hypixel.hytale.server.core.universe.world.worldgen.WorldGenTimingsCollector;
import java.util.concurrent.CompletableFuture;
import java.util.function.LongPredicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class VoidWorldGenProvider implements IWorldGenProvider {
public static final String ID = "Void" ;
public static BuilderCodec<VoidWorldGenProvider> CODEC;
Color tint;
String environment;
{
}
{
.tint = tint;
.environment = environment;
}
IWorldGen WorldGenLoadException {
.tint == ? : ColorParseUtil.colorToARGBInt( .tint);
.environment != ? .environment : ;
Environment.getAssetMap().getIndex(key);
(index == - ) {
( + key);
} {
(tintId, index);
}
}
String {
+ .environment + ;
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(VoidWorldGenProvider.class, VoidWorldGenProvider:: ).documentation( )).append( ( , ProtocolCodecs.COLOR), (config, o) -> config.tint = o, (config) -> config.tint).documentation( ).add()).append( ( , Codec.STRING), (config, s) -> config.environment = s, (config) -> config.environment).documentation( ).addValidator(Environment.VALIDATOR_CACHE.getValidator()).add()).build();
}
{
tintId;
environmentId;
{
.tintId = ;
.environmentId = ;
}
WorldGenLoadException {
tint == ? : ColorParseUtil.colorToARGBInt(tint);
.tintId = tintId;
environment != ? environment : ;
Environment.getAssetMap().getIndex(key);
(index == - ) {
( + key);
} {
.environmentId = index;
}
}
{
.tintId = tintId;
.environmentId = environmentId;
}
WorldGenTimingsCollector {
;
}
Transform[] getSpawnPoints( seed) {
[]{ ( , , )};
}
CompletableFuture<GeneratedChunk> {
(index, cx, cz);
( ; x < ; ++x) {
( ; z < ; ++z) {
( .environmentId != ) {
generatedBlockChunk.setEnvironmentColumn(x, z, .environmentId);
}
generatedBlockChunk.setTint(x, z, .tintId);
}
}
CompletableFuture.completedFuture( (generatedBlockChunk, (), (), GeneratedChunk.makeSections()));
}
}
}
com/hypixel/hytale/server/core/universe/world/worldlocationcondition/WorldLocationCondition.java
package com.hypixel.hytale.server.core.universe.world.worldlocationcondition;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.lookup.CodecMapCodec;
import com.hypixel.hytale.server.core.universe.world.World;
import javax.annotation.Nonnull;
public abstract class WorldLocationCondition {
public static final CodecMapCodec<WorldLocationCondition> CODEC = new CodecMapCodec <WorldLocationCondition>("Type" );
public static final BuilderCodec<WorldLocationCondition> BASE_CODEC = BuilderCodec.abstractBuilder(WorldLocationCondition.class).build();
public WorldLocationCondition () {
}
public abstract boolean test (World var1, int var2, int var3, int var4) ;
public abstract boolean equals (Object var1) ;
public abstract int hashCode () ;
@Nonnull
public String toString () {
return "WorldLocationCondition{}" ;
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/IWorldMap.java
package com.hypixel.hytale.server.core.universe.world.worldmap;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.map.WorldMap;
import it.unimi.dsi.fastutil.longs.LongSet;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
public interface IWorldMap {
WorldMapSettings getWorldMapSettings () ;
CompletableFuture<WorldMap> generate (World var1, int var2, int var3, LongSet var4) ;
CompletableFuture<Map<String, MapMarker>> generatePointsOfInterest (World var1) ;
default void shutdown () {
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/WorldMapLoadException.java
package com.hypixel.hytale.server.core.universe.world.worldmap;
import com.hypixel.hytale.common.util.ExceptionUtil;
import java.util.Objects;
import javax.annotation.Nonnull;
public class WorldMapLoadException extends Exception {
public WorldMapLoadException (@Nonnull String message) {
super ((String)Objects.requireNonNull(message));
}
public WorldMapLoadException (@Nonnull String message, Throwable cause) {
super ((String)Objects.requireNonNull(message), cause);
}
@Nonnull
public String getTraceMessage () {
return this .getTraceMessage(", " );
}
@Nonnull
public String getTraceMessage (@Nonnull String joiner) {
return ExceptionUtil.combineMessages(this , joiner);
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/WorldMapManager.java
package com.hypixel.hytale.server.core.universe.world.worldmap;
import com.hypixel.fastutil.longs.Long2ObjectConcurrentHashMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.lookup.CodecMapCodec;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.common.util.CompletableFutureUtil;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.protocol.packets.worldmap.MapImage;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
import com.hypixel.hytale.server.core.entity.UUIDComponent;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerConfigData;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldData;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.DeathMarkerProvider;
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.POIMarkerProvider;
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.PlayerIconMarkerProvider;
com.hypixel.hytale.server.core.universe.world.worldmap.markers.PlayerMarkersProvider;
com.hypixel.hytale.server.core.universe.world.worldmap.markers.RespawnMarkerProvider;
com.hypixel.hytale.server.core.universe.world.worldmap.markers.SpawnMarkerProvider;
com.hypixel.hytale.server.core.util.thread.TickingThread;
it.unimi.dsi.fastutil.longs.LongOpenHashSet;
it.unimi.dsi.fastutil.longs.LongSet;
java.util.List;
java.util.Map;
java.util.UUID;
java.util.concurrent.CompletableFuture;
java.util.concurrent.ConcurrentHashMap;
java.util.concurrent.atomic.AtomicInteger;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
;
;
HytaleLogger logger;
World world;
Long2ObjectConcurrentHashMap<ImageEntry> images = <ImageEntry>( , ChunkUtil.indexChunk(- , - ));
Long2ObjectConcurrentHashMap<CompletableFuture<MapImage>> generating = <CompletableFuture<MapImage>>( , ChunkUtil.indexChunk(- , - ));
Map<String, MarkerProvider> markerProviders = ();
Map<String, MapMarker> pointsOfInterest = ();
WorldMapSettings worldMapSettings;
IWorldMap generator;
CompletableFuture<Void> generatorLoaded;
unloadDelay;
{
( + world.getName(), , );
.worldMapSettings = WorldMapSettings.DISABLED;
.generatorLoaded = ();
.unloadDelay = ;
.logger = HytaleLogger.get( + world.getName() + );
.world = world;
.addMarkerProvider( , SpawnMarkerProvider.INSTANCE);
.addMarkerProvider( , PlayerIconMarkerProvider.INSTANCE);
.addMarkerProvider( , DeathMarkerProvider.INSTANCE);
.addMarkerProvider( , RespawnMarkerProvider.INSTANCE);
.addMarkerProvider( , PlayerMarkersProvider.INSTANCE);
.addMarkerProvider( , POIMarkerProvider.INSTANCE);
}
IWorldMap {
.generator;
}
{
.shouldTick();
( .generator != ) {
.generator.shutdown();
}
.generator = generator;
(generator != ) {
.logger.at(Level.INFO).log( , generator.toString());
.generatorLoaded.complete((Object) );
.generatorLoaded = ();
.worldMapSettings = generator.getWorldMapSettings();
.images.clear();
.generating.clear();
(Player worldPlayer : .world.getPlayers()) {
worldPlayer.getWorldMapTracker().clear();
}
.updateTickingState(before);
.sendSettings();
.logger.at(Level.INFO).log( );
CompletableFutureUtil._catch(generator.generatePointsOfInterest( .world).thenAcceptAsync((pointsOfInterest) -> {
.pointsOfInterest.putAll(pointsOfInterest);
.logger.at(Level.INFO).log( );
}));
} {
.logger.at(Level.INFO).log( );
.worldMapSettings = WorldMapSettings.DISABLED;
.sendSettings();
}
}
{
.world.getPlayerCount() == ;
}
{
(Player player : .world.getPlayers()) {
player.getWorldMapTracker().tick(dt);
}
.unloadDelay -= dt;
( .unloadDelay <= ) {
.unloadDelay = ;
.unloadImages();
}
}
{
}
{
.images.size();
(imagesCount != ) {
List<Player> players = .world.getPlayers();
();
.images.forEach((index, chunk) -> {
( .isWorldMapEnabled() && isWorldMapImageVisibleToAnyPlayer(players, index, .worldMapSettings)) {
chunk.keepAlive.set( );
} {
(chunk.keepAlive.decrementAndGet() <= ) {
toRemove.add(index);
}
}
});
(!toRemove.isEmpty()) {
toRemove.forEach((value) -> {
.logger.at(Level.FINE).log( , value);
.images.remove(value);
});
}
toRemove.size();
(toRemoveSize > ) {
.logger.at(Level.FINE).log( , toRemoveSize, imagesCount - toRemoveSize);
}
}
}
{
.worldMapSettings.getSettingsPacket().enabled;
}
{
(Player player : players) {
settings.getViewRadius(player.getViewRadius());
(player.getWorldMapTracker().shouldBeVisible(viewRadius, imageIndex)) {
;
}
}
;
}
World {
.world;
}
WorldMapSettings {
.worldMapSettings;
}
Map<String, MarkerProvider> {
.markerProviders;
}
{
.markerProviders.put(key, provider);
}
Map<String, MapMarker> {
.pointsOfInterest;
}
MapImage {
.getImageIfInMemory(ChunkUtil.indexChunk(x, z));
}
MapImage {
.images.get(index);
pair != ? pair.image : ;
}
CompletableFuture<MapImage> {
.getImageAsync(ChunkUtil.indexChunk(x, z));
}
CompletableFuture<MapImage> {
.images.get(index);
pair != ? pair.image : ;
(image != ) {
CompletableFuture.completedFuture(image);
} {
CompletableFuture<MapImage> gen = .generating.get(index);
(gen != ) {
gen;
} {
MathUtil.fastFloor( * .worldMapSettings.getImageScale());
();
chunksToGenerate.add(index);
CompletableFuture<MapImage> future = CompletableFutureUtil.<MapImage>_catch( .generator.generate( .world, imageSize, imageSize, chunksToGenerate).thenApplyAsync((worldMap) -> {
(MapImage)worldMap.getChunks().get(index);
( .generating.remove(index) != ) {
.images.put(index, (newImage));
}
newImage;
}));
.generating.put(index, future);
future;
}
}
}
{
}
{
(Player player : .world.getPlayers()) {
player.getWorldMapTracker().sendSettings( .world);
}
}
{
.world.getWorldConfig().isCompassUpdating() || .isWorldMapEnabled();
}
{
.shouldTick();
(before != after) {
(after) {
.start();
} {
.stop();
}
}
}
{
.images.clear();
.generating.clear();
}
{
chunkIndices.forEach((index) -> {
.images.remove(index);
.generating.remove(index);
});
}
PlayerMarkerReference {
((EntityStore)componentAccessor.getExternalData()).getWorld();
(Player)componentAccessor.getComponent(playerRef, Player.getComponentType());
playerComponent != ;
(UUIDComponent)componentAccessor.getComponent(playerRef, UUIDComponent.getComponentType());
uuidComponent != ;
playerComponent.getPlayerConfigData().getPerWorldData(world.getName());
MapMarker[] worldMapMarkers = perWorldData.getWorldMapMarkers();
perWorldData.setWorldMapMarkers((MapMarker[])ArrayUtil.append(worldMapMarkers, marker));
(uuidComponent.getUuid(), world.getName(), marker.id);
}
{
WorldMapManager.MarkerReference.CODEC.register((String) , PlayerMarkerReference.class, WorldMapManager.PlayerMarkerReference.CODEC);
}
{
CodecMapCodec<MarkerReference> CODEC = <MarkerReference>();
String ;
;
}
{
BuilderCodec<PlayerMarkerReference> CODEC;
UUID player;
String world;
String markerId;
{
}
{
.player = player;
.world = world;
.markerId = markerId;
}
UUID {
.player;
}
String {
.markerId;
}
{
Universe.get().getPlayer( .player);
(playerRef != ) {
(Player)playerRef.getComponent(Player.getComponentType());
.removeMarkerFromOnlinePlayer(playerComponent);
} {
.removeMarkerFromOfflinePlayer();
}
}
{
player.getPlayerConfigData();
.world;
(world == ) {
world = player.getWorld().getName();
}
removeMarkerFromData(data, world, .markerId);
}
{
Universe.get().getPlayerStorage().load( .player).thenApply((holder) -> {
(Player)holder.getComponent(Player.getComponentType());
player.getPlayerConfigData();
.world;
(world == ) {
world = data.getWorld();
}
removeMarkerFromData(data, world, .markerId);
holder;
}).thenCompose((holder) -> Universe.get().getPlayerStorage().save( .player, holder));
}
MapMarker {
data.getPerWorldData(worldName);
MapMarker[] worldMapMarkers = perWorldData.getWorldMapMarkers();
(worldMapMarkers == ) {
;
} {
- ;
( ; i < worldMapMarkers.length; ++i) {
(worldMapMarkers[i].id.equals(markerId)) {
index = i;
;
}
}
(index == - ) {
;
} {
MapMarker[] newWorldMapMarkers = [worldMapMarkers.length - ];
System.arraycopy(worldMapMarkers, , newWorldMapMarkers, , index);
System.arraycopy(worldMapMarkers, index + , newWorldMapMarkers, index, newWorldMapMarkers.length - index);
perWorldData.setWorldMapMarkers(newWorldMapMarkers);
worldMapMarkers[index];
}
}
}
{
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(PlayerMarkerReference.class, PlayerMarkerReference:: ).addField( ( , Codec.UUID_BINARY), (playerMarkerReference, uuid) -> playerMarkerReference.player = uuid, (playerMarkerReference) -> playerMarkerReference.player)).addField( ( , Codec.STRING), (playerMarkerReference, s) -> playerMarkerReference.world = s, (playerMarkerReference) -> playerMarkerReference.world)).addField( ( , Codec.STRING), (playerMarkerReference, s) -> playerMarkerReference.markerId = s, (playerMarkerReference) -> playerMarkerReference.markerId)).build();
}
}
{
();
MapImage image;
{
.image = image;
}
}
{
;
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/WorldMapSettings.java
package com.hypixel.hytale.server.core.universe.world.worldmap;
import com.hypixel.hytale.math.shape.Box2D;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.protocol.packets.worldmap.UpdateWorldMapSettings;
import javax.annotation.Nonnull;
public class WorldMapSettings {
public static final WorldMapSettings DISABLED = new WorldMapSettings ();
private Box2D worldMapArea;
private float imageScale = 0.5F ;
private float viewRadiusMultiplier = 1.0F ;
private int viewRadiusMin = 1 ;
private int viewRadiusMax = 512 ;
@Nonnull
private UpdateWorldMapSettings settingsPacket;
public WorldMapSettings () {
this .settingsPacket = new UpdateWorldMapSettings ();
this .settingsPacket.enabled = false ;
}
{
.worldMapArea = worldMapArea;
.imageScale = imageScale;
.viewRadiusMultiplier = viewRadiusMultiplier;
.viewRadiusMin = viewRadiusMin;
.viewRadiusMax = viewRadiusMax;
.settingsPacket = settingsPacket;
}
Box2D {
.worldMapArea;
}
{
.imageScale;
}
UpdateWorldMapSettings {
.settingsPacket;
}
{
MathUtil.clamp(Math.round(( )viewRadius * .viewRadiusMultiplier), .viewRadiusMin, .viewRadiusMax);
}
String {
String.valueOf( .worldMapArea);
+ var10000 + + .imageScale + + .viewRadiusMultiplier + + .viewRadiusMin + + .viewRadiusMax + + String.valueOf( .settingsPacket) + ;
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/markers/DeathMarkerProvider.java
package com.hypixel.hytale.server.core.universe.world.worldmap.markers;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.protocol.packets.worldmap.ContextMenuItem;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
import com.hypixel.hytale.server.core.asset.type.gameplay.WorldMapConfig;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerDeathPositionData;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldData;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
import com.hypixel.hytale.server.core.util.PositionUtil;
import javax.annotation.Nonnull;
public class DeathMarkerProvider implements WorldMapManager .MarkerProvider {
public static final DeathMarkerProvider INSTANCE = new DeathMarkerProvider ();
private DeathMarkerProvider () {
}
public void update (@Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, chunkViewRadius, playerChunkX, playerChunkZ) {
gameplayConfig.getWorldMapConfig();
(worldMapConfig.isDisplayDeathMarker()) {
tracker.getPlayer();
player.getPlayerConfigData().getPerWorldData(world.getName());
(PlayerDeathPositionData deathPosition : perWorldData.getDeathPositions()) {
addDeathMarker(tracker, playerChunkX, playerChunkZ, deathPosition);
}
}
}
{
deathPosition.getMarkerId();
deathPosition.getTransform();
deathPosition.getDay();
tracker.trySendMarker(- , playerChunkX, playerChunkZ, transform.getPosition(), transform.getRotation().getYaw(), markerId, + deathDay + , transform, (id, name, t) -> (id, name, , PositionUtil.toTransformPacket(t), (ContextMenuItem[]) ));
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/markers/POIMarkerProvider.java
package com.hypixel.hytale.server.core.universe.world.worldmap.markers;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
import java.util.Map;
import javax.annotation.Nonnull;
public class POIMarkerProvider implements WorldMapManager .MarkerProvider {
public static final POIMarkerProvider INSTANCE = new POIMarkerProvider ();
private POIMarkerProvider () {
}
public void update (@Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) {
Map<String, MapMarker> globalMarkers = world.getWorldMapManager().getPointsOfInterest();
if (!globalMarkers.isEmpty()) {
for (MapMarker marker : globalMarkers.values()) {
tracker.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, marker);
}
}
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/markers/PlayerIconMarkerProvider.java
package com.hypixel.hytale.server.core.universe.world.worldmap.markers;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.protocol.packets.worldmap.ContextMenuItem;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
import com.hypixel.hytale.server.core.asset.type.gameplay.WorldMapConfig;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
import com.hypixel.hytale.server.core.util.PositionUtil;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
public class PlayerIconMarkerProvider implements WorldMapManager .MarkerProvider {
public static final PlayerIconMarkerProvider INSTANCE = new PlayerIconMarkerProvider ();
private PlayerIconMarkerProvider () {
}
public void update (@Nonnull World world, @Nonnull GameplayConfig gameplayConfig, WorldMapTracker tracker, chunkViewRadius, playerChunkX, playerChunkZ) {
gameplayConfig.getWorldMapConfig();
(worldMapConfig.isDisplayPlayers()) {
(tracker.shouldUpdatePlayerMarkers()) {
tracker.getPlayer();
chunkViewRadius * chunkViewRadius;
Predicate<PlayerRef> playerMapFilter = tracker.getPlayerMapFilter();
(PlayerRef otherPlayer : world.getPlayerRefs()) {
(!otherPlayer.getUuid().equals(player.getUuid())) {
otherPlayer.getTransform();
otherPlayerTransform.getPosition();
( )otherPos.x >> ;
( )otherPos.z >> ;
otherChunkX - playerChunkX;
otherChunkZ - playerChunkZ;
chunkDiffX * chunkDiffX + chunkDiffZ * chunkDiffZ;
(chunkDistSq <= chunkViewRadiusSq && (playerMapFilter == || !playerMapFilter.test(otherPlayer))) {
tracker.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, otherPos, otherPlayer.getHeadRotation().getYaw(), + String.valueOf(otherPlayer.getUuid()), + otherPlayer.getUsername(), otherPlayer, (id, name, op) -> (id, name, , PositionUtil.toTransformPacket(op.getTransform()), (ContextMenuItem[]) ));
}
}
}
tracker.resetPlayerMarkersUpdateTimer();
}
}
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/markers/PlayerMarkersProvider.java
package com.hypixel.hytale.server.core.universe.world.worldmap.markers;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldData;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
import javax.annotation.Nonnull;
public class PlayerMarkersProvider implements WorldMapManager .MarkerProvider {
public static final PlayerMarkersProvider INSTANCE = new PlayerMarkersProvider ();
private PlayerMarkersProvider () {
}
public void update (@Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) {
Player player = tracker.getPlayer();
PlayerWorldData perWorldData = player.getPlayerConfigData().getPerWorldData(world.getName());
MapMarker[] worldMapMarkers = perWorldData.getWorldMapMarkers();
(worldMapMarkers != ) {
(MapMarker marker : worldMapMarkers) {
tracker.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, marker);
}
}
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/markers/RespawnMarkerProvider.java
package com.hypixel.hytale.server.core.universe.world.worldmap.markers;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.packets.worldmap.ContextMenuItem;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
import com.hypixel.hytale.server.core.asset.type.gameplay.WorldMapConfig;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerRespawnPointData;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
import com.hypixel.hytale.server.core.util.PositionUtil;
import javax.annotation.Nonnull;
public class RespawnMarkerProvider implements WorldMapManager .MarkerProvider {
public static final RespawnMarkerProvider INSTANCE = new RespawnMarkerProvider ();
private RespawnMarkerProvider () {
}
public void update (@Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, playerChunkZ) {
gameplayConfig.getWorldMapConfig();
(worldMapConfig.isDisplayHome()) {
PlayerRespawnPointData[] respawnPoints = tracker.getPlayer().getPlayerConfigData().getPerWorldData(world.getName()).getRespawnPoints();
(respawnPoints != ) {
( ; i < respawnPoints.length; ++i) {
addRespawnMarker(tracker, playerChunkX, playerChunkZ, respawnPoints[i], i);
}
}
}
}
{
respawnPoint.getName();
respawnPoint.getBlockPosition();
tracker.trySendMarker(- , playerChunkX, playerChunkZ, respawnPointPosition.toVector3d(), , respawnPointName + index, respawnPointName, respawnPointPosition, (id, name, rp) -> (id, name, , PositionUtil.toTransformPacket( (rp)), (ContextMenuItem[]) ));
}
}
package com.hypixel.hytale.server.core.universe.world.worldmap.markers;
import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.protocol.packets.worldmap.ContextMenuItem;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
import com.hypixel.hytale.server.core.asset.type.gameplay.WorldMapConfig;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
import com.hypixel.hytale.server.core.util.PositionUtil;
import javax.annotation.Nonnull;
public class SpawnMarkerProvider implements WorldMapManager .MarkerProvider {
public static final SpawnMarkerProvider INSTANCE = new SpawnMarkerProvider ();
private SpawnMarkerProvider () {
}
public void update (@Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, playerChunkZ) {
gameplayConfig.getWorldMapConfig();
(worldMapConfig.isDisplaySpawn()) {
tracker.getPlayer();
world.getWorldConfig().getSpawnProvider().getSpawnPoint(player);
(spawnPoint != ) {
spawnPoint.getPosition();
tracker.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, spawnPosition, spawnPoint.getRotation().getYaw(), , , spawnPosition, (id, name, pos) -> (id, name, , PositionUtil.toTransformPacket( (pos)), (ContextMenuItem[]) ));
}
}
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/provider/DisabledWorldMapProvider.java
package com.hypixel.hytale.server.core.universe.world.worldmap.provider;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.map.WorldMap;
import com.hypixel.hytale.server.core.universe.world.worldmap.IWorldMap;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapLoadException;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapSettings;
import it.unimi.dsi.fastutil.longs.LongSet;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public class DisabledWorldMapProvider implements IWorldMapProvider {
public static final String ID = "Disabled" ;
public static final BuilderCodec<DisabledWorldMapProvider> CODEC = BuilderCodec.builder(DisabledWorldMapProvider.class, DisabledWorldMapProvider::new ).build();
public DisabledWorldMapProvider () {
}
@Nonnull
public IWorldMap getGenerator (World world) throws WorldMapLoadException {
return DisabledWorldMapProvider.DisabledWorldMap.INSTANCE;
}
String {
;
}
{
();
DisabledWorldMap() {
}
WorldMapSettings {
WorldMapSettings.DISABLED;
}
CompletableFuture<WorldMap> {
CompletableFuture.completedFuture( ( ));
}
CompletableFuture<Map<String, MapMarker>> {
CompletableFuture.completedFuture(Collections.emptyMap());
}
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/provider/IWorldMapProvider.java
package com.hypixel.hytale.server.core.universe.world.worldmap.provider;
import com.hypixel.hytale.codec.lookup.BuilderCodecMapCodec;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.worldmap.IWorldMap;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapLoadException;
public interface IWorldMapProvider {
BuilderCodecMapCodec<IWorldMapProvider> CODEC = new BuilderCodecMapCodec <IWorldMapProvider>("Type" , true );
IWorldMap getGenerator (World var1) throws WorldMapLoadException;
}
com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/ChunkWorldMap.java
package com.hypixel.hytale.server.core.universe.world.worldmap.provider.chunk;
import com.hypixel.hytale.math.shape.Box2D;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.protocol.packets.worldmap.UpdateWorldMapSettings;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.map.WorldMap;
import com.hypixel.hytale.server.core.universe.world.worldmap.IWorldMap;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapSettings;
import it.unimi.dsi.fastutil.longs.LongIterator;
import it.unimi.dsi.fastutil.longs.LongSet;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public class ChunkWorldMap implements IWorldMap {
public static final ChunkWorldMap INSTANCE = new ChunkWorldMap ();
public ChunkWorldMap () {
}
@Nonnull
public WorldMapSettings getWorldMapSettings () {
UpdateWorldMapSettings settingsPacket = new UpdateWorldMapSettings ();
settingsPacket.defaultScale = ;
settingsPacket.minScale = ;
settingsPacket.maxScale = ;
((Box2D) , , , , , settingsPacket);
}
CompletableFuture<WorldMap> {
CompletableFuture<ImageBuilder>[] futures = [chunksToGenerate.size()];
;
( chunksToGenerate.iterator(); iterator.hasNext(); futures[futureIndex++] = ImageBuilder.build(iterator.nextLong(), imageWidth, imageHeight, world)) {
}
CompletableFuture.allOf(futures).thenApply((unused) -> {
(futures.length);
(CompletableFuture<ImageBuilder> future : futures) {
(ImageBuilder)future.getNow((Object) );
(builder != ) {
worldMap.getChunks().put(builder.getIndex(), builder.getImage());
}
}
worldMap;
});
}
CompletableFuture<Map<String, MapMarker>> {
CompletableFuture.completedFuture(Collections.emptyMap());
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/ImageBuilder.java
package com.hypixel.hytale.server.core.universe.world.worldmap.provider.chunk;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.math.util.ChunkUtil;
import com.hypixel.hytale.protocol.packets.worldmap.MapImage;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.environment.config.Environment;
import com.hypixel.hytale.server.core.asset.type.fluid.Fluid;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.FluidSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
class ImageBuilder {
private final long index;
private final World world;
@Nonnull
private final MapImage image;
private final int sampleWidth;
private final int sampleHeight;
private final int blockStepX;
private final int blockStepZ;
[] heightSamples;
[] tintSamples;
[] blockSamples;
[] neighborHeightSamples;
[] fluidDepthSamples;
[] environmentSamples;
[] fluidSamples;
();
WorldChunk worldChunk;
FluidSection[] fluidSections;
{
.index = index;
.world = world;
.image = (imageWidth, imageHeight, [imageWidth * imageHeight]);
.sampleWidth = Math.min( , .image.width);
.sampleHeight = Math.min( , .image.height);
.blockStepX = Math.max( , / .image.width);
.blockStepZ = Math.max( , / .image.height);
.heightSamples = [ .sampleWidth * .sampleHeight];
.tintSamples = [ .sampleWidth * .sampleHeight];
.blockSamples = [ .sampleWidth * .sampleHeight];
.neighborHeightSamples = [( .sampleWidth + ) * ( .sampleHeight + )];
.fluidDepthSamples = [ .sampleWidth * .sampleHeight];
.environmentSamples = [ .sampleWidth * .sampleHeight];
.fluidSamples = [ .sampleWidth * .sampleHeight];
}
{
.index;
}
MapImage {
.image;
}
CompletableFuture<ImageBuilder> {
.world.getChunkStore().getChunkReferenceAsync( .index).thenApplyAsync((ref) -> {
(ref != && ref.isValid()) {
.worldChunk = (WorldChunk)ref.getStore().getComponent(ref, WorldChunk.getComponentType());
(ChunkColumn)ref.getStore().getComponent(ref, ChunkColumn.getComponentType());
.fluidSections = [ ];
( ; y < ; ++y) {
Ref<ChunkStore> sectionRef = chunkColumn.getSection(y);
.fluidSections[y] = (FluidSection) .world.getChunkStore().getStore().getComponent(sectionRef, FluidSection.getComponentType());
}
;
} {
;
}
}, .world);
}
CompletableFuture<ImageBuilder> {
CompletableFuture<Void> north = .world.getChunkStore().getChunkReferenceAsync(ChunkUtil.indexChunk( .worldChunk.getX(), .worldChunk.getZ() - )).thenAcceptAsync((ref) -> {
(ref != && ref.isValid()) {
(WorldChunk)ref.getStore().getComponent(ref, WorldChunk.getComponentType());
( .sampleHeight - ) * .blockStepZ;
( ; ix < .sampleWidth; ++ix) {
ix * .blockStepX;
.neighborHeightSamples[ + ix] = worldChunk.getHeight(x, z);
}
}
}, .world);
CompletableFuture<Void> south = .world.getChunkStore().getChunkReferenceAsync(ChunkUtil.indexChunk( .worldChunk.getX(), .worldChunk.getZ() + )).thenAcceptAsync((ref) -> {
(ref != && ref.isValid()) {
(WorldChunk)ref.getStore().getComponent(ref, WorldChunk.getComponentType());
;
( .sampleHeight + ) * ( .sampleWidth + ) + ;
( ; ix < .sampleWidth; ++ix) {
ix * .blockStepX;
.neighborHeightSamples[neighbourStartIndex + ix] = worldChunk.getHeight(x, z);
}
}
}, .world);
CompletableFuture<Void> west = .world.getChunkStore().getChunkReferenceAsync(ChunkUtil.indexChunk( .worldChunk.getX() - , .worldChunk.getZ())).thenAcceptAsync((ref) -> {
(ref != && ref.isValid()) {
(WorldChunk)ref.getStore().getComponent(ref, WorldChunk.getComponentType());
( .sampleWidth - ) * .blockStepX;
( ; iz < .sampleHeight; ++iz) {
iz * .blockStepZ;
.neighborHeightSamples[(iz + ) * ( .sampleWidth + )] = worldChunk.getHeight(x, z);
}
}
}, .world);
CompletableFuture<Void> east = .world.getChunkStore().getChunkReferenceAsync(ChunkUtil.indexChunk( .worldChunk.getX() + , .worldChunk.getZ())).thenAcceptAsync((ref) -> {
(ref != && ref.isValid()) {
(WorldChunk)ref.getStore().getComponent(ref, WorldChunk.getComponentType());
;
( ; iz < .sampleHeight; ++iz) {
iz * .blockStepZ;
.neighborHeightSamples[(iz + ) * ( .sampleWidth + ) + .sampleWidth + ] = worldChunk.getHeight(x, z);
}
}
}, .world);
CompletableFuture<Void> northeast = .world.getChunkStore().getChunkReferenceAsync(ChunkUtil.indexChunk( .worldChunk.getX() + , .worldChunk.getZ() - )).thenAcceptAsync((ref) -> {
(ref != && ref.isValid()) {
(WorldChunk)ref.getStore().getComponent(ref, WorldChunk.getComponentType());
;
( .sampleHeight - ) * .blockStepZ;
.neighborHeightSamples[ ] = worldChunk.getHeight(x, z);
}
}, .world);
CompletableFuture<Void> northwest = .world.getChunkStore().getChunkReferenceAsync(ChunkUtil.indexChunk( .worldChunk.getX() - , .worldChunk.getZ() - )).thenAcceptAsync((ref) -> {
(ref != && ref.isValid()) {
(WorldChunk)ref.getStore().getComponent(ref, WorldChunk.getComponentType());
( .sampleWidth - ) * .blockStepX;
( .sampleHeight - ) * .blockStepZ;
.neighborHeightSamples[ .sampleWidth + ] = worldChunk.getHeight(x, z);
}
}, .world);
CompletableFuture<Void> southeast = .world.getChunkStore().getChunkReferenceAsync(ChunkUtil.indexChunk( .worldChunk.getX() + , .worldChunk.getZ() + )).thenAcceptAsync((ref) -> {
(ref != && ref.isValid()) {
(WorldChunk)ref.getStore().getComponent(ref, WorldChunk.getComponentType());
;
;
.neighborHeightSamples[( .sampleHeight + ) * ( .sampleWidth + ) + .sampleWidth + ] = worldChunk.getHeight(x, z);
}
}, .world);
CompletableFuture<Void> southwest = .world.getChunkStore().getChunkReferenceAsync(ChunkUtil.indexChunk( .worldChunk.getX() - , .worldChunk.getZ() + )).thenAcceptAsync((ref) -> {
(ref != && ref.isValid()) {
(WorldChunk)ref.getStore().getComponent(ref, WorldChunk.getComponentType());
( .sampleWidth - ) * .blockStepX;
;
.neighborHeightSamples[( .sampleHeight + ) * ( .sampleWidth + )] = worldChunk.getHeight(x, z);
}
}, .world);
CompletableFuture.allOf(north, south, west, east, northeast, northwest, southeast, southwest).thenApply((v) -> );
}
ImageBuilder {
( ; ix < .sampleWidth; ++ix) {
( ; iz < .sampleHeight; ++iz) {
iz * .sampleWidth + ix;
ix * .blockStepX;
iz * .blockStepZ;
.worldChunk.getHeight(x, z);
.worldChunk.getTint(x, z);
.heightSamples[sampleIndex] = height;
.tintSamples[sampleIndex] = tint;
.worldChunk.getBlock(x, height, z);
.blockSamples[sampleIndex] = blockId;
;
;
;
ChunkUtil.chunkCoordinate(height);
;
label107:
(chunkY >= && chunkY >= chunkYGround) {
.fluidSections[chunkY];
(fluidSection != && !fluidSection.isEmpty()) {
Math.max(ChunkUtil.minBlock(chunkY), height);
ChunkUtil.maxBlock(chunkY);
( maxBlockY; blockY >= minBlockY; --blockY) {
fluidId = fluidSection.getFluidId(x, blockY, z);
(fluidId != ) {
fluid = (Fluid)Fluid.getAssetMap().getAsset(fluidId);
fluidTop = blockY;
label107;
}
}
--chunkY;
} {
--chunkY;
}
}
fluidBottom;
label129:
(fluidBottom = height; chunkY >= && chunkY >= chunkYGround; --chunkY) {
.fluidSections[chunkY];
(fluidSection == || fluidSection.isEmpty()) {
fluidBottom = Math.min(ChunkUtil.maxBlock(chunkY) + , fluidTop);
;
}
Math.max(ChunkUtil.minBlock(chunkY), height);
Math.min(ChunkUtil.maxBlock(chunkY), fluidTop - );
( maxBlockY; blockY >= minBlockY; --blockY) {
fluidSection.getFluidId(x, blockY, z);
(nextFluidId != fluidId) {
(Fluid)Fluid.getAssetMap().getAsset(nextFluidId);
(!Objects.equals(fluid.getParticleColor(), nextFluid.getParticleColor())) {
fluidBottom = blockY + ;
label129;
}
}
}
}
fluidId != ? ( )(fluidTop - fluidBottom + ) : ;
.worldChunk.getBlockChunk().getEnvironment(x, fluidTop, z);
.fluidDepthSamples[sampleIndex] = fluidDepth;
.environmentSamples[sampleIndex] = environmentId;
.fluidSamples[sampleIndex] = fluidId;
}
}
( ) .sampleWidth / ( ) .image.width;
( ) .sampleHeight / ( ) .image.height;
Math.max( , .image.width / .sampleWidth);
Math.max( , .image.height / .sampleHeight);
( ; iz < .sampleHeight; ++iz) {
System.arraycopy( .heightSamples, iz * .sampleWidth, .neighborHeightSamples, (iz + ) * ( .sampleWidth + ) + , .sampleWidth);
}
( ; ix < .image.width; ++ix) {
( ; iz < .image.height; ++iz) {
Math.min(( )(( )ix * imageToSampleRatioWidth), .sampleWidth - );
Math.min(( )(( )iz * imageToSampleRatioHeight), .sampleHeight - );
sampleZ * .sampleWidth + sampleX;
ix % blockPixelWidth;
iz % blockPixelHeight;
.heightSamples[sampleIndex];
.tintSamples[sampleIndex];
.blockSamples[sampleIndex];
(height >= && blockId != ) {
getBlockColor(blockId, tint, .outColor);
.neighborHeightSamples[sampleZ * ( .sampleWidth + ) + sampleX + ];
.neighborHeightSamples[(sampleZ + ) * ( .sampleWidth + ) + sampleX + ];
.neighborHeightSamples[(sampleZ + ) * ( .sampleWidth + ) + sampleX];
.neighborHeightSamples[(sampleZ + ) * ( .sampleWidth + ) + sampleX + ];
.neighborHeightSamples[sampleZ * ( .sampleWidth + ) + sampleX];
.neighborHeightSamples[sampleZ * ( .sampleWidth + ) + sampleX + ];
.neighborHeightSamples[(sampleZ + ) * ( .sampleWidth + ) + sampleX];
.neighborHeightSamples[(sampleZ + ) * ( .sampleWidth + ) + sampleX + ];
shadeFromHeights(blockPixelX, blockPixelZ, blockPixelWidth, blockPixelHeight, height, north, south, west, east, northWest, northEast, southWest, southEast);
.outColor.multiply(shade);
(height < ) {
.fluidSamples[sampleIndex];
(fluidId != ) {
.fluidDepthSamples[sampleIndex];
.environmentSamples[sampleIndex];
getFluidColor(fluidId, environmentId, fluidDepth, .outColor);
}
}
.packImageData(ix, iz);
} {
.outColor.r = .outColor.g = .outColor.b = .outColor.a = ;
.packImageData(ix, iz);
}
}
}
;
}
{
.image.data[iz * .image.width + ix] = .outColor.pack();
}
{
(( )blockPixelX + ) / ( )blockPixelWidth;
(( )blockPixelZ + ) / ( )blockPixelHeight;
(u + v) / ;
( - u + v) / ;
( )(height - west) * ( - u) + ( )(east - height) * u;
( )(height - north) * ( - v) + ( )(south - height) * v;
( )(height - northWest) * ( - ud) + ( )(southEast - height) * ud;
( )(height - northEast) * ( - vd) + ( )(southWest - height) * vd;
dhdx1 * + dhdx2;
dhdz1 * + dhdz2;
;
/ ( )Math.sqrt(( )(dhdx * dhdx + dy * dy + dhdz * dhdz));
dhdx * invS;
dy * invS;
dhdz * invS;
- ;
;
;
/ ( )Math.sqrt(( )(lx * lx + ly * ly + lz * lz));
lx *= invL;
ly *= invL;
lz *= invL;
Math.max( , nx * lx + ny * ly + nz * lz);
;
;
ambient + diffuse * lambert;
}
{
(BlockType)BlockType.getAssetMap().getAsset(blockId);
biomeTintColor >> & ;
biomeTintColor >> & ;
biomeTintColor >> & ;
com.hypixel.hytale.protocol.Color[] tintUp = block.getTintUp();
tintUp != && tintUp.length > ;
hasTint ? tintUp[ ].red & : ;
hasTint ? tintUp[ ].green & : ;
hasTint ? tintUp[ ].blue & : ;
( )block.getBiomeTintUp() / ;
( )(( )selfTintR + ( )(biomeTintR - selfTintR) * biomeTintMultiplier);
( )(( )selfTintG + ( )(biomeTintG - selfTintG) * biomeTintMultiplier);
( )(( )selfTintB + ( )(biomeTintB - selfTintB) * biomeTintMultiplier);
com.hypixel.hytale.protocol. block.getParticleColor();
(particleColor != && biomeTintMultiplier < ) {
tintColorR = tintColorR * (particleColor.red & ) / ;
tintColorG = tintColorG * (particleColor.green & ) / ;
tintColorB = tintColorB * (particleColor.blue & ) / ;
}
outColor.r = tintColorR & ;
outColor.g = tintColorG & ;
outColor.b = tintColorB & ;
outColor.a = ;
}
{
;
;
;
(Environment)Environment.getAssetMap().getAsset(environmentId);
com.hypixel.hytale.protocol. environment.getWaterTint();
(waterTint != ) {
tintColorR = tintColorR * (waterTint.red & ) / ;
tintColorG = tintColorG * (waterTint.green & ) / ;
tintColorB = tintColorB * (waterTint.blue & ) / ;
}
(Fluid)Fluid.getAssetMap().getAsset(fluidId);
com.hypixel.hytale.protocol. fluid.getParticleColor();
(partcileColor != ) {
tintColorR = tintColorR * (partcileColor.red & ) / ;
tintColorG = tintColorG * (partcileColor.green & ) / ;
tintColorB = tintColorB * (partcileColor.blue & ) / ;
}
Math.min( , / ( )fluidDepth);
outColor.r = ( )(( )tintColorR + ( )((outColor.r & ) - tintColorR) * depthMultiplier) & ;
outColor.g = ( )(( )tintColorG + ( )((outColor.g & ) - tintColorG) * depthMultiplier) & ;
outColor.b = ( )(( )tintColorB + ( )((outColor.b & ) - tintColorB) * depthMultiplier) & ;
}
CompletableFuture<ImageBuilder> {
CompletableFuture.completedFuture( (index, imageWidth, imageHeight, world)).thenCompose(ImageBuilder::fetchChunk).thenCompose((builder) -> builder != ? builder.sampleNeighborsSync() : CompletableFuture.completedFuture((Object) )).thenApplyAsync((builder) -> builder != ? builder.generateImageAsync() : );
}
{
r;
g;
b;
a;
{
}
{
( .r & ) << | ( .g & ) << | ( .b & ) << | .a & ;
}
{
.r = Math.min( , Math.max( , ( )(( ) .r * value)));
.g = Math.min( , Math.max( , ( )(( ) .g * value)));
.b = Math.min( , Math.max( , ( )(( ) .b * value)));
}
}
}
com/hypixel/hytale/server/core/universe/world/worldmap/provider/chunk/WorldGenWorldMapProvider.java
package com.hypixel.hytale.server.core.universe.world.worldmap.provider.chunk;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.worldgen.IWorldGen;
import com.hypixel.hytale.server.core.universe.world.worldmap.IWorldMap;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapLoadException;
import com.hypixel.hytale.server.core.universe.world.worldmap.provider.IWorldMapProvider;
import javax.annotation.Nonnull;
public class WorldGenWorldMapProvider implements IWorldMapProvider {
public static final String ID = "WorldGen" ;
public static final BuilderCodec<WorldGenWorldMapProvider> CODEC = BuilderCodec.builder(WorldGenWorldMapProvider.class, WorldGenWorldMapProvider::new ).build();
public WorldGenWorldMapProvider () {
}
public IWorldMap getGenerator (@Nonnull World world) throws WorldMapLoadException {
IWorldGen generator = world.getChunkStore().getGenerator();
return (IWorldMap)(generator instanceof IWorldMapProvider ? ((IWorldMapProvider)generator).getGenerator(world) : ChunkWorldMap.INSTANCE);
}
@Nonnull
String {
;
}
}