package com.hypixel.hytale.builtin.mounts;
import com.hypixel.hytale.builtin.mounts.minecart.MinecartComponent;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.Archetype;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.SystemGroup;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.dependency.Order;
import com.hypixel.hytale.component.dependency.OrderPriority;
import com.hypixel.hytale.component.dependency.RootDependency;
import com.hypixel.hytale.component.dependency.SystemDependency;
import com.hypixel.hytale.component.dependency.SystemGroupDependency;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.HolderSystem;
import com.hypixel.hytale.component.system.RefChangeSystem;
import com.hypixel.hytale.component.system.RefSystem;
import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.protocol.AnimationSlot;
import com.hypixel.hytale.protocol.BlockMount;
import com.hypixel.hytale.protocol.ComponentUpdate;
import com.hypixel.hytale.protocol.ComponentUpdateType;
import com.hypixel.hytale.protocol.GameMode;
import com.hypixel.hytale.protocol.MountController;
import com.hypixel.hytale.protocol.MountedUpdate;
import com.hypixel.hytale.protocol.MovementStates;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.mountpoints.BlockMountPoint;
import com.hypixel.hytale.server.core.entity.AnimationUtils;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.movement.MovementStatesComponent;
import com.hypixel.hytale.server.core.inventory.ItemStack;
import com.hypixel.hytale.server.core.modules.entity.component.Interactable;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.modules.entity.damage.Damage;
import com.hypixel.hytale.server.core.modules.entity.damage.DamageEventSystem;
import com.hypixel.hytale.server.core.modules.entity.damage.DamageModule;
import com.hypixel.hytale.server.core.modules.entity.damage.DeathComponent;
import com.hypixel.hytale.server.core.modules.entity.item.ItemComponent;
import com.hypixel.hytale.server.core.modules.entity.player.PlayerInput;
import com.hypixel.hytale.server.core.modules.entity.player.PlayerSystems;
import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport;
import com.hypixel.hytale.server.core.modules.entity.teleport.TeleportSystems;
import com.hypixel.hytale.server.core.modules.entity.tracker.EntityTrackerSystems;
import com.hypixel.hytale.server.core.modules.entity.tracker.NetworkId;
import com.hypixel.hytale.server.core.modules.time.TimeResource;
import com.hypixel.hytale.server.core.prefab.PrefabCopyableComponent;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class MountSystems {
public MountSystems() {
}
private static void handleMountedRemoval(Ref<EntityStore> ref, @Nonnull CommandBuffer<EntityStore> commandBuffer, @Nonnull MountedComponent component) {
Ref<EntityStore> mountedToEntity = component.getMountedToEntity();
if (mountedToEntity != null && mountedToEntity.isValid()) {
MountedByComponent mountedBy = (MountedByComponent)commandBuffer.getComponent(mountedToEntity, MountedByComponent.getComponentType());
if (mountedBy != null) {
mountedBy.removePassenger(ref);
}
}
Ref<ChunkStore> mountedToBlock = component.getMountedToBlock();
if (mountedToBlock != null && mountedToBlock.isValid()) {
Store<ChunkStore> chunkStore = mountedToBlock.getStore();
BlockMountComponent seatComponent = (BlockMountComponent)chunkStore.getComponent(mountedToBlock, BlockMountComponent.getComponentType());
if (seatComponent != null) {
seatComponent.removeSeatedEntity(ref);
if (seatComponent.isDead()) {
chunkStore.removeComponent(mountedToBlock, BlockMountComponent.getComponentType());
}
}
}
}
public static class TrackerUpdate extends EntityTickingSystem<EntityStore> {
private final ComponentType<EntityStore, EntityTrackerSystems.Visible> componentType = EntityTrackerSystems.Visible.getComponentType();
@Nonnull
private final Query<EntityStore> query;
public TrackerUpdate() {
this.query = Query.<EntityStore>and(this.componentType, MountedComponent.getComponentType());
}
@Nullable
public SystemGroup<EntityStore> getGroup() {
return EntityTrackerSystems.QUEUE_UPDATE_GROUP;
}
@Nonnull
public Query<EntityStore> getQuery() {
return this.query;
}
public boolean isParallel(int archetypeChunkSize, int taskCount) {
return EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount);
}
public void tick(float dt, int index, @Nonnull ArchetypeChunk<EntityStore> archetypeChunk, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
EntityTrackerSystems.Visible visible = (EntityTrackerSystems.Visible)archetypeChunk.getComponent(index, this.componentType);
MountedComponent mounted = (MountedComponent)archetypeChunk.getComponent(index, MountedComponent.getComponentType());
Ref<EntityStore> ref = archetypeChunk.getReferenceTo(index);
if (mounted.consumeNetworkOutdated()) {
queueUpdatesFor(ref, visible.visibleTo, mounted);
} else if (!visible.newlyVisibleTo.isEmpty()) {
queueUpdatesFor(ref, visible.newlyVisibleTo, mounted);
}
}
private static void queueUpdatesFor(@Nonnull Ref<EntityStore> ref, @Nonnull Map<Ref<EntityStore>, EntityTrackerSystems.EntityViewer> visibleTo, @Nonnull MountedComponent component) {
ComponentUpdate update = new ComponentUpdate();
update.type = ComponentUpdateType.Mounted;
Ref<EntityStore> mountedToEntity = component.getMountedToEntity();
Ref<ChunkStore> mountedToBlock = component.getMountedToBlock();
Vector3f offset = component.getAttachmentOffset();
com.hypixel.hytale.protocol.Vector3f netOffset = new com.hypixel.hytale.protocol.Vector3f(offset.x, offset.y, offset.z);
MountedUpdate mountedUpdate;
if (mountedToEntity != null) {
int mountedToNetworkId = ((NetworkId)ref.getStore().getComponent(mountedToEntity, NetworkId.getComponentType())).getId();
mountedUpdate = new MountedUpdate(mountedToNetworkId, netOffset, component.getControllerType(), (BlockMount)null);
} else {
if (mountedToBlock == null) {
throw new UnsupportedOperationException("Couldn't create MountedUpdate packet for MountedComponent");
}
BlockMountComponent blockMountComponent = (BlockMountComponent)mountedToBlock.getStore().getComponent(mountedToBlock, BlockMountComponent.getComponentType());
if (blockMountComponent == null) {
return;
}
BlockMountPoint occupiedSeat = blockMountComponent.getSeatBlockBySeatedEntity(ref);
if (occupiedSeat == null) {
return;
}
BlockType blockType = blockMountComponent.getExpectedBlockType();
Vector3f position = occupiedSeat.computeWorldSpacePosition(blockMountComponent.getBlockPos());
Vector3f rotationEuler = occupiedSeat.computeRotationEuler(blockMountComponent.getExpectedRotation());
BlockMount blockMount = new BlockMount(blockMountComponent.getType(), new com.hypixel.hytale.protocol.Vector3f(position.x, position.y, position.z), new com.hypixel.hytale.protocol.Vector3f(rotationEuler.x, rotationEuler.y, rotationEuler.z), BlockType.getAssetMap().getIndex(blockType.getId()));
mountedUpdate = new MountedUpdate(0, netOffset, component.getControllerType(), blockMount);
}
update.mounted = mountedUpdate;
for(EntityTrackerSystems.EntityViewer viewer : visibleTo.values()) {
viewer.queueUpdate(ref, update);
}
}
}
public static class TrackerRemove extends RefChangeSystem<EntityStore, MountedComponent> {
public TrackerRemove() {
}
public Query<EntityStore> getQuery() {
return EntityTrackerSystems.Visible.getComponentType();
}
@Nonnull
public ComponentType<EntityStore, MountedComponent> componentType() {
return MountedComponent.getComponentType();
}
public void onComponentAdded(@Nonnull Ref<EntityStore> ref, @Nonnull MountedComponent component, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
public void onComponentSet(@Nonnull Ref<EntityStore> ref, MountedComponent oldComponent, @Nonnull MountedComponent newComponent, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
public void onComponentRemoved(@Nonnull Ref<EntityStore> ref, @Nonnull MountedComponent component, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
if (component.getControllerType() == MountController.BlockMount) {
AnimationUtils.stopAnimation(ref, AnimationSlot.Movement, true, commandBuffer);
}
EntityTrackerSystems.Visible visibleComponent = (EntityTrackerSystems.Visible)store.getComponent(ref, EntityTrackerSystems.Visible.getComponentType());
assert visibleComponent != null;
for(EntityTrackerSystems.EntityViewer viewer : visibleComponent.visibleTo.values()) {
viewer.queueRemove(ref, ComponentUpdateType.Mounted);
}
}
}
public static class TrackedMounted extends RefChangeSystem<EntityStore, MountedComponent> {
public TrackedMounted() {
}
public Query<EntityStore> getQuery() {
return MountedComponent.getComponentType();
}
@Nonnull
public ComponentType<EntityStore, MountedComponent> componentType() {
return MountedComponent.getComponentType();
}
public void onComponentAdded(@Nonnull Ref<EntityStore> ref, @Nonnull MountedComponent component, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
Ref<EntityStore> target = component.getMountedToEntity();
if (target != null && target.isValid()) {
MountedByComponent mountedBy = (MountedByComponent)commandBuffer.ensureAndGetComponent(target, MountedByComponent.getComponentType());
mountedBy.addPassenger(ref);
}
}
public void onComponentSet(@Nonnull Ref<EntityStore> ref, MountedComponent oldComponent, @Nonnull MountedComponent newComponent, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
public void onComponentRemoved(@Nonnull Ref<EntityStore> ref, @Nonnull MountedComponent component, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
MountSystems.handleMountedRemoval(ref, commandBuffer, component);
}
}
public static class RemoveMounted extends RefSystem<EntityStore> {
public RemoveMounted() {
}
public void onEntityAdded(@Nonnull Ref<EntityStore> ref, @Nonnull AddReason reason, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
public void onEntityRemove(@Nonnull Ref<EntityStore> ref, @Nonnull RemoveReason reason, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
MountedComponent mounted = (MountedComponent)commandBuffer.getComponent(ref, MountedComponent.getComponentType());
commandBuffer.removeComponent(ref, MountedComponent.getComponentType());
MountSystems.handleMountedRemoval(ref, commandBuffer, mounted);
}
public Query<EntityStore> getQuery() {
return MountedComponent.getComponentType();
}
}
public static class PlayerMount extends RefChangeSystem<EntityStore, MountedComponent> {
private final Query<EntityStore> query = PlayerInput.getComponentType();
public PlayerMount() {
}
public Query<EntityStore> getQuery() {
return this.query;
}
@Nonnull
public ComponentType<EntityStore, MountedComponent> componentType() {
return MountedComponent.getComponentType();
}
public void onComponentAdded(@Nonnull Ref<EntityStore> ref, @Nonnull MountedComponent component, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
MountedComponent mounted = (MountedComponent)commandBuffer.getComponent(ref, MountedComponent.getComponentType());
assert mounted != null;
PlayerInput input = (PlayerInput)commandBuffer.getComponent(ref, PlayerInput.getComponentType());
assert input != null;
Ref<EntityStore> mountRef = mounted.getMountedToEntity();
if (mountRef != null && mountRef.isValid()) {
int mountNetworkId = ((NetworkId)commandBuffer.getComponent(mountRef, NetworkId.getComponentType())).getId();
input.setMountId(mountNetworkId);
input.getMovementUpdateQueue().clear();
}
}
public void onComponentSet(@Nonnull Ref<EntityStore> ref, @Nullable MountedComponent oldComponent, @Nonnull MountedComponent newComponent, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
public void onComponentRemoved(@Nonnull Ref<EntityStore> ref, @Nonnull MountedComponent component, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
PlayerInput input = (PlayerInput)commandBuffer.getComponent(ref, PlayerInput.getComponentType());
assert input != null;
input.setMountId(0);
}
}
public static class RemoveMountedBy extends RefSystem<EntityStore> {
public RemoveMountedBy() {
}
public void onEntityAdded(@Nonnull Ref<EntityStore> ref, @Nonnull AddReason reason, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
public void onEntityRemove(@Nonnull Ref<EntityStore> ref, @Nonnull RemoveReason reason, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
MountedByComponent by = (MountedByComponent)commandBuffer.getComponent(ref, MountedByComponent.getComponentType());
for(Ref<EntityStore> p : by.getPassengers()) {
if (p.isValid()) {
MountedComponent mounted = (MountedComponent)commandBuffer.getComponent(p, MountedComponent.getComponentType());
if (mounted != null) {
Ref<EntityStore> target = mounted.getMountedToEntity();
if (!target.isValid() || target.equals(ref)) {
commandBuffer.removeComponent(p, MountedComponent.getComponentType());
}
}
}
}
}
public Query<EntityStore> getQuery() {
return MountedByComponent.getComponentType();
}
}
public static class RemoveBlockSeat extends RefSystem<ChunkStore> {
public RemoveBlockSeat() {
}
public void onEntityAdded(@Nonnull Ref<ChunkStore> ref, @Nonnull AddReason reason, @Nonnull Store<ChunkStore> store, @Nonnull CommandBuffer<ChunkStore> commandBuffer) {
}
public void onEntityRemove(@Nonnull Ref<ChunkStore> ref, @Nonnull RemoveReason reason, @Nonnull Store<ChunkStore> store, @Nonnull CommandBuffer<ChunkStore> commandBuffer) {
BlockMountComponent blockSeatComponent = (BlockMountComponent)commandBuffer.getComponent(ref, BlockMountComponent.getComponentType());
assert blockSeatComponent != null;
ObjectArrayList<? extends Ref<EntityStore>> dismounting = new ObjectArrayList<Ref<EntityStore>>(blockSeatComponent.getSeatedEntities());
World world = ((ChunkStore)ref.getStore().getExternalData()).getWorld();
for(Ref<EntityStore> seated : dismounting) {
blockSeatComponent.removeSeatedEntity(seated);
world.execute(() -> {
if (seated.isValid()) {
seated.getStore().tryRemoveComponent(seated, MountedComponent.getComponentType());
}
});
}
}
public Query<ChunkStore> getQuery() {
return BlockMountComponent.getComponentType();
}
}
public static class HandleMountInput extends EntityTickingSystem<EntityStore> {
private final Query<EntityStore> query = Query.<EntityStore>and(MountedComponent.getComponentType(), PlayerInput.getComponentType());
private final Set<Dependency<EntityStore>> deps;
public HandleMountInput() {
this.deps = Set.of(new SystemDependency(Order.BEFORE, PlayerSystems.ProcessPlayerInput.class));
}
public void tick(float dt, int index, @Nonnull ArchetypeChunk<EntityStore> archetypeChunk, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
MountedComponent mounted = (MountedComponent)archetypeChunk.getComponent(index, MountedComponent.getComponentType());
assert mounted != null;
PlayerInput input = (PlayerInput)archetypeChunk.getComponent(index, PlayerInput.getComponentType());
assert input != null;
MountController controller = mounted.getControllerType();
Ref<EntityStore> targetRef = controller == MountController.BlockMount ? archetypeChunk.getReferenceTo(index) : mounted.getMountedToEntity();
List<PlayerInput.InputUpdate> queue = input.getMovementUpdateQueue();
for(int i = 0; i < queue.size(); ++i) {
PlayerInput.InputUpdate q = (PlayerInput.InputUpdate)queue.get(i);
if (controller == MountController.BlockMount && (q instanceof PlayerInput.RelativeMovement || q instanceof PlayerInput.AbsoluteMovement)) {
if (mounted.getMountedDurationMs() < 600L) {
continue;
}
Ref<EntityStore> ref = archetypeChunk.getReferenceTo(index);
commandBuffer.removeComponent(ref, MountedComponent.getComponentType());
}
if (q instanceof PlayerInput.SetRiderMovementStates) {
PlayerInput.SetRiderMovementStates s = (PlayerInput.SetRiderMovementStates)q;
MovementStates states = s.movementStates();
MovementStatesComponent movementStatesComponent = (MovementStatesComponent)archetypeChunk.getComponent(index, MovementStatesComponent.getComponentType());
if (movementStatesComponent != null) {
movementStatesComponent.setMovementStates(states);
}
} else if (!(q instanceof PlayerInput.WishMovement)) {
if (q instanceof PlayerInput.RelativeMovement) {
PlayerInput.RelativeMovement relative = (PlayerInput.RelativeMovement)q;
relative.apply(commandBuffer, archetypeChunk, index);
TransformComponent transform = (TransformComponent)commandBuffer.getComponent(targetRef, TransformComponent.getComponentType());
transform.getPosition().add(relative.getX(), relative.getY(), relative.getZ());
} else if (q instanceof PlayerInput.AbsoluteMovement) {
PlayerInput.AbsoluteMovement absolute = (PlayerInput.AbsoluteMovement)q;
absolute.apply(commandBuffer, archetypeChunk, index);
TransformComponent transform = (TransformComponent)commandBuffer.getComponent(targetRef, TransformComponent.getComponentType());
transform.getPosition().assign(absolute.getX(), absolute.getY(), absolute.getZ());
} else if (q instanceof PlayerInput.SetMovementStates) {
PlayerInput.SetMovementStates s = (PlayerInput.SetMovementStates)q;
MovementStates states = s.movementStates();
MovementStatesComponent movementStatesComponent = (MovementStatesComponent)commandBuffer.getComponent(targetRef, MovementStatesComponent.getComponentType());
if (movementStatesComponent != null) {
movementStatesComponent.setMovementStates(states);
}
} else if (q instanceof PlayerInput.SetBody) {
PlayerInput.SetBody body = (PlayerInput.SetBody)q;
body.apply(commandBuffer, archetypeChunk, index);
TransformComponent transform = (TransformComponent)commandBuffer.getComponent(targetRef, TransformComponent.getComponentType());
transform.getRotation().assign(body.direction().pitch, body.direction().yaw, body.direction().roll);
} else if (q instanceof PlayerInput.SetHead) {
PlayerInput.SetHead head = (PlayerInput.SetHead)q;
head.apply(commandBuffer, archetypeChunk, index);
}
}
}
queue.clear();
}
@Nonnull
public Query<EntityStore> getQuery() {
return this.query;
}
@Nonnull
public Set<Dependency<EntityStore>> getDependencies() {
return this.deps;
}
}
public static class EnsureMinecartComponents extends HolderSystem<EntityStore> {
public EnsureMinecartComponents() {
}
public void onEntityAdd(@Nonnull Holder<EntityStore> holder, @Nonnull AddReason reason, @Nonnull Store<EntityStore> store) {
holder.ensureComponent(Interactable.getComponentType());
holder.putComponent(NetworkId.getComponentType(), new NetworkId(((EntityStore)store.getExternalData()).takeNextNetworkId()));
holder.ensureComponent(PrefabCopyableComponent.getComponentType());
}
public void onEntityRemoved(@Nonnull Holder<EntityStore> holder, @Nonnull RemoveReason reason, @Nonnull Store<EntityStore> store) {
}
public Query<EntityStore> getQuery() {
return MinecartComponent.getComponentType();
}
@Nonnull
public Set<Dependency<EntityStore>> getDependencies() {
return RootDependency.firstSet();
}
}
public static class OnMinecartHit extends DamageEventSystem {
private static final Duration HIT_RESET_TIME = Duration.ofSeconds(10L);
private static final int NUMBER_OF_HITS = 3;
@Nonnull
private static final Query<EntityStore> QUERY = Archetype.of(MinecartComponent.getComponentType(), TransformComponent.getComponentType());
@Nonnull
private static final Set<Dependency<EntityStore>> DEPENDENCIES;
public OnMinecartHit() {
}
public Query<EntityStore> getQuery() {
return QUERY;
}
@Nonnull
public Set<Dependency<EntityStore>> getDependencies() {
return DEPENDENCIES;
}
public void handle(int index, @Nonnull ArchetypeChunk<EntityStore> archetypeChunk, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer, @Nonnull Damage damage) {
MinecartComponent minecartComponent = (MinecartComponent)archetypeChunk.getComponent(index, MinecartComponent.getComponentType());
assert minecartComponent != null;
Instant currentTime = ((TimeResource)commandBuffer.getResource(TimeResource.getResourceType())).getNow();
if (minecartComponent.getLastHit() != null && currentTime.isAfter(minecartComponent.getLastHit().plus(HIT_RESET_TIME))) {
minecartComponent.setLastHit((Instant)null);
minecartComponent.setNumberOfHits(0);
}
if (!(damage.getAmount() <= 0.0F)) {
minecartComponent.setNumberOfHits(minecartComponent.getNumberOfHits() + 1);
minecartComponent.setLastHit(currentTime);
if (minecartComponent.getNumberOfHits() == 3) {
commandBuffer.removeEntity(archetypeChunk.getReferenceTo(index), RemoveReason.REMOVE);
boolean shouldDropItem = true;
Damage.Source var10 = damage.getSource();
if (var10 instanceof Damage.EntitySource) {
Damage.EntitySource source = (Damage.EntitySource)var10;
Player playerComponent = source.getRef().isValid() ? (Player)commandBuffer.getComponent(source.getRef(), Player.getComponentType()) : null;
if (playerComponent != null) {
shouldDropItem = playerComponent.getGameMode() != GameMode.Creative;
}
}
if (shouldDropItem && minecartComponent.getSourceItem() != null) {
TransformComponent transform = (TransformComponent)archetypeChunk.getComponent(index, TransformComponent.getComponentType());
assert transform != null;
Holder<EntityStore> drop = ItemComponent.generateItemDrop(commandBuffer, new ItemStack(minecartComponent.getSourceItem()), transform.getPosition(), transform.getRotation(), 0.0F, 1.0F, 0.0F);
if (drop != null) {
commandBuffer.addEntity(drop, AddReason.SPAWN);
}
}
}
}
}
static {
DEPENDENCIES = Set.of(new SystemGroupDependency(Order.AFTER, DamageModule.get().getGatherDamageGroup()), new SystemGroupDependency(Order.AFTER, DamageModule.get().getFilterDamageGroup()), new SystemGroupDependency(Order.BEFORE, DamageModule.get().getInspectDamageGroup()));
}
}
public static class TeleportMountedEntity extends RefChangeSystem<EntityStore, Teleport> {
private static final Set<Dependency<EntityStore>> DEPENDENCIES;
public TeleportMountedEntity() {
}
public Query<EntityStore> getQuery() {
return MountedComponent.getComponentType();
}
@Nonnull
public ComponentType<EntityStore, Teleport> componentType() {
return Teleport.getComponentType();
}
public void onComponentAdded(@Nonnull Ref<EntityStore> ref, @Nonnull Teleport component, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
commandBuffer.removeComponent(ref, MountedComponent.getComponentType());
}
public void onComponentSet(@Nonnull Ref<EntityStore> ref, @Nullable Teleport oldComponent, @Nonnull Teleport newComponent, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
public void onComponentRemoved(@Nonnull Ref<EntityStore> ref, @Nonnull Teleport component, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
@Nonnull
public Set<Dependency<EntityStore>> getDependencies() {
return DEPENDENCIES;
}
static {
DEPENDENCIES = Set.of(new SystemDependency(Order.BEFORE, TeleportSystems.MoveSystem.class, OrderPriority.CLOSEST), new SystemDependency(Order.BEFORE, TeleportSystems.PlayerMoveSystem.class, OrderPriority.CLOSEST));
}
}
public static class MountedEntityDeath extends RefChangeSystem<EntityStore, DeathComponent> {
public MountedEntityDeath() {
}
public Query<EntityStore> getQuery() {
return MountedComponent.getComponentType();
}
@Nonnull
public ComponentType<EntityStore, DeathComponent> componentType() {
return DeathComponent.getComponentType();
}
public void onComponentAdded(@Nonnull Ref<EntityStore> ref, @Nonnull DeathComponent component, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
commandBuffer.removeComponent(ref, MountedComponent.getComponentType());
}
public void onComponentSet(@Nonnull Ref<EntityStore> ref, @Nullable DeathComponent oldComponent, @Nonnull DeathComponent newComponent, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
public void onComponentRemoved(@Nonnull Ref<EntityStore> ref, @Nonnull DeathComponent component, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
}
}
}