com/hypixel/hytale/server/core/prefab/PrefabCopyableComponent.java
package com.hypixel.hytale.server.core.prefab;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
public class PrefabCopyableComponent implements Component <EntityStore> {
public static final PrefabCopyableComponent INSTANCE = new PrefabCopyableComponent ();
public static final BuilderCodec<PrefabCopyableComponent> CODEC = BuilderCodec.builder(PrefabCopyableComponent.class, () -> INSTANCE).build();
public PrefabCopyableComponent () {
}
public static ComponentType<EntityStore, PrefabCopyableComponent> getComponentType () {
return EntityModule.get().getPrefabCopyableComponentType();
}
public static PrefabCopyableComponent get () {
return INSTANCE;
}
public Component<EntityStore> clone () {
return INSTANCE;
}
}
com/hypixel/hytale/server/core/prefab/PrefabEntry.java
package com.hypixel.hytale.server.core.prefab;
import com.hypixel.hytale.assetstore.AssetPack;
import com.hypixel.hytale.server.core.asset.AssetModule;
import java.nio.file.Path;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public record PrefabEntry (@Nonnull Path path, @Nonnull Path relativePath, @Nullable AssetPack pack, @Nonnull String displayName) {
public PrefabEntry (@Nonnull Path path, @Nonnull Path relativePath, @Nullable AssetPack pack) {
this (path, relativePath, pack, buildDisplayName(relativePath, pack));
}
public boolean isFromBasePack () {
return this .pack != null && this .pack.equals(AssetModule.get().getBaseAssetPack());
}
public boolean isFromAssetPack () {
return this .pack != null ;
}
@Nonnull
public String getPackName () {
return this .pack != null ? this .pack.getName() : "Server" ;
}
@Nonnull
public String getFileName {
.path.getFileName().toString();
}
String {
( .pack != && ! .isFromBasePack()) {
.pack.getName();
+ var10000 + + .getFileName();
} {
.getFileName();
}
}
String {
relativePath.getFileName().toString();
(pack != && !pack.equals(AssetModule.get().getBaseAssetPack())) {
pack.getName();
+ var10000 + + fileName;
} {
fileName;
}
}
}
com/hypixel/hytale/server/core/prefab/PrefabLoadException.java
package com.hypixel.hytale.server.core.prefab;
import javax.annotation.Nonnull;
public class PrefabLoadException extends RuntimeException {
private Type type;
public PrefabLoadException (@Nonnull Type type) {
super (type.name());
this .type = type;
}
public PrefabLoadException (Type type, String message) {
super (message);
this .type = type;
}
public PrefabLoadException (Type type, String message, Throwable cause) {
super (message, cause);
this .type = type;
}
public PrefabLoadException (Type type, Throwable cause) {
super (cause);
this .type = type;
}
public Type getType () {
return this .type;
}
public static enum Type {
ERROR,
NOT_FOUND;
private Type () {
}
}
}
com/hypixel/hytale/server/core/prefab/PrefabRotation.java
package com.hypixel.hytale.server.core.prefab;
import com.hypixel.hytale.math.Axis;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.math.vector.Vector3l;
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.chunk.BlockRotationUtil;
import javax.annotation.Nonnull;
public enum PrefabRotation {
ROTATION_0(Rotation.None, new RotationExecutor_0 ()),
ROTATION_90(Rotation.Ninety, new RotationExecutor_90 ()),
ROTATION_180(Rotation.OneEighty, new RotationExecutor_180 ()),
ROTATION_270(Rotation.TwoSeventy, new RotationExecutor_270 ());
public static final PrefabRotation[] VALUES = values();
public static final String PREFIX = "ROTATION_" ;
private final Rotation rotation;
private final RotationExecutor executor;
@Nonnull
public static PrefabRotation fromRotation (@Nonnull Rotation rotation) {
PrefabRotation var10000;
(rotation) {
None -> var10000 = ROTATION_0;
Ninety -> var10000 = ROTATION_90;
OneEighty -> var10000 = ROTATION_180;
TwoSeventy -> var10000 = ROTATION_270;
-> ((String) , (Throwable) );
}
var10000;
}
PrefabRotation {
s.startsWith( ) ? valueOf(s) : valueOf( + s);
}
{
.rotation = rotation;
.executor = executor;
}
PrefabRotation {
.rotation.getDegrees() + other.rotation.getDegrees();
VALUES[val % / ];
}
{
v.x;
v.z;
v.x = .executor.rotateDoubleX(x, z);
v.z = .executor.rotateDoubleZ(x, z);
}
{
v.x;
v.z;
v.x = .executor.rotateIntX(x, z);
v.z = .executor.rotateIntZ(x, z);
}
{
v.x;
v.z;
v.x = .executor.rotateLongX(x, z);
v.z = .executor.rotateLongZ(x, z);
}
{
.executor.rotateIntX(x, z);
}
{
.executor.rotateIntZ(x, z);
}
{
.executor.getYaw();
}
{
( .rotation == Rotation.None) {
rotation;
} {
RotationTuple.get(rotation);
RotationTuple.of(inRotation.yaw().add( .rotation), inRotation.pitch(), inRotation.roll()).index();
}
}
{
.rotation == Rotation.None ? filler : BlockRotationUtil.getRotatedFiller(filler, Axis.Y, .rotation);
}
{
{
}
{
;
}
{
x;
}
{
x;
}
{
x;
}
{
z;
}
{
z;
}
{
z;
}
}
{
{
}
{
- ;
}
{
z;
}
{
z;
}
{
z;
}
{
-x;
}
{
-x;
}
{
-x;
}
}
{
{
}
{
- ;
}
{
-x;
}
{
-x;
}
{
-x;
}
{
-z;
}
{
-z;
}
{
-z;
}
}
{
{
}
{
- ;
}
{
-z;
}
{
-z;
}
{
-z;
}
{
x;
}
{
x;
}
{
x;
}
}
{
;
;
;
;
;
;
;
}
}
com/hypixel/hytale/server/core/prefab/PrefabSaveException.java
package com.hypixel.hytale.server.core.prefab;
public class PrefabSaveException extends RuntimeException {
private Type type;
public PrefabSaveException (Type type) {
this .type = type;
}
public PrefabSaveException (Type type, String message) {
super (message);
this .type = type;
}
public PrefabSaveException (Type type, String message, Throwable cause) {
super (message, cause);
this .type = type;
}
public PrefabSaveException (Type type, Throwable cause) {
super (cause);
this .type = type;
}
public Type getType () {
return this .type;
}
public static enum Type {
ERROR,
ALREADY_EXISTS;
private Type () {
}
}
}
com/hypixel/hytale/server/core/prefab/PrefabStore.java
package com.hypixel.hytale.server.core.prefab;
import com.hypixel.hytale.assetstore.AssetPack;
import com.hypixel.hytale.common.plugin.PluginManifest;
import com.hypixel.hytale.server.core.asset.AssetModule;
import com.hypixel.hytale.server.core.prefab.config.SelectionPrefabSerializer;
import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.util.AssetUtil;
import com.hypixel.hytale.server.core.util.BsonUtil;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonDocument;
public class PrefabStore {
public static final Predicate<Path> PREFAB_FILTER = (path) -> path.toString().endsWith(".prefab.json" );
public static final Path Path.of( );
;
();
Map<Path, BlockSelection> PREFAB_CACHE = ();
{
}
BlockSelection {
.getPrefab( .getServerPrefabsPath().resolve(key));
}
BlockSelection {
(BlockSelection) .PREFAB_CACHE.computeIfAbsent(path.toAbsolutePath().normalize(), (p) -> {
(Files.exists(p, [ ])) {
SelectionPrefabSerializer.deserialize((BsonDocument)BsonUtil.readDocument(p).join());
} {
(PrefabLoadException.Type.NOT_FOUND);
}
});
}
Path {
PREFABS_PATH;
}
Map<Path, BlockSelection> {
.getPrefabDir( .getServerPrefabsPath().resolve(key));
}
Map<Path, BlockSelection> {
{
Stream<Path> stream = Files.list(dir);
Map var3;
{
var3 = (Map)stream.filter(PREFAB_FILTER).sorted().collect(Collectors.toMap(Function.identity(), ::getPrefab, (u, v) -> {
(String.format( , u));
}, LinkedHashMap:: ));
} (Throwable var6) {
(stream != ) {
{
stream.close();
} (Throwable var5) {
var6.addSuppressed(var5);
}
}
var6;
}
(stream != ) {
stream.close();
}
var3;
} (IOException e) {
( + String.valueOf(dir), e);
}
}
{
.saveWorldGenPrefab(key, prefab, );
}
{
.savePrefab( .getWorldGenPrefabsPath().resolve(key), prefab, overwrite);
}
{
path.toFile();
(file.exists() && !overwrite) {
(PrefabSaveException.Type.ALREADY_EXISTS);
} {
file.getParentFile().mkdirs();
{
BsonUtil.writeDocument(path, SelectionPrefabSerializer.serialize(prefab)).join();
} (Throwable e) {
(PrefabSaveException.Type.ERROR, e);
}
.PREFAB_CACHE.remove(path);
}
}
Path {
.getWorldGenPrefabsPath( );
}
Path {
AssetUtil.getHytaleAssetsPath();
}
Path {
name = name == ? : name;
Universe.getWorldGenPath().resolve(name).resolve( );
}
{
.savePrefab( .getServerPrefabsPath().resolve(key), prefab, overwrite);
}
Path {
AssetUtil.getHytaleAssetsPath().resolve( ).resolve( );
}
Path {
pack.getRoot().resolve( ).resolve( );
}
List<AssetPackPrefabPath> {
List<AssetPackPrefabPath> result = <AssetPackPrefabPath>();
(AssetPack pack : AssetModule.get().getAssetPacks()) {
.getAssetPrefabsPathForPack(pack);
(Files.isDirectory(prefabsPath, [ ])) {
result.add( (pack, prefabsPath));
}
}
result;
}
BlockSelection {
(AssetPack pack : AssetModule.get().getAssetPacks()) {
.getAssetPrefabsPathForPack(pack);
prefabsPath.resolve(key);
(Files.exists(prefabPath, [ ])) {
.getPrefab(prefabPath);
}
}
;
}
Path {
(AssetPack pack : AssetModule.get().getAssetPacks()) {
.getAssetPrefabsPathForPack(pack);
prefabsPath.resolve(key);
(Files.exists(prefabPath, [ ])) {
prefabPath;
}
}
;
}
AssetPack {
prefabPath.toAbsolutePath().normalize();
(AssetPack pack : AssetModule.get().getAssetPacks()) {
.getAssetPrefabsPathForPack(pack).toAbsolutePath().normalize();
(normalizedPath.startsWith(prefabsPath)) {
pack;
}
}
;
}
BlockSelection {
.getPrefab( .getAssetPrefabsPath().resolve(key));
}
Map<Path, BlockSelection> {
.getPrefabDir( .getAssetPrefabsPath().resolve(key));
}
{
.saveWorldGenPrefab(key, prefab, );
}
{
.savePrefab( .getAssetPrefabsPath().resolve(key), prefab, overwrite);
}
BlockSelection {
.getWorldGenPrefab( .getWorldGenPrefabsPath(), key);
}
BlockSelection {
.getPrefab(prefabsPath.resolve(key));
}
Map<Path, BlockSelection> {
.getPrefabDir( .getWorldGenPrefabsPath().resolve(key));
}
{
.saveWorldGenPrefab(key, prefab, );
}
PrefabStore {
INSTANCE;
}
{
{
.pack != && .pack.equals(AssetModule.get().getBaseAssetPack());
}
{
.pack != ;
}
String {
.pack != ? .pack.getName() : ;
}
String {
( .pack == ) {
;
} ( .isBasePack()) {
;
} {
.pack.getManifest();
manifest != ? manifest.getName() : .pack.getName();
}
}
}
}
com/hypixel/hytale/server/core/prefab/PrefabWeights.java
package com.hypixel.hytale.server.core.prefab;
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.Object2DoubleMapCodec;
import com.hypixel.hytale.codec.validation.LegacyValidator;
import com.hypixel.hytale.codec.validation.ValidationResults;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.common.util.ArrayUtil;
import it.unimi.dsi.fastutil.objects.Object2DoubleMap;
import it.unimi.dsi.fastutil.objects.Object2DoubleMaps;
import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap;
import java.util.Random;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Supplier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PrefabWeights {
public static final Supplier<Object2DoubleMap<String>> MAP_SUPPLIER = Object2DoubleOpenHashMap::new ;
public static final Codec<Object2DoubleMap<String>> MAP_CODEC;
public static final Codec<PrefabWeights> CODEC;
public static final PrefabWeights NONE;
public static final double ;
;
;
defaultWeight;
Object2DoubleMap<String> weightsLookup;
sum;
[] weights;
initialized;
{
((Object2DoubleMap)MAP_SUPPLIER.get());
}
{
.weightsLookup = weights;
.defaultWeight = ;
}
{
.weightsLookup.size();
}
<T> T {
(T) .get(elements, nameFunc, random.nextDouble());
}
<T> T {
(value < ) {
;
} {
.initialize(elements, nameFunc);
( .weights.length != elements.length) {
;
} {
Math.min(value, ) * .sum;
( ; i < .weights.length; ++i) {
(weightedValue <= .weights[i]) {
(T)elements[i];
}
}
;
}
}
}
{
.weightsLookup.getOrDefault(prefab, .defaultWeight);
}
{
( != NONE) {
checkWeight(prefab, weight);
.weightsLookup.put(prefab, weight);
}
}
{
( != NONE) {
.weightsLookup.removeDouble(prefab);
}
}
{
.defaultWeight;
}
{
( != NONE) {
.defaultWeight = Math.max( , defaultWeight);
}
}
String {
( .weightsLookup.isEmpty()) {
;
} {
();
(Object2DoubleMap.Entry<String> entry : Object2DoubleMaps.fastIterable( .weightsLookup)) {
(!sb.isEmpty()) {
sb.append( ).append( );
}
sb.append((String)entry.getKey()).append( ).append(entry.getDoubleValue());
}
sb.toString();
}
}
String {
.defaultWeight;
+ var10000 + + .getMappingString() + ;
}
<T> {
(! .initialized) {
( ) {
(! .initialized) {
;
[] weights = [elements.length];
( ; i < elements.length; ++i) {
(String)nameFunc.apply(elements[i]);
sum += .getWeight(name);
weights[i] = sum;
}
.sum = sum;
.weights = weights;
.initialized = ;
}
}
}
}
PrefabWeights {
Object2DoubleMap<String> map = ;
endPoint;
( ; startPoint < mappingString.length(); startPoint = endPoint + ) {
endPoint = mappingString.indexOf( , startPoint);
(endPoint == - ) {
endPoint = mappingString.length();
}
mappingString.indexOf( , startPoint);
(equalsPoint <= startPoint) {
;
}
mappingString.substring(startPoint, equalsPoint).trim();
mappingString.substring(equalsPoint + , endPoint).trim();
Double.parseDouble(value);
(map == ) {
map = (Object2DoubleMap)MAP_SUPPLIER.get();
}
map.put(name, weight);
}
map == ? NONE : (map);
}
Set<Object2DoubleMap.Entry<String>> entrySet() {
.weightsLookup.object2DoubleEntrySet();
}
{
(weight < ) {
(String.format( , weight, prefab));
}
}
{
MAP_CODEC = <Object2DoubleMap<String>>(Codec.STRING, MAP_SUPPLIER, );
CODEC = ((BuilderCodec.Builder)((BuilderCodec.Builder)BuilderCodec.builder(PrefabWeights.class, PrefabWeights:: ).append( ( , Codec.DOUBLE), (weights, def) -> weights.defaultWeight = def, (weights) -> weights.defaultWeight).documentation( ).addValidator(Validators.greaterThanOrEqual( )).add()).append( ( , MAP_CODEC), (weights, map) -> weights.weightsLookup = map, (weights) -> weights.weightsLookup).documentation( ).addValidator( ()).add()).build();
NONE = (Object2DoubleMaps.emptyMap()) {
{
.sum = ;
.weights = ArrayUtil.EMPTY_DOUBLE_ARRAY;
.initialized = ;
}
};
}
<Object2DoubleMap<String>> {
{
}
{
(Object2DoubleMap.Entry<String> entry : Object2DoubleMaps.fastIterable(stringObject2DoubleMap)) {
PrefabWeights.checkWeight((String)entry.getKey(), entry.getDoubleValue());
}
}
}
}
com/hypixel/hytale/server/core/prefab/config/SelectionPrefabSerializer.java
package com.hypixel.hytale.server.core.prefab.config;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.codec.DirectDecodeCodec;
import com.hypixel.hytale.codec.ExtraInfo;
import com.hypixel.hytale.codec.lookup.ACodecMapCodec;
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.data.unknown.TempUnknownComponent;
import com.hypixel.hytale.component.data.unknown.UnknownComponents;
import com.hypixel.hytale.logger.HytaleLogger;
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.entity.Entity;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.server.core.prefab.selection.buffer.BsonPrefabBufferDeserializer;
import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.meta.BlockState;
import com.hypixel.hytale.server.core.universe.world.meta.BlockStateModule;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
com.hypixel.hytale.server.core.util.FillerBlockUtil;
java.util.ArrayList;
java.util.Comparator;
java.util.List;
java.util.Map;
java.util.Objects;
java.util.function.Function;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
org.bson.BsonArray;
org.bson.BsonDocument;
org.bson.BsonInt32;
org.bson.BsonString;
org.bson.BsonValue;
{
;
Comparator<BsonDocument> COMPARE_BLOCK_POSITION = Comparator.comparingInt((doc) -> doc.getInt32( ).getValue()).thenComparingInt((doc) -> doc.getInt32( ).getValue()).thenComparingInt((doc) -> doc.getInt32( ).getValue());
( );
( );
( );
{
}
BlockSelection {
doc.get( );
versionValue != ? versionValue.asInt32().getValue() : - ;
(version <= ) {
( + version);
} (version > ) {
( + version + );
} {
version < ? readWorldVersion(doc) : ;
doc.get( );
entityVersionValue != ? entityVersionValue.asInt32().getValue() : ;
doc.getInt32( ).getValue();
doc.getInt32( ).getValue();
doc.getInt32( ).getValue();
();
selection.setAnchor(anchorX, anchorY, anchorZ);
doc.getInt32( , BsonPrefabBufferDeserializer.LEGACY_BLOCK_ID_VERSION).getValue();
Function<String, String> blockMigration = ;
Map<Integer, BlockMigration> blockMigrationMap = BlockMigration.getAssetMap().getAssetMap();
blockIdVersion;
( (BlockMigration)blockMigrationMap.get(blockIdVersion); migration != ; migration = (BlockMigration)blockMigrationMap.get(v)) {
(blockMigration == ) {
Objects.requireNonNull(migration);
blockMigration = migration::getMigration;
} {
Objects.requireNonNull(migration);
blockMigration = blockMigration.andThen(migration::getMigration);
}
++v;
}
doc.get( );
(blocksValue != ) {
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
blocksValue.asArray();
( ; i < bsonArray.size(); ++i) {
bsonArray.get(i).asDocument();
innerObj.getInt32( ).getValue();
innerObj.getInt32( ).getValue();
innerObj.getInt32( ).getValue();
innerObj.getString( ).getValue();
;
(version <= ) {
Fluid. Fluid.convertBlockToFluid(blockTypeStr);
(result != ) {
legacyStripName = ;
selection.addFluidAtLocalPos(x, y, z, result.fluidId, result.fluidLevel);
(result.blockTypeStr == ) {
;
}
}
}
;
(version >= ) {
support = innerObj.getInt32( , DEFAULT_SUPPORT_VALUE).getValue();
} (blockTypeStr.contains( )) {
legacyStripName = ;
support = ;
} (blockTypeStr.contains( )) {
legacyStripName = ;
blockTypeStr.indexOf( ) + .length();
blockTypeStr.indexOf( , start);
(end == - ) {
end = blockTypeStr.length();
}
support = Integer.parseInt(blockTypeStr, start, end, );
} {
support = ;
}
;
(version >= ) {
filler = innerObj.getInt32( , DEFAULT_FILLER_VALUE).getValue();
} (blockTypeStr.contains( )) {
legacyStripName = ;
blockTypeStr.indexOf( ) + .length();
blockTypeStr.indexOf( , start);
(firstComma == - ) {
( );
}
blockTypeStr.indexOf( , firstComma + );
(secondComma == - ) {
( );
}
blockTypeStr.indexOf( , start);
(end == - ) {
end = blockTypeStr.length();
}
Integer.parseInt(blockTypeStr, start, firstComma, );
Integer.parseInt(blockTypeStr, firstComma + , secondComma, );
Integer.parseInt(blockTypeStr, secondComma + , end, );
filler = FillerBlockUtil.pack(fillerX, fillerY, fillerZ);
} {
filler = ;
}
;
(version >= ) {
rotation = innerObj.getInt32( , DEFAULT_ROTATION_VALUE).getValue();
} {
Rotation.None;
Rotation.None;
Rotation.None;
(blockTypeStr.contains( )) {
legacyStripName = ;
blockTypeStr.indexOf( ) + .length();
blockTypeStr.indexOf( , start);
(end == - ) {
end = blockTypeStr.length();
}
yaw = Rotation.ofDegrees(Integer.parseInt(blockTypeStr, start, end, ));
}
(blockTypeStr.contains( )) {
legacyStripName = ;
blockTypeStr.indexOf( ) + .length();
blockTypeStr.indexOf( , start);
(end == - ) {
end = blockTypeStr.length();
}
pitch = Rotation.ofDegrees(Integer.parseInt(blockTypeStr, start, end, ));
}
(blockTypeStr.contains( )) {
legacyStripName = ;
blockTypeStr.indexOf( ) + .length();
blockTypeStr.indexOf( , start);
(end == - ) {
end = blockTypeStr.length();
}
pitch = Rotation.ofDegrees(Integer.parseInt(blockTypeStr, start, end, ));
}
rotation = RotationTuple.index(yaw, pitch, roll);
}
(legacyStripName) {
blockTypeStr.indexOf( );
(endOfName != - ) {
blockTypeStr = blockTypeStr.substring( , endOfName);
}
}
blockTypeStr;
(blockMigration != ) {
blockTypeKey = (String)blockMigration.apply(blockTypeStr);
}
BlockType.getBlockIdOrUnknown(assetMap, blockTypeKey, , blockTypeStr);
Holder<ChunkStore> wrapper = ;
(version <= ) {
innerObj.get( );
(stateValue != ) {
wrapper = legacyStateDecode(stateValue.asDocument());
}
} {
innerObj.get( );
(stateValue != ) {
(version < ) {
wrapper = ChunkStore.REGISTRY.deserialize(stateValue.asDocument(), worldVersion);
} {
wrapper = ChunkStore.REGISTRY.deserialize(stateValue.asDocument());
}
}
}
selection.addBlockAtLocalPos(x, y, z, blockId, rotation, filler, support, wrapper);
}
}
doc.get( );
(fluidsValue != ) {
IndexedLookupTableAssetMap<String, Fluid> assetMap = Fluid.getAssetMap();
fluidsValue.asArray();
( ; i < bsonArray.size(); ++i) {
bsonArray.get(i).asDocument();
innerObj.getInt32( ).getValue();
innerObj.getInt32( ).getValue();
innerObj.getInt32( ).getValue();
innerObj.getString( ).getValue();
Fluid.getFluidIdOrUnknown(assetMap, fluidName, , fluidName);
( )innerObj.getInt32( ).getValue();
selection.addFluidAtLocalPos(x, y, z, fluidId, fluidLevel);
}
}
doc.get( );
(entitiesValues != ) {
entitiesValues.asArray();
( ; i < entities.size(); ++i) {
entities.get(i).asDocument();
(version <= ) {
{
selection.addEntityHolderRaw(legacyEntityDecode(bsonDocument, entityVersion));
} (Throwable t) {
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.WARNING).withCause(t)).log( , bsonDocument);
}
} {
selection.addEntityHolderRaw(EntityStore.REGISTRY.deserialize(bsonDocument));
}
}
}
selection;
}
}
BsonDocument {
Objects.requireNonNull(prefab, );
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
IndexedLookupTableAssetMap<String, Fluid> fluidMap = Fluid.getAssetMap();
();
out.put((String) , (BsonValue)( ( )));
out.put((String) , (BsonValue)( (BlockMigration.getAssetMap().getAssetCount())));
out.put((String) , (BsonValue)( (prefab.getAnchorX())));
out.put((String) , (BsonValue)( (prefab.getAnchorY())));
out.put((String) , (BsonValue)( (prefab.getAnchorZ())));
();
prefab.forEachBlock((x, y, z, block) -> {
();
innerObj.put((String) , (BsonValue)( (x)));
innerObj.put((String) , (BsonValue)( (y)));
innerObj.put((String) , (BsonValue)( (z)));
innerObj.put((String) , (BsonValue)( (((BlockType)assetMap.getAsset(block.blockId())).getId().toString())));
(block.holder() != ) {
innerObj.put((String) , (BsonValue)ChunkStore.REGISTRY.serialize(block.holder()));
}
(block.supportValue() != ) {
innerObj.put((String) , (BsonValue)( (block.supportValue())));
}
(block.filler() != ) {
innerObj.put((String) , (BsonValue)( (block.filler())));
}
(block.rotation() != ) {
innerObj.put((String) , (BsonValue)( (block.rotation())));
}
contentOut.add((BsonValue)innerObj);
});
contentOut.sort((a, b) -> {
a.asDocument();
b.asDocument();
COMPARE_BLOCK_POSITION.compare(aDoc, bDoc);
});
out.put((String) , (BsonValue)contentOut);
();
prefab.forEachFluid((x, y, z, fluid, level) -> {
();
innerObj.put((String) , (BsonValue)( (x)));
innerObj.put((String) , (BsonValue)( (y)));
innerObj.put((String) , (BsonValue)( (z)));
innerObj.put((String) , (BsonValue)( (((Fluid)fluidMap.getAsset(fluid)).getId())));
innerObj.put((String) , (BsonValue)( (level)));
fluidContentOut.add((BsonValue)innerObj);
});
fluidContentOut.sort((a, b) -> {
a.asDocument();
b.asDocument();
COMPARE_BLOCK_POSITION.compare(aDoc, bDoc);
});
(!fluidContentOut.isEmpty()) {
out.put((String) , (BsonValue)fluidContentOut);
}
List<BsonDocument> entityList = ();
prefab.forEachEntity((holder) -> entityList.add(EntityStore.REGISTRY.serialize(holder)));
(!entityList.isEmpty()) {
();
Objects.requireNonNull(entities);
entityList.forEach(entities::add);
out.put((String) , (BsonValue)entities);
}
out;
}
{
worldVersion;
(document.containsKey( )) {
worldVersion = document.getInt32( ).getValue();
} (document.containsKey( )) {
worldVersion = document.getInt32( ).getValue();
} {
worldVersion = ;
}
(worldVersion == ) {
( );
} (worldVersion > ) {
( + worldVersion + );
} {
worldVersion;
}
}
Holder<EntityStore> {
document.getString( ).getValue();
Class<? > entityType = EntityModule.get().getClass(entityTypeStr);
(entityType == ) {
();
unknownComponents.addComponent(entityTypeStr, (document));
EntityStore.REGISTRY.newHolder(Archetype.of(EntityStore.REGISTRY.getUnknownComponentType()), []{unknownComponents});
} {
Function<World, ? > constructor = EntityModule.get().getConstructor(entityType);
(constructor == ) {
;
} {
DirectDecodeCodec<? > codec = EntityModule.get().<Entity>getCodec(entityType);
Objects.requireNonNull(codec, );
(Entity)constructor.apply((Object) );
codec.decode(document, entity, (version));
entity.toHolder();
}
}
}
Holder<ChunkStore> {
(ExtraInfo)ExtraInfo.THREAD_LOCAL.get();
BlockState.TYPE_STRUCTURE.getNow(document, extraInto);
Class<? > blockStateClass = BlockState.CODEC.getClassFor(type);
(blockStateClass != ) {
{
(BlockState)BlockState.CODEC.decode(document, extraInto);
Holder<ChunkStore> holder = ChunkStore.REGISTRY.newHolder();
ComponentType<ChunkStore, ? > componentType = BlockStateModule.get().getComponentType(blockStateClass);
(componentType == ) {
( + String.valueOf(blockStateClass));
}
holder.addComponent(componentType, t);
holder;
} (ACodecMapCodec.UnknownIdException var7) {
}
}
Holder<ChunkStore> holder = ChunkStore.REGISTRY.newHolder();
UnknownComponents<ChunkStore> unknownComponents = <ChunkStore>();
unknownComponents.addComponent(type, (document));
holder.addComponent(ChunkStore.REGISTRY.getUnknownComponentType(), unknownComponents);
holder;
}
}
com/hypixel/hytale/server/core/prefab/event/PrefabPasteEvent.java
package com.hypixel.hytale.server.core.prefab.event;
import com.hypixel.hytale.component.system.CancellableEcsEvent;
public class PrefabPasteEvent extends CancellableEcsEvent {
private final int prefabId;
private final boolean pasteStart;
public PrefabPasteEvent (int prefabId, boolean pasteStart) {
this .prefabId = prefabId;
this .pasteStart = pasteStart;
}
public int getPrefabId () {
return this .prefabId;
}
public boolean isPasteStart () {
return this .pasteStart;
}
}
com/hypixel/hytale/server/core/prefab/event/PrefabPlaceEntityEvent.java
package com.hypixel.hytale.server.core.prefab.event;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.system.EcsEvent;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class PrefabPlaceEntityEvent extends EcsEvent {
private final int prefabId;
@Nonnull
private final Holder<EntityStore> holder;
public PrefabPlaceEntityEvent (int prefabId, @Nonnull Holder<EntityStore> holder) {
this .prefabId = prefabId;
this .holder = holder;
}
public int getPrefabId () {
return this .prefabId;
}
@Nonnull
public Holder<EntityStore> getHolder () {
return this .holder;
}
}
com/hypixel/hytale/server/core/prefab/selection/SelectionManager.java
package com.hypixel.hytale.server.core.prefab.selection;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nullable;
public final class SelectionManager {
private static final AtomicReference<SelectionProvider> SELECTION_PROVIDER = new AtomicReference ();
private SelectionManager () {
}
public static void setSelectionProvider (SelectionProvider provider) {
SELECTION_PROVIDER.set(provider);
}
@Nullable
public static SelectionProvider getSelectionProvider () {
return (SelectionProvider)SELECTION_PROVIDER.get();
}
}
com/hypixel/hytale/server/core/prefab/selection/SelectionProvider.java
package com.hypixel.hytale.server.core.prefab.selection;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.sneakythrow.consumer.ThrowableConsumer;
import javax.annotation.Nonnull;
public interface SelectionProvider {
<T extends Throwable > void computeSelectionCopy (@Nonnull Ref<EntityStore> var1, @Nonnull Player var2, @Nonnull ThrowableConsumer<BlockSelection, T> var3, @Nonnull ComponentAccessor<EntityStore> var4) ;
}
com/hypixel/hytale/server/core/prefab/selection/buffer/BinaryPrefabBufferCodec.java
package com.hypixel.hytale.server.core.prefab.selection.buffer;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.math.block.BlockUtil;
import com.hypixel.hytale.math.util.MathUtil;
import com.hypixel.hytale.math.vector.Vector3i;
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.fluid.Fluid;
import com.hypixel.hytale.server.core.prefab.config.SelectionPrefabSerializer;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.IPrefabBuffer;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.PrefabBuffer;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.PrefabBufferBlockEntry;
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.BsonUtil;
import com.hypixel.hytale.server.core.util.io.ByteBufUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.nio.file.Path;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonDocument;
public class <ByteBuf> {
();
;
;
;
;
;
;
;
{
}
PrefabBuffer {
buffer.readUnsignedShort();
(version == ) {
( );
} ( < version) {
( + version);
} {
version < ? buffer.readUnsignedShort() : ;
(version == ) {
buffer.readUnsignedShort();
}
version >= && version < ? buffer.readUnsignedShort() : ;
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
;
(version >= ) {
blockIdVersion = buffer.readShort();
}
Vector3i.ZERO;
(version >= ) {
buffer.readLong();
anchor = (BlockUtil.unpackX(packedAnchor), BlockUtil.unpackY(packedAnchor), BlockUtil.unpackZ(packedAnchor));
}
Function<String, String> blockMigration = ;
Map<Integer, BlockMigration> blockMigrationMap = BlockMigration.getAssetMap().getAssetMap();
blockIdVersion;
( (BlockMigration)blockMigrationMap.get(blockIdVersion); migration != ; migration = (BlockMigration)blockMigrationMap.get(v)) {
(blockMigration == ) {
Objects.requireNonNull(migration);
blockMigration = migration::getMigration;
} {
Objects.requireNonNull(migration);
blockMigration = blockMigration.andThen(migration::getMigration);
}
++v;
}
buffer.readInt();
Int2ObjectOpenHashMap<BlockIdEntry> blockIdMapping = <BlockIdEntry>(blockNameCount);
( ; i < blockNameCount; ++i) {
{
buffer.readInt();
.deserializeBlock(buffer, assetMap, blockMigration);
blockIdMapping.put(readId, block);
} (Exception e) {
( + i, e);
}
}
IndexedLookupTableAssetMap<String, Fluid> fluidMap = Fluid.getAssetMap();
version >= ? buffer.readInt() : ;
Int2ObjectOpenHashMap<FluidIdEntry> fluidIdMapping = <FluidIdEntry>(fluidNameCount);
( ; i < fluidNameCount; ++i) {
{
buffer.readInt();
.deserializeFluid(buffer, fluidMap);
fluidIdMapping.put(readId, fluid);
} (Exception e) {
( + i, e);
}
}
PrefabBuffer. PrefabBuffer.newBuilder();
builder.setAnchor(anchor);
buffer.readInt();
( ; i < columnCount; ++i) {
buffer.readInt();
buffer.readInt();
PrefabBufferBlockEntry[] blockEntries = [blocks];
( ; j < blocks; ++j) {
buffer.readShort();
buffer.readInt();
blockIdMapping.get(readId);
buffer.readUnsignedByte();
(mask & ) == ;
(mask & ) == ;
(mask & ) == ;
(mask & ) == ;
(mask & ) == ;
(mask & ) == ;
hasChance ? buffer.readFloat() : ;
Holder<ChunkStore> holder = ;
(hasState) {
BsonUtil.readFromBinaryStream(buffer);
(version < ) {
holder = SelectionPrefabSerializer.legacyStateDecode(doc);
} (version < ) {
holder = ChunkStore.REGISTRY.deserialize(doc, worldVersion);
} {
holder = ChunkStore.REGISTRY.deserialize(doc);
}
}
;
(hasSupportValue) {
supportValue = ( )(buffer.readByte() & );
}
;
(hasFiller) {
filler = buffer.readUnsignedShort();
}
;
(hasRotation) {
rotation = buffer.readUnsignedByte();
}
;
;
(hasFluid) {
buffer.readInt();
fluidId = (fluidIdMapping.get(id)).id;
fluidLevel = buffer.readByte();
}
blockEntries[j] = (y, block.id, block.key, chance, holder, fluidId, fluidLevel, supportValue, rotation, filler);
}
buffer.readUnsignedShort();
Holder<EntityStore>[] entityHolders = ;
(entityCount > ) {
entityHolders = [entityCount];
( ; j < entityCount; ++j) {
{
(version >= && version < ) {
entityVersion = buffer.readUnsignedShort();
}
BsonUtil.readFromBinaryStream(buffer);
Holder<EntityStore> entityHolder;
(version < ) {
entityHolder = SelectionPrefabSerializer.legacyEntityDecode(entityDocument, entityVersion);
} (version < ) {
entityHolder = EntityStore.REGISTRY.deserialize(entityDocument, entityVersion);
} {
entityHolder = EntityStore.REGISTRY.deserialize(entityDocument);
}
entityHolders[j] = entityHolder;
} (Exception e) {
( + i, e);
}
}
}
MathUtil.unpackLeft(columnIndex);
MathUtil.unpackRight(columnIndex);
builder.addColumn(x, z, blockEntries, entityHolders);
}
builder.build();
}
}
BlockIdEntry {
ByteBufUtil.readUTF(buffer);
blockTypeString;
(blockMigration != ) {
blockTypeKey = (String)blockMigration.apply(blockTypeString);
}
BlockType.getBlockIdOrUnknown(assetMap, blockTypeKey, , blockTypeString);
(blockId, blockTypeKey);
}
FluidIdEntry {
ByteBufUtil.readUTF(buffer);
Fluid.getFluidIdOrUnknown(assetMap, fluidName, , fluidName);
(fluidId, fluidName);
}
ByteBuf {
PrefabBuffer. prefabBuffer.newAccess();
Int2ObjectOpenHashMap<String> blockNameMapping = <String>();
Int2ObjectOpenHashMap<String> fluidNameMapping = <String>();
[] counts = [ ];
access.forEachRaw((x, z, blocks, o) -> {
counts[ ]++;
counts[ ] += blocks;
;
}, (IPrefabBuffer.RawBlockConsumer)((x, y, z, mask, blockId, chance, holder, support, rotation, filler, o) -> {
(!blockNameMapping.containsKey(blockId)) {
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
assetMap.getAsset(blockId);
(blockType == ) {
blockType = BlockType.UNKNOWN;
}
blockNameMapping.put(blockId, blockType.getId().toString());
}
}), (IPrefabBuffer.FluidConsumer)((x, y, z, fluidId, level, o) -> {
(!fluidNameMapping.containsKey(fluidId)) {
IndexedLookupTableAssetMap<String, Fluid> assetMap = Fluid.getAssetMap();
assetMap.getAsset(fluidId);
(fluidType == ) {
fluidType = Fluid.UNKNOWN;
}
fluidNameMapping.put(fluidId, fluidType.getId());
}
}), (IPrefabBuffer.EntityConsumer)((x, z, entityHolders, o) -> {
(entityHolders != ) {
counts[ ] += entityHolders.length;
}
}), (Object) );
Unpooled.buffer( + blockNameMapping.size() * + counts[ ] * + counts[ ] * + counts[ ] * );
buffer.writeShort( );
buffer.writeShort(BlockMigration.getAssetMap().getAssetCount());
buffer.writeLong(BlockUtil.pack(prefabBuffer.getAnchorX(), prefabBuffer.getAnchorY(), prefabBuffer.getAnchorZ()));
buffer.writeInt(blockNameMapping.size());
blockNameMapping.int2ObjectEntrySet().fastForEach((entry) -> {
buffer.writeInt(entry.getIntKey());
ByteBufUtil.writeUTF(buffer, (String)entry.getValue());
});
buffer.writeInt(fluidNameMapping.size());
fluidNameMapping.int2ObjectEntrySet().fastForEach((entry) -> {
buffer.writeInt(entry.getIntKey());
ByteBufUtil.writeUTF(buffer, (String)entry.getValue());
});
buffer.writeInt(access.getColumnCount());
access.forEachRaw((x, z, blocks, o) -> {
buffer.writeInt(MathUtil.packInt(x, z));
buffer.writeInt(blocks);
;
}, (IPrefabBuffer.RawBlockConsumer)((x, y, z, entryMask, blockId, chance, holder, supportValue, rotation, filler, o) -> {
buffer.writeShort(( )y);
buffer.writeInt(blockId);
chance < ;
holder != ;
;
(hasChance) {
mask |= ;
}
(hasComponents) {
mask |= ;
}
((entryMask & ) != ) {
mask |= ;
}
(supportValue != ) {
mask |= ;
}
(filler != ) {
mask |= ;
}
(rotation != ) {
mask |= ;
}
buffer.writeByte(mask);
(hasChance) {
buffer.writeFloat(chance);
}
(hasComponents) {
{
BsonUtil.writeToBinaryStream(buffer, ChunkStore.REGISTRY.serialize(holder));
} (Throwable t) {
(String.format( , x, y, z), t);
}
}
(supportValue != ) {
buffer.writeByte(supportValue);
}
(filler != ) {
buffer.writeShort(filler);
}
(rotation != ) {
buffer.writeByte(rotation);
}
}), (IPrefabBuffer.FluidConsumer)((x, y, z, fluidId, level, o) -> {
buffer.writeInt(fluidId);
buffer.writeByte(level);
}), (IPrefabBuffer.EntityConsumer)((x, z, entityHolders, o) -> {
entityHolders != ? entityHolders.length : ;
buffer.writeShort(entities);
( ; i < entities; ++i) {
Holder<EntityStore> entityHolder = entityHolders[i];
{
EntityStore.REGISTRY.serialize(entityHolder);
BsonUtil.writeToBinaryStream(buffer, document);
} (Exception e) {
(String.format( , x, z, i), e);
}
}
}), (Object) );
buffer;
}
{
id;
String key;
{
.id = id;
.key = key;
}
}
{
id;
String key;
{
.id = id;
.key = key;
}
}
}
com/hypixel/hytale/server/core/prefab/selection/buffer/BsonPrefabBufferDeserializer.java
package com.hypixel.hytale.server.core.prefab.selection.buffer;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.component.Holder;
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.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.fluid.Fluid;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.prefab.config.SelectionPrefabSerializer;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.PrefabBuffer;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.PrefabBufferBlockEntry;
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.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonArray;
import org.bson.BsonDocument;
org.bson.BsonInt32;
org.bson.BsonValue;
<BsonDocument> {
();
( );
( );
( );
( );
{
}
PrefabBuffer {
document.get( );
versionValue != ? versionValue.asInt32().getValue() : - ;
(version > ) {
( + version + );
} {
version < ? SelectionPrefabSerializer.readWorldVersion(document) : ;
document.get( );
entityVersionValue != ? entityVersionValue.asInt32().getValue() : ;
(version < ) {
( + version + );
} {
();
anchor.x = document.getInt32( ).getValue();
anchor.y = document.getInt32( ).getValue();
anchor.z = document.getInt32( ).getValue();
document.getInt32( , LEGACY_BLOCK_ID_VERSION).getValue();
Function<String, String> blockMigration = ;
Map<Integer, BlockMigration> blockMigrationMap = BlockMigration.getAssetMap().getAssetMap();
blockIdVersion;
( (BlockMigration)blockMigrationMap.get(blockIdVersion); migration != ; migration = (BlockMigration)blockMigrationMap.get(v)) {
(blockMigration == ) {
Objects.requireNonNull(migration);
blockMigration = migration::getMigration;
} {
Objects.requireNonNull(migration);
blockMigration = blockMigration.andThen(migration::getMigration);
}
++v;
}
Int2ObjectOpenHashMap<Int2ObjectMap<PrefabBufferBlockEntry>> columnMap = <Int2ObjectMap<PrefabBufferBlockEntry>>();
PrefabBuffer. PrefabBuffer.newBuilder();
builder.setAnchor(anchor);
document.get( );
(blocksValue != ) {
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
(BsonValue blockValue : blocksValue.asArray()) {
blockValue.asDocument();
blockDocument.getInt32( ).getValue();
blockDocument.getInt32( ).getValue();
blockDocument.getInt32( ).getValue();
realX - anchor.x;
realY - anchor.y;
realZ - anchor.z;
(- > x || x > ) {
( + x + );
}
(- > y || y > ) {
( + y + );
}
(- > z || z > ) {
( + z + );
}
builder.newBlockEntry(y);
{
deserializeBlockType(blockEntry, blockDocument, assetMap, blockMigration);
} (Throwable t) {
( + String.valueOf(path) + + realX + + realY + + realZ, t);
}
deserializeState(blockEntry, blockDocument, version, worldVersion);
blockEntry.supportValue = ( )blockDocument.getInt32( , DEFAULT_SUPPORT_VALUE).getValue();
blockEntry.filler = blockDocument.getInt32( , DEFAULT_FILLER_VALUE).getValue();
blockEntry.rotation = blockDocument.getInt32( , DEFAULT_ROTATION_VALUE).getValue();
MathUtil.packInt(x, z);
Int2ObjectMap<PrefabBufferBlockEntry> column = columnMap.get(columnIndex);
(column == ) {
columnMap.put(columnIndex, column = <PrefabBufferBlockEntry>());
}
column.putIfAbsent(y, blockEntry);
(existing != ) {
( + realX + + realY + + realZ + + blockEntry.blockTypeKey + + existing.y + + existing.blockTypeKey);
}
}
}
document.get( );
(fluidsValue != ) {
IndexedLookupTableAssetMap<String, Fluid> assetMap = Fluid.getAssetMap();
(BsonValue fluidValue : fluidsValue.asArray()) {
fluidValue.asDocument();
fluidDocument.getInt32( ).getValue();
fluidDocument.getInt32( ).getValue();
fluidDocument.getInt32( ).getValue();
realX - anchor.x;
realY - anchor.y;
realZ - anchor.z;
(- > x || x > ) {
( + x + );
}
(- > y || y > ) {
( + y + );
}
(- > z || z > ) {
( + z + );
}
MathUtil.packInt(x, z);
Int2ObjectMap<PrefabBufferBlockEntry> column = columnMap.get(columnIndex);
(column == ) {
columnMap.put(columnIndex, column = <PrefabBufferBlockEntry>());
}
Objects.requireNonNull(builder);
(PrefabBufferBlockEntry)column.computeIfAbsent(y, builder::newBlockEntry);
fluidDocument.getString( ).getValue();
entry.fluidId = Fluid.getFluidIdOrUnknown(fluidName, , fluidName);
entry.fluidLevel = ( )fluidDocument.getInt32( ).getValue();
}
}
Int2ObjectOpenHashMap<List<Holder<EntityStore>>> entityMap = deserializeEntityHolders(document, anchor, version, entityVersion);
columnMap.int2ObjectEntrySet().fastForEach((entryx) -> {
entryx.getIntKey();
MathUtil.unpackLeft(columnIndex);
MathUtil.unpackRight(columnIndex);
Int2ObjectMap<PrefabBufferBlockEntry> columnBlockMap = (Int2ObjectMap)entryx.getValue();
PrefabBufferBlockEntry[] entries = (PrefabBufferBlockEntry[])columnBlockMap.values().toArray((x$ ) -> [x$ ]);
Arrays.sort(entries, Comparator.comparingInt((o) -> o.y));
List<Holder<EntityStore>> entityColumn = entityMap.remove(columnIndex);
Holder[] entityArray = entityColumn != && !entityColumn.isEmpty() ? (Holder[])entityColumn.toArray((x$ ) -> [x$ ]) : ;
builder.addColumn(x, z, entries, entityArray);
});
entityMap.int2ObjectEntrySet().fastForEach((entryx) -> {
entryx.getIntKey();
MathUtil.unpackLeft(columnIndex);
MathUtil.unpackRight(columnIndex);
List<Holder<EntityStore>> entityColumn = (List)entryx.getValue();
Holder[] entityArray = !entityColumn.isEmpty() ? (Holder[])entityColumn.toArray((x$ ) -> [x$ ]) : ;
(entityArray != ) {
builder.addColumn(x, z, PrefabBufferBlockEntry.EMPTY_ARRAY, entityArray);
}
});
builder.build();
}
}
}
{
blockDocument.getString( ).getValue();
blockType.indexOf( );
String blockTypeStr;
(idx != - ) {
blockTypeStr = blockType.substring(idx + );
} {
blockTypeStr = blockType;
}
blockEntry.blockTypeKey = blockTypeStr;
(blockMigration != ) {
blockEntry.blockTypeKey = (String)blockMigration.apply(blockEntry.blockTypeKey);
}
blockEntry.blockId = BlockType.getBlockIdOrUnknown(assetMap, blockEntry.blockTypeKey, , blockTypeStr);
(idx != - ) {
blockType.substring( , idx);
Float.parseFloat(chanceString);
(chancePercent < ) {
( + chancePercent);
}
(chancePercent > ) {
( + chancePercent);
}
blockEntry.chance = chancePercent / ;
}
}
{
(version <= ) {
blockDocument.get( );
(stateValue != ) {
blockEntry.state = SelectionPrefabSerializer.legacyStateDecode(stateValue.asDocument());
}
} {
blockDocument.get( );
(stateValue != ) {
(version < ) {
blockEntry.state = ChunkStore.REGISTRY.deserialize(stateValue.asDocument(), worldVersion);
} {
blockEntry.state = ChunkStore.REGISTRY.deserialize(stateValue.asDocument());
}
}
}
}
Int2ObjectOpenHashMap<List<Holder<EntityStore>>> {
document.get( );
Int2ObjectOpenHashMap<List<Holder<EntityStore>>> entityMap = <List<Holder<EntityStore>>>();
(entitiesValue == ) {
entityMap;
} {
entitiesValue.asArray();
;
( entitiesArray.size(); i < size; ++i) {
entitiesArray.get(i).asDocument();
{
Holder<EntityStore> entityHolder;
(version <= ) {
entityHolder = SelectionPrefabSerializer.legacyEntityDecode(entityDocument, entityVersion);
} {
entityHolder = EntityStore.REGISTRY.deserialize(entityDocument);
}
(TransformComponent)entityHolder.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
position.add(( )(-anchor.x), ( )(-anchor.y), ( )(-anchor.z));
MathUtil.floor(position.getX()) & ;
MathUtil.floor(position.getZ()) & ;
MathUtil.packInt(x, z);
List<Holder<EntityStore>> entityColumn = entityMap.get(columnIndex);
(entityColumn == ) {
entityMap.put(columnIndex, entityColumn = <Holder<EntityStore>>());
}
entityColumn.add(entityHolder);
} (Exception e) {
( + i + + String.valueOf(entityDocument), e);
}
}
entityMap;
}
}
}
com/hypixel/hytale/server/core/prefab/selection/buffer/PrefabBufferCall.java
package com.hypixel.hytale.server.core.prefab.selection.buffer;
import com.hypixel.hytale.server.core.prefab.PrefabRotation;
import java.util.Random;
public class PrefabBufferCall {
public Random random;
public PrefabRotation rotation;
public PrefabBufferCall () {
}
public PrefabBufferCall (Random random, PrefabRotation rotation) {
this .random = random;
this .rotation = rotation;
}
}
com/hypixel/hytale/server/core/prefab/selection/buffer/PrefabBufferCodec.java
package com.hypixel.hytale.server.core.prefab.selection.buffer;
public interface PrefabBufferCodec <T> extends PrefabBufferSerializer <T>, PrefabBufferDeserializer<T> {
}
com/hypixel/hytale/server/core/prefab/selection/buffer/PrefabBufferDeserializer.java
package com.hypixel.hytale.server.core.prefab.selection.buffer;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.PrefabBuffer;
import java.nio.file.Path;
public interface PrefabBufferDeserializer <T> {
PrefabBuffer deserialize (Path var1, T var2) ;
}
com/hypixel/hytale/server/core/prefab/selection/buffer/PrefabBufferSerializer.java
package com.hypixel.hytale.server.core.prefab.selection.buffer;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.PrefabBuffer;
public interface PrefabBufferSerializer <T> {
T serialize (PrefabBuffer var1) ;
}
com/hypixel/hytale/server/core/prefab/selection/buffer/PrefabBufferUtil.java
package com.hypixel.hytale.server.core.prefab.selection.buffer;
import com.hypixel.hytale.assetstore.AssetPack;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.logger.sentry.SkipSentryException;
import com.hypixel.hytale.server.core.Options;
import com.hypixel.hytale.server.core.asset.AssetModule;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.IPrefabBuffer;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.PrefabBuffer;
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 io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.StampedLock;
import java.util.logging.Level;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bson.BsonDocument;
{
Path CACHE_PATH;
;
;
;
;
Pattern FILE_SUFFIX_PATTERN;
HytaleLogger LOGGER;
Map<Path, WeakReference<CachedEntry>> CACHE;
{
}
IPrefabBuffer {
WeakReference<CachedEntry> reference = (WeakReference)CACHE.get(path);
reference != ? (CachedEntry)reference.get() : ;
(cachedPrefab != ) {
cachedPrefab.lock.readLock();
{
(cachedPrefab.buffer != ) {
PrefabBuffer. cachedPrefab.buffer.newAccess();
var5;
}
} {
cachedPrefab.lock.unlockRead(stamp);
}
}
cachedPrefab = getOrCreateCacheEntry(path);
cachedPrefab.lock.writeLock();
PrefabBuffer.PrefabBufferAccessor var16;
{
(cachedPrefab.buffer == ) {
cachedPrefab.buffer = loadBuffer(path);
var16 = cachedPrefab.buffer.newAccess();
var16;
}
var16 = cachedPrefab.buffer.newAccess();
} {
cachedPrefab.lock.unlockWrite(stamp);
}
var16;
}
PrefabBuffer {
path.getFileName().toString();
fileNameStr.replace( , ).replace( , );
path.resolveSibling(fileName + );
(Files.exists(lpfPath, [ ])) {
loadFromLPF(path, lpfPath);
} {
Path cachedLpfPath;
AssetPack pack;
(AssetModule.get().isAssetPathImmutable(path)) {
path.resolveSibling(fileName + );
(Files.exists(lpfConvertedPath, [ ])) {
loadFromLPF(path, lpfConvertedPath);
}
pack = AssetModule.get().findAssetPackForPath(path);
(pack != ) {
FileUtil.INVALID_FILENAME_CHARACTERS.matcher(pack.getName()).replaceAll( );
cachedLpfPath = CACHE_PATH.resolve(safePackName).resolve(pack.getRoot().relativize(lpfConvertedPath).toString());
} (lpfConvertedPath.getRoot() != ) {
cachedLpfPath = CACHE_PATH.resolve(lpfConvertedPath.subpath( , lpfConvertedPath.getNameCount()).toString());
} {
cachedLpfPath = CACHE_PATH.resolve(lpfConvertedPath.toString());
}
} {
cachedLpfPath = path.resolveSibling(fileName + );
pack = ;
}
path.resolveSibling(fileName + );
(!Files.exists(jsonPath, [ ])) {
{
Files.deleteIfExists(cachedLpfPath);
} (IOException var8) {
}
( + String.valueOf(jsonPath.toAbsolutePath()) + );
} {
{
loadFromJson(pack, path, cachedLpfPath, jsonPath);
} (IOException e) {
SneakyThrow.sneakyThrow(e);
}
}
}
}
CompletableFuture<Void> {
CompletableFuture.runAsync(SneakyThrow.sneakyRunnable(() -> {
Files.newByteChannel(path, FileUtil.DEFAULT_WRITE_OPTIONS);
{
channel.write(BinaryPrefabBufferCodec.INSTANCE.serialize(prefab).nioBuffer());
} (Throwable var6) {
(channel != ) {
{
channel.close();
} (Throwable x2) {
var6.addSuppressed(x2);
}
}
var6;
}
(channel != ) {
channel.close();
}
}));
}
PrefabBuffer {
(PrefabBuffer)readFromFileAsync(path).join();
}
CompletableFuture<PrefabBuffer> {
CompletableFuture.supplyAsync(SneakyThrow.sneakySupplier((ThrowableSupplier)(() -> {
Files.newByteChannel(path);
PrefabBuffer var4;
{
( )channel.size();
Unpooled.buffer(size);
buf.writerIndex(size);
(channel.read(buf.internalNioBuffer( , size)) != size) {
( );
}
var4 = BinaryPrefabBufferCodec.INSTANCE.deserialize(path, buf);
} (Throwable var6) {
(channel != ) {
{
channel.close();
} (Throwable x2) {
var6.addSuppressed(x2);
}
}
var6;
}
(channel != ) {
channel.close();
}
var4;
})));
}
PrefabBuffer {
{
readFromFile(realPath);
} (Exception e) {
( + String.valueOf(path.toAbsolutePath()) + + String.valueOf(realPath.toAbsolutePath()), e);
}
}
PrefabBuffer IOException {
;
{
cachedAttr = Files.readAttributes(cachedLpfPath, BasicFileAttributes.class);
} (IOException var10) {
}
FileTime targetModifiedTime;
(pack != && pack.isImmutable()) {
targetModifiedTime = Files.readAttributes(pack.getPackLocation(), BasicFileAttributes.class).lastModifiedTime();
} {
targetModifiedTime = Files.readAttributes(jsonPath, BasicFileAttributes.class).lastModifiedTime();
}
(cachedAttr != && targetModifiedTime.compareTo(cachedAttr.lastModifiedTime()) <= ) {
{
readFromFile(cachedLpfPath);
} (CompletionException e) {
(!Options.getOptionSet().has(Options.VALIDATE_PREFABS)) {
(e.getCause() UpdateBinaryPrefabException) {
LOGGER.at(Level.FINE).log( , path, e.getMessage());
} {
((HytaleLogger.Api)LOGGER.at(Level.WARNING).withCause( (e))).log( , cachedLpfPath);
}
}
}
}
{
BsonPrefabBufferDeserializer.INSTANCE.deserialize(jsonPath, (BsonDocument)BsonUtil.readDocument(jsonPath, ).join());
(!Options.getOptionSet().has(Options.DISABLE_CPB_BUILD)) {
{
Files.createDirectories(cachedLpfPath.getParent());
writeToFileAsync(buffer, cachedLpfPath).thenRun(() -> {
{
Files.setLastModifiedTime(cachedLpfPath, targetModifiedTime);
} (IOException var3) {
}
}).exceptionally((throwable) -> {
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.FINE).withCause( (throwable))).log( , cachedLpfPath);
;
});
} (IOException e) {
LOGGER.at(Level.FINE).log( , cachedLpfPath, e.getMessage());
}
}
buffer;
} (Exception e) {
( + String.valueOf(jsonPath.toAbsolutePath()), e);
}
}
CachedEntry {
CachedEntry[] temp = [ ];
CACHE.compute(path, (p, ref) -> {
(ref != ) {
(CachedEntry)ref.get();
temp[ ] = cached;
(cached != ) {
ref;
}
}
(temp[ ] = ());
});
temp[ ];
}
{
CACHE_PATH = (Path)Options.getOrDefault(Options.PREFAB_CACHE_DIRECTORY, Options.getOptionSet(), Path.of( ));
FILE_SUFFIX_PATTERN = Pattern.compile( );
LOGGER = HytaleLogger.forEnclosingClass();
CACHE = ();
}
{
();
PrefabBuffer buffer;
{
}
}
}
com/hypixel/hytale/server/core/prefab/selection/buffer/PrefabLoader.java
package com.hypixel.hytale.server.core.prefab.selection.buffer;
import com.hypixel.hytale.server.core.util.io.FileUtil;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.NoSuchFileException;
import java.nio.file.NotDirectoryException;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import javax.annotation.Nonnull;
public class PrefabLoader {
private static final char JSON_FILEPATH_SEPARATOR = '.' ;
private final Path rootFolder;
public PrefabLoader (Path rootFolder) {
this .rootFolder = rootFolder;
}
public Path getRootFolder () {
return this .rootFolder;
}
public void resolvePrefabs (@Nonnull String prefabName, @Nonnull Consumer<Path> pathConsumer) throws IOException {
resolvePrefabs( .rootFolder, prefabName, pathConsumer);
}
IOException {
(prefabName.endsWith( )) {
resolvePrefabFolder(rootFolder, prefabName, pathConsumer);
} {
rootFolder.resolve(prefabName.replace( , File.separatorChar) + );
(!Files.exists(prefabPath, [ ])) {
(prefabPath.toString());
}
pathConsumer.accept(prefabPath);
}
}
IOException {
prefabName.substring( , prefabName.length() - );
rootFolder.resolve(prefabDirectory.replace( , File.separatorChar));
(!Files.isDirectory(directoryPath, [ ])) {
(directoryPath.toString());
} {
Files.walkFileTree(directoryPath, FileUtil.DEFAULT_WALK_TREE_OPTIONS_SET, , <Path>() {
FileVisitResult {
file.getFileName().toString();
PrefabBufferUtil.FILE_SUFFIX_PATTERN.matcher(fileName);
(matcher.find()) {
matcher.replaceAll( );
pathConsumer.accept(file.resolveSibling(fileNameNoExtension));
}
FileVisitResult.CONTINUE;
}
});
}
}
String {
(!prefabName.endsWith( )) {
prefabName;
} {
rootPrefabDir.relativize(prefabPath).toString();
prefabName.equals( ) ? : prefabName.length() - ;
getFilepathLengthNoExtension(filepath);
(length < start) {
(String.format( , prefabName, filepath));
} {
[] chars = [length - start];
filepath.getChars(start, length, chars, );
( ; i < chars.length; ++i) {
(chars[i] == File.separatorChar) {
chars[i] = ;
}
}
(chars);
}
}
}
{
;
(filepath.endsWith( )) {
extensionSize = .length();
} (filepath.endsWith( )) {
extensionSize = .length();
}
filepath.length() - extensionSize;
}
}
com/hypixel/hytale/server/core/prefab/selection/buffer/PrefabSupplier.java
package com.hypixel.hytale.server.core.prefab.selection.buffer;
import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.IPrefabBuffer;
import java.util.function.Supplier;
public interface PrefabSupplier extends Supplier <IPrefabBuffer> {
}
com/hypixel/hytale/server/core/prefab/selection/buffer/UpdateBinaryPrefabException.java
package com.hypixel.hytale.server.core.prefab.selection.buffer;
public class UpdateBinaryPrefabException extends RuntimeException {
public UpdateBinaryPrefabException (String message) {
super (message);
}
}
com/hypixel/hytale/server/core/prefab/selection/buffer/impl/IPrefabBuffer.java
package com.hypixel.hytale.server.core.prefab.selection.buffer.impl;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.server.core.prefab.PrefabRotation;
import com.hypixel.hytale.server.core.prefab.PrefabWeights;
import com.hypixel.hytale.server.core.prefab.selection.buffer.PrefabBufferCall;
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 interface IPrefabBuffer {
ColumnPredicate<?> ALL_COLUMNS = (x, z, blocks, o) -> true ;
int getAnchorX () ;
int getAnchorY () ;
int getAnchorZ () ;
int getMinX (@Nonnull PrefabRotation var1) ;
int getMinY () ;
int getMinZ (@Nonnull PrefabRotation var1) ;
int getMaxX (@Nonnull PrefabRotation var1) ;
int getMaxY () ;
int getMaxZ (@Nonnull PrefabRotation var1) ;
{
.getMinX(PrefabRotation.ROTATION_0);
}
{
.getMinZ(PrefabRotation.ROTATION_0);
}
{
.getMaxX(PrefabRotation.ROTATION_0);
}
{
.getMaxZ(PrefabRotation.ROTATION_0);
}
;
;
;
PrefabBuffer.ChildPrefab[] getChildPrefabs();
{
;
(PrefabRotation rotation : PrefabRotation.VALUES) {
.getMaxX(rotation) - .getMinX(rotation);
(x > max) {
max = x;
}
.getMaxZ(rotation) - .getMinZ(rotation);
(z > max) {
max = z;
}
}
max;
}
<T > ;
<T> ;
<T> ;
;
<T > {
.forEachRaw(iterateAllColumns(), (RawBlockPredicate)((x, y, z, blockId, chance, holder, support, rotation, filler, o) -> blockComparingPredicate.test(x, y, z, blockId, rotation, holder, o)), (FluidPredicate)((x, y, z, fluidId, level, o) -> ), (EntityPredicate)((x, z, entityWrappers, o) -> ), t);
}
<T > {
( );
}
;
;
;
<T> ColumnPredicate<T> {
ALL_COLUMNS;
}
<T> {
;
}
<T> {
;
}
<T> {
;
}
<T> {
;
}
<T> {
;
}
<T> {
;
}
<T> {
;
}
<T> {
;
}
<T> {
;
}
<T> {
;
}
<T> {
;
}
}
com/hypixel/hytale/server/core/prefab/selection/buffer/impl/PrefabBuffer.java
package com.hypixel.hytale.server.core.prefab.selection.buffer.impl;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.util.MathUtil;
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.modules.prefabspawner.PrefabSpawnerState;
import com.hypixel.hytale.server.core.prefab.PrefabRotation;
import com.hypixel.hytale.server.core.prefab.PrefabWeights;
import com.hypixel.hytale.server.core.prefab.selection.buffer.PrefabBufferCall;
import com.hypixel.hytale.server.core.universe.world.meta.BlockStateModule;
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.io.ByteBufUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntIterator;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.List;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class {
;
Vector3i anchor;
Vector3i min;
Vector3i max;
Int2ObjectMap<PrefabBufferColumn> columns;
ChildPrefab[] childPrefabs;
ByteBuf buf;
{
.buf = buf;
.anchor = anchor;
.min = min;
.max = max;
.columns = columns;
.childPrefabs = childPrefabs;
}
Builder {
();
}
{
.anchor.getX();
}
{
.anchor.getY();
}
{
.anchor.getZ();
}
PrefabBufferAccessor {
.checkReleased();
( );
}
{
.checkReleased();
.buf.release();
.buf = ;
}
{
( .buf == ) {
( );
}
}
{
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
{
;
(blockBytes) {
:
;
:
mask |= ;
;
:
mask |= ;
;
:
:
( + blockBytes);
:
mask |= ;
}
(chance) {
mask |= ;
}
(offsetBytes) {
:
;
:
mask |= ;
;
:
mask |= ;
;
:
:
( + offsetBytes);
:
mask |= ;
}
(holder != ) {
mask |= ;
}
(fluidBytes) {
:
;
:
mask |= ;
;
:
mask |= ;
;
:
:
( + fluidBytes);
:
mask |= ;
}
mask |= supportValue << & ;
(filler != ) {
mask |= ;
}
(rotation != ) {
mask |= ;
}
mask;
}
{
;
bytes += getBlockBytes(mask);
bytes += getOffsetBytes(mask);
(hasChance(mask)) {
bytes += ;
}
bytes += getFluidBytes(mask);
(hasFiller(mask)) {
bytes += ;
}
(hasRotation(mask)) {
++bytes;
}
bytes;
}
{
(mask & ) == ;
}
{
(mask & ) == ;
}
{
(mask & ) == ;
}
{
var10000;
(mask & ) {
-> var10000 = ;
-> var10000 = ;
-> var10000 = ;
-> var10000 = ;
}
var10000;
}
{
var10000;
(mask & ) {
-> var10000 = ;
-> var10000 = ;
-> var10000 = ;
-> var10000 = ;
}
var10000;
}
{
var10000;
(mask & ) {
-> var10000 = ;
-> var10000 = ;
-> var10000 = ;
-> var10000 = ;
}
var10000;
}
{
(mask & ) >> ;
}
{
(mask & ) == ;
}
}
{
x;
y;
z;
String path;
fitHeightmap;
inheritSeed;
inheritHeightCondition;
PrefabWeights weights;
PrefabRotation rotation;
{
.x = x;
.y = y;
.z = z;
.path = path;
.fitHeightmap = fitHeightmap;
.inheritSeed = inheritSeed;
.inheritHeightCondition = inheritHeightCondition;
.weights = weights;
.rotation = rotation;
}
{
.x;
}
{
.y;
}
{
.z;
}
String {
.path;
}
{
.fitHeightmap;
}
{
.inheritSeed;
}
{
.inheritHeightCondition;
}
PrefabWeights {
.weights;
}
PrefabRotation {
.rotation;
}
}
{
Unpooled.buffer();
Vector3i min;
Vector3i max;
Int2ObjectMap<PrefabBufferColumn> columns;
List<ChildPrefab> childPrefabs;
Vector3i anchor;
{
.min = (Vector3i.MAX);
.max = (Vector3i.MIN);
.columns = <PrefabBufferColumn>();
.childPrefabs = <ChildPrefab>( );
.anchor = Vector3i.ZERO;
}
{
.anchor = anchor;
}
{
(x < - ) {
( + x);
} (x > ) {
( + x);
} (z < - ) {
( + z);
} (z > ) {
( + z);
} {
MathUtil.packInt(( )x, ( )z);
( .columns.containsKey(columnIndex)) {
( + x + + z);
} {
entries.length;
Int2ObjectOpenHashMap<Holder<ChunkStore>> holderMap = <Holder<ChunkStore>>();
(blockCount != || entityHolders != && entityHolders.length != ) {
.buf.writerIndex();
.buf.writeInt(blockCount);
(blockCount > ) {
entries[ ].y;
(offset < .min.y) {
.min.y = offset;
}
.buf.writeInt(offset - );
offset = - ;
( ; i < blockCount; ++i) {
entries[i];
entry.y;
entry.blockId;
entry.chance;
Holder<ChunkStore> holder = entry.state;
entry.fluidId;
entry.fluidLevel;
(y <= offset) {
( + offset + + y);
}
i == ? : y - offset;
(offset > ) {
( + offset);
}
chance < ;
MathUtil.byteCount(blockId);
offset == ? : MathUtil.byteCount(offset);
MathUtil.byteCount(fluidId);
PrefabBuffer.BlockMaskConstants.getBlockMask(blockBytes, fluidBytes, hasChance, offsetBytes, holder, entry.supportValue, entry.rotation, entry.filler);
.buf.writeShort(mask);
ByteBufUtil.writeNumber( .buf, blockBytes, blockId);
ByteBufUtil.writeNumber( .buf, offsetBytes, offset);
(hasChance) {
.buf.writeFloat(chance);
}
(entry.rotation != ) {
.buf.writeByte(entry.rotation);
}
(entry.filler != ) {
.buf.writeShort(entry.filler);
}
(fluidId != ) {
ByteBufUtil.writeNumber( .buf, fluidBytes, fluidId);
.buf.writeByte(fluidLevel);
}
(holder != ) {
holderMap.put(y, holder);
.handleBlockComponents(entry.rotation, x, y, z, holder);
}
offset = y;
}
(offset > .max.y) {
.max.y = offset;
}
}
(x < .min.x) {
.min.x = x;
}
(x > .max.x) {
.max.x = x;
}
(z < .min.z) {
.min.z = z;
}
(z > .max.z) {
.max.z = z;
}
(holderMap.isEmpty()) {
holderMap = ;
}
(readerIndex, entityHolders, holderMap);
.columns.put(columnIndex, column);
}
}
}
}
{
ComponentType<ChunkStore, PrefabSpawnerState> componentType = BlockStateModule.get().getComponentType(PrefabSpawnerState.class);
(PrefabSpawnerState)holder.getComponent(componentType);
(spawnerState != ) {
spawnerState.getPrefabPath();
(path == ) {
HytaleLogger.getLogger().at(Level.WARNING).log( , x, y, z);
} {
spawnerState.getPrefabWeights();
PrefabRotation.fromRotation(RotationTuple.get(blockRotation).yaw());
.addChildPrefab(x, y, z, path, spawnerState.isFitHeightmap(), spawnerState.isInheritSeed(), spawnerState.isInheritHeightCondition(), weights, rotation);
}
}
}
{
.childPrefabs.add( (x, y, z, path, fitHeightmap, inheritSeed, inheritHeightCondition, weights, rotation));
}
PrefabBufferBlockEntry {
(y);
}
PrefabBuffer {
Unpooled.copiedBuffer( .buf);
.buf.release();
ChildPrefab[] childPrefabArray = (ChildPrefab[]) .childPrefabs.toArray((x$ ) -> [x$ ]);
( .columns.isEmpty()) {
.min.assign( );
.max.assign( );
}
(buffer, .anchor, .min, .max, .columns, childPrefabArray);
}
}
{
PrefabBuffer prefabBuffer;
ByteBuf buffer;
{
.buffer = prefabBuffer.buf.retainedDuplicate();
.prefabBuffer = prefabBuffer;
}
{
.prefabBuffer.getAnchorX();
}
{
.prefabBuffer.getAnchorY();
}
{
.prefabBuffer.getAnchorZ();
}
{
.prefabBuffer.checkReleased();
Math.min(rotation.getX( .prefabBuffer.min.getX(), .prefabBuffer.min.getZ()), rotation.getX( .prefabBuffer.max.getX(), .prefabBuffer.max.getZ()));
}
{
.prefabBuffer.checkReleased();
.prefabBuffer.min.getY();
}
{
.prefabBuffer.checkReleased();
Math.min(rotation.getZ( .prefabBuffer.min.getX(), .prefabBuffer.min.getZ()), rotation.getZ( .prefabBuffer.max.getX(), .prefabBuffer.max.getZ()));
}
{
.prefabBuffer.checkReleased();
Math.max(rotation.getX( .prefabBuffer.min.getX(), .prefabBuffer.min.getZ()), rotation.getX( .prefabBuffer.max.getX(), .prefabBuffer.max.getZ()));
}
{
.prefabBuffer.checkReleased();
.prefabBuffer.max.getY();
}
{
.prefabBuffer.checkReleased();
Math.max(rotation.getZ( .prefabBuffer.min.getX(), .prefabBuffer.min.getZ()), rotation.getZ( .prefabBuffer.max.getX(), .prefabBuffer.max.getZ()));
}
{
.prefabBuffer.columns.size();
}
ChildPrefab[] getChildPrefabs() {
.prefabBuffer.childPrefabs;
}
{
.prefabBuffer.checkReleased();
rotation.getX(x, z);
rotation.getZ(x, z);
MathUtil.packInt(rotatedX, rotatedZ);
(PrefabBufferColumn) .prefabBuffer.columns.get(columnIndex);
(columnData != ) {
.buffer.readerIndex(columnData.getReaderIndex());
.buffer.readInt();
(blockCount > ) {
.buffer.readInt() + ;
}
}
- ;
}
{
.prefabBuffer.checkReleased();
rotation.getX(x, z);
rotation.getZ(x, z);
MathUtil.packInt(rotatedX, rotatedZ);
(PrefabBufferColumn) .prefabBuffer.columns.get(columnIndex);
(column == ) {
- ;
} {
.buffer.readerIndex(column.getReaderIndex());
.buffer.readInt();
(blockCount > ) {
.buffer.readInt();
( ; i < blockCount; ++i) {
.buffer.readUnsignedShort();
(PrefabBuffer.BlockMaskConstants.getOffsetBytes(mask) > ) {
.buffer.skipBytes(PrefabBuffer.BlockMaskConstants.getBlockBytes(mask));
y += ByteBufUtil.readNumber( .buffer, PrefabBuffer.BlockMaskConstants.getOffsetBytes(mask));
(PrefabBuffer.BlockMaskConstants.hasChance(mask)) {
.buffer.skipBytes( );
}
(PrefabBuffer.BlockMaskConstants.hasRotation(mask)) {
.buffer.skipBytes( );
}
(PrefabBuffer.BlockMaskConstants.hasFiller(mask)) {
.buffer.skipBytes( );
}
.buffer.skipBytes(PrefabBuffer.BlockMaskConstants.getFluidBytes(mask));
} {
.buffer.skipBytes(PrefabBuffer.BlockMaskConstants.getSkipBytes(mask));
++y;
}
}
y;
} {
- ;
}
}
}
<T > {
.prefabBuffer.checkReleased();
.prefabBuffer.columns.int2ObjectEntrySet().forEach((entry) -> {
entry.getIntKey();
MathUtil.unpackLeft(columnIndex);
MathUtil.unpackRight(columnIndex);
t.rotation.getX(cx, cz);
t.rotation.getZ(cx, cz);
(PrefabBufferColumn)entry.getValue();
.buffer.readerIndex(column.getReaderIndex());
.buffer.readInt();
(columnPredicate.test(x, z, blockCount, t)) {
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
(blockCount > ) {
.buffer.readInt();
( ; i < blockCount; ++i) {
.buffer.readUnsignedShort();
PrefabBuffer.BlockMaskConstants.getBlockBytes(mask);
ByteBufUtil.readNumber( .buffer, blockBytes);
PrefabBuffer.BlockMaskConstants.getOffsetBytes(mask);
y += offsetBytes == ? : ByteBufUtil.readNumber( .buffer, offsetBytes);
(PrefabBuffer.BlockMaskConstants.hasChance(mask)) {
.buffer.readFloat();
(chance < t.random.nextFloat()) {
.buffer.skipBytes( );
.buffer.skipBytes(PrefabBuffer.BlockMaskConstants.getFluidBytes(mask));
;
}
}
Holder<ChunkStore> holder = PrefabBuffer.BlockMaskConstants.hasComponents(mask) ? (Holder)column.getBlockComponents().get(y) : ;
PrefabBuffer.BlockMaskConstants.getSupportValue(mask);
;
(PrefabBuffer.BlockMaskConstants.hasRotation(mask)) {
rotation = .buffer.readUnsignedByte();
}
rotation = t.rotation.getRotation(rotation);
;
(PrefabBuffer.BlockMaskConstants.hasFiller(mask)) {
filler = t.rotation.getFiller( .buffer.readUnsignedShort());
}
PrefabBuffer.BlockMaskConstants.getFluidBytes(mask);
;
;
(fluidBytes != ) {
fluidId = ByteBufUtil.readNumber( .buffer, fluidBytes - );
fluidLevel = .buffer.readByte();
}
blockConsumer.accept(x, y, z, blockId, holder, supportValue, rotation, filler, t, fluidId, fluidLevel);
}
}
Holder<EntityStore>[] entityHolders = column.getEntityHolders();
(entityHolders != && entityConsumer != ) {
entityConsumer.accept(x, z, entityHolders, t);
}
}
});
( .prefabBuffer.childPrefabs != && childConsumer != ) {
(ChildPrefab childPrefab : .prefabBuffer.childPrefabs) {
t.rotation.getX(childPrefab.x, childPrefab.z);
t.rotation.getZ(childPrefab.x, childPrefab.z);
childConsumer.accept(x, childPrefab.y, z, childPrefab.path, childPrefab.fitHeightmap, childPrefab.inheritSeed, childPrefab.inheritHeightCondition, childPrefab.weights, childPrefab.rotation, t);
}
}
}
<T> {
.prefabBuffer.checkReleased();
.prefabBuffer.columns.int2ObjectEntrySet().forEach((entry) -> {
entry.getIntKey();
MathUtil.unpackLeft(columnIndex);
MathUtil.unpackRight(columnIndex);
(PrefabBufferColumn)entry.getValue();
.buffer.readerIndex(column.getReaderIndex());
.buffer.readInt();
(columnPredicate.test(x, z, blockCount, t)) {
(blockCount > ) {
.buffer.readInt();
( ; i < blockCount; ++i) {
.buffer.readUnsignedShort();
PrefabBuffer.BlockMaskConstants.getBlockBytes(mask);
ByteBufUtil.readNumber( .buffer, blockBytes);
PrefabBuffer.BlockMaskConstants.getOffsetBytes(mask);
y += offsetBytes == ? : ByteBufUtil.readNumber( .buffer, offsetBytes);
PrefabBuffer.BlockMaskConstants.hasChance(mask) ? .buffer.readFloat() : ;
Holder<ChunkStore> holder = PrefabBuffer.BlockMaskConstants.hasComponents(mask) ? (Holder)column.getBlockComponents().get(y) : ;
PrefabBuffer.BlockMaskConstants.getSupportValue(mask);
;
(PrefabBuffer.BlockMaskConstants.hasRotation(mask)) {
rotation = .buffer.readUnsignedByte();
}
;
(PrefabBuffer.BlockMaskConstants.hasFiller(mask)) {
filler = .buffer.readUnsignedShort();
}
.buffer.readerIndex();
blockConsumer.accept(x, y, z, mask, blockId, chance, holder, supportValue, rotation, filler, t);
.buffer.readerIndex(position);
PrefabBuffer.BlockMaskConstants.getFluidBytes(mask);
(fluidBytes != ) {
ByteBufUtil.readNumber( .buffer, fluidBytes - );
.buffer.readByte();
position = .buffer.readerIndex();
fluidConsumer.accept(x, y, z, fluidId, fluidLevel, t);
.buffer.readerIndex(position);
}
}
}
Holder<EntityStore>[] entityHolders = column.getEntityHolders();
(entityConsumer != ) {
entityConsumer.accept(x, z, entityHolders, t);
}
}
});
}
<T> {
.prefabBuffer.checkReleased();
(Int2ObjectMap.Entry<PrefabBufferColumn> entry : .prefabBuffer.columns.int2ObjectEntrySet()) {
entry.getIntKey();
MathUtil.unpackLeft(columnIndex);
MathUtil.unpackRight(columnIndex);
(PrefabBufferColumn)entry.getValue();
.buffer.readerIndex(column.getReaderIndex());
.buffer.readInt();
(!columnPredicate.test(x, z, blockCount, t)) {
;
}
(blockCount > ) {
.buffer.readInt();
( ; i < blockCount; ++i) {
.buffer.readUnsignedShort();
PrefabBuffer.BlockMaskConstants.getBlockBytes(mask);
ByteBufUtil.readNumber( .buffer, blockBytes);
PrefabBuffer.BlockMaskConstants.getOffsetBytes(mask);
y += offsetBytes == ? : ByteBufUtil.readNumber( .buffer, offsetBytes);
PrefabBuffer.BlockMaskConstants.hasChance(mask) ? .buffer.readFloat() : ;
Holder<ChunkStore> holder = PrefabBuffer.BlockMaskConstants.hasComponents(mask) ? (Holder)column.getBlockComponents().get(y) : ;
PrefabBuffer.BlockMaskConstants.hasRotation(mask) ? .buffer.readUnsignedByte() : ;
PrefabBuffer.BlockMaskConstants.hasFiller(mask) ? .buffer.readUnsignedShort() : ;
PrefabBuffer.BlockMaskConstants.getSupportValue(mask);
.buffer.readerIndex();
(!blockPredicate.test(x, y, z, blockId, chance, holder, supportValue, rotation, filler, t)) {
;
}
.buffer.readerIndex(position);
PrefabBuffer.BlockMaskConstants.getFluidBytes(mask);
(fluidBytes != ) {
ByteBufUtil.readNumber( .buffer, fluidBytes - );
.buffer.readByte();
position = .buffer.readerIndex();
(!fluidPredicate.test(x, y, z, fluidId, fluidLevel, t)) {
;
}
.buffer.readerIndex(position);
}
}
}
Holder<EntityStore>[] entityHolders = column.getEntityHolders();
(entityPredicate != && !entityPredicate.test(x, z, entityHolders, t)) {
;
}
}
;
}
{
.buffer.release();
.buffer = ;
}
<T > {
(!(otherPrefab PrefabBufferAccessor secondPrefab)) {
IPrefabBuffer. .compare(blockComparingIterator, t, otherPrefab);
} {
secondPrefab.prefabBuffer.columns;
( .prefabBuffer.columns.size() + secondPrefabColumns.size());
columnIndexes.addAll( .prefabBuffer.columns.keySet());
columnIndexes.addAll(secondPrefabColumns.keySet());
.prefabBuffer.checkReleased();
BlockType.getAssetMap();
columnIndexes.iterator();
(columnIterator.hasNext()) {
columnIterator.nextInt();
MathUtil.unpackLeft(columnIndex);
MathUtil.unpackRight(columnIndex);
t.rotation.getX(cx, cz);
t.rotation.getZ(cx, cz);
(PrefabBufferColumn) .prefabBuffer.columns.get(columnIndex);
(PrefabBufferColumn)secondPrefabColumns.get(columnIndex);
(firstColumn != ) {
.buffer.readerIndex(firstColumn.getReaderIndex());
}
(secondColumn != ) {
secondPrefab.buffer.readerIndex(secondColumn.getReaderIndex());
}
firstColumn != ? .buffer.readInt() : ;
secondColumn != ? secondPrefab.buffer.readInt() : ;
(firstColumnBlockCount != || secondColumnBlockCount != ) {
firstColumnBlockCount > ? .buffer.readInt() : ;
secondColumnBlockCount > ? secondPrefab.buffer.readInt() : ;
- ;
;
;
;
Holder<ChunkStore> firstColumnComponents = ;
- ;
;
;
;
Holder<ChunkStore> secondColumnComponents = ;
;
;
(firstColumnBlocksRead < firstColumnBlockCount || secondColumnBlocksRead < secondColumnBlockCount) {
firstColumnY;
secondColumnY;
firstColumnBlocksRead < firstColumnBlockCount ? .buffer.readerIndex() : - ;
secondColumnBlocksRead < secondColumnBlockCount ? secondPrefab.buffer.readerIndex() : - ;
(firstColumnBlocksRead < firstColumnBlockCount) {
.buffer.readUnsignedShort();
PrefabBuffer.BlockMaskConstants.getBlockBytes(mask);
firstColumnBlockId = ByteBufUtil.readNumber( .buffer, blockBytes);
PrefabBuffer.BlockMaskConstants.getOffsetBytes(mask);
firstColumnY += offsetBytes == ? : ByteBufUtil.readNumber( .buffer, offsetBytes);
firstColumnChance = PrefabBuffer.BlockMaskConstants.hasChance(mask) ? .buffer.readFloat() : ;
firstColumnRotation = t.rotation.getRotation(PrefabBuffer.BlockMaskConstants.hasRotation(mask) ? .buffer.readUnsignedByte() : );
firstColumnFiller = PrefabBuffer.BlockMaskConstants.hasFiller(mask) ? t.rotation.getFiller( .buffer.readUnsignedShort()) : ;
firstColumnComponents = PrefabBuffer.BlockMaskConstants.hasComponents(mask) ? (Holder)firstColumn.getBlockComponents().get(firstColumnY) : ;
.buffer.skipBytes(PrefabBuffer.BlockMaskConstants.getFluidBytes(mask));
}
(secondColumnBlocksRead < secondColumnBlockCount) {
secondPrefab.buffer.readUnsignedShort();
PrefabBuffer.BlockMaskConstants.getBlockBytes(mask);
secondColumnBlockId = ByteBufUtil.readNumber(secondPrefab.buffer, blockBytes);
PrefabBuffer.BlockMaskConstants.getOffsetBytes(mask);
secondColumnY += offsetBytes == ? : ByteBufUtil.readNumber(secondPrefab.buffer, offsetBytes);
secondColumnChance = PrefabBuffer.BlockMaskConstants.hasChance(mask) ? secondPrefab.buffer.readFloat() : ;
secondColumnRotation = t.rotation.getRotation(PrefabBuffer.BlockMaskConstants.hasRotation(mask) ? secondPrefab.buffer.readUnsignedByte() : );
secondColumnFiller = PrefabBuffer.BlockMaskConstants.hasFiller(mask) ? t.rotation.getFiller(secondPrefab.buffer.readUnsignedShort()) : ;
secondColumnComponents = PrefabBuffer.BlockMaskConstants.hasComponents(mask) ? (Holder)secondColumn.getBlockComponents().get(secondColumnY) : ;
secondPrefab.buffer.skipBytes(PrefabBuffer.BlockMaskConstants.getFluidBytes(mask));
}
(firstColumnY == secondColumnY) {
++firstColumnBlocksRead;
++secondColumnBlocksRead;
blockComparingIterator.test(x, firstColumnY, z, firstColumnBlockId, firstColumnComponents, firstColumnChance, firstColumnRotation, firstColumnFiller, secondColumnBlockId, secondColumnComponents, secondColumnChance, secondColumnRotation, secondColumnFiller, t);
(!test) {
;
}
} ((firstColumnY >= secondColumnY || firstColumnBlocksRead >= firstColumnBlockCount) && secondColumnBlocksRead < secondColumnBlockCount) {
++secondColumnBlocksRead;
firstColumnY = oldFirstColumnY;
(oldFirstColumnReaderIndex != - ) {
.buffer.readerIndex(oldFirstColumnReaderIndex);
}
blockComparingIterator.test(x, secondColumnY, z, - , (Holder) , , , , secondColumnBlockId, secondColumnComponents, secondColumnChance, secondColumnRotation, secondColumnFiller, t);
(!test) {
;
}
} {
++firstColumnBlocksRead;
secondColumnY = oldSecondColumnY;
(oldSecondColumnReaderIndex != - ) {
secondPrefab.buffer.readerIndex(oldSecondColumnReaderIndex);
}
blockComparingIterator.test(x, firstColumnY, z, firstColumnBlockId, firstColumnComponents, firstColumnChance, firstColumnRotation, firstColumnFiller, - , (Holder) , , , , t);
(!test) {
;
}
}
}
}
}
;
}
}
{
.prefabBuffer.checkReleased();
(PrefabBufferColumn) .prefabBuffer.columns.get(MathUtil.packInt(x, z));
(column == ) {
;
} {
.buffer.readerIndex(column.getReaderIndex());
.buffer.readInt();
(blockCount <= ) {
;
} {
.buffer.readInt();
( ; i < blockCount; ++i) {
.buffer.readUnsignedShort();
PrefabBuffer.BlockMaskConstants.getBlockBytes(mask);
ByteBufUtil.readNumber( .buffer, blockBytes);
PrefabBuffer.BlockMaskConstants.getOffsetBytes(mask);
blockY += offsetBytes == ? : ByteBufUtil.readNumber( .buffer, offsetBytes);
(blockY > y) {
;
}
(PrefabBuffer.BlockMaskConstants.hasChance(mask)) {
.buffer.readFloat();
}
(PrefabBuffer.BlockMaskConstants.hasRotation(mask)) {
.buffer.readUnsignedByte();
}
(PrefabBuffer.BlockMaskConstants.hasFiller(mask)) {
.buffer.readUnsignedShort();
}
PrefabBuffer.BlockMaskConstants.getFluidBytes(mask);
.buffer.skipBytes(fluidBytes);
(blockY == y) {
(PrefabBuffer.BlockMaskConstants.hasChance(mask)) {
( );
}
blockId;
}
}
;
}
}
}
{
.prefabBuffer.checkReleased();
(PrefabBufferColumn) .prefabBuffer.columns.get(MathUtil.packInt(x, z));
(column == ) {
;
} {
.buffer.readerIndex(column.getReaderIndex());
.buffer.readInt();
(blockCount <= ) {
;
} {
.buffer.readInt();
( ; i < blockCount; ++i) {
.buffer.readUnsignedShort();
PrefabBuffer.BlockMaskConstants.getBlockBytes(mask);
ByteBufUtil.readNumber( .buffer, blockBytes);
PrefabBuffer.BlockMaskConstants.getOffsetBytes(mask);
blockY += offsetBytes == ? : ByteBufUtil.readNumber( .buffer, offsetBytes);
(blockY > y) {
;
}
(PrefabBuffer.BlockMaskConstants.hasChance(mask)) {
.buffer.readFloat();
}
(PrefabBuffer.BlockMaskConstants.hasRotation(mask)) {
.buffer.readUnsignedByte();
}
;
(PrefabBuffer.BlockMaskConstants.hasFiller(mask)) {
filler = .buffer.readUnsignedShort();
}
PrefabBuffer.BlockMaskConstants.getFluidBytes(mask);
.buffer.skipBytes(fluidBytes);
(blockY == y) {
(PrefabBuffer.BlockMaskConstants.hasChance(mask)) {
( );
}
filler;
}
}
;
}
}
}
{
.prefabBuffer.checkReleased();
(PrefabBufferColumn) .prefabBuffer.columns.get(MathUtil.packInt(x, z));
(column == ) {
;
} {
.buffer.readerIndex(column.getReaderIndex());
.buffer.readInt();
(blockCount <= ) {
;
} {
.buffer.readInt();
( ; i < blockCount; ++i) {
.buffer.readUnsignedShort();
PrefabBuffer.BlockMaskConstants.getBlockBytes(mask);
ByteBufUtil.readNumber( .buffer, blockBytes);
PrefabBuffer.BlockMaskConstants.getOffsetBytes(mask);
blockY += offsetBytes == ? : ByteBufUtil.readNumber( .buffer, offsetBytes);
(blockY > y) {
;
}
(PrefabBuffer.BlockMaskConstants.hasChance(mask)) {
.buffer.readFloat();
}
;
(PrefabBuffer.BlockMaskConstants.hasRotation(mask)) {
rotation = .buffer.readUnsignedByte();
}
(PrefabBuffer.BlockMaskConstants.hasFiller(mask)) {
.buffer.readUnsignedShort();
}
PrefabBuffer.BlockMaskConstants.getFluidBytes(mask);
.buffer.skipBytes(fluidBytes);
(blockY == y) {
(PrefabBuffer.BlockMaskConstants.hasChance(mask)) {
( );
}
rotation;
}
}
;
}
}
}
}
}
com/hypixel/hytale/server/core/prefab/selection/buffer/impl/PrefabBufferBlockEntry.java
package com.hypixel.hytale.server.core.prefab.selection.buffer.impl;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import javax.annotation.Nullable;
public class PrefabBufferBlockEntry {
public static final PrefabBufferBlockEntry[] EMPTY_ARRAY = new PrefabBufferBlockEntry [0 ];
public final int y;
public String blockTypeKey;
public int blockId;
public float chance;
@Nullable
public Holder<ChunkStore> state;
public int fluidId;
public byte fluidLevel;
public byte supportValue;
public int filler;
public int rotation;
public PrefabBufferBlockEntry (int y) {
this (y, 0 , "Empty" );
}
public PrefabBufferBlockEntry (int y, int blockId, String blockTypeKey) {
this (y, blockId, blockTypeKey, );
}
{
(y, blockId, blockTypeKey, chance, (Holder) , , ( ) , ( ) , , );
}
{
.y = y;
.blockId = blockId;
.blockTypeKey = blockTypeKey;
.chance = chance;
.state = state;
.fluidId = fluidId;
.fluidLevel = fluidLevel;
.supportValue = supportValue;
.rotation = rotation;
.filler = filler;
}
}
com/hypixel/hytale/server/core/prefab/selection/buffer/impl/PrefabBufferColumn.java
package com.hypixel.hytale.server.core.prefab.selection.buffer.impl;
import com.hypixel.hytale.component.Holder;
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 javax.annotation.Nullable;
public class PrefabBufferColumn {
private final int readerIndex;
private final Holder<EntityStore>[] entityHolders;
private final Int2ObjectMap<Holder<ChunkStore>> blockComponents;
public PrefabBufferColumn (int readerIndex, Holder<EntityStore>[] entityHolders, Int2ObjectMap<Holder<ChunkStore>> blockComponents) {
this .readerIndex = readerIndex;
this .entityHolders = entityHolders;
this .blockComponents = blockComponents;
}
public int getReaderIndex () {
return this .readerIndex;
}
@Nullable
public Holder<EntityStore>[] getEntityHolders() {
return this .entityHolders;
}
public Int2ObjectMap<Holder<ChunkStore>> getBlockComponents () {
return this .blockComponents;
}
}
com/hypixel/hytale/server/core/prefab/selection/mask/BlockFilter.java
package com.hypixel.hytale.server.core.prefab.selection.mask;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.function.FunctionCodec;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.protocol.InteractionType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.buildertool.config.BlockTypeListAsset;
import com.hypixel.hytale.server.core.asset.type.fluid.Fluid;
import com.hypixel.hytale.server.core.asset.type.item.config.Item;
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Interaction;
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.RootInteraction;
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.client.PlaceFluidInteraction;
import com.hypixel.hytale.server.core.universe.world.accessor.ChunkAccessor;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.ints.IntSets;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockFilter {
public static final BlockFilter[] EMPTY_ARRAY = new BlockFilter [0 ];
public static final Codec<BlockFilter> CODEC;
;
Pattern BLOCK_SEPARATOR_PATTERN;
FilterType blockFilterType;
String[] blocks;
inverted;
String toString0;
IntSet resolvedBlocks;
IntSet resolvedFluids;
{
Objects.requireNonNull(blockFilterType);
Objects.requireNonNull(blocks);
.blockFilterType = blockFilterType;
.blocks = blocks;
.inverted = inverted;
.toString0 = .toString0();
}
{
( .resolvedBlocks == ) {
parseBlocksAndFluids( .blocks);
.resolvedBlocks = result.blocks;
.resolvedFluids = result.fluids;
}
}
FilterType {
.blockFilterType;
}
String[] getBlocks() {
.blocks;
}
{
.inverted;
}
{
.isExcluded(accessor, x, y, z, min, max, blockId, - );
}
{
! .isIncluded(accessor, x, y, z, min, max, blockId, fluidId);
.inverted != exclude;
}
{
.isIncluded(accessor, x, y, z, min, max, blockId, - );
}
{
( .blockFilterType.ordinal()) {
:
.resolve();
.resolvedBlocks.contains(blockId);
fluidId >= && .resolvedFluids != && .resolvedFluids.contains(fluidId);
matchesBlock || matchesFluid;
:
.matchesAt(accessor, x, y - , z);
:
.matchesAt(accessor, x, y + , z);
:
.matchesAt(accessor, x - , y, z) || .matchesAt(accessor, x + , y, z) || .matchesAt(accessor, x, y, z - ) || .matchesAt(accessor, x, y, z + );
:
( - ; xo < ; ++xo) {
( - ; yo < ; ++yo) {
( - ; zo < ; ++zo) {
((xo != || yo != || zo != ) && .matchesAt(accessor, x + xo, y + yo, z + zo)) {
;
}
}
}
}
;
:
.matchesAt(accessor, x, y, z - );
:
.matchesAt(accessor, x, y, z + );
:
.matchesAt(accessor, x, y, z + );
:
.matchesAt(accessor, x, y, z - );
:
.matchesAt(accessor, x - , y + , z) || .matchesAt(accessor, x - , y - , z) || .matchesAt(accessor, x + , y + , z) || .matchesAt(accessor, x + , y - , z);
:
.matchesAt(accessor, x - , y, z + ) || .matchesAt(accessor, x - , y, z - ) || .matchesAt(accessor, x + , y, z + ) || .matchesAt(accessor, x + , y, z - );
:
.matchesAt(accessor, x, y - , z + ) || .matchesAt(accessor, x, y - , z - ) || .matchesAt(accessor, x, y + , z + ) || .matchesAt(accessor, x, y + , z - );
:
(min != && max != ) {
x >= min.x && y >= min.y && z >= min.z && x <= max.x && y <= max.y && z <= max.z;
}
;
:
( + String.valueOf( .blockFilterType));
}
}
{
.resolve();
( .resolvedBlocks.contains(accessor.getBlock(x, y, z))) {
;
} {
.resolvedFluids != && .resolvedFluids.contains(accessor.getFluidId(x, y, z));
}
}
String {
.toString0;
}
String {
.inverted ? : ;
var10000 + .blockFilterType.getPrefix() + String.join( , .blocks);
}
String {
();
.inverted ? : ;
var10000 + .blockFilterType.getPrefix();
( .blocks.length > ) {
builder.append( );
}
( ; i < .blocks.length; ++i) {
builder.append(prefix).append( .blocks[i]);
(i != .blocks.length - ) {
builder.append( );
}
}
( .blocks.length > ) {
builder.append( );
}
builder.toString();
}
BlockFilter {
parseComponents(str);
String[] blocks = parts.type.hasBlocks() ? BLOCK_SEPARATOR_PATTERN.split(parts.blocks) : ArrayUtil.EMPTY_STRING_ARRAY;
(parts.type, blocks, parts.inverted);
}
ParsedFilterParts {
str.startsWith( );
invert ? : ;
BlockFilter.FilterType.parse(str, index);
index += filterType.getPrefix().length();
str.substring(index);
(filterType, invert, blocks);
}
IntSet {
parseBlocksAndFluids(blocksArgs).blocks;
}
BlocksAndFluids {
();
();
label41:
(String blockArg : blocksArgs) {
(Item)Item.getAssetMap().getAsset(blockArg);
(item != ) {
getFluidIdFromItem(item);
(fluidId >= ) {
fluids.add(fluidId);
;
}
}
BlockPattern.parseBlock(blockArg);
(BlockType)BlockType.getAssetMap().getAsset(blockId);
(blockType != && blockType.getBlockListAssetId() != ) {
(BlockTypeListAsset)BlockTypeListAsset.getAssetMap().getAsset(blockType.getBlockListAssetId());
(blockTypeListAsset != && blockTypeListAsset.getBlockPattern() != ) {
Integer[] var11 = blockTypeListAsset.getBlockPattern().getResolvedKeys();
var11.length;
;
( ) {
(var13 >= var12) {
label41;
}
var11[var13];
blocks.add(resolvedKey);
++var13;
}
}
}
blocks.add(blockId);
}
(IntSets.unmodifiable(blocks), fluids.isEmpty() ? : IntSets.unmodifiable(fluids));
}
{
Map<InteractionType, String> interactions = item.getInteractions();
(String)interactions.get(InteractionType.Secondary);
(secondaryRootId == ) {
- ;
} {
(RootInteraction)RootInteraction.getAssetMap().getAsset(secondaryRootId);
(rootInteraction == ) {
- ;
} {
(String interactionId : rootInteraction.getInteractionIds()) {
(Interaction)Interaction.getAssetMap().getAsset(interactionId);
(interaction PlaceFluidInteraction) {
(PlaceFluidInteraction)interaction;
placeFluidInteraction.getFluidKey();
(fluidKey != ) {
Fluid.getAssetMap().getIndex(fluidKey);
(fluidId >= ) {
fluidId;
}
}
}
}
- ;
}
}
}
{
CODEC = (Codec.STRING, BlockFilter::parse, BlockFilter::toString);
BLOCK_SEPARATOR_PATTERN = Pattern.compile(Pattern.quote( ));
}
{
}
{
IntSet blocks;
IntSet fluids;
BlocksAndFluids(IntSet blocks, IntSet fluids) {
.blocks = blocks;
.fluids = fluids;
}
}
{
TargetBlock( ),
AboveBlock( ),
BelowBlock( ),
AdjacentBlock( ),
NeighborBlock( ),
NorthBlock( ),
EastBlock( ),
SouthBlock( ),
WestBlock( ),
DiagonalXy( ),
DiagonalXz( ),
DiagonalZy( ),
Selection( , );
;
;
;
;
;
;
;
;
;
;
;
;
;
;
FilterType[] VALUES_TO_PARSE;
String prefix;
hasBlocks;
{
.prefix = prefix;
.hasBlocks = ;
}
{
.prefix = prefix;
.hasBlocks = hasBlocks;
}
{
.hasBlocks;
}
String {
.prefix;
}
FilterType {
(FilterType filterType : VALUES_TO_PARSE) {
(str.startsWith(filterType.prefix, index)) {
filterType;
}
}
TargetBlock;
}
{
FilterType[] values = values();
FilterType[] valuesToParse = [values.length - ];
;
(FilterType value : values) {
(value != TargetBlock) {
valuesToParse[i++] = value;
}
}
VALUES_TO_PARSE = valuesToParse;
}
}
}
com/hypixel/hytale/server/core/prefab/selection/mask/BlockMask.java
package com.hypixel.hytale.server.core.prefab.selection.mask;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.function.FunctionCodec;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.universe.world.accessor.ChunkAccessor;
import it.unimi.dsi.fastutil.ints.Int2ObjectFunction;
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockMask {
public static final BlockMask EMPTY;
public static final Codec<BlockMask> CODEC;
public static final String MASK_SEPARATOR = "," ;
public static final String ALT_MASK_SEPARATOR = ";" ;
public static final String EMPTY_MASK_CHARACTER = "-" ;
private final BlockFilter[] filters;
inverted;
{
.filters = filters;
}
BlockMask {
( == EMPTY) {
;
} {
BlockFilter[] filters = .filters;
(BlockFilter filter : filters) {
(filter.getBlockFilterType() != filterType || filter.isInverted() != inverted) {
filters = [filters.length];
;
}
}
(filters == .filters) {
;
} {
( ; i < filters.length; ++i) {
.filters[i];
(filter.getBlockFilterType() != filterType || filter.isInverted() != inverted) {
filter = (filterType, filter.getBlocks(), inverted);
}
filters[i] = filter;
}
(filters);
}
}
}
BlockFilter[] getFilters() {
.filters;
}
{
.inverted = inverted;
}
{
.inverted;
}
{
.isExcluded(accessor, x, y, z, min, max, blockId, - );
}
{
;
(BlockFilter filter : .filters) {
(filter.isExcluded(accessor, x, y, z, min, max, blockId, fluidId)) {
excluded = ;
;
}
}
.inverted != excluded;
}
String {
( .filters.length == ) {
;
} {
joinElements( , .filters);
.inverted ? + base : base;
}
}
String {
( .filters.length == ) {
;
} {
();
( .inverted) {
builder.append( );
}
( .filters.length > ) {
builder.append( );
}
( ; i < .filters.length; ++i) {
builder.append( .filters[i].informativeToString());
(i != .filters.length - ) {
builder.append( );
}
}
( .filters.length > ) {
builder.append( );
}
( .inverted) {
builder.append( );
}
builder.toString();
}
}
String {
();
(Object o : elements) {
(!sb.isEmpty()) {
sb.append(separator);
}
sb.append(o);
}
sb.toString();
}
BlockMask {
(!masks.isEmpty() && !masks.equals( )) {
masks = masks.replace( , );
parse(masks.split( ));
} {
EMPTY;
}
}
BlockMask {
(masks.length == ) {
EMPTY;
} (masks.length == ) {
( []{BlockFilter.parse(masks[ ])});
} {
BlockFilter[] parsedFilters = [masks.length];
( ; i < masks.length; ++i) {
parsedFilters[i] = BlockFilter.parse(masks[i]);
}
groupFilters(parsedFilters);
}
}
BlockMask {
(masks != && masks.length != ) {
;
(BlockMask mask : masks) {
(mask != && mask != EMPTY) {
totalFilters += mask.getFilters().length;
}
}
(totalFilters == ) {
EMPTY;
} {
BlockFilter[] allFilters = [totalFilters];
;
(BlockMask mask : masks) {
(mask != && mask != EMPTY) {
(BlockFilter filter : mask.getFilters()) {
allFilters[idx++] = filter;
}
}
}
groupFilters(allFilters);
}
} {
EMPTY;
}
}
BlockMask {
(inputFilters.length == ) {
EMPTY;
} (inputFilters.length == ) {
(inputFilters);
} {
Int2ObjectLinkedOpenHashMap<List<String>> groups = <List<String>>();
(BlockFilter filter : inputFilters) {
filter.getBlockFilterType().ordinal() << | (filter.isInverted() ? : );
List<String> list = (List)groups.computeIfAbsent(key, (Int2ObjectFunction)((k) -> ()));
(String block : filter.getBlocks()) {
list.add(block);
}
}
(groups.size() == inputFilters.length) {
(inputFilters);
} {
BlockFilter[] filters = [groups.size()];
;
(Int2ObjectMap.Entry<List<String>> entry : groups.int2ObjectEntrySet()) {
entry.getIntKey();
BlockFilter. BlockFilter.FilterType.values()[key >> ];
(key & ) != ;
String[] blocks = (String[])((List)entry.getValue()).toArray( [ ]);
filters[i++] = (filterType, blocks, inverted);
}
(filters);
}
}
}
{
EMPTY = (BlockFilter.EMPTY_ARRAY);
CODEC = (Codec.STRING, BlockMask::parse, BlockMask::toString);
}
}
com/hypixel/hytale/server/core/prefab/selection/mask/BlockPattern.java
package com.hypixel.hytale.server.core.prefab.selection.mask;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.function.FunctionCodec;
import com.hypixel.hytale.common.map.IWeightedMap;
import com.hypixel.hytale.common.map.WeightedMap;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.logger.HytaleLogger;
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.util.FillerBlockUtil;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockPattern {
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
public static final Codec<BlockPattern> CODEC;
public static final BlockPattern EMPTY;
public static final BlockPattern[] EMPTY_ARRAY;
Pattern FILLER_TEMP_REMOVER_PATTERN;
;
;
;
;
IWeightedMap<String> weightedMap;
String toString0;
IWeightedMap<Integer> resolvedWeightedMap;
IWeightedMap<BlockEntry> resolvedWeightedMapBtk;
{
.weightedMap = weightedMap;
.toString0 = .toString0();
}
Integer[] getResolvedKeys() {
.resolve();
(Integer[]) .resolvedWeightedMap.internalKeys();
}
{
( .resolvedWeightedMap == ) {
WeightedMap.Builder<Integer> mapBuilder = WeightedMap.<Integer>builder(ArrayUtil.EMPTY_INTEGER_ARRAY);
WeightedMap.Builder<BlockEntry> mapBuilderKey = WeightedMap.<BlockEntry>builder( [ ]);
.weightedMap.forEachEntry((blockName, weight) -> {
parseBlock(blockName);
tryParseBlockTypeKey(blockName);
(BlockType)BlockType.getAssetMap().getAsset(blockId);
(blockType != && blockType.getBlockListAssetId() != ) {
(BlockTypeListAsset)BlockTypeListAsset.getAssetMap().getAsset(blockType.getBlockListAssetId());
(blockTypeListAsset != && blockTypeListAsset.getBlockPattern() != ) {
(String resolvedKey : blockTypeListAsset.getBlockTypeKeys()) {
BlockType.getAssetMap().getIndex(resolvedKey);
(resolvedId == - ) {
LOGGER.at(Level.WARNING).log( , blockType.getBlockListAssetId(), resolvedKey);
} {
mapBuilder.put(resolvedId, weight / ( )blockTypeListAsset.getBlockTypeKeys().size());
}
}
;
}
}
mapBuilder.put(blockId, weight);
(key != ) {
mapBuilderKey.put(key, weight);
}
});
.resolvedWeightedMap = mapBuilder.build();
.resolvedWeightedMapBtk = mapBuilderKey.build();
}
}
{
.weightedMap.size() == ;
}
{
.resolve();
(Integer) .resolvedWeightedMap.get(random);
}
BlockEntry {
.resolve();
(BlockEntry) .resolvedWeightedMapBtk.get(random);
}
{
.resolve();
.resolvedWeightedMap.size() > ? ((Integer[]) .resolvedWeightedMap.internalKeys())[ ] : ;
}
String {
.toString0;
}
String {
( .weightedMap.size() == ) {
((String[]) .weightedMap.internalKeys())[ ];
} {
List<String> blocks = <String>();
.weightedMap.forEachEntry((k, v) -> blocks.add(v + + k));
String.join( , blocks);
}
}
BlockPattern {
(!str.isEmpty() && !str.equals( )) {
(str.toLowerCase().contains( )) {
str = FILLER_TEMP_REMOVER_PATTERN.matcher(str).replaceAll( );
}
str = str.replace( , );
(parseBlockPattern(str.split( )));
} {
EMPTY;
}
}
IWeightedMap<String> {
WeightedMap.Builder<String> builder = WeightedMap.<String>builder(ArrayUtil.EMPTY_STRING_ARRAY);
(String blockArg : blocksArgs) {
(!blockArg.isEmpty()) {
;
String[] blockArr = blockArg.split( );
(blockArr.length > ) {
{
chance = Double.parseDouble(blockArr[ ]);
} (NumberFormatException e) {
( + blockArr[ ], e);
}
blockArg = blockArr[ ];
}
builder.put(blockArg, chance);
}
}
builder.build();
}
{
blockId;
{
blockId = Integer.parseInt(blockText);
(BlockType.getAssetMap().getAsset(blockId) == ) {
( + blockText + );
}
} (NumberFormatException var4) {
blockText = blockText.replace( , );
blockText.indexOf( );
(oldData != - ) {
blockText = blockText.substring( , oldData);
}
blockId = BlockType.getAssetMap().getIndex(blockText);
(blockId == - ) {
LOGGER.at(Level.WARNING).log( , blockText);
;
}
}
blockId;
}
BlockEntry {
{
blockText = blockText.replace( , );
BlockPattern.BlockEntry.decode(blockText);
} (Exception var2) {
;
}
}
{
CODEC = (Codec.STRING, BlockPattern::parse, BlockPattern::toString);
EMPTY = (parseBlockPattern( ));
EMPTY_ARRAY = [ ];
FILLER_TEMP_REMOVER_PATTERN = Pattern.compile( );
}
{
Codec<BlockEntry> CODEC;
String {
( .filler == && .rotation == ) {
.blockTypeKey;
} {
( .blockTypeKey);
RotationTuple.get( .rotation);
(rot.yaw() != Rotation.None) {
out.append( ).append(rot.yaw().getDegrees());
}
(rot.pitch() != Rotation.None) {
out.append( ).append(rot.pitch().getDegrees());
}
(rot.roll() != Rotation.None) {
out.append( ).append(rot.roll().getDegrees());
}
( .filler != ) {
FillerBlockUtil.unpackX( .filler);
FillerBlockUtil.unpackY( .filler);
FillerBlockUtil.unpackZ( .filler);
out.append( ).append(fillerX).append( ).append(fillerY).append( ).append(fillerZ);
}
out.toString();
}
}
BlockEntry {
;
(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, );
filler = FillerBlockUtil.pack(fillerX, fillerY, fillerZ);
}
Rotation.None;
Rotation.None;
Rotation.None;
(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, ));
}
key.indexOf( );
(end == - ) {
end = key.length();
}
key.substring( , end);
(name, RotationTuple.of(rotationYaw, rotationPitch, rotationRoll).index(), filler);
}
{
CODEC = (Codec.STRING, BlockEntry::decode, BlockEntry::encode);
}
}
}
com/hypixel/hytale/server/core/prefab/selection/mask/MultiBlockMask.java
package com.hypixel.hytale.server.core.prefab.selection.mask;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.universe.world.accessor.ChunkAccessor;
import javax.annotation.Nonnull;
public class MultiBlockMask extends BlockMask {
private static final String BLOCK_MASK_SEPARATOR = ";" ;
private final BlockMask[] masks;
public MultiBlockMask (BlockMask[] masks) {
super (BlockFilter.EMPTY_ARRAY);
this .masks = masks;
}
public boolean isExcluded (@Nonnull ChunkAccessor accessor, int x, int y, int z, Vector3i min, Vector3i max, int blockId) {
return this .isExcluded(accessor, x, y, z, min, max, blockId, -1 );
}
public boolean isExcluded (@Nonnull ChunkAccessor accessor, int x, int y, int z, Vector3i min, Vector3i max, int blockId, int fluidId) {
boolean ;
(BlockMask mask : .masks) {
(mask.isExcluded(accessor, x, y, z, min, max, blockId, fluidId)) {
excluded = ;
;
}
}
.isInverted() != excluded;
}
String {
( .masks.length == ) {
;
} {
joinElements( , .masks);
.isInverted() ? + base : base;
}
}
String {
( .masks.length == ) {
;
} {
();
( .isInverted()) {
builder.append( );
}
( ; i < .masks.length; ++i) {
.masks[i];
builder.append(mask.informativeToString());
(i != .masks.length - ) {
builder.append( );
}
}
( .isInverted()) {
builder.append( );
}
builder.toString();
}
}
}
com/hypixel/hytale/server/core/prefab/selection/standard/BlockSelection.java
package com.hypixel.hytale.server.core.prefab.selection.standard;
import com.hypixel.hytale.assetstore.map.BlockTypeAssetMap;
import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.component.AddReason;
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.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.SystemType;
import com.hypixel.hytale.logger.HytaleLogger;
import com.hypixel.hytale.math.Axis;
import com.hypixel.hytale.math.block.BlockUtil;
import com.hypixel.hytale.math.matrix.Matrix4d;
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.math.vector.Vector3i;
import com.hypixel.hytale.metrics.MetricProvider;
import com.hypixel.hytale.metrics.MetricResults;
import com.hypixel.hytale.metrics.MetricsRegistry;
import com.hypixel.hytale.protocol.Opacity;
import com.hypixel.hytale.protocol.packets.interface_.BlockChange;
import com.hypixel.hytale.protocol.packets.interface_.EditorBlocksChange;
import com.hypixel.hytale.protocol.packets.interface_.EditorSelection;
import com.hypixel.hytale.protocol.packets.interface_.FluidChange;
com.hypixel.hytale.server.core.asset.type.blockhitbox.BlockBoundingBoxes;
com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
com.hypixel.hytale.server.core.asset.type.blocktype.config.StateData;
com.hypixel.hytale.server.core.asset.type.blocktype.config.VariantRotation;
com.hypixel.hytale.server.core.asset.type.fluid.Fluid;
com.hypixel.hytale.server.core.asset.type.fluid.FluidTicker;
com.hypixel.hytale.server.core.blocktype.component.BlockPhysics;
com.hypixel.hytale.server.core.command.system.CommandSender;
com.hypixel.hytale.server.core.io.NetworkSerializable;
com.hypixel.hytale.server.core.modules.block.BlockModule;
com.hypixel.hytale.server.core.modules.entity.EntityModule;
com.hypixel.hytale.server.core.modules.entity.component.FromPrefab;
com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
com.hypixel.hytale.server.core.prefab.event.PrefabPlaceEntityEvent;
com.hypixel.hytale.server.core.prefab.selection.mask.BlockMask;
com.hypixel.hytale.server.core.universe.world.World;
com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
com.hypixel.hytale.server.core.universe.world.chunk.BlockRotationUtil;
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.FluidSection;
com.hypixel.hytale.server.core.universe.world.meta.BlockState;
com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
com.hypixel.hytale.server.core.util.FillerBlockUtil;
it.unimi.dsi.fastutil.ints.IntList;
it.unimi.dsi.fastutil.longs.Long2ObjectMap;
it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
it.unimi.dsi.fastutil.longs.LongIterator;
it.unimi.dsi.fastutil.longs.LongOpenHashSet;
it.unimi.dsi.fastutil.longs.LongSet;
it.unimi.dsi.fastutil.objects.ObjectArrayList;
java.io.IOException;
java.util.BitSet;
java.util.List;
java.util.concurrent.atomic.AtomicInteger;
java.util.concurrent.locks.ReentrantReadWriteLock;
java.util.function.Consumer;
java.util.function.IntUnaryOperator;
java.util.logging.Level;
javax.annotation.Nonnull;
javax.annotation.Nullable;
org.bson.BsonDocument;
<EditorBlocksChange>, MetricProvider {
Consumer<Ref<EntityStore>> DEFAULT_ENTITY_CONSUMER = (ref) -> {
};
MetricsRegistry<BlockSelection> METRICS_REGISTRY;
HytaleLogger LOGGER;
x;
y;
z;
anchorX;
anchorY;
anchorZ;
- ;
Vector3i min;
Vector3i max;
Long2ObjectMap<BlockHolder> blocks;
Long2ObjectMap<FluidHolder> fluids;
List<Holder<EntityStore>> entities;
ReentrantReadWriteLock blocksLock;
ReentrantReadWriteLock entitiesLock;
{
.min = Vector3i.ZERO;
.max = Vector3i.ZERO;
.blocksLock = ();
.entitiesLock = ();
.blocks = <BlockHolder>();
.fluids = <FluidHolder>();
.entities = <Holder<EntityStore>>();
}
{
.min = Vector3i.ZERO;
.max = Vector3i.ZERO;
.blocksLock = ();
.entitiesLock = ();
.blocks = <BlockHolder>(initialBlockCapacity);
.fluids = <FluidHolder>(initialBlockCapacity);
.entities = <Holder<EntityStore>>(initialEntityCapacity);
}
{
.min = Vector3i.ZERO;
.max = Vector3i.ZERO;
.blocksLock = ();
.entitiesLock = ();
(other == ) {
( );
} {
.blocks = <BlockHolder>(other.getBlockCount());
.fluids = <FluidHolder>(other.getFluidCount());
.entities = <Holder<EntityStore>>(other.getEntityCount());
.copyPropertiesFrom(other);
.add(other);
}
}
{
.x;
}
{
.y;
}
{
.z;
}
{
.anchorX;
}
{
.anchorY;
}
{
.anchorZ;
}
Vector3i {
.min.clone();
}
Vector3i {
.max.clone();
}
{
! .min.equals(Vector3i.ZERO) || ! .max.equals(Vector3i.ZERO);
}
{
.blocksLock.readLock().lock();
var1;
{
var1 = .blocks.size();
} {
.blocksLock.readLock().unlock();
}
var1;
}
{
.blocksLock.readLock().lock();
var1;
{
var1 = .fluids.size();
} {
.blocksLock.readLock().unlock();
}
var1;
}
{
.max.x - .min.x;
.max.y - .min.y;
.max.z - .min.z;
xLength * yLength & zLength;
}
{
.entitiesLock.readLock().lock();
var1;
{
var1 = .entities.size();
} {
.entitiesLock.readLock().unlock();
}
var1;
}
{
.x = x;
.y = y;
.z = z;
}
{
.setAnchor(anchorX - .x, anchorY - .y, anchorZ - .z);
}
{
.anchorX = anchorX;
.anchorY = anchorY;
.anchorZ = anchorZ;
}
{
.min = Vector3i.min(min, max);
.max = Vector3i.max(min, max);
}
{
.prefabId = id;
}
{
.x = other.x;
.y = other.y;
.z = other.z;
.anchorX = other.anchorX;
.anchorY = other.anchorY;
.anchorZ = other.anchorZ;
.min = other.min.clone();
.max = other.max.clone();
}
{
.compare((x1, y1, z1, block) -> {
x1 + position.getX() - .anchorX;
y1 + position.getY() - .anchorY;
z1 + position.getZ() - .anchorZ;
world.getBlock(blockX, blockY, blockZ);
blockId == || mask == || mask.contains(blockId);
});
}
{
.compare((x1, y1, z1, block) -> {
x1 + position.getX() - .anchorX;
y1 + position.getY() - .anchorY;
z1 + position.getZ() - .anchorZ;
world.getBlock(blockX, blockY, blockZ);
block.blockId == blockId;
});
}
{
(Long2ObjectMap.Entry<BlockHolder> entry : .blocks.long2ObjectEntrySet()) {
entry.getLongKey();
(BlockHolder)entry.getValue();
BlockUtil.unpackX(packed);
BlockUtil.unpackY(packed);
BlockUtil.unpackZ(packed);
(!iterator.test(x1, y1, z1, value)) {
;
}
}
;
}
{
.hasBlockAtLocalPos(x - .x, y - .y, z - .z);
}
{
.blocksLock.readLock().lock();
var4;
{
var4 = .blocks.containsKey(BlockUtil.pack(x, y, z));
} {
.blocksLock.readLock().unlock();
}
var4;
}
{
.getBlockAtLocalPos(x - .x, y - .y, z - .z);
}
{
.blocksLock.readLock().lock();
var5;
{
(BlockHolder) .blocks.get(BlockUtil.pack(x, y, z));
(blockHolder != ) {
var5 = blockHolder.blockId();
var5;
}
var5 = - ;
} {
.blocksLock.readLock().unlock();
}
var5;
}
BlockHolder {
.getBlockHolderAtLocalPos(x - .x, y - .y, z - .z);
}
BlockHolder {
.blocksLock.readLock().lock();
BlockHolder var4;
{
var4 = (BlockHolder) .blocks.get(BlockUtil.pack(x, y, z));
} {
.blocksLock.readLock().unlock();
}
var4;
}
{
.getFluidAtLocalPos(x - .x, y - .y, z - .z);
}
{
.blocksLock.readLock().lock();
var5;
{
(FluidHolder) .fluids.get(BlockUtil.pack(x, y, z));
(fluidStore != ) {
var5 = fluidStore.fluidId();
var5;
}
var5 = - ;
} {
.blocksLock.readLock().unlock();
}
var5;
}
{
.getFluidLevelAtLocalPos(x - .x, y - .y, z - .z);
}
{
.blocksLock.readLock().lock();
var5;
{
(FluidHolder) .fluids.get(BlockUtil.pack(x, y, z));
(fluidStore != ) {
var5 = fluidStore.fluidLevel();
var5;
}
var5 = ;
} {
.blocksLock.readLock().unlock();
}
var5;
}
{
.getSupportValueAtLocalPos(x - .x, y - .y, z - .z);
}
{
.blocksLock.readLock().lock();
var5;
{
(BlockHolder) .blocks.get(BlockUtil.pack(x, y, z));
(blockHolder != ) {
var5 = blockHolder.supportValue();
var5;
}
var5 = ;
} {
.blocksLock.readLock().unlock();
}
var5;
}
Holder<ChunkStore> {
.getStateAtLocalPos(x - .x, y - .y, z - .z);
}
Holder<ChunkStore> {
.blocksLock.readLock().lock();
Holder<ChunkStore> holder;
{
(BlockHolder) .blocks.get(BlockUtil.pack(x, y, z));
(blockHolder != ) {
holder = blockHolder.holder();
holder != ? holder.clone() : ;
var6;
}
holder = ;
} {
.blocksLock.readLock().unlock();
}
holder;
}
{
.blocksLock.readLock().lock();
{
Long2ObjectMaps.fastForEach( .blocks, (e) -> {
e.getLongKey();
(BlockHolder)e.getValue();
BlockUtil.unpackX(packed);
BlockUtil.unpackY(packed);
BlockUtil.unpackZ(packed);
iterator.accept(x1, y1, z1, block);
});
} {
.blocksLock.readLock().unlock();
}
}
{
.blocksLock.readLock().lock();
{
Long2ObjectMaps.fastForEach( .fluids, (e) -> {
e.getLongKey();
(FluidHolder)e.getValue();
BlockUtil.unpackX(packed);
BlockUtil.unpackY(packed);
BlockUtil.unpackZ(packed);
iterator.accept(x1, y1, z1, block.fluidId(), block.fluidLevel());
});
} {
.blocksLock.readLock().unlock();
}
}
{
.entitiesLock.readLock().lock();
{
.entities.forEach(consumer);
} {
.entitiesLock.readLock().unlock();
}
}
{
.addBlockAtWorldPos(x, y, z, other.getBlock(x, y, z), other.getRotationIndex(x, y, z), other.getFiller(x, y, z), blockPhysics != ? blockPhysics.get(x, y, z) : , other.getBlockComponentHolder(x, y, z));
.addFluidAtWorldPos(x, y, z, other.getFluidId(x, y, z), other.getFluidLevel(x, y, z));
}
{
.addBlockAtWorldPos(x, y, z, , , , );
.addFluidAtWorldPos(x, y, z, , ( ) );
}
{
.addBlockAtWorldPos(x, y, z, block, rotation, filler, supportValue, (Holder) );
}
{
.addBlockAtLocalPos(x - .x, y - .y, z - .z, block, rotation, filler, supportValue, state);
}
{
.addBlockAtLocalPos(x, y, z, block, rotation, filler, supportValue, (Holder) );
}
{
.blocksLock.writeLock().lock();
{
.addBlock0(x, y, z, block, rotation, filler, supportValue, state);
} {
.blocksLock.writeLock().unlock();
}
}
{
.blocks.put(BlockUtil.pack(x, y, z), (block, rotation, filler, supportValue, state));
}
{
.blocks.put(BlockUtil.pack(x, y, z), block.cloneBlockHolder());
}
{
.addFluidAtLocalPos(x - .x, y - .y, z - .z, fluidId, fluidLevel);
}
{
.blocksLock.writeLock().lock();
{
.addFluid0(x, y, z, fluidId, fluidLevel);
} {
.blocksLock.writeLock().unlock();
}
}
{
.fluids.put(BlockUtil.pack(x, y, z), (fluidId, fluidLevel));
}
{
.entities.add(holder);
}
{
.blocksLock.writeLock().lock();
{
.blocks.replaceAll((k, b) -> {
Holder<ChunkStore> holder = b.holder();
(holder == && b.filler == ) {
(BlockType)BlockType.getAssetMap().getAsset(b.blockId);
(blockType == ) {
b;
}
(blockType.getBlockEntity() != ) {
holder = blockType.getBlockEntity().clone();
}
blockType.getState();
(state != && state.getId() != ) {
(BlockUtil.unpackX(k), BlockUtil.unpackY(k), BlockUtil.unpackZ(k));
Codec<? > codec = BlockState.CODEC.getCodecFor(state.getId());
(codec == ) {
b;
}
codec.decode( ());
(blockState == ) {
b;
}
blockState.setPosition((WorldChunk) , position);
holder = blockState.toHolder();
}
}
(holder != && b.filler != ) {
(b.blockId(), b.rotation(), b.filler(), b.supportValue(), (Holder) );
} (holder == ) {
b;
} {
{
ComponentRegistry<ChunkStore> registry = ChunkStore.REGISTRY;
ComponentRegistry.Data<ChunkStore> data = registry.getData();
SystemType<ChunkStore, BlockModule.MigrationSystem> systemType = BlockModule.get().getMigrationSystemType();
data.getSystemIndexesForType(systemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
BlockModule. (BlockModule.MigrationSystem)data.getSystem(systemIndex, systemType);
(system.test(registry, holder.getArchetype())) {
system.onEntityAdd(holder, AddReason.LOAD, store.getStore());
}
}
systemIndex = - ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
BlockModule. (BlockModule.MigrationSystem)data.getSystem(systemIndex, systemType);
(system.test(registry, holder.getArchetype())) {
system.onEntityRemoved(holder, RemoveReason.UNLOAD, store.getStore());
}
}
(destructive) {
holder.tryRemoveComponent(registry.getUnknownComponentType());
}
(!holder.hasSerializableComponents(data)) {
(b.blockId(), b.rotation(), b.filler(), b.supportValue(), (Holder) );
} {
(b.blockId(), b.rotation(), b.filler(), b.supportValue(), holder.clone());
}
} (Throwable e) {
( + String.valueOf(b), e);
}
}
});
} {
.blocksLock.writeLock().unlock();
}
}
{
(TransformComponent)entityHolder.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition().subtract(( ) .x, ( ) .y, ( ) .z);
.addEntityHolderRaw(entityHolder);
}
{
.entitiesLock.writeLock().lock();
{
.entities.add(entityHolder);
} {
.entitiesLock.writeLock().unlock();
}
}
{
.entitiesLock.writeLock().lock();
{
ComponentType<EntityStore, TransformComponent> transformType = TransformComponent.getComponentType();
.entities.sort((a, b) -> {
(TransformComponent)a.getComponent(transformType);
(TransformComponent)b.getComponent(transformType);
(ta == && tb == ) {
;
} (ta == ) {
;
} (tb == ) {
- ;
} {
ta.getPosition();
tb.getPosition();
(pa == && pb == ) {
;
} (pa == ) {
;
} (pb == ) {
- ;
} {
Double.compare(pa.getX(), pb.getX());
(cmp != ) {
cmp;
} {
cmp = Double.compare(pa.getY(), pb.getY());
cmp != ? cmp : Double.compare(pa.getZ(), pb.getZ());
}
}
}
});
} {
.entitiesLock.writeLock().unlock();
}
}
{
.placeNoReturn((String) , (CommandSender) , FeedbackConsumer.DEFAULT, world, position, (BlockMask) , componentAccessor);
}
{
.placeNoReturn(feedbackKey, feedback, FeedbackConsumer.DEFAULT, outerWorld, Vector3i.ZERO, (BlockMask) , componentAccessor);
}
{
.placeNoReturn(feedbackKey, feedback, feedbackConsumer, outerWorld, Vector3i.ZERO, (BlockMask) , componentAccessor);
}
{
IntUnaryOperator xConvert;
(position != && position.getX() != ) {
xConvert = (localX) -> localX + .x + position.getX() - .anchorX;
} {
xConvert = (localX) -> localX + .x - .anchorX;
}
IntUnaryOperator yConvert;
(position != && position.getY() != ) {
yConvert = (localY) -> localY + .y + position.getY() - .anchorY;
} {
yConvert = (localY) -> localY + .y - .anchorY;
}
IntUnaryOperator zConvert;
(position != && position.getZ() != ) {
zConvert = (localZ) -> localZ + .z + position.getZ() - .anchorZ;
} {
zConvert = (localZ) -> localZ + .z - .anchorZ;
}
();
.blocksLock.readLock().lock();
{
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
.blocks.size();
();
outerWorld.getBlockBulkRelative( .blocks, xConvert, yConvert, zConvert, (world, blockHolder, chunkIndex, chunk, blockX, blockY, blockZ, localX, localY, localZ) -> {
blockHolder.blockId();
Holder<ChunkStore> holder = blockHolder.holder();
.placeBlockNoReturn(feedbackKey, feedback, feedbackConsumer, outerWorld, blockMask, dirtyChunks, assetMap, totalBlocks, counter.incrementAndGet(), chunkIndex, chunk, blockX, blockY, blockZ, newBlockId, blockHolder.rotation(), blockHolder.filler(), holder != ? holder.clone() : , componentAccessor);
});
outerWorld.getBlockBulkRelative( .fluids, xConvert, yConvert, zConvert, (world, fluidStore, chunkIndex, chunk, blockX, blockY, blockZ, localX, localY, localZ) -> .placeFluidNoReturn(feedbackKey, feedback, feedbackConsumer, outerWorld, blockMask, dirtyChunks, assetMap, totalBlocks, counter.incrementAndGet(), chunkIndex, chunk, blockX, blockY, blockZ, fluidStore.fluidId, fluidStore.fluidLevel, componentAccessor));
} {
.blocksLock.readLock().unlock();
}
dirtyChunks.forEach((value) -> outerWorld.getChunkLighting().invalidateLightInChunk(outerWorld.getChunkIfInMemory(value)));
.placeEntities(outerWorld, position);
dirtyChunks.forEach((value) -> outerWorld.getNotificationHandler().updateChunk(value));
}
{
(blockY >= && blockY < ) {
chunk.getBlock(blockX, blockY, blockZ);
(blockMask == || !blockMask.isExcluded(outerWorld, blockX, blockY, blockZ, .min, .max, oldBlockId)) {
chunk.getBlockChunk();
(blockChunk.setBlock(blockX, blockY, blockZ, newBlockId, newRotation, newFiller)) {
assetMap.getAsset(newBlockId);
(newBlockType != && FluidTicker.isFullySolid(newBlockType)) {
.clearFluidAtPosition(outerWorld, chunk, blockX, blockY, blockZ);
}
blockChunk.getHeight(blockX, blockZ);
(height <= blockY) {
(height == blockY && newBlockId == ) {
blockChunk.updateHeight(blockX, blockZ, ( )blockY);
} (height < blockY && newBlockId != && newBlockType != && newBlockType.getOpacity() != Opacity.Transparent) {
blockChunk.setHeight(blockX, blockZ, ( )blockY);
}
}
}
chunk.setState(blockX, blockY, blockZ, holder);
dirtyChunks.add(chunkIndex);
feedbackConsumer.accept(feedbackKey, totalBlocks, counter, feedback, componentAccessor);
}
}
}
{
(blockY >= && blockY < ) {
ChunkUtil.chunkCoordinate(blockY);
Store<ChunkStore> store = outerWorld.getChunkStore().getStore();
(ChunkColumn)store.getComponent(chunk.getReference(), ChunkColumn.getComponentType());
Ref<ChunkStore> section = column.getSection(sectionY);
(FluidSection)store.ensureAndGetComponent(section, FluidSection.getComponentType());
fluidSection.setFluid(blockX, blockY, blockZ, newFluidId, newFluidLevel);
dirtyChunks.add(chunkIndex);
feedbackConsumer.accept(feedbackKey, totalBlocks, counter, feedback, componentAccessor);
}
}
{
Ref<ChunkStore> ref = chunk.getReference();
(ref != && ref.isValid()) {
Store<ChunkStore> store = world.getChunkStore().getStore();
(ChunkColumn)store.getComponent(ref, ChunkColumn.getComponentType());
(column != ) {
Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(blockY));
(section != ) {
(FluidSection)store.getComponent(section, FluidSection.getComponentType());
(fluidSection != ) {
fluidSection.setFluid(blockX, blockY, blockZ, , ( ) );
}
}
}
}
}
BlockSelection {
.place(feedback, outerWorld, Vector3i.ZERO, (BlockMask) );
}
BlockSelection {
.place(feedback, outerWorld, Vector3i.ZERO, blockMask);
}
BlockSelection {
.place(feedback, outerWorld, position, blockMask, DEFAULT_ENTITY_CONSUMER);
}
BlockSelection {
( .getBlockCount(), );
before.setAnchor( .anchorX, .anchorY, .anchorZ);
before.setPosition( .x, .y, .z);
IntUnaryOperator xConvert;
(position != && position.getX() != ) {
xConvert = (localX) -> localX + .x + position.getX() - .anchorX;
} {
xConvert = (localX) -> localX + .x - .anchorX;
}
IntUnaryOperator yConvert;
(position != && position.getY() != ) {
yConvert = (localY) -> localY + .y + position.getY() - .anchorY;
} {
yConvert = (localY) -> localY + .y - .anchorY;
}
IntUnaryOperator zConvert;
(position != && position.getZ() != ) {
zConvert = (localZ) -> localZ + .z + position.getZ() - .anchorZ;
} {
zConvert = (localZ) -> localZ + .z - .anchorZ;
}
();
.blocksLock.readLock().lock();
{
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
outerWorld.getBlockBulkRelative( .blocks, xConvert, yConvert, zConvert, (world, blockHolder, chunkIndex, chunk, blockX, blockY, blockZ, localX, localY, localZ) -> {
Holder<ChunkStore> holder = blockHolder.holder();
.placeBlock(feedback, outerWorld, blockMask, before, dirtyChunks, assetMap, chunkIndex, chunk, blockX, blockY, blockZ, localX, localY, localZ, blockHolder.blockId(), blockHolder.rotation(), blockHolder.filler(), holder != ? holder.clone() : , blockHolder.supportValue());
});
IndexedLookupTableAssetMap<String, Fluid> fluidMap = Fluid.getAssetMap();
outerWorld.getBlockBulkRelative( .fluids, xConvert, yConvert, zConvert, (world, fluidStore, chunkIndex, chunk, blockX, blockY, blockZ, localX, localY, localZ) -> .placeFluid(feedback, outerWorld, before, dirtyChunks, fluidMap, chunkIndex, chunk, blockX, blockY, blockZ, localX, localY, localZ, fluidStore.fluidId, fluidStore.fluidLevel));
} {
.blocksLock.readLock().unlock();
}
dirtyChunks.forEach((value) -> outerWorld.getChunkLighting().invalidateLightInChunk(outerWorld.getChunkIfInMemory(value)));
.placeEntities(outerWorld, position, entityConsumer);
dirtyChunks.forEach((value) -> outerWorld.getNotificationHandler().updateChunk(value));
before;
}
{
(blockY >= && blockY < ) {
Store<ChunkStore> chunkStore = chunk.getWorld().getChunkStore().getStore();
(ChunkColumn)chunkStore.getComponent(chunk.getReference(), ChunkColumn.getComponentType());
Ref<ChunkStore> section = chunkColumn.getSection(ChunkUtil.chunkCoordinate(blockY));
(BlockSection)chunkStore.getComponent(section, BlockSection.getComponentType());
chunk.getBlock(blockX, blockY, blockZ);
(blockMask == || !blockMask.isExcluded(outerWorld, blockX, blockY, blockZ, .min, .max, oldBlockId)) {
section != ? (BlockPhysics)chunkStore.getComponent(section, BlockPhysics.getComponentType()) : ;
blockPhysics != ? blockPhysics.get(blockX, blockY, blockZ) : ;
blockSection.getFiller(blockX, blockY, blockZ);
blockSection.getRotationIndex(blockX, blockY, blockZ);
before.addBlockAtLocalPos(localX, localY, localZ, oldBlockId, rotation, filler, supportValue, chunk.getBlockComponentHolder(blockX, blockY, blockZ));
chunk.getBlockChunk();
(blockChunk.setBlock(blockX, blockY, blockZ, newBlockId, newRotation, newFiller)) {
assetMap.getAsset(newBlockId);
(newBlockType != && FluidTicker.isFullySolid(newBlockType)) {
.clearFluidAtPosition(outerWorld, chunk, blockX, blockY, blockZ);
}
blockChunk.getHeight(blockX, blockZ);
(height <= blockY) {
(height == blockY && newBlockId == ) {
blockChunk.updateHeight(blockX, blockZ, ( )blockY);
} (height < blockY && newBlockId != && newBlockType.getOpacity() != Opacity.Transparent) {
blockChunk.setHeight(blockX, blockZ, ( )blockY);
}
}
(newSupportValue != supportValue) {
(newSupportValue != ) {
(blockPhysics == ) {
blockPhysics = (BlockPhysics)chunkStore.ensureAndGetComponent(section, BlockPhysics.getComponentType());
}
blockPhysics.set(blockX, blockY, blockZ, newSupportValue);
} (blockPhysics != ) {
blockPhysics.set(blockX, blockY, blockZ, );
}
}
}
chunk.setState(blockX, blockY, blockZ, holder);
dirtyChunks.add(chunkIndex);
}
}
}
{
(blockY >= && blockY < ) {
ChunkUtil.chunkCoordinate(blockY);
Store<ChunkStore> store = outerWorld.getChunkStore().getStore();
(ChunkColumn)store.getComponent(chunk.getReference(), ChunkColumn.getComponentType());
Ref<ChunkStore> section = column.getSection(sectionY);
(FluidSection)store.ensureAndGetComponent(section, FluidSection.getComponentType());
fluidSection.getFluidId(blockX, blockY, blockZ);
fluidSection.getFluidLevel(blockX, blockY, blockZ);
before.addFluidAtLocalPos(localX, localY, localZ, oldFluidId, oldFluidLevel);
fluidSection.setFluid(blockX, blockY, blockZ, newFluidId, newFluidLevel);
dirtyChunks.add(chunkIndex);
}
}
{
.placeEntities(world, pos, DEFAULT_ENTITY_CONSUMER);
}
{
.entitiesLock.readLock().lock();
{
(Holder<EntityStore> entityHolder : .entities) {
Ref<EntityStore> entity = .placeEntity(world, entityHolder.clone(), pos, .prefabId);
(entity == ) {
LOGGER.at(Level.WARNING).log( , world.getName(), entityHolder);
} {
entityConsumer.accept(entity);
}
}
} {
.entitiesLock.readLock().unlock();
}
}
Ref<EntityStore> {
(TransformComponent)entityHolder.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition().add(( )( .x + pos.getX() - .anchorX), ( )( .y + pos.getY() - .anchorY), ( )( .z + pos.getZ() - .anchorZ));
Store<EntityStore> store = world.getEntityStore().getStore();
(prefabId, entityHolder);
store.invoke(prefabPlaceEntityEvent);
entityHolder.addComponent(FromPrefab.getComponentType(), FromPrefab.INSTANCE);
Ref<EntityStore> entityRef = <EntityStore>(store);
world.execute(() -> store.addEntity(entityHolder, entityRef, AddReason.LOAD));
entityRef;
}
BlockSelection {
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
( .getBlockCount(), .getEntityCount());
selection.copyPropertiesFrom( );
( , , );
Rotation.ofDegrees(angle);
.forEachBlock((x1, y1, z1, block) -> {
mutable.assign(x1 - .anchorX, y1 - .anchorY, z1 - .anchorZ);
axis.rotate(mutable, angle);
block.blockId;
Holder<ChunkStore> holder = block.holder;
RotationTuple.get(block.rotation);
RotationTuple var10000;
(axis) {
X -> var10000 = RotationTuple.of(blockRotation.yaw(), blockRotation.pitch().add(rotation), blockRotation.roll());
Y -> var10000 = RotationTuple.of(blockRotation.yaw().add(rotation), blockRotation.pitch(), blockRotation.roll());
Z -> var10000 = RotationTuple.of(blockRotation.yaw(), blockRotation.pitch(), blockRotation.roll().add(rotation));
-> ((String) , (Throwable) );
}
var10000;
(rotatedRotation == ) {
rotatedRotation = blockRotation;
}
BlockRotationUtil.getRotatedFiller(block.filler, axis, rotation);
selection.addBlock0(mutable.getX() + .anchorX, mutable.getY() + .anchorY, mutable.getZ() + .anchorZ, blockId, rotatedRotation.index(), rotatedFiller, block.supportValue(), holder != ? holder.clone() : );
});
.forEachEntity((entityHolder) -> {
Holder<EntityStore> copy = entityHolder.clone();
(TransformComponent)copy.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
(HeadRotation)copy.getComponent(HeadRotation.getComponentType());
position.subtract(( ) .anchorX, ( ) .anchorY, ( ) .anchorZ).subtract( , , );
axis.rotate(position, angle);
position.add(( ) .anchorX, ( ) .anchorY, ( ) .anchorZ).add( , , );
transformComponent.getRotation().addRotationOnAxis(axis, angle);
(headRotationComponent != ) {
headRotationComponent.getRotation().addRotationOnAxis(axis, angle);
}
selection.addEntity0(copy);
});
selection;
}
BlockSelection {
( .getBlockCount(), .getEntityCount());
selection.copyPropertiesFrom( );
( , , );
Rotation.ofDegrees(angle);
originOfRotation.clone().subtract(( ) .x, ( ) .y, ( ) .z);
.forEachBlock((x1, y1, z1, block) -> {
mutable.assign(( )(( )x1 - finalOriginOfRotation.x), ( )(( )y1 - finalOriginOfRotation.y), ( )(( )z1 - finalOriginOfRotation.z));
axis.rotate(mutable, angle);
block.blockId;
Holder<ChunkStore> holder = block.holder;
block.supportValue();
RotationTuple.get(block.rotation);
RotationTuple var10000;
(axis) {
X -> var10000 = RotationTuple.of(blockRotation.yaw(), blockRotation.pitch().add(rotation), blockRotation.roll());
Y -> var10000 = RotationTuple.of(blockRotation.yaw().add(rotation), blockRotation.pitch(), blockRotation.roll());
Z -> var10000 = RotationTuple.of(blockRotation.yaw(), blockRotation.pitch(), blockRotation.roll().add(rotation));
-> ((String) , (Throwable) );
}
var10000;
(rotatedRotation == ) {
rotatedRotation = blockRotation;
}
BlockRotationUtil.getRotatedFiller(block.filler, axis, rotation);
selection.addBlock0(( )(mutable.getX() + ( )finalOriginOfRotation.x), ( )(mutable.getY() + ( )finalOriginOfRotation.z), ( )(mutable.getZ() + ( )finalOriginOfRotation.z), blockId, rotatedRotation.index(), rotatedFiller, supportValue, holder != ? holder.clone() : );
});
.forEachEntity((entityHolder) -> {
Holder<EntityStore> copy = entityHolder.clone();
(TransformComponent)copy.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
(HeadRotation)copy.getComponent(HeadRotation.getComponentType());
position.subtract(( ) .anchorX, ( ) .anchorY, ( ) .anchorZ).subtract( , , );
axis.rotate(position, angle);
position.add(( ) .anchorX, ( ) .anchorY, ( ) .anchorZ).add( , , );
transformComponent.getRotation().addRotationOnAxis(axis, angle);
(headRotationComponent != ) {
headRotationComponent.getRotation().addRotationOnAxis(axis, angle);
}
selection.addEntity0(copy);
});
selection;
}
BlockSelection {
Math.toRadians(( )pitchDegrees);
Math.toRadians(( )yawDegrees);
Math.toRadians(( )rollDegrees);
();
rotation.setRotateEuler(pitchRad, yawRad, rollRad);
(rotation);
inverse.invert();
();
;
;
;
- ;
- ;
- ;
;
;
;
- ;
- ;
- ;
.blocksLock.readLock().lock();
{
(Long2ObjectMap.Entry<BlockHolder> entry : .blocks.long2ObjectEntrySet()) {
entry.getLongKey();
BlockUtil.unpackX(packed) - .anchorX;
BlockUtil.unpackY(packed) - .anchorY;
BlockUtil.unpackZ(packed) - .anchorZ;
srcMinX = Math.min(srcMinX, bx);
srcMinY = Math.min(srcMinY, by);
srcMinZ = Math.min(srcMinZ, bz);
srcMaxX = Math.max(srcMaxX, bx);
srcMaxY = Math.max(srcMaxY, by);
srcMaxZ = Math.max(srcMaxZ, bz);
}
} {
.blocksLock.readLock().unlock();
}
(srcMinX == ) {
( , .getEntityCount());
selection.copyPropertiesFrom( );
selection;
} {
[][] corners = [][]{{srcMinX, srcMinY, srcMinZ}, {srcMaxX, srcMinY, srcMinZ}, {srcMinX, srcMaxY, srcMinZ}, {srcMaxX, srcMaxY, srcMinZ}, {srcMinX, srcMinY, srcMaxZ}, {srcMaxX, srcMinY, srcMaxZ}, {srcMinX, srcMaxY, srcMaxZ}, {srcMaxX, srcMaxY, srcMaxZ}};
( [] corner : corners) {
tempVec.assign(( )corner[ ], ( )corner[ ], ( )corner[ ]);
rotation.multiplyDirection(tempVec);
MathUtil.floor(tempVec.x);
MathUtil.floor(tempVec.y);
MathUtil.floor(tempVec.z);
destMinX = Math.min(destMinX, rx);
destMinY = Math.min(destMinY, ry);
destMinZ = Math.min(destMinZ, rz);
destMaxX = Math.max(destMaxX, rx + );
destMaxY = Math.max(destMaxY, ry + );
destMaxZ = Math.max(destMaxZ, rz + );
}
( .getBlockCount(), .getEntityCount());
selection.copyPropertiesFrom( );
Rotation.ofDegrees(Math.round(yawDegrees / ) * );
Rotation.ofDegrees(Math.round(pitchDegrees / ) * );
Rotation.ofDegrees(Math.round(rollDegrees / ) * );
.blocksLock.readLock().lock();
{
( destMinX; dx <= destMaxX; ++dx) {
( destMinY; dy <= destMaxY; ++dy) {
( destMinZ; dz <= destMaxZ; ++dz) {
tempVec.assign(( )dx, ( )dy, ( )dz);
inverse.multiplyDirection(tempVec);
( )Math.round(tempVec.x);
( )Math.round(tempVec.y);
( )Math.round(tempVec.z);
BlockUtil.pack(sx + .anchorX, sy + .anchorY, sz + .anchorZ);
(BlockHolder) .blocks.get(packedSource);
(block != ) {
RotationTuple.get(block.rotation());
RotationTuple.of(blockRotation.yaw().add(snappedYaw), blockRotation.pitch().add(snappedPitch), blockRotation.roll().add(snappedRoll));
(rotatedRotation == ) {
rotatedRotation = blockRotation;
}
block.filler();
(rotatedFiller != ) {
FillerBlockUtil.unpackX(rotatedFiller);
FillerBlockUtil.unpackY(rotatedFiller);
FillerBlockUtil.unpackZ(rotatedFiller);
tempVec.assign(( )fillerX, ( )fillerY, ( )fillerZ);
rotation.multiplyDirection(tempVec);
rotatedFiller = FillerBlockUtil.pack(( )Math.round(tempVec.x), ( )Math.round(tempVec.y), ( )Math.round(tempVec.z));
}
Holder<ChunkStore> holder = block.holder();
selection.addBlock0(dx + .anchorX, dy + .anchorY, dz + .anchorZ, block.blockId(), rotatedRotation.index(), rotatedFiller, block.supportValue(), holder != ? holder.clone() : );
}
}
}
}
( destMinX; dx <= destMaxX; ++dx) {
( destMinY; dy <= destMaxY; ++dy) {
( destMinZ; dz <= destMaxZ; ++dz) {
tempVec.assign(( )dx, ( )dy, ( )dz);
inverse.multiplyDirection(tempVec);
( )Math.round(tempVec.x);
( )Math.round(tempVec.y);
( )Math.round(tempVec.z);
BlockUtil.pack(sx + .anchorX, sy + .anchorY, sz + .anchorZ);
(FluidHolder) .fluids.get(packedSource);
(fluid != ) {
selection.addFluid0(dx + .anchorX, dy + .anchorY, dz + .anchorZ, fluid.fluidId(), fluid.fluidLevel());
}
}
}
}
} {
.blocksLock.readLock().unlock();
}
( )yawRad;
( )pitchRad;
( )rollRad;
.forEachEntity((entityHolder) -> {
Holder<EntityStore> copy = entityHolder.clone();
(TransformComponent)copy.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
(HeadRotation)copy.getComponent(HeadRotation.getComponentType());
position.subtract(( ) .anchorX, ( ) .anchorY, ( ) .anchorZ).subtract( , , );
rotation.multiplyDirection(position);
position.add(( ) .anchorX, ( ) .anchorY, ( ) .anchorZ).add( , , );
transformComponent.getRotation();
bodyRotation.addPitch(var68);
bodyRotation.addYaw(var64);
bodyRotation.addRoll(var71);
(headRotationComp != ) {
headRotationComp.getRotation();
headRot.addPitch(var68);
headRot.addYaw(var64);
headRot.addRoll(var71);
}
selection.addEntity0(copy);
});
selection;
}
}
BlockSelection {
BlockTypeAssetMap<String, BlockType> assetMap = BlockType.getAssetMap();
( .getBlockCount(), .getEntityCount());
selection.copyPropertiesFrom( );
( , , );
.forEachBlock((x1, y1, z1, block) -> {
mutable.assign(x1 - .anchorX, y1 - .anchorY, z1 - .anchorZ);
axis.flip(mutable);
block.blockId;
Holder<ChunkStore> holder = block.holder;
block.supportValue();
block.filler;
assetMap.getAsset(blockId);
blockType.getVariantRotation();
(variantRotation == VariantRotation.None) {
selection.addBlock0(mutable.getX() + .anchorX, mutable.getY() + .anchorY, mutable.getZ() + .anchorZ, block);
} {
RotationTuple.get(block.rotation);
BlockRotationUtil.getFlipped(blockRotation, blockType.getFlipType(), axis, variantRotation);
(rotatedRotation != ) {
rotatedRotation = blockRotation;
}
BlockRotationUtil.getFlippedFiller(filler, axis);
selection.addBlock0(mutable.getX() + .anchorX, mutable.getY() + .anchorY, mutable.getZ() + .anchorZ, blockId, rotatedRotation.index(), rotatedFiller, supportValue, holder != ? holder.clone() : );
}
});
.forEachEntity((entityHolder) -> {
Holder<EntityStore> copy = entityHolder.clone();
(HeadRotation)copy.getComponent(HeadRotation.getComponentType());
headRotationComponent != ;
headRotationComponent.getRotation();
(TransformComponent)copy.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition();
transformComponent.getRotation();
position.subtract(( ) .anchorX, ( ) .anchorY, ( ) .anchorZ).subtract( , , );
axis.flip(position);
position.add(( ) .anchorX, ( ) .anchorY, ( ) .anchorZ).add( , , );
axis.flipRotation(bodyRotation);
axis.flipRotation(headRotation);
selection.addEntity0(copy);
});
selection;
}
BlockSelection {
.relativize( .anchorX, .anchorY, .anchorZ);
}
BlockSelection {
(originX == && originY == && originZ == ) {
.cloneSelection();
} {
( .getBlockCount(), .getEntityCount());
selection.setAnchor( .anchorX - originX, .anchorY - originY, .anchorZ - originZ);
selection.setPosition( .x - originX, .y - originY, .z - originZ);
selection.setSelectionArea( .min.clone().subtract(originX, originY, originZ), .max.clone().subtract(originX, originY, originZ));
.forEachBlock((x, y, z, block) -> selection.addBlock0(x - originX, y - originY, z - originZ, block));
.forEachEntity((holder) -> {
Holder<EntityStore> copy = holder.clone();
(TransformComponent)copy.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition().subtract(( )originX, ( )originY, ( )originZ);
selection.addEntity0(copy);
});
selection;
}
}
BlockSelection {
( .getBlockCount(), .getEntityCount());
selection.copyPropertiesFrom( );
.blocksLock.readLock().lock();
{
Long2ObjectMaps.fastForEach( .blocks, (entry) -> selection.blocks.put(entry.getLongKey(), ((BlockHolder)entry.getValue()).cloneBlockHolder()));
selection.fluids.putAll( .fluids);
} {
.blocksLock.readLock().unlock();
}
.entitiesLock.readLock().lock();
{
.entities.forEach((holder) -> selection.entities.add(holder.clone()));
} {
.entitiesLock.readLock().unlock();
}
selection;
}
{
.entitiesLock.writeLock().lock();
{
other.forEachEntity((holder) -> {
Holder<EntityStore> copy = holder.clone();
(TransformComponent)copy.getComponent(TransformComponent.getComponentType());
transformComponent != ;
transformComponent.getPosition().add(( )other.x, ( )other.y, ( )other.z).subtract(( ) .x, ( ) .y, ( ) .z);
.addEntity0(copy);
});
} {
.entitiesLock.writeLock().unlock();
}
.blocksLock.writeLock().lock();
{
other.forEachBlock((x1, y1, z1, block) -> .addBlock0(x1 + other.x - .x, y1 + other.y - .y, z1 + other.z - .z, block));
other.forEachFluid((x1, y1, z1, fluidId, fluidLevel) -> .addFluid0(x1 + other.x - .x, y1 + other.y - .y, z1 + other.z - .z, fluidId, fluidLevel));
} {
.blocksLock.writeLock().unlock();
}
}
MetricResults {
METRICS_REGISTRY.toMetricResults( );
}
EditorBlocksChange {
();
.blocksLock.readLock().lock();
{
.getBlockCount();
List<BlockChange> blockList = <BlockChange>(blockCount);
.forEachBlock((x1, y1, z1, block) -> {
(block.filler == ) {
blockList.add( (x1 - .anchorX, y1 - .anchorY, z1 - .anchorZ, block.blockId, ( )block.rotation));
}
});
List<FluidChange> fluidList = <FluidChange>();
.forEachFluid((x1, y1, z1, fluidId, fluidLevel) -> {
(fluidId != ) {
fluidList.add( (x1 - .anchorX, y1 - .anchorY, z1 - .anchorZ, fluidId, fluidLevel));
}
});
packet.blocksChange = (BlockChange[])blockList.toArray((x$ ) -> [x$ ]);
packet.fluidsChange = (FluidChange[])fluidList.toArray((x$ ) -> [x$ ]);
packet.advancedPreview = ;
packet.blocksCount = blockCount;
} {
.blocksLock.readLock().unlock();
}
packet;
}
EditorBlocksChange {
();
();
( .min != ) {
selection.minX = .min.getX();
selection.minY = .min.getY();
selection.minZ = .min.getZ();
}
( .max != ) {
selection.maxX = .max.getX();
selection.maxY = .max.getY();
selection.maxZ = .max.getZ();
}
packet.selection = selection;
packet;
}
EditorBlocksChange {
.toPacket();
( .min != && .max != ) {
();
selection.minX = .min.getX();
selection.minY = .min.getY();
selection.minZ = .min.getZ();
selection.maxX = .max.getX();
selection.maxY = .max.getY();
selection.maxZ = .max.getZ();
packet.selection = selection;
}
packet;
}
{
.blocksLock.readLock().lock();
LongOpenHashSet blockPositions;
{
blockPositions = ( .blocks.keySet());
} {
.blocksLock.readLock().unlock();
}
BlockType.getAssetMap();
BlockBoundingBoxes.getAssetMap();
blockPositions.iterator();
(it.hasNext()) {
it.nextLong();
BlockUtil.unpackX(packed);
BlockUtil.unpackY(packed);
BlockUtil.unpackZ(packed);
.getBlockHolderAtLocalPos(x, y, z);
(blockHolder != ) {
blockHolder.blockId;
(blockId != ) {
(BlockType)blockTypeAssetMap.getAsset(blockId);
(blockType != ) {
blockType.getId();
(blockHolder.filler != ) {
FillerBlockUtil.unpackX(blockHolder.filler);
FillerBlockUtil.unpackY(blockHolder.filler);
FillerBlockUtil.unpackZ(blockHolder.filler);
.getBlockHolderAtLocalPos(x - fillerX, y - fillerY, z - fillerZ);
(BlockType)blockTypeAssetMap.getAsset(baseBlockHolder.blockId);
(baseBlock == ) {
.addBlockAtLocalPos(x, y, z, , , , );
} {
baseBlock.getId();
(BlockBoundingBoxes)hitboxAssetMap.getAsset(baseBlock.getHitboxTypeIndex());
(hitbox != && (!id.equals(baseId) || baseBlockHolder.rotation != blockHolder.rotation || !hitbox.get(blockHolder.rotation).getBoundingBox().containsBlock(fillerX, fillerY, fillerZ))) {
.addBlockAtLocalPos(x, y, z, , , , );
}
}
} {
(BlockBoundingBoxes)hitboxAssetMap.getAsset(blockType.getHitboxTypeIndex());
(hitbox != && hitbox.protrudesUnitBox()) {
FillerBlockUtil.forEachFillerBlock(hitbox.get(blockHolder.rotation), (x1, y1, z1) -> {
(x1 != || y1 != || z1 != ) {
x + x1;
y + y1;
z + z1;
.getBlockHolderAtLocalPos(worldX, worldY, worldZ);
(BlockType)blockTypeAssetMap.getAsset(fillerBlockHolder.blockId);
FillerBlockUtil.pack(x1, y1, z1);
(fillerBlock == || !fillerBlock.getId().equals(id) || filler != fillerBlockHolder.filler) {
(!allowDestructive && fillerBlockHolder.blockId != ) {
fillerBlock.getId();
( + var10002 + + blockType.getId() + + worldX + + worldY + + worldZ + + x + + y + + z);
}
.addBlockAtLocalPos(worldX, worldY, worldZ, blockId, blockHolder.rotation, filler, );
}
}
});
}
}
}
}
}
}
}
IOException {
.entitiesLock.writeLock().lock();
{
(! .entities.isEmpty()) {
ComponentRegistry<EntityStore> registry = EntityStore.REGISTRY;
ComponentRegistry.Data<EntityStore> data = registry.getData();
SystemType<EntityStore, EntityModule.MigrationSystem> systemType = EntityModule.get().getMigrationSystemType();
data.getSystemIndexesForType(systemType);
- ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
EntityModule. (EntityModule.MigrationSystem)data.getSystem(systemIndex, systemType);
( ; i < .entities.size(); ++i) {
Holder<EntityStore> holder = (Holder) .entities.get(i);
(system.test(registry, holder.getArchetype())) {
system.onEntityAdd(holder, AddReason.LOAD, store);
}
}
}
systemIndex = - ;
((systemIndex = systemIndexes.nextSetBit(systemIndex + )) >= ) {
EntityModule. (EntityModule.MigrationSystem)data.getSystem(systemIndex, systemType);
( ; i < .entities.size(); ++i) {
Holder<EntityStore> holder = (Holder) .entities.get(i);
(system.test(registry, holder.getArchetype())) {
system.onEntityRemoved(holder, RemoveReason.UNLOAD, store);
}
}
}
(!destructive) {
;
}
( ; i < .entities.size(); ++i) {
Holder<EntityStore> holder = (Holder) .entities.get(i);
holder.tryRemoveComponent(registry.getUnknownComponentType());
}
;
}
} {
.entitiesLock.writeLock().unlock();
}
}
String {
String.valueOf( .blocksLock);
+ var10000 + + .x + + .y + + .z + + .anchorX + + .anchorY + + .anchorZ + + String.valueOf( .min) + + String.valueOf( .max) + ;
}
{
METRICS_REGISTRY = ( ()).register( , (selection) -> selection.blocksLock.toString(), Codec.STRING).register( , (selection) -> selection.entitiesLock.toString(), Codec.STRING).register( , (selection) -> (selection.x, selection.y, selection.z), Vector3i.CODEC).register( , (selection) -> (selection.anchorX, selection.anchorY, selection.anchorZ), Vector3i.CODEC).register( , BlockSelection::getSelectionMin, Vector3i.CODEC).register( , BlockSelection::getSelectionMax, Vector3i.CODEC).register( , BlockSelection::getBlockCount, Codec.INTEGER).register( , BlockSelection::getEntityCount, Codec.INTEGER);
LOGGER = HytaleLogger.forEnclosingClass();
}
{
PASS_THOUGH,
COPY;
{
}
}
{
BlockHolder {
.holder == ? : ( .blockId, .rotation, .filler, .supportValue, .holder.clone());
}
}
{
}
{
;
}
{
;
}
{
;
}
}
com/hypixel/hytale/server/core/prefab/selection/standard/FeedbackConsumer.java
package com.hypixel.hytale.server.core.prefab.selection.standard;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
@FunctionalInterface
public interface FeedbackConsumer {
FeedbackConsumer DEFAULT = (key, total, count, target, componentAccessor) -> {
};
void accept (@Nonnull String var1, int var2, int var3, @Nonnull CommandSender var4, @Nonnull ComponentAccessor<EntityStore> var5) ;
}