BlockReservation class
Пакет: com.hypixel.hytale.server.npc.blackboard.view.resource
Файл: com/hypixel/hytale/server/npc/blackboard/view/resource/ResourceView.java
Поля (2)
| Модификаторы | Тип | Имя |
|---|---|---|
|
private final int |
blockIndex |
|
private final int |
sectionIndex |
Методы (2)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
public int |
getBlockIndexpublic int getBlockIndex() |
|
public int |
getSectionIndexpublic int getSectionIndex() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.blackboard.view.resource;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.blackboard.BlackboardSubscription;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.BlockRegionView;
class="kw">import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
class="kw">import it.unimi.dsi.fastutil.ints.IntSet;
class="kw">import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
class="kw">import java.util.Map;
class="kw">import javax.annotation.Nonnull;
class="kw">public class ResourceView class="kw">extends BlockRegionView<ResourceView> {
class="kw">private class="kw">final long index;
class="kw">private class="kw">final IntSet[] reservationsBySection = new IntSet[10];
class="kw">private class="kw">final Map<Ref<EntityStore>, ResourceView.BlockReservation> reservationsByEntity = new Reference2ObjectOpenHashMap();
class="kw">public ResourceView(long var1) {
this.index = var1;
}
@Override
class="kw">public boolean isOutdated(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2) {
class="kw">return false;
}
@Nonnull
class="kw">public ResourceView getUpdatedView(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
class="kw">return this;
}
@Override
class="kw">public void initialiseEntity(@Nonnull Ref<EntityStore> var1, @Nonnull BlackboardSubscription var2) {
}
@Override
class="kw">public void cleanup() {
}
@Override
class="kw">public void onWorldRemoved() {
}
class="kw">public boolean isBlockReserved(int var1, int var2, int var3) {
IntSet var4 = this.reservationsBySection[indexSection(var2)];
class="kw">return var4 == null ? false : var4.contains(indexBlock(var1, var2, var3));
}
class="kw">public void reserveBlock(@Nonnull Ref<EntityStore> var1, int var2, int var3, int var4) {
int var5 = indexSection(var3);
IntSet var6 = this.reservationsBySection[var5];
if (var6 == null) {
var6 = new IntOpenHashSet();
this.reservationsBySection[var5] = var6;
}
int var7 = indexBlock(var2, var3, var4);
var6.add(var7);
this.reservationsByEntity.put(var1, new ResourceView.BlockReservation(var5, var7));
}
class="kw">public void clearReservation(@Nonnull Ref<EntityStore> var1) {
ResourceView.BlockReservation var2 = this.reservationsByEntity.remove(var1);
if (var2 != null) {
IntSet var3 = this.reservationsBySection[var2.getSectionIndex()];
var3.remove(var2.getBlockIndex());
}
}
class="kw">public long getIndex() {
class="kw">return this.index;
}
@Nonnull
class="kw">public Map<Ref<EntityStore>, ResourceView.BlockReservation> getReservationsByEntity() {
class="kw">return this.reservationsByEntity;
}
class="kw">public class="kw">static class BlockReservation {
class="kw">private class="kw">final int sectionIndex;
class="kw">private class="kw">final int blockIndex;
class="kw">public BlockReservation(int var1, int var2) {
this.sectionIndex = var1;
this.blockIndex = var2;
}
class="kw">public int getSectionIndex() {
class="kw">return this.sectionIndex;
}
class="kw">public int getBlockIndex() {
class="kw">return this.blockIndex;
}
}
}