PrefabEditingMetadata class
Пакет: com.hypixel.hytale.builtin.buildertools.prefabeditor
Файл: com/hypixel/hytale/builtin/buildertools/prefabeditor/PrefabEditingMetadata.java
Поля (8)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
float |
PREFAB_ANCHOR_ENTITY_SCALE |
|
Store |
var3 |
|
int |
var3 |
|
Ref |
var4 |
|
int |
var4 |
|
Holder |
var5 |
|
int |
var5 |
|
TimeResource |
var6 |
Методы (28)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
IllegalStateExceptionthrow new IllegalStateException("minX must be less than or equal to maxX: " + var1) |
abstract |
throw new |
IllegalStateExceptionthrow new IllegalStateException("minY must be less than or equal to maxY: " + var1) |
abstract |
throw new |
IllegalStateExceptionthrow new IllegalStateException("minZ must be less than or equal to maxZ: " + var1) |
private |
void |
createAnchorEntityAtvoid createAnchorEntityAt(@Nonnull Vector3i var1, @Nonnull World var2) |
public |
Vector3i |
getAnchorEntityPositionVector3i getAnchorEntityPosition() |
public |
Vector3i |
getAnchorPointVector3i getAnchorPoint() |
public |
Vector3i |
getMaxPointVector3i getMaxPoint() |
public |
Vector3i |
getMinPointVector3i getMinPoint() |
public |
Vector3i |
getOriginalFileAnchorVector3i getOriginalFileAnchor() |
public |
Vector3i |
getPastePositionVector3i getPastePosition() |
public |
Path |
getPrefabPathPath getPrefabPath() |
public |
UUID |
getUuidUUID getUuid() |
|
|
if if(var2.x > var3.x) |
|
|
if if(var2.y > var3.y) |
|
|
if if(var2.z > var3.z) |
|
|
if if(this.anchorEntityUuid != null) |
|
|
if if(this.originalFileAnchor == null && this.anchorPoint != null && this.pastePosition != null) |
|
|
if if(this.anchorEntityPosition != null) |
public |
boolean |
isDirtyboolean isDirty() |
public |
boolean |
isLocationWithinPrefabBoundingBoxboolean isLocationWithinPrefabBoundingBox(@Nonnull Vector3i var1) |
public |
boolean |
isReadOnlyboolean isReadOnly() |
public |
void |
recreateAnchorEntityvoid recreateAnchorEntity(@Nonnull World var1) |
public |
void |
sendAnchorHighlightingPacketvoid sendAnchorHighlightingPacket(@Nonnull PacketHandler var1) |
public |
void |
setAnchorPointvoid setAnchorPoint(@Nonnull Vector3i var1, @Nonnull World var2) |
public |
void |
setDirtyvoid setDirty(boolean var1) |
|
void |
setMaxPointvoid setMaxPoint(Vector3i var1) |
|
void |
setMinPointvoid setMinPoint(Vector3i var1) |
public |
void |
setPrefabPathvoid setPrefabPath(@Nonnull Path var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.buildertools.prefabeditor;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.component.AddReason;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.RemoveReason;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.codec.Vector3iArrayCodec;
class="kw">import com.hypixel.hytale.math.vector.Vector3iUtil;
class="kw">import com.hypixel.hytale.protocol.packets.buildertools.BuilderToolShowAnchor;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.entity.entities.BlockEntity;
class="kw">import com.hypixel.hytale.server.core.io.PacketHandler;
class="kw">import com.hypixel.hytale.server.core.modules.entity.DespawnComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.EntityScaleComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.Intangible;
class="kw">import com.hypixel.hytale.server.core.modules.time.TimeResource;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.nio.file.FileSystems;
class="kw">import java.nio.file.Path;
class="kw">import java.util.UUID;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3i;
class="kw">public class PrefabEditingMetadata {
class="kw">private class="kw">static class="kw">final float PREFAB_ANCHOR_ENTITY_SCALE = 1.05F;
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<PrefabEditingMetadata> CODEC = BuilderCodec.builder(PrefabEditingMetadata.class, PrefabEditingMetadata::new)
.append(new KeyedCodec<>("Path", Codec.PATH), (var0, var1) -> var0.prefabPath = var1, var0 -> var0.prefabPath)
.add()
.append(new KeyedCodec<>("MinPoint", new Vector3iArrayCodec()), (var0, var1) -> var0.minPoint = var1, var0 -> var0.minPoint)
.add()
.append(new KeyedCodec<>("MaxPoint", new Vector3iArrayCodec()), (var0, var1) -> var0.maxPoint = var1, var0 -> var0.maxPoint)
.add()
.append(new KeyedCodec<>("AnchorPoint", new Vector3iArrayCodec()), (var0, var1) -> var0.anchorPoint = var1, var0 -> var0.anchorPoint)
.add()
.append(new KeyedCodec<>("PastePosition", new Vector3iArrayCodec()), (var0, var1) -> var0.pastePosition = var1, var0 -> var0.pastePosition)
.add()
.append(new KeyedCodec<>("AnchorEntityUuid", Codec.UUID_STRING, false), (var0, var1) -> var0.anchorEntityUuid = var1, var0 -> var0.anchorEntityUuid)
.add()
.append(
new KeyedCodec<>("AnchorEntityPosition", new Vector3iArrayCodec(), false),
(var0, var1) -> var0.anchorEntityPosition = var1,
var0 -> var0.anchorEntityPosition
)
.add()
.append(
new KeyedCodec<>("OriginalFileAnchor", new Vector3iArrayCodec(), false),
(var0, var1) -> var0.originalFileAnchor = var1,
var0 -> var0.originalFileAnchor
)
.add()
.append(new KeyedCodec<>("Uuid", Codec.UUID_STRING), (var0, var1) -> var0.uuid = var1, var0 -> var0.uuid)
.add()
.append(new KeyedCodec<>("Dirty", Codec.BOOLEAN, true), (var0, var1) -> var0.dirty = var1, var0 -> var0.dirty)
.add()
.build();
class="kw">private UUID uuid;
class="kw">private Path prefabPath;
class="kw">private Vector3i minPoint;
class="kw">private Vector3i maxPoint;
class="kw">private Vector3i anchorPoint;
class="kw">private Vector3i pastePosition;
@Nullable
class="kw">private UUID anchorEntityUuid;
class="kw">private Vector3i anchorEntityPosition;
class="kw">private Vector3i originalFileAnchor;
class="kw">private boolean dirty = false;
class="kw">private PrefabEditingMetadata() {
}
class="kw">public PrefabEditingMetadata(
@Nonnull Path var1, @Nonnull Vector3i var2, @Nonnull Vector3i var3, @Nonnull Vector3i var4, @Nonnull Vector3i var5, @Nonnull World var6
) {
this.prefabPath = var1;
this.minPoint = var2;
this.maxPoint = var3;
if (var2.x > var3.x) {
throw new IllegalStateException("minX must be less than or equal to maxX: " + var1);
}
if (var2.y > var3.y) {
throw new IllegalStateException("minY must be less than or equal to maxY: " + var1);
}
if (var2.z > var3.z) {
throw new IllegalStateException("minZ must be less than or equal to maxZ: " + var1);
}
this.uuid = UUID.randomUUID();
this.anchorPoint = var4;
this.pastePosition = var5;
this.originalFileAnchor = new Vector3i(var4.x - var5.x, var4.y - var5.y, var4.z - var5.z);
this.createAnchorEntityAt(var5, var6);
}
class="kw">private void createAnchorEntityAt(@Nonnull Vector3i var1, @Nonnull World var2) {
this.anchorEntityPosition = new Vector3i(var1);
Store var3 = var2.getEntityStore().getStore();
if (this.anchorEntityUuid != null) {
Ref var4 = var3.getExternalData().getRefFromUUID(this.anchorEntityUuid);
if (var4 != null && var4.isValid()) {
var2.execute(() -> var3.removeEntity(var4, RemoveReason.REMOVE));
}
}
TimeResource var6 = var3.getResource(TimeResource.getResourceType());
Holder var5 = BlockEntity.assembleDefaultBlockEntity(var6, "Editor_Anchor", Vector3iUtil.toVector3d(var1).add(0.5, 0.5, 0.5));
var5.removeComponent(DespawnComponent.getComponentType());
var5.addComponent(Intangible.getComponentType(), Intangible.INSTANCE);
var5.addComponent(PrefabAnchor.getComponentType(), PrefabAnchor.INSTANCE);
var5.addComponent(EntityScaleComponent.getComponentType(), new EntityScaleComponent(1.05F));
this.anchorEntityUuid = var5.ensureAndGetComponent(UUIDComponent.getComponentType()).getUuid();
var2.execute(() -> var3.addEntity(var5, AddReason.SPAWN));
}
class="kw">public void setPrefabPath(@Nonnull Path var1) {
this.prefabPath = var1;
}
class="kw">public void setAnchorPoint(@Nonnull Vector3i var1, @Nonnull World var2) {
int var3 = var1.x - this.anchorEntityPosition.x;
int var4 = var1.y - this.anchorEntityPosition.y;
int var5 = var1.z - this.anchorEntityPosition.z;
this.anchorPoint = new Vector3i(this.anchorPoint.x + var3, this.anchorPoint.y + var4, this.anchorPoint.z + var5);
this.createAnchorEntityAt(var1, var2);
}
class="kw">public void recreateAnchorEntity(@Nonnull World var1) {
if (this.originalFileAnchor == null && this.anchorPoint != null && this.pastePosition != null) {
this.originalFileAnchor = new Vector3i(
this.anchorPoint.x - this.pastePosition.x, this.anchorPoint.y - this.pastePosition.y, this.anchorPoint.z - this.pastePosition.z
);
}
if (this.anchorEntityPosition != null) {
this.createAnchorEntityAt(this.anchorEntityPosition, var1);
}
}
class="kw">public void sendAnchorHighlightingPacket(@Nonnull PacketHandler var1) {
var1.writeNoCache(new BuilderToolShowAnchor(this.anchorEntityPosition.x, this.anchorEntityPosition.y, this.anchorEntityPosition.z));
}
class="kw">public boolean isLocationWithinPrefabBoundingBox(@Nonnull Vector3i var1) {
class="kw">return var1.x >= this.getMinPoint().x
&& var1.x <= this.getMaxPoint().x
&& var1.y >= this.getMinPoint().y
&& var1.y <= this.getMaxPoint().y
&& var1.z >= this.getMinPoint().z
&& var1.z <= this.getMaxPoint().z;
}
void setMinPoint(Vector3i var1) {
this.minPoint = var1;
}
void setMaxPoint(Vector3i var1) {
this.maxPoint = var1;
}
class="kw">public Vector3i getAnchorPoint() {
class="kw">return this.anchorPoint;
}
class="kw">public Vector3i getPastePosition() {
class="kw">return this.pastePosition;
}
class="kw">public Vector3i getOriginalFileAnchor() {
class="kw">return this.originalFileAnchor;
}
class="kw">public Path getPrefabPath() {
class="kw">return this.prefabPath;
}
class="kw">public Vector3i getMinPoint() {
class="kw">return this.minPoint;
}
class="kw">public Vector3i getMaxPoint() {
class="kw">return this.maxPoint;
}
@Nullable
class="kw">public UUID getAnchorEntityUuid() {
class="kw">return this.anchorEntityUuid;
}
class="kw">public Vector3i getAnchorEntityPosition() {
class="kw">return this.anchorEntityPosition;
}
class="kw">public UUID getUuid() {
class="kw">return this.uuid;
}
class="kw">public boolean isDirty() {
class="kw">return this.dirty;
}
class="kw">public void setDirty(boolean var1) {
this.dirty = var1;
}
class="kw">public boolean isReadOnly() {
class="kw">return this.prefabPath != null && this.prefabPath.getFileSystem() != FileSystems.getDefault();
}
}