CameraShakeInteraction class
Пакет: com.hypixel.hytale.builtin.adventure.camera.interaction
Файл: com/hypixel/hytale/builtin/adventure/camera/interaction/CameraShakeInteraction.java
extends: SimpleInstantInteraction
Поля (4)
| Модификаторы | Тип | Имя |
|---|---|---|
|
Ref |
var4 |
|
CommandBuffer |
var5 |
|
PlayerRef |
var6 |
|
CameraEffect |
var7 |
Методы (4)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(var0.effectId != null) |
|
|
if if(this.effectIndex != Integer.MIN_VALUE) |
|
|
if if(var6 != null) |
|
|
if if(var7 != null) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.adventure.camera.interaction;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.server.core.asset.type.camera.CameraEffect;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInstantInteraction;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class CameraShakeInteraction class="kw">extends SimpleInstantInteraction {
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<CameraShakeInteraction> CODEC = BuilderCodec.builder(
CameraShakeInteraction.class, CameraShakeInteraction::new, SimpleInstantInteraction.CODEC
)
.documentation("Triggers a camera shake effect on use.")
.<String>appendInherited(
new KeyedCodec<>("CameraEffect", CameraEffect.CHILD_ASSET_CODEC),
(var0, var1) -> var0.effectId = var1,
var0 -> var0.effectId,
(var0, var1) -> var0.effectId = var1.effectId
)
.addValidator(Validators.nonNull())
.addValidator(CameraEffect.VALIDATOR_CACHE.getValidator())
.add()
.afterDecode(var0 -> {
if (var0.effectId != null) {
var0.effectIndex = CameraEffect.getAssetMap().getIndex(var0.effectId);
}
})
.build();
@Nullable
class="kw">protected String effectId;
class="kw">protected int effectIndex = Integer.MIN_VALUE;
class="kw">public CameraShakeInteraction() {
}
@Override
class="kw">protected void firstRun(@Nonnull InteractionType var1, @Nonnull InteractionContext var2, @Nonnull CooldownHandler var3) {
if (this.effectIndex != Integer.MIN_VALUE) {
Ref var4 = var2.getEntity();
CommandBuffer var5 = var2.getCommandBuffer();
assert var5 != null;
PlayerRef var6 = var5.getComponent(var4, PlayerRef.getComponentType());
if (var6 != null) {
CameraEffect var7 = CameraEffect.getAssetMap().getAsset(this.effectIndex);
if (var7 != null) {
var6.getPacketHandler().writeNoCache(var7.createCameraShakePacket());
}
}
}
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "CameraShakeInteraction{effectId='" + this.effectId + "', effectIndex=" + this.effectIndex + "}";
}
}