OnAddRemove class
Пакет: com.hypixel.hytale.server.core.modules.interaction.blocktrack
Файл: com/hypixel/hytale/server/core/modules/interaction/blocktrack/TrackedPlacement.java
extends: RefSystem<ChunkStore>
Поля (12)
| Модификаторы | Тип | Имя |
|---|---|---|
|
private static final ResourceType<ChunkStore, BlockCounter> |
BLOCK_COUNTER_RESOURCE_TYPE |
|
private static final ComponentType<ChunkStore, TrackedPlacement> |
COMPONENT_TYPE |
|
BlockCounter |
var10 |
|
String |
var11 |
|
TrackedPlacement |
var12 |
|
BlockModule.BlockStateInfo |
var5 |
|
TrackedPlacement |
var5 |
|
Ref |
var6 |
|
BlockCounter |
var6 |
|
BlockSection |
var7 |
|
int |
var8 |
|
BlockType |
var9 |
Методы (6)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
public Query<ChunkStore> |
getQuerypublic Query<ChunkStore> getQuery() |
|
|
if if(var2 == AddReason.SPAWN) |
|
|
if if(var9 != null) |
|
|
if if(var2 == RemoveReason.REMOVE) |
|
public void |
onEntityAddedpublic void onEntityAdded(@Nonnull Ref<ChunkStore> var1, @Nonnull AddReason var2, @Nonnull Store<ChunkStore> var3, @Nonnull CommandBuffer<ChunkStore> var4) |
|
public void |
onEntityRemovepublic void onEntityRemove(@Nonnull Ref<ChunkStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<ChunkStore> var3, @Nonnull CommandBuffer<ChunkStore> var4) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.interaction.blocktrack;
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.AddReason;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Component;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.RemoveReason;
class="kw">import com.hypixel.hytale.component.ResourceType;
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.RefSystem;
class="kw">import com.hypixel.hytale.math.util.ChunkUtil;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.modules.block.BlockModule;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.InteractionModule;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class TrackedPlacement class="kw">implements Component<ChunkStore> {
class="kw">public class="kw">static class="kw">final BuilderCodec<TrackedPlacement> CODEC = BuilderCodec.builder(TrackedPlacement.class, TrackedPlacement::new)
.append(new KeyedCodec<>("BlockName", Codec.STRING), (var0, var1) -> var0.blockName = var1, var0 -> var0.blockName)
.add()
.build();
class="kw">private String blockName;
class="kw">public class="kw">static ComponentType<ChunkStore, TrackedPlacement> getComponentType() {
class="kw">return InteractionModule.get().getTrackedPlacementComponentType();
}
class="kw">public TrackedPlacement() {
}
class="kw">public TrackedPlacement(String var1) {
this.blockName = var1;
}
@Nullable
@Override
class="kw">public Component<ChunkStore> clone() {
class="kw">return new TrackedPlacement(this.blockName);
}
class="kw">public class="kw">static class OnAddRemove class="kw">extends RefSystem<ChunkStore> {
class="kw">private class="kw">static class="kw">final ComponentType<ChunkStore, TrackedPlacement> COMPONENT_TYPE = TrackedPlacement.getComponentType();
class="kw">private class="kw">static class="kw">final ResourceType<ChunkStore, BlockCounter> BLOCK_COUNTER_RESOURCE_TYPE = BlockCounter.getResourceType();
class="kw">public OnAddRemove() {
}
@Override
class="kw">public void onEntityAdded(
@Nonnull Ref<ChunkStore> var1, @Nonnull AddReason var2, @Nonnull Store<ChunkStore> var3, @Nonnull CommandBuffer<ChunkStore> var4
) {
if (var2 == AddReason.SPAWN) {
BlockModule.BlockStateInfo var5 = var4.getComponent(var1, BlockModule.BlockStateInfo.getComponentType());
assert var5 != null;
Ref var6 = var5.getSectionRef();
if (var6 != null && var6.isValid()) {
BlockSection var7 = var4.getComponent(var6, BlockSection.getComponentType());
assert var7 != null;
int var8 = var7.get(ChunkUtil.xFromIndex(var5.getIndex()), ChunkUtil.yFromIndex(var5.getIndex()), ChunkUtil.zFromIndex(var5.getIndex()));
BlockType var9 = BlockType.getAssetMap().getAsset(var8);
if (var9 != null) {
BlockCounter var10 = var4.getResource(BLOCK_COUNTER_RESOURCE_TYPE);
String var11 = var9.getId();
var10.trackBlock(var11);
TrackedPlacement var12 = var4.getComponent(var1, COMPONENT_TYPE);
assert var12 != null;
var12.blockName = var11;
}
}
}
}
@Override
class="kw">public void onEntityRemove(
@Nonnull Ref<ChunkStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<ChunkStore> var3, @Nonnull CommandBuffer<ChunkStore> var4
) {
if (var2 == RemoveReason.REMOVE) {
TrackedPlacement var5 = var4.getComponent(var1, COMPONENT_TYPE);
assert var5 != null;
BlockCounter var6 = var4.getResource(BLOCK_COUNTER_RESOURCE_TYPE);
var6.untrackBlock(var5.blockName);
}
}
@Nullable
@Override
class="kw">public Query<ChunkStore> getQuery() {
class="kw">return COMPONENT_TYPE;
}
}
}