ChangeActiveSlotInteraction class
Пакет: com.hypixel.hytale.server.core.modules.interaction.interaction.config.none
Файл: com/hypixel/hytale/server/core/modules/interaction/interaction/config/none/ChangeActiveSlotInteraction.java
extends: Interaction
Поля (13)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
return |
|
byte |
var10 |
|
|
var10 |
|
|
var10 |
|
Runnable |
var11 |
|
InteractionManager |
var12 |
|
InteractionContext |
var13 |
|
String |
var14 |
|
com.hypixel.hytale.protocol.ChangeActiveSlotInteraction |
var2 |
|
CommandBuffer |
var6 |
|
Ref |
var7 |
|
InventoryComponent.Hotbar |
var8 |
|
DynamicMetaStore |
var9 |
Методы (7)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(!var1) |
|
|
if if(var8 != null) |
|
|
if if(this.targetSlot == Integer.MIN_VALUE) |
|
|
if if(var11 != null) |
|
|
if if(var14 != null) |
|
|
if if(this.targetSlot != Integer.MIN_VALUE) |
abstract |
|
super super(var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.interaction.interaction.config.none;
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.protocol.InteractionCooldown;
class="kw">import com.hypixel.hytale.protocol.InteractionItemChangeBehavior;
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.inventory.InventoryComponent;
class="kw">import com.hypixel.hytale.server.core.meta.DynamicMetaStore;
class="kw">import com.hypixel.hytale.server.core.meta.MetaKey;
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.RootInteraction;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.data.Collector;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">public class ChangeActiveSlotInteraction class="kw">extends Interaction {
@Nonnull
class="kw">public class="kw">static class="kw">final ChangeActiveSlotInteraction DEFAULT_INTERACTION = new ChangeActiveSlotInteraction("*Change_Active_Slot");
@Nonnull
class="kw">public class="kw">static class="kw">final RootInteraction DEFAULT_ROOT = new RootInteraction(
"*Default_Swap",
new InteractionCooldown("ChangeActiveSlot", 0.0F, false, InteractionManager.DEFAULT_CHARGE_TIMES, true, false),
DEFAULT_INTERACTION.getId()
);
@Deprecated
class="kw">public class="kw">static class="kw">final MetaKey<Runnable> PLACE_MOVED_ITEM = CONTEXT_META_REGISTRY.registerMetaObject(var0 -> null);
class="kw">private class="kw">static class="kw">final int UNSET_INT = Integer.MIN_VALUE;
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<ChangeActiveSlotInteraction> CODEC = BuilderCodec.<Interaction>builder(
ChangeActiveSlotInteraction.class, ChangeActiveSlotInteraction::new, Interaction.ABSTRACT_CODEC
)
.documentation("Changes the active hotbar slot for the user of the interaction.")
.<Integer>appendInherited(
new KeyedCodec<>("TargetSlot", Codec.INTEGER),
(var0, var1) -> var0.targetSlot = var1 == null ? Integer.MIN_VALUE : var1,
var0 -> var0.targetSlot == Integer.MIN_VALUE ? null : var0.targetSlot,
(var0, var1) -> var0.targetSlot = var1.targetSlot
)
.addValidator(Validators.range(0, 8))
.add()
.afterDecode(var0 -> var0.onItemChangeBehavior = InteractionItemChangeBehavior.Ignore)
.build();
class="kw">protected int targetSlot = Integer.MIN_VALUE;
class="kw">public ChangeActiveSlotInteraction() {
}
class="kw">private ChangeActiveSlotInteraction(@Nonnull String var1) {
super(var1);
this.onItemChangeBehavior = InteractionItemChangeBehavior.Ignore;
}
@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) {
if (!var1) {
var4.getState().state = InteractionState.Finished;
} else {
CommandBuffer var6 = var4.getCommandBuffer();
assert var6 != null;
Ref var7 = var4.getEntity();
InventoryComponent.Hotbar var8 = var6.getComponent(var7, InventoryComponent.Hotbar.getComponentType());
if (var8 != null) {
DynamicMetaStore var9 = var4.getMetaStore();
byte var10;
if (this.targetSlot == Integer.MIN_VALUE) {
var10 = var9.getMetaObject(TARGET_SLOT).byteValue();
} else {
if (var8.getActiveSlot() == this.targetSlot) {
var4.getState().state = InteractionState.Finished;
class="kw">return;
}
var10 = (byte)this.targetSlot;
var9.putMetaObject(TARGET_SLOT, Integer.valueOf(var10));
}
var8.setActiveSlot(var10, var7, var6);
Runnable var11 = var9.removeMetaObject(PLACE_MOVED_ITEM);
if (var11 != null) {
var11.run();
}
InteractionManager var12 = var4.getInteractionManager();
assert var12 != null;
InteractionContext var13 = InteractionContext.forInteraction(var12, var7, InteractionType.SwapTo, var6);
String var14 = var13.getRootInteractionId(InteractionType.SwapTo);
if (var14 != null) {
if (this.targetSlot != Integer.MIN_VALUE) {
var13.getMetaStore().putMetaObject(TARGET_SLOT, Integer.valueOf(var10));
}
var4.fork(InteractionType.SwapTo, var13, RootInteraction.getRootInteractionOrUnknown(var14), var11 == null);
}
var4.getState().state = InteractionState.Finished;
}
}
}
@Override
class="kw">protected void simulateTick0(boolean var1, float var2, @Nonnull InteractionType var3, @Nonnull InteractionContext var4, @Nonnull CooldownHandler var5) {
var4.getState().state = var4.getServerState().state;
}
@Override
class="kw">public boolean walk(@Nonnull Collector var1, @Nonnull InteractionContext var2) {
class="kw">return false;
}
@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.ChangeActiveSlotInteraction();
}
@Override
class="kw">protected void configurePacket(com.hypixel.hytale.protocol.Interaction var1) {
super.configurePacket(var1);
com.hypixel.hytale.protocol.ChangeActiveSlotInteraction var2 = (com.hypixel.hytale.protocol.ChangeActiveSlotInteraction)var1;
var2.targetSlot = this.targetSlot;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "ChangeActiveSlotInteraction{targetSlot=" + this.targetSlot + "} " + super.toString();
}
}