Ref class
Пакет: com.hypixel.hytale.component
Файл: com/hypixel/hytale/component/Ref.java
Поля (1)
| Модификаторы | Тип | Имя |
|---|---|---|
|
int |
var2 |
Методы (18)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
IllegalStateExceptionthrow new IllegalStateException("Invalid entity reference!", this.invalidatedBy) |
abstract |
throw new |
IllegalStateExceptionthrow new IllegalStateException("Incorrect store for entity reference") |
|
void |
beginMutationvoid beginMutation() |
|
void |
endMutationvoid endMutation() |
|
int |
getChunkEntityIndexint getChunkEntityIndex() |
public |
int |
getIndexint getIndex() |
|
int |
getSeqint getSeq() |
|
|
if if(var2 == Integer.MIN_VALUE) |
|
|
if if(this.index == Integer.MIN_VALUE) |
|
void |
invalidatevoid invalidate() |
|
void |
invalidatevoid invalidate(@Nullable Throwable var1) |
public |
boolean |
isValidboolean isValid() |
|
boolean |
isValidboolean isValid(@Nonnull Store<ECS_TYPE> var1) |
|
void |
setIndexvoid setIndex(int var1) |
|
void |
setPositionvoid setPosition(@Nonnull ArchetypeChunk<ECS_TYPE> var1, int var2) |
abstract |
|
this this(var1, Integer.MIN_VALUE) |
public |
int |
validateint validate(@Nonnull Store<ECS_TYPE> var1) |
public |
void |
validatevoid validate() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.component;
class="kw">import com.hypixel.hytale.common.util.DebugFlags;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class Ref<ECS_TYPE> {
class="kw">public class="kw">static class="kw">final Ref<?>[] EMPTY_ARRAY = new Ref[0];
@Nonnull
class="kw">private class="kw">final Store<ECS_TYPE> store;
class="kw">private class="kw">volatile int index;
@Nullable
class="kw">private ArchetypeChunk<ECS_TYPE> archetypeChunk;
class="kw">private int chunkEntityIndex;
class="kw">private class="kw">volatile int seq = 0;
class="kw">private class="kw">volatile Throwable invalidatedBy;
class="kw">public Ref(@Nonnull Store<ECS_TYPE> var1) {
this(var1, Integer.MIN_VALUE);
}
class="kw">public Ref(@Nonnull Store<ECS_TYPE> var1, int var2) {
this.store = var1;
this.index = var2;
}
@Nonnull
class="kw">public Store<ECS_TYPE> getStore() {
class="kw">return this.store;
}
class="kw">public int getIndex() {
class="kw">return this.index;
}
@Nullable
ArchetypeChunk<ECS_TYPE> getArchetypeChunk() {
class="kw">return this.archetypeChunk;
}
int getChunkEntityIndex() {
class="kw">return this.chunkEntityIndex;
}
void setIndex(int var1) {
this.index = var1;
}
void beginMutation() {
this.seq++;
}
void setPosition(@Nonnull ArchetypeChunk<ECS_TYPE> var1, int var2) {
this.archetypeChunk = var1;
this.chunkEntityIndex = var2;
}
void endMutation() {
this.seq++;
}
int getSeq() {
class="kw">return this.seq;
}
void invalidate() {
if ((this.seq & 1) == 0) {
this.seq++;
}
this.index = Integer.MIN_VALUE;
this.archetypeChunk = null;
this.chunkEntityIndex = Integer.MIN_VALUE;
this.seq++;
this.invalidatedBy = DebugFlags.CAPTURE_THROWABLES ? new Throwable() : null;
}
void invalidate(@Nullable Throwable var1) {
if ((this.seq & 1) == 0) {
this.seq++;
}
this.index = Integer.MIN_VALUE;
this.archetypeChunk = null;
this.chunkEntityIndex = Integer.MIN_VALUE;
this.seq++;
this.invalidatedBy = var1 != null ? var1 : (DebugFlags.CAPTURE_THROWABLES ? new Throwable() : null);
}
class="kw">public int validate(@Nonnull Store<ECS_TYPE> var1) {
int var2 = this.index;
if (var2 == Integer.MIN_VALUE) {
throw new IllegalStateException("Invalid entity reference!", this.invalidatedBy);
} else if (this.store != var1) {
throw new IllegalStateException("Incorrect store for entity reference");
} else {
class="kw">return var2;
}
}
class="kw">public void validate() {
if (this.index == Integer.MIN_VALUE) {
throw new IllegalStateException("Invalid entity reference!", this.invalidatedBy);
}
}
class="kw">public boolean isValid() {
class="kw">return this.index != Integer.MIN_VALUE;
}
boolean isValid(@Nonnull Store<ECS_TYPE> var1) {
class="kw">return this.index != Integer.MIN_VALUE && this.store == var1;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "Ref{store=" + this.store.getClass() + "@" + this.store.hashCode() + ", index=" + this.index + "}";
}
}