ProjectileModule class
Пакет: com.hypixel.hytale.server.core.modules.projectile
Файл: com/hypixel/hytale/server/core/modules/projectile/ProjectileModule.java
extends: JavaPlugin
Поля (16)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
instance |
|
ComponentRegistryProxy |
var1 |
|
Direction |
var10 |
|
Vector3d |
var11 |
|
Model |
var12 |
|
int |
var13 |
|
int |
var14 |
|
AudioComponent |
var15 |
|
Ref |
var16 |
|
InteractionManager |
var3 |
|
InteractionContext |
var4 |
|
String |
var5 |
|
RootInteraction |
var6 |
|
InteractionChain |
var7 |
|
Holder |
var8 |
|
Rotation3f |
var9 |
Методы (12)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
UnsupportedOperationExceptionthrow new UnsupportedOperationException() |
static |
ProjectileModule |
getProjectileModule get() |
|
|
if if(var1 != null) |
|
|
if if(var1 != null) |
|
|
if if(var13 != 0) |
|
|
if if(var14 != 0) |
|
|
if if(var1 == null && var3 != null) |
|
|
if if(var3 != null) |
|
|
if if(var5 != null) |
|
|
if if(var6 != null) |
static |
void |
onProjectileSpawnInteractionvoid onProjectileSpawnInteraction(@Nonnull Ref<EntityStore> var0, @Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2) |
abstract |
|
super super(var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.projectile;
class="kw">import com.hypixel.hytale.common.plugin.PluginManifest;
class="kw">import com.hypixel.hytale.component.AddReason;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.ComponentRegistryProxy;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.protocol.Direction;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.Model;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionChain;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionContext;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionManager;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.modules.collision.CollisionModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.DespawnComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.EntityModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.AudioComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.BoundingBox;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.PersistentModel;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.tracker.NetworkId;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.InteractionModule;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.Interactions;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Interaction;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.RootInteraction;
class="kw">import com.hypixel.hytale.server.core.modules.physics.component.Velocity;
class="kw">import com.hypixel.hytale.server.core.modules.physics.util.PhysicsMath;
class="kw">import com.hypixel.hytale.server.core.modules.projectile.component.PredictedProjectile;
class="kw">import com.hypixel.hytale.server.core.modules.projectile.component.Projectile;
class="kw">import com.hypixel.hytale.server.core.modules.projectile.config.PhysicsConfig;
class="kw">import com.hypixel.hytale.server.core.modules.projectile.config.ProjectileConfig;
class="kw">import com.hypixel.hytale.server.core.modules.projectile.config.StandardPhysicsConfig;
class="kw">import com.hypixel.hytale.server.core.modules.projectile.config.StandardPhysicsProvider;
class="kw">import com.hypixel.hytale.server.core.modules.projectile.interaction.ProjectileInteraction;
class="kw">import com.hypixel.hytale.server.core.modules.projectile.system.PredictedProjectileSystems;
class="kw">import com.hypixel.hytale.server.core.modules.projectile.system.StandardPhysicsTickSystem;
class="kw">import com.hypixel.hytale.server.core.modules.time.TimeResource;
class="kw">import com.hypixel.hytale.server.core.plugin.JavaPlugin;
class="kw">import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
class="kw">import com.hypixel.hytale.server.core.universe.world.SoundUtil;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.time.Duration;
class="kw">import java.util.UUID;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">public class ProjectileModule class="kw">extends JavaPlugin {
@Nonnull
class="kw">public class="kw">static class="kw">final PluginManifest MANIFEST = PluginManifest.corePlugin(ProjectileModule.class)
.description(
"This module class="kw">implements the new projectile system. Disabling this module will prevent anything using the new projectile system from functioning."
)
.depends(CollisionModule.class)
.depends(EntityModule.class)
.build();
@Nonnull
class="kw">private class="kw">static class="kw">final Duration DESPAWN_DELAY = Duration.ofMinutes(5L);
class="kw">private class="kw">static ProjectileModule instance;
class="kw">private ComponentType<EntityStore, Projectile> projectileComponentType;
class="kw">private ComponentType<EntityStore, StandardPhysicsProvider> standardPhysicsProviderComponentType;
class="kw">private ComponentType<EntityStore, PredictedProjectile> predictedProjectileComponentType;
class="kw">public class="kw">static ProjectileModule get() {
class="kw">return instance;
}
class="kw">public ProjectileModule(@Nonnull JavaPluginInit var1) {
super(var1);
instance = this;
}
@Override
class="kw">protected void setup() {
ComponentRegistryProxy var1 = this.getEntityStoreRegistry();
this.getCodecRegistry(Interaction.CODEC).register("Projectile", ProjectileInteraction.class, ProjectileInteraction.CODEC);
this.projectileComponentType = var1.registerComponent(Projectile.class, "IsProjectile", Projectile.CODEC);
this.predictedProjectileComponentType = var1.registerComponent(PredictedProjectile.class, () -> {
throw new UnsupportedOperationException();
});
this.standardPhysicsProviderComponentType = var1.registerComponent(StandardPhysicsProvider.class, () -> {
throw new UnsupportedOperationException();
});
var1.registerSystem(new StandardPhysicsTickSystem());
var1.registerSystem(new PredictedProjectileSystems.EntityTrackerUpdate());
this.getCodecRegistry(PhysicsConfig.CODEC).register("Standard", StandardPhysicsConfig.class, StandardPhysicsConfig.CODEC);
}
@Nonnull
class="kw">public Ref<EntityStore> spawnProjectile(
Ref<EntityStore> var1, @Nonnull CommandBuffer<EntityStore> var2, @Nonnull ProjectileConfig var3, @Nonnull Vector3d var4, @Nonnull Vector3d var5
) {
class="kw">return this.spawnProjectile(null, null, var1, var2, var3, var4, var5);
}
@Nonnull
class="kw">public Ref<EntityStore> spawnProjectile(
@Nullable UUID var1,
@Nullable Long var2,
Ref<EntityStore> var3,
@Nonnull CommandBuffer<EntityStore> var4,
@Nonnull ProjectileConfig var5,
@Nonnull Vector3d var6,
@Nonnull Vector3d var7
) {
Holder var8 = EntityStore.REGISTRY.newHolder();
Rotation3f var9 = new Rotation3f();
Direction var10 = var5.getSpawnRotationOffset();
var9.setYaw(PhysicsMath.normalizeTurnAngle(PhysicsMath.headingFromDirection(var7.x, var7.z)));
var9.setPitch(PhysicsMath.pitchFromDirection(var7.x, var7.y, var7.z));
var9.add(var10.pitch, var10.yaw, var10.roll);
PhysicsMath.vectorFromAngles(var9.yaw(), var9.pitch(), var7);
Vector3d var11 = var5.getCalculatedOffset(var9.pitch(), var9.yaw());
var6.add(var11);
var8.addComponent(TransformComponent.getComponentType(), new TransformComponent(var6, var9));
var8.addComponent(HeadRotation.getComponentType(), new HeadRotation(var9));
if (var1 != null) {
var8.addComponent(UUIDComponent.getComponentType(), new UUIDComponent(var1));
}
var8.addComponent(Interactions.getComponentType(), new Interactions(var5.getInteractions()));
Model var12 = var5.createSpawnModel(var2);
var8.addComponent(ModelComponent.getComponentType(), new ModelComponent(var12));
var8.addComponent(PersistentModel.getComponentType(), new PersistentModel(var12.toReference()));
var8.addComponent(BoundingBox.getComponentType(), new BoundingBox(var12.getBoundingBox()));
var8.addComponent(NetworkId.getComponentType(), new NetworkId(var4.getExternalData().takeNextNetworkId()));
var8.ensureComponent(Projectile.getComponentType());
if (var1 != null) {
var8.addComponent(PredictedProjectile.getComponentType(), new PredictedProjectile(var1));
}
var8.addComponent(Velocity.getComponentType(), new Velocity());
var5.getPhysicsConfig().apply(var8, var3, new Vector3d(var7).mul(var5.getLaunchForce()), var4, var1 != null);
var8.ensureComponent(EntityStore.REGISTRY.getNonSerializedComponentType());
var8.addComponent(
DespawnComponent.getComponentType(), new DespawnComponent(var4.getResource(TimeResource.getResourceType()).getNow().plus(DESPAWN_DELAY))
);
int var13 = var5.getLaunchWorldSoundEventIndex();
if (var13 != 0) {
SoundUtil.playSoundEvent3d(var13, SoundCategory.SFX, var6.x, var6.y, var6.z, var1x -> !var1x.equals(var3), var4);
}
int var14 = var5.getProjectileSoundEventIndex();
if (var14 != 0) {
AudioComponent var15 = new AudioComponent();
var15.addSound(var14);
var8.addComponent(AudioComponent.getComponentType(), var15);
}
Ref var16 = var4.addEntity(var8, AddReason.SPAWN);
if (var1 == null && var3 != null) {
var4.run(var2x -> onProjectileSpawnInteraction(var16, var3, var2x));
}
class="kw">return var16;
}
class="kw">private class="kw">static void onProjectileSpawnInteraction(@Nonnull Ref<EntityStore> var0, @Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2) {
InteractionManager var3 = var2.getComponent(var1, InteractionModule.get().getInteractionManagerComponent());
if (var3 != null) {
InteractionContext var4 = InteractionContext.forProxyEntity(var3, var1, var0, var2);
String var5 = var4.getRootInteractionId(InteractionType.ProjectileSpawn);
if (var5 != null) {
RootInteraction var6 = RootInteraction.getRootInteractionOrUnknown(var5);
if (var6 != null) {
InteractionChain var7 = var3.initChain(InteractionType.ProjectileSpawn, var4, var6, true);
var3.queueExecuteChain(var7);
}
}
}
}
@Nonnull
class="kw">public ComponentType<EntityStore, Projectile> getProjectileComponentType() {
class="kw">return this.projectileComponentType;
}
@Nonnull
class="kw">public ComponentType<EntityStore, StandardPhysicsProvider> getStandardPhysicsProviderComponentType() {
class="kw">return this.standardPhysicsProviderComponentType;
}
@Nonnull
class="kw">public ComponentType<EntityStore, PredictedProjectile> getPredictedProjectileComponentType() {
class="kw">return this.predictedProjectileComponentType;
}
}