ActiveSlotInventoryComponent class
Пакет: com.hypixel.hytale.server.core.inventory
Файл: com/hypixel/hytale/server/core/inventory/ActiveSlotInventoryComponent.java
extends: InventoryComponent
Поля (2)
| Модификаторы | Тип | Имя |
|---|---|---|
|
byte |
var4 |
|
byte |
var4 |
Методы (8)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
protected |
void |
clampActiveSlotvoid clampActiveSlot() |
public |
byte |
getActiveSlotbyte getActiveSlot() |
abstract abstract |
int |
getSectionIdint getSectionId() |
|
|
if if(this.activeSlot != var1) |
|
|
if if(this.activeSlot != var1) |
public |
void |
setActiveSlotvoid setActiveSlot(byte var1, @Nonnull Ref<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3) |
public |
void |
setActiveSlotvoid setActiveSlot(byte var1, @Nonnull Holder<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3) |
abstract |
|
super super(var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.inventory;
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.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.server.core.event.events.ecs.InventorySetActiveSlotEvent;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.List;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class="kw">abstract class ActiveSlotInventoryComponent class="kw">extends InventoryComponent {
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<ActiveSlotInventoryComponent> CODEC = BuilderCodec.abstractBuilder(
ActiveSlotInventoryComponent.class, InventoryComponent.CODEC
)
.append(new KeyedCodec<>("ActiveSlot", Codec.BYTE), (var0, var1) -> var0.activeSlot = var1, var0 -> var0.activeSlot)
.add()
.afterDecode(ActiveSlotInventoryComponent::clampActiveSlot)
.build();
class="kw">protected byte activeSlot = -1;
class="kw">protected ActiveSlotInventoryComponent() {
}
class="kw">protected ActiveSlotInventoryComponent(short var1) {
super(var1);
this.clampActiveSlot();
}
class="kw">public class="kw">abstract int getSectionId();
class="kw">protected void clampActiveSlot() {
if (this.activeSlot >= this.inventory.getCapacity()) {
this.activeSlot = -1;
}
}
@Override
class="kw">public void ensureCapacity(short var1, @Nonnull List<ItemStack> var2) {
super.ensureCapacity(var1, var2);
this.clampActiveSlot();
}
class="kw">public byte getActiveSlot() {
class="kw">return this.activeSlot;
}
class="kw">public void setActiveSlot(byte var1, @Nonnull Ref<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3) {
if (this.activeSlot != var1) {
byte var4 = this.activeSlot;
this.activeSlot = var1;
var3.invoke(var2, new InventorySetActiveSlotEvent(this.getSectionId(), var4, var1));
}
}
class="kw">public void setActiveSlot(byte var1, @Nonnull Holder<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3) {
if (this.activeSlot != var1) {
byte var4 = this.activeSlot;
this.activeSlot = var1;
var3.invoke(var2, new InventorySetActiveSlotEvent(this.getSectionId(), var4, var1));
}
}
@Nullable
class="kw">public ItemStack getActiveItem() {
class="kw">return this.activeSlot != -1 && this.activeSlot < this.inventory.getCapacity() ? this.inventory.getItemStack(this.activeSlot) : null;
}
}