WeatherTracker class
Пакет: com.hypixel.hytale.builtin.weather.components
Файл: com/hypixel/hytale/builtin/weather/components/WeatherTracker.java
implements: Component<EntityStore>
Поля (18)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
return |
|
|
return |
|
|
return |
final |
UpdateWeather |
updateWeather |
|
ChunkSection |
var10 |
|
Ref |
var11 |
|
EnvironmentChunk |
var12 |
|
int |
var13 |
|
|
var2 |
|
Vector3d |
var3 |
|
int |
var4 |
|
int |
var5 |
|
int |
var6 |
|
int |
var6 |
|
int |
var7 |
|
Ref |
var7 |
|
World |
var8 |
|
Store |
var9 |
Методы (17)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
public |
void |
clearvoid clear() |
public |
void |
clearOverrideWeatherIndexvoid clearOverrideWeatherIndex() |
public |
boolean |
consumeFirstSendForWorldboolean consumeFirstSendForWorld() |
static |
ComponentType<EntityStore, WeatherTracker> |
getComponentTypeComponentType<EntityStore, WeatherTracker> getComponentType() |
public |
int |
getEnvironmentIdint getEnvironmentId() |
public |
int |
getWeatherIndexint getWeatherIndex() |
|
|
if if(this.overrideWeatherIndex != 0) |
|
|
if if(var6 != 0) |
|
|
if if(var2 == Integer.MIN_VALUE) |
|
|
if if(this.updateWeather.weatherIndex != var2) |
|
|
if if(this.firstSendForWorld) |
|
|
if if(var10 == null) |
public |
void |
sendWeatherIndexvoid sendWeatherIndex(@Nonnull PlayerRef var1, int var2, float var3) |
public |
void |
setOverrideWeatherIndexvoid setOverrideWeatherIndex(int var1) |
public |
void |
setWeatherIndexvoid setWeatherIndex(@Nonnull PlayerRef var1, int var2) |
public |
void |
updateEnvironmentvoid updateEnvironment(@Nonnull TransformComponent var1, @Nonnull ComponentAccessor<EntityStore> var2) |
public |
void |
updateWeathervoid updateWeather(@Nonnull PlayerRef var1, @Nonnull WeatherResource var2, @Nonnull TransformComponent var3, float var4, @Nonnull ComponentAccessor<EntityStore> var5) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.weather.components;
class="kw">import com.hypixel.hytale.builtin.weather.WeatherPlugin;
class="kw">import com.hypixel.hytale.builtin.weather.resources.WeatherResource;
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.math.util.MathUtil;
class="kw">import com.hypixel.hytale.protocol.packets.world.UpdateWeather;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.environment.EnvironmentChunk;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.section.ChunkSection;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3i;
class="kw">public class WeatherTracker class="kw">implements Component<EntityStore> {
class="kw">private class="kw">final UpdateWeather updateWeather = new UpdateWeather(0, 10.0F);
class="kw">private class="kw">final Vector3i previousBlockPosition = new Vector3i();
class="kw">private int environmentId;
class="kw">private boolean firstSendForWorld = true;
class="kw">private int overrideWeatherIndex = 0;
class="kw">public class="kw">static ComponentType<EntityStore, WeatherTracker> getComponentType() {
class="kw">return WeatherPlugin.get().getWeatherTrackerComponentType();
}
class="kw">public WeatherTracker() {
}
class="kw">private WeatherTracker(@Nonnull WeatherTracker var1) {
this.environmentId = var1.environmentId;
this.updateWeather.weatherIndex = var1.updateWeather.weatherIndex;
this.previousBlockPosition.set(var1.previousBlockPosition);
this.overrideWeatherIndex = var1.overrideWeatherIndex;
}
class="kw">public void updateWeather(
@Nonnull PlayerRef var1, @Nonnull WeatherResource var2, @Nonnull TransformComponent var3, float var4, @Nonnull ComponentAccessor<EntityStore> var5
) {
if (this.overrideWeatherIndex != 0) {
this.sendWeatherIndex(var1, this.overrideWeatherIndex, var4);
} else {
int var6 = var2.getForcedWeatherIndex();
if (var6 != 0) {
this.sendWeatherIndex(var1, var6, var4);
} else {
this.updateEnvironment(var3, var5);
int var7 = var2.getWeatherIndexForEnvironment(this.environmentId);
this.sendWeatherIndex(var1, var7, var4);
}
}
}
class="kw">public void sendWeatherIndex(@Nonnull PlayerRef var1, int var2, float var3) {
if (var2 == Integer.MIN_VALUE) {
var2 = 0;
}
if (this.updateWeather.weatherIndex != var2) {
this.updateWeather.weatherIndex = var2;
this.updateWeather.transitionSeconds = var3;
var1.getPacketHandler().write(this.updateWeather);
}
}
class="kw">public boolean consumeFirstSendForWorld() {
if (this.firstSendForWorld) {
this.firstSendForWorld = false;
class="kw">return true;
} else {
class="kw">return false;
}
}
class="kw">public void clear() {
this.updateWeather.weatherIndex = 0;
this.firstSendForWorld = true;
this.overrideWeatherIndex = 0;
}
class="kw">public void setOverrideWeatherIndex(int var1) {
this.overrideWeatherIndex = var1;
}
class="kw">public void clearOverrideWeatherIndex() {
this.overrideWeatherIndex = 0;
}
class="kw">public void updateEnvironment(@Nonnull TransformComponent var1, @Nonnull ComponentAccessor<EntityStore> var2) {
Vector3d var3 = var1.getPosition();
int var4 = MathUtil.floor(var3.x());
int var5 = MathUtil.floor(var3.y());
int var6 = MathUtil.floor(var3.z());
if (this.previousBlockPosition.x() != var4 || this.previousBlockPosition.y() != var5 || this.previousBlockPosition.z() != var6) {
Ref var7 = var1.getSectionRef();
if (var7 == null || !var7.isValid()) {
class="kw">return;
}
World var8 = var2.getExternalData().getWorld();
Store var9 = var8.getChunkStore().getStore();
ChunkSection var10 = var9.getComponent(var7, ChunkSection.getComponentType());
if (var10 == null) {
class="kw">return;
}
Ref var11 = var10.getChunkColumnReference();
if (var11 == null || !var11.isValid()) {
class="kw">return;
}
EnvironmentChunk var12 = var9.getComponent(var11, EnvironmentChunk.getComponentType());
assert var12 != null;
int var13 = MathUtil.clamp(var5, 0, 319);
this.environmentId = var12.get(var4, var13, var6);
}
this.previousBlockPosition.x = var4;
this.previousBlockPosition.y = var5;
this.previousBlockPosition.z = var6;
}
class="kw">public int getEnvironmentId() {
class="kw">return this.environmentId;
}
class="kw">public int getWeatherIndex() {
class="kw">return this.updateWeather.weatherIndex;
}
class="kw">public void setWeatherIndex(@Nonnull PlayerRef var1, int var2) {
this.updateWeather.weatherIndex = var2;
var1.getPacketHandler().write(this.updateWeather);
}
@Nonnull
@Override
class="kw">public Component<EntityStore> clone() {
class="kw">return new WeatherTracker(this);
}
}