InvalidatablePersistentRef class
Пакет: com.hypixel.hytale.server.core.entity.reference
Файл: com/hypixel/hytale/server/core/entity/reference/InvalidatablePersistentRef.java
extends: PersistentRef
Поля (4)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<InvalidatablePersistentRef> |
CODEC |
|
PersistentRefCount |
var3 |
|
|
var3 |
|
PersistentRefCount |
var3 |
Методы (3)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
public |
int |
getRefCountint getRefCount() |
|
|
if if(var3 == null) |
public |
void |
setRefCountvoid setRefCount(int var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.entity.reference;
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.Ref;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">public class InvalidatablePersistentRef class="kw">extends PersistentRef {
class="kw">public class="kw">static class="kw">final BuilderCodec<InvalidatablePersistentRef> CODEC = BuilderCodec.builder(
InvalidatablePersistentRef.class, InvalidatablePersistentRef::new, PersistentRef.CODEC
)
.append(new KeyedCodec<>("RefCount", Codec.INTEGER), (var0, var1) -> var0.refCount = var1, var0 -> var0.refCount)
.add()
.build();
class="kw">protected int refCount;
class="kw">public InvalidatablePersistentRef() {
}
@Override
class="kw">public void setEntity(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
super.setEntity(var1, var2);
PersistentRefCount var3 = var2.getComponent(var1, PersistentRefCount.getComponentType());
if (var3 == null) {
var3 = new PersistentRefCount();
var2.addComponent(var1, PersistentRefCount.getComponentType(), var3);
}
this.refCount = var3.get();
}
@Override
class="kw">public void clear() {
super.clear();
this.refCount = -1;
}
class="kw">public void setRefCount(int var1) {
this.refCount = var1;
}
class="kw">public int getRefCount() {
class="kw">return this.refCount;
}
@Override
class="kw">protected boolean validateEntityReference(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
PersistentRefCount var3 = var2.getComponent(var1, PersistentRefCount.getComponentType());
class="kw">return super.validateEntityReference(var1, var2) && var3 != null && var3.get() == this.refCount;
}
}