8.0 KiB
title, type, weight
| title | type | weight |
|---|---|---|
| Systemes Portail | docs | 2 |
Les systemes portail gerent la logique d'execution pour le suivi des portails, les evenements du vide et la gestion des instances.
Package: com.hypixel.hytale.builtin.portals.systems
Systemes de Suivi Portail
TrackerSystem
Suit les joueurs entrant et sortant des mondes portail:
public class TrackerSystem extends RefSystem<EntityStore> {
// Appele quand joueur entre dans monde portail
@Override
public void onEntityAdded(Ref<EntityStore> ref, AddReason reason,
Store<EntityStore> store,
CommandBuffer<EntityStore> commandBuffer) {
PortalWorld portalWorld = store.getResource(PortalWorld.getResourceType());
if (!portalWorld.exists()) return;
// Envoyer UI portail au joueur
PlayerRef playerRef = commandBuffer.getComponent(ref, PlayerRef.getComponentType());
UpdatePortal packet = portalWorld.createFullPacket(world);
playerRef.getPacketHandler().write(packet);
}
// Appele quand joueur quitte monde portail
@Override
public void onEntityRemove(Ref<EntityStore> ref, RemoveReason reason,
Store<EntityStore> store,
CommandBuffer<EntityStore> commandBuffer) {
// Effacer etat UI
playerRef.getPacketHandler().write(new UpdatePortal(null, null));
portalWorld.getSeesUi().remove(playerRef.getUuid());
}
@Override
public Query<EntityStore> getQuery() {
return Query.and(Player.getComponentType(), PlayerRef.getComponentType());
}
}
UiTickingSystem
Met a jour l'UI portail chaque seconde:
public class UiTickingSystem extends DelayedEntitySystem<EntityStore> {
public UiTickingSystem() {
super(1.0f); // Tick chaque 1 seconde
}
@Override
public void tick(float dt, int index, ArchetypeChunk<EntityStore> archetypeChunk,
Store<EntityStore> store, CommandBuffer<EntityStore> commandBuffer) {
PortalWorld portalWorld = store.getResource(PortalWorld.getResourceType());
if (!portalWorld.exists()) return;
// Envoyer temps mis a jour au joueur
UpdatePortal packet = portalWorld.createUpdatePacket(world);
playerRef.getPacketHandler().write(packet);
}
}
Systemes Destination Portail
PortalInvalidDestinationSystem
Gere les portails avec destinations invalides:
public class PortalInvalidDestinationSystem {
// Eteint portails quand monde destination ferme
public static void turnOffPortalsInWorld(World world, World closedWorld) {
// Trouver tous portails pointant vers closedWorld
// Mettre leur destination a null
// Mettre a jour etat bloc a "off"
}
}
CloseWorldWhenBreakingDeviceSystems
Gere la destruction du dispositif portail:
// Quand composant dispositif portail supprime
public class ComponentRemoved extends System<ChunkStore> {
// Fermer le monde de destination
}
// Quand entite bloc portail supprimee
public class EntityRemoved extends System<ChunkStore> {
// Fermer le monde de destination
}
Systemes Evenement Vide
VoidEventRefSystem
Gere les references entites evenement vide:
public class VoidEventRefSystem extends System<EntityStore> {
// Suit cycle de vie entite evenement vide
// Met a jour PortalWorld.voidEventRef
}
VoidEventStagesSystem
Progresse a travers les etapes evenement vide:
public class VoidEventStagesSystem extends System<EntityStore> {
// Verifie temps ecoule
// Active etape suivante quand seuil temps atteint
// Met a jour VoidEvent.activeStage
}
VoidInvasionPortalsSpawnSystem
Fait apparaitre portails invasion pendant evenements vide:
public class VoidInvasionPortalsSpawnSystem extends System<EntityStore> {
// Cree entites spawner vide
// Utilise grille hash spatiale pour maintenir distance minimum
}
VoidSpawnerSystems.Instantiate
Instancie entites spawner vide:
public class Instantiate extends System<EntityStore> {
// Cree entite spawner depuis config
// Ajoute a grille spatiale VoidEvent
}
StartVoidEventInFragmentSystem
Initie evenements vide dans fragments portail:
public class StartVoidEventInFragmentSystem extends System<EntityStore> {
// Verifie si invasion vide devrait demarrer
// Cree entite VoidEvent
// Configure premiere etape
}
Systemes Malediction
DiedInPortalSystem
Suit les morts joueurs dans mondes portail:
public class DiedInPortalSystem extends System<EntityStore> {
// A la mort joueur dans monde portail:
// - Ajouter UUID joueur a set diedInWorld
// - Empeche re-entree
}
CurseItemDropsSystem
Marque items laches comme maudits:
public class CurseItemDropsSystem extends System<EntityStore> {
// Items laches dans monde portail deviennent maudits
// Items maudits sont perdus a la mort
}
DeleteCursedItemsOnSpawnSystem
Supprime items maudits quand joueur spawn:
public class DeleteCursedItemsOnSpawnSystem extends System<EntityStore> {
// Quand joueur reapparait apres mort dans portail
// Supprimer tous items maudits de l'inventaire
}
Interactions Portail
EnterPortalInteraction
Gere l'entree dans un portail:
public class EnterPortalInteraction extends SimpleBlockInteraction {
// Temps minimum avant autoriser utilisation portail
public static final Duration MINIMUM_TIME_IN_WORLD = Duration.ofMillis(3000L);
@Override
protected void interactWithBlock(...) {
// Verifier dispositif portail existe
// Verifier monde destination vivant
// Verifier joueur pas mort dans monde cible
// Teleporter joueur vers instance
}
}
Etats monde cible:
OKAY- Peut entrerWORLD_DEAD- Destination fermeeDIED_IN_WORLD- Joueur mort la-basNO_SPAWN_AVAILABLE- Pas de point de spawn
ReturnPortalInteraction
Gere le retour d'un monde portail:
public class ReturnPortalInteraction extends SimpleBlockInteraction {
// Temps minimum avant autoriser retour
public static final Duration MINIMUM_TIME_IN_WORLD = Duration.ofSeconds(15L);
// Avertissement affiche avant expiration timer
public static final Duration WARNING_TIME = Duration.ofSeconds(4L);
@Override
protected void interactWithBlock(...) {
// Verifier temps minimum ecoule
// Retirer malediction tous items
// Sortir instance
}
}
Enregistrement Systemes
Tous les systemes sont enregistres dans setup PortalsPlugin:
// Systemes ChunkStore
this.getChunkStoreRegistry().registerSystem(new PortalInvalidDestinationSystem());
this.getChunkStoreRegistry().registerSystem(new CloseWorldWhenBreakingDeviceSystems.ComponentRemoved());
this.getChunkStoreRegistry().registerSystem(new CloseWorldWhenBreakingDeviceSystems.EntityRemoved());
// Systemes EntityStore
this.getEntityStoreRegistry().registerSystem(new PortalTrackerSystems.TrackerSystem());
this.getEntityStoreRegistry().registerSystem(new PortalTrackerSystems.UiTickingSystem());
this.getEntityStoreRegistry().registerSystem(new DiedInPortalSystem());
this.getEntityStoreRegistry().registerSystem(new CurseItemDropsSystem());
this.getEntityStoreRegistry().registerSystem(new DeleteCursedItemsOnSpawnSystem());
this.getEntityStoreRegistry().registerSystem(new VoidEventRefSystem());
this.getEntityStoreRegistry().registerSystem(new VoidInvasionPortalsSpawnSystem());
this.getEntityStoreRegistry().registerSystem(new VoidSpawnerSystems.Instantiate());
this.getEntityStoreRegistry().registerSystem(new StartVoidEventInFragmentSystem());
this.getEntityStoreRegistry().registerSystem(new VoidEventStagesSystem());
Enregistrement Interactions
Les interactions portail sont enregistrees comme types codec:
this.getCodecRegistry(Interaction.CODEC)
.register("Portal", EnterPortalInteraction.class, EnterPortalInteraction.CODEC)
.register("PortalReturn", ReturnPortalInteraction.class, ReturnPortalInteraction.CODEC);