SpawnPrefabInteraction class
Пакет: com.hypixel.hytale.server.core.modules.interaction.interaction.config.server
Файл: com/hypixel/hytale/server/core/modules/interaction/interaction/config/server/SpawnPrefabInteraction.java
extends: SimpleInstantInteraction
Поля (24)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<SpawnPrefabInteraction> |
CODEC |
|
|
break |
|
|
break |
|
|
return |
|
|
return |
|
|
return |
|
BlockPosition |
var10 |
|
ChunkStore |
var11 |
|
Ref |
var12 |
|
BlockSection |
var13 |
|
Rotation |
var14 |
|
Ref |
var15 |
|
int |
var16 |
|
TransformComponent |
var17 |
|
int |
var18 |
|
Path |
var4 |
|
IPrefabBuffer |
var5 |
|
CommandBuffer |
var6 |
|
World |
var7 |
|
Rotation |
var8 |
|
|
var8 |
|
Vector3i |
var9 |
|
|
var9 |
|
|
var9 |
Методы (5)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("Unhandled origin source") |
|
|
if if(var4 != null) |
|
|
if if(var10 == null) |
|
|
if if(var13 == null) |
|
|
switch switch(this.originSource) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.interaction.interaction.config.server;
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.codec.validation.Validators;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.math.util.FastRandom;
class="kw">import com.hypixel.hytale.math.vector.Vector3dUtil;
class="kw">import com.hypixel.hytale.math.vector.Vector3iUtil;
class="kw">import com.hypixel.hytale.protocol.BlockPosition;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.OriginSource;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInstantInteraction;
class="kw">import com.hypixel.hytale.server.core.prefab.PrefabStore;
class="kw">import com.hypixel.hytale.server.core.prefab.selection.buffer.PrefabBufferUtil;
class="kw">import com.hypixel.hytale.server.core.prefab.selection.buffer.impl.IPrefabBuffer;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.core.util.PrefabUtil;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3i;
class="kw">public class SpawnPrefabInteraction class="kw">extends SimpleInstantInteraction {
class="kw">public class="kw">static class="kw">final BuilderCodec<SpawnPrefabInteraction> CODEC = BuilderCodec.builder(
SpawnPrefabInteraction.class, SpawnPrefabInteraction::new, SimpleInstantInteraction.CODEC
)
.documentation("Spawns a prefab at the current location.")
.appendInherited(
new KeyedCodec<>("PrefabPath", Codec.STRING),
(var0, var1) -> var0.prefabPath = var1,
var0 -> var0.prefabPath,
(var0, var1) -> var0.prefabPath = var1.prefabPath
)
.add()
.<Vector3i>appendInherited(
new KeyedCodec<>("Offset", Vector3iUtil.CODEC), (var0, var1) -> var0.offset = var1, var0 -> var0.offset, (var0, var1) -> var0.offset = var1.offset
)
.addValidator(Validators.nonNull())
.add()
.<Rotation>appendInherited(
new KeyedCodec<>("RotationYaw", Rotation.CODEC),
(var0, var1) -> var0.rotationYaw = var1,
var0 -> var0.rotationYaw,
(var0, var1) -> var0.rotationYaw = var1.rotationYaw
)
.addValidator(Validators.nonNull())
.add()
.<OriginSource>appendInherited(
new KeyedCodec<>("OriginSource", OriginSource.CODEC),
(var0, var1) -> var0.originSource = var1,
var0 -> var0.originSource,
(var0, var1) -> var0.originSource = var1.originSource
)
.addValidator(Validators.nonNull())
.add()
.appendInherited(new KeyedCodec<>("Force", Codec.BOOLEAN), (var0, var1) -> var0.force = var1, var0 -> var0.force, (var0, var1) -> var0.force = var1.force)
.add()
.build();
class="kw">private String prefabPath;
class="kw">private Vector3i offset = new Vector3i();
class="kw">private Rotation rotationYaw = Rotation.None;
@Nonnull
class="kw">private OriginSource originSource = OriginSource.ENTITY;
class="kw">private boolean force;
class="kw">public SpawnPrefabInteraction() {
}
@Override
class="kw">protected void firstRun(@Nonnull InteractionType var1, @Nonnull InteractionContext var2, @Nonnull CooldownHandler var3) {
Path var4 = PrefabStore.get().findAssetPrefabPath(this.prefabPath);
if (var4 != null) {
IPrefabBuffer var5 = PrefabBufferUtil.getCached(var4);
CommandBuffer var6 = var2.getCommandBuffer();
assert var6 != null;
World var7 = var6.getExternalData().getWorld();
Rotation var8 = this.rotationYaw;
Vector3i var9;
class="kw">switch (this.originSource) {
case ENTITY:
Ref var15 = var2.getEntity();
TransformComponent var17 = var6.getComponent(var15, TransformComponent.getComponentType());
assert var17 != null;
var9 = Vector3dUtil.toVector3i(var17.getPosition());
var9.add(this.offset);
break;
case BLOCK:
BlockPosition var10 = var2.getTargetBlock();
if (var10 == null) {
class="kw">return;
}
ChunkStore var11 = var7.getChunkStore();
Ref var12 = var11.getChunkSectionReferenceAtBlock(var10.x, var10.y, var10.z);
if (var12 == null || !var12.isValid()) {
class="kw">return;
}
BlockSection var13 = var11.getStore().getComponent(var12, BlockSection.getComponentType());
if (var13 == null) {
class="kw">return;
}
Rotation var14 = var13.getRotation(var10.x, var10.y, var10.z).yaw();
var9 = new Vector3i();
var14.rotateYaw(this.offset, var9);
var8 = var8.add(var14);
var9.add(var10.x, var10.y, var10.z);
break;
class="kw">default:
throw new IllegalArgumentException("Unhandled origin source");
}
int var16 = (this.force ? 1 : 0) | 8;
int var18 = 0;
PrefabUtil.paste(var5, var7, var9, var8, new FastRandom(), var16, 0, var6);
}
}
}