PlayerLives class
Пакет: com.hypixel.hytale.server.core.modules.entity.component
Файл: com/hypixel/hytale/server/core/modules/entity/component/PlayerLives.java
implements: Component<EntityStore>
Поля (3)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<PlayerLives> |
CODEC |
|
PlayerLives |
var3 |
|
PlayerLives |
var6 |
Методы (8)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
public |
CancelRespawnWhenExhaustedpublic CancelRespawnWhenExhausted() |
static |
ComponentType<EntityStore, PlayerLives> |
getComponentTypeComponentType<EntityStore, PlayerLives> getComponentType() |
|
public Query<EntityStore> |
getQuerypublic Query<EntityStore> getQuery() |
public |
int |
getRemainingint getRemaining() |
static |
int |
getRemainingOrDefaultint getRemainingOrDefault(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1, int var2) |
|
public void |
handlepublic void handle(int var1,
@Nonnull ArchetypeChunk<EntityStore> var2,
@Nonnull Store<EntityStore> var3,
@Nonnull CommandBuffer<EntityStore> var4,
@Nonnull RespawnEvent var5) |
static |
void |
markExhaustedvoid markExhausted(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) |
abstract |
|
super super(RespawnEvent.class) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.entity.component;
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.ArchetypeChunk;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Component;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.component.query.Query;
class="kw">import com.hypixel.hytale.component.system.EntityEventSystem;
class="kw">import com.hypixel.hytale.server.core.event.events.ecs.RespawnEvent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">public class PlayerLives class="kw">implements Component<EntityStore> {
class="kw">public class="kw">static class="kw">final BuilderCodec<PlayerLives> CODEC = BuilderCodec.builder(PlayerLives.class, PlayerLives::new)
.append(new KeyedCodec<>("Remaining", Codec.INTEGER), (var0, var1) -> var0.remaining = var1, var0 -> var0.remaining)
.add()
.build();
class="kw">private class="kw">volatile int remaining;
class="kw">public class="kw">static ComponentType<EntityStore, PlayerLives> getComponentType() {
class="kw">return EntityModule.get().getPlayerLivesComponentType();
}
class="kw">public class="kw">static int getRemainingOrDefault(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1, int var2) {
PlayerLives var3 = var1.getComponent(var0, getComponentType());
class="kw">return var3 != null ? var3.getRemaining() : var2;
}
class="kw">public class="kw">static void markExhausted(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) {
var1.putComponent(var0, getComponentType(), new PlayerLives(0));
}
class="kw">private PlayerLives() {
}
class="kw">public PlayerLives(int var1) {
this.remaining = var1;
}
class="kw">public int getRemaining() {
class="kw">return this.remaining;
}
@Nonnull
@Override
class="kw">public Component<EntityStore> clone() {
class="kw">return new PlayerLives(this.remaining);
}
class="kw">public class="kw">static class CancelRespawnWhenExhausted class="kw">extends EntityEventSystem<EntityStore, RespawnEvent> {
class="kw">public CancelRespawnWhenExhausted() {
super(RespawnEvent.class);
}
class="kw">public void handle(
int var1,
@Nonnull ArchetypeChunk<EntityStore> var2,
@Nonnull Store<EntityStore> var3,
@Nonnull CommandBuffer<EntityStore> var4,
@Nonnull RespawnEvent var5
) {
PlayerLives var6 = var2.getComponent(var1, PlayerLives.getComponentType());
assert var6 != null;
if (var6.getRemaining() <= 0) {
var5.setCancelled(true);
}
}
@Nonnull
@Override
class="kw">public Query<EntityStore> getQuery() {
class="kw">return PlayerLives.getComponentType();
}
}
}