PlaceModeSelectInteraction class
Пакет: com.hypixel.hytale.server.core.modules.interaction.interaction.config.none
Файл: com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/PlaceModeSelectInteraction.java
extends: SimpleInteraction
Поля (9)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<PlaceModeSelectInteraction> |
CODEC |
|
Label[] |
var2 |
|
CommandBuffer |
var2 |
|
com.hypixel.hytale.protocol.PlaceModeSelectInteraction |
var2 |
|
Label |
var3 |
|
Ref |
var3 |
|
Player |
var4 |
|
PlayerSettings |
var5 |
|
int |
var6 |
Методы (11)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
static |
void |
compileBranchvoid compileBranch(@Nonnull OperationsBuilder var0, @Nonnull Label[] var1, int var2, @Nullable String var3, @Nonnull Label var4) |
abstract |
|
compileBranch compileBranch(var1, var2, 1, this.replaceInteractions, var3) |
abstract |
|
compileBranch compileBranch(var1, var2, 2, this.retypeInteractions, var3) |
abstract |
|
compileBranch compileBranch(var1, var2, 3, this.extrudeInteractions, var3) |
abstract |
|
compileBranch compileBranch(var1, var2, 4, this.surfaceDrawInteractions, var3) |
abstract |
|
compileBranch compileBranch(var1, var2, 5, this.fastPlaceInteractions, var3) |
|
|
if if(this.next != null) |
|
|
if if(var3 == null) |
|
|
if if(var2 != null && var3 != null) |
|
|
if if(var5 == null) |
private |
int |
resolveModeIndexint resolveModeIndex(@Nonnull InteractionContext var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.interaction.interaction.config.none;
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.protocol.GameMode;
class="kw">import com.hypixel.hytale.protocol.InteractionState;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.protocol.WaitForDataFrom;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionManager;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.modules.entity.player.PlayerSettings;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Interaction;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInteraction;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.data.Collector;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.data.StringTag;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.operation.Label;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.operation.OperationsBuilder;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class PlaceModeSelectInteraction class="kw">extends SimpleInteraction {
class="kw">public class="kw">static class="kw">final BuilderCodec<PlaceModeSelectInteraction> CODEC = BuilderCodec.builder(
PlaceModeSelectInteraction.class, PlaceModeSelectInteraction::new, SimpleInteraction.CODEC
)
.documentation("Runs the interactions for the player's active creative place mode. Players outside Creative always run the Default branch.")
.<String>appendInherited(
new KeyedCodec<>("DefaultInteractions", Interaction.CHILD_ASSET_CODEC),
(var0, var1) -> var0.defaultInteractions = var1,
var0 -> var0.defaultInteractions,
(var0, var1) -> var0.defaultInteractions = var1.defaultInteractions
)
.documentation("The interactions to run for the class="kw">default place mode, non-Creative players, and any mode without its own branch.")
.addValidator(Validators.nonNull())
.addValidatorLate(() -> VALIDATOR_CACHE.getValidator().late())
.add()
.<String>appendInherited(
new KeyedCodec<>("ReplaceInteractions", Interaction.CHILD_ASSET_CODEC),
(var0, var1) -> var0.replaceInteractions = var1,
var0 -> var0.replaceInteractions,
(var0, var1) -> var0.replaceInteractions = var1.replaceInteractions
)
.documentation("The interactions to run for the quick replace place mode.")
.addValidatorLate(() -> VALIDATOR_CACHE.getValidator().late())
.add()
.<String>appendInherited(
new KeyedCodec<>("RetypeInteractions", Interaction.CHILD_ASSET_CODEC),
(var0, var1) -> var0.retypeInteractions = var1,
var0 -> var0.retypeInteractions,
(var0, var1) -> var0.retypeInteractions = var1.retypeInteractions
)
.documentation("The interactions to run for the quick retype place mode.")
.addValidatorLate(() -> VALIDATOR_CACHE.getValidator().late())
.add()
.<String>appendInherited(
new KeyedCodec<>("ExtrudeInteractions", Interaction.CHILD_ASSET_CODEC),
(var0, var1) -> var0.extrudeInteractions = var1,
var0 -> var0.extrudeInteractions,
(var0, var1) -> var0.extrudeInteractions = var1.extrudeInteractions
)
.documentation("The interactions to run for the extrude place mode.")
.addValidatorLate(() -> VALIDATOR_CACHE.getValidator().late())
.add()
.<String>appendInherited(
new KeyedCodec<>("SurfaceDrawInteractions", Interaction.CHILD_ASSET_CODEC),
(var0, var1) -> var0.surfaceDrawInteractions = var1,
var0 -> var0.surfaceDrawInteractions,
(var0, var1) -> var0.surfaceDrawInteractions = var1.surfaceDrawInteractions
)
.documentation("The interactions to run for the surface draw place mode.")
.addValidatorLate(() -> VALIDATOR_CACHE.getValidator().late())
.add()
.<String>appendInherited(
new KeyedCodec<>("FastPlaceInteractions", Interaction.CHILD_ASSET_CODEC),
(var0, var1) -> var0.fastPlaceInteractions = var1,
var0 -> var0.fastPlaceInteractions,
(var0, var1) -> var0.fastPlaceInteractions = var1.fastPlaceInteractions
)
.documentation("The interactions to run for the fast place mode.")
.addValidatorLate(() -> VALIDATOR_CACHE.getValidator().late())
.add()
.build();
class="kw">private class="kw">static class="kw">final int DEFAULT_LABEL_INDEX = 0;
class="kw">private class="kw">static class="kw">final int REPLACE_LABEL_INDEX = 1;
class="kw">private class="kw">static class="kw">final int RETYPE_LABEL_INDEX = 2;
class="kw">private class="kw">static class="kw">final int EXTRUDE_LABEL_INDEX = 3;
class="kw">private class="kw">static class="kw">final int SURFACE_DRAW_LABEL_INDEX = 4;
class="kw">private class="kw">static class="kw">final int FAST_PLACE_LABEL_INDEX = 5;
class="kw">private class="kw">static class="kw">final int LABEL_COUNT = 6;
class="kw">private class="kw">static class="kw">final StringTag TAG_DEFAULT = StringTag.of("Default");
class="kw">private class="kw">static class="kw">final StringTag TAG_REPLACE = StringTag.of("Replace");
class="kw">private class="kw">static class="kw">final StringTag TAG_RETYPE = StringTag.of("Retype");
class="kw">private class="kw">static class="kw">final StringTag TAG_EXTRUDE = StringTag.of("Extrude");
class="kw">private class="kw">static class="kw">final StringTag TAG_SURFACE_DRAW = StringTag.of("SurfaceDraw");
class="kw">private class="kw">static class="kw">final StringTag TAG_FAST_PLACE = StringTag.of("FastPlace");
class="kw">private class="kw">static class="kw">final StringTag TAG_NEXT = StringTag.of("Next");
class="kw">private class="kw">static class="kw">final StringTag TAG_FAILED = StringTag.of("Failed");
class="kw">protected String defaultInteractions;
@Nullable
class="kw">protected String replaceInteractions;
@Nullable
class="kw">protected String retypeInteractions;
@Nullable
class="kw">protected String extrudeInteractions;
@Nullable
class="kw">protected String surfaceDrawInteractions;
@Nullable
class="kw">protected String fastPlaceInteractions;
class="kw">public PlaceModeSelectInteraction() {
}
@Nonnull
@Override
class="kw">public WaitForDataFrom getWaitForDataFrom() {
class="kw">return WaitForDataFrom.None;
}
@Override
class="kw">protected void tick0(boolean var1, float var2, @Nonnull InteractionType var3, @Nonnull InteractionContext var4, @Nonnull CooldownHandler var5) {
int var6 = this.resolveModeIndex(var4);
var4.jump(var4.getLabel(var6));
var4.getState().nextLabel = var6;
var4.getState().state = InteractionState.Finished;
}
@Override
class="kw">protected void simulateTick0(boolean var1, float var2, @Nonnull InteractionType var3, @Nonnull InteractionContext var4, @Nonnull CooldownHandler var5) {
this.tick0(var1, var2, var3, var4, var5);
}
@Override
class="kw">public void compile(@Nonnull OperationsBuilder var1) {
Label[] var2 = new Label[6];
var1.addOperation(this, var2);
Label var3 = var1.createUnresolvedLabel();
var2[0] = var1.createLabel();
Interaction.getInteractionOrUnknown(this.defaultInteractions).compile(var1);
var1.jump(var3);
compileBranch(var1, var2, 1, this.replaceInteractions, var3);
compileBranch(var1, var2, 2, this.retypeInteractions, var3);
compileBranch(var1, var2, 3, this.extrudeInteractions, var3);
compileBranch(var1, var2, 4, this.surfaceDrawInteractions, var3);
compileBranch(var1, var2, 5, this.fastPlaceInteractions, var3);
var1.resolveLabel(var3);
if (this.next != null) {
Interaction.getInteractionOrUnknown(this.next).compile(var1);
}
}
class="kw">private class="kw">static void compileBranch(@Nonnull OperationsBuilder var0, @Nonnull Label[] var1, int var2, @Nullable String var3, @Nonnull Label var4) {
if (var3 == null) {
var1[var2] = var1[0];
} else {
var1[var2] = var0.createLabel();
Interaction.getInteractionOrUnknown(var3).compile(var0);
var0.jump(var4);
}
}
class="kw">private int resolveModeIndex(@Nonnull InteractionContext var1) {
CommandBuffer var2 = var1.getCommandBuffer();
Ref var3 = var1.getEntity();
if (var2 != null && var3 != null) {
Player var4 = var2.getComponent(var3, Player.getComponentType());
if (var4 != null && var4.getGameMode() == GameMode.Creative) {
PlayerSettings var5 = var2.getComponent(var3, PlayerSettings.getComponentType());
if (var5 == null) {
class="kw">return 0;
}
class="kw">return class="kw">switch (var5.creativeSettings().placeMode()) {
case Replace -> this.replaceInteractions != null ? 1 : 0;
case Retype -> this.retypeInteractions != null ? 2 : 0;
case Extrude -> this.extrudeInteractions != null ? 3 : 0;
case SurfaceDraw -> this.surfaceDrawInteractions != null ? 4 : 0;
case FastPlace -> this.fastPlaceInteractions != null ? 5 : 0;
case Default -> 0;
};
} else {
class="kw">return 0;
}
} else {
class="kw">return 0;
}
}
@Override
class="kw">public boolean walk(@Nonnull Collector var1, @Nonnull InteractionContext var2) {
if (InteractionManager.walkInteraction(var1, var2, TAG_DEFAULT, this.defaultInteractions)) {
class="kw">return true;
} else if (this.replaceInteractions != null && InteractionManager.walkInteraction(var1, var2, TAG_REPLACE, this.replaceInteractions)) {
class="kw">return true;
} else if (this.retypeInteractions != null && InteractionManager.walkInteraction(var1, var2, TAG_RETYPE, this.retypeInteractions)) {
class="kw">return true;
} else if (this.extrudeInteractions != null && InteractionManager.walkInteraction(var1, var2, TAG_EXTRUDE, this.extrudeInteractions)) {
class="kw">return true;
} else if (this.surfaceDrawInteractions != null && InteractionManager.walkInteraction(var1, var2, TAG_SURFACE_DRAW, this.surfaceDrawInteractions)) {
class="kw">return true;
} else if (this.fastPlaceInteractions != null && InteractionManager.walkInteraction(var1, var2, TAG_FAST_PLACE, this.fastPlaceInteractions)) {
class="kw">return true;
} else {
class="kw">return this.next != null && InteractionManager.walkInteraction(var1, var2, TAG_NEXT, this.next)
? true
: this.failed != null && InteractionManager.walkInteraction(var1, var2, TAG_FAILED, this.failed);
}
}
@Override
class="kw">public boolean needsRemoteSync() {
class="kw">return true;
}
@Nonnull
@Override
class="kw">protected com.hypixel.hytale.protocol.Interaction generatePacket() {
class="kw">return new com.hypixel.hytale.protocol.PlaceModeSelectInteraction();
}
@Override
class="kw">protected void configurePacket(com.hypixel.hytale.protocol.Interaction var1) {
super.configurePacket(var1);
com.hypixel.hytale.protocol.PlaceModeSelectInteraction var2 = (com.hypixel.hytale.protocol.PlaceModeSelectInteraction)var1;
var2.defaultInteractions = Interaction.getInteractionIdOrUnknown(this.defaultInteractions);
var2.replaceInteractions = Interaction.getInteractionIdOrUnknown(this.replaceInteractions);
var2.retypeInteractions = Interaction.getInteractionIdOrUnknown(this.retypeInteractions);
var2.extrudeInteractions = Interaction.getInteractionIdOrUnknown(this.extrudeInteractions);
var2.surfaceDrawInteractions = Interaction.getInteractionIdOrUnknown(this.surfaceDrawInteractions);
var2.fastPlaceInteractions = Interaction.getInteractionIdOrUnknown(this.fastPlaceInteractions);
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "PlaceModeSelectInteraction{defaultInteractions='"
+ this.defaultInteractions
+ "', replaceInteractions='"
+ this.replaceInteractions
+ "', retypeInteractions='"
+ this.retypeInteractions
+ "', extrudeInteractions='"
+ this.extrudeInteractions
+ "', surfaceDrawInteractions='"
+ this.surfaceDrawInteractions
+ "', fastPlaceInteractions='"
+ this.fastPlaceInteractions
+ "'} "
+ super.toString();
}
}