Skip to content

Hytale plugin template with gradle and pluginmanifest

License

Notifications You must be signed in to change notification settings

Koboo/hytale-plugin-template

Repository files navigation

Hytale Plugin Template

This project doesn't contain a manifest.json, because it's automatically generated by the eu.koboo.pluginmanifest gradle-plugin.

The HytaleServer.jar dependency should be automatically resolved from your client's installation, and added to your project as a dependency, done by the eu.koboo.pluginmanifest gradle-plugin.

Overview

Quick tips

  • Enabled Diagnostics Mode in your client settings

Useful links:

Tutorials:

Advanced Tutorials

Entity-Component-System Cheatsheet

Core Classes

Class Purpose
Component<ECS_TYPE> Interface for data containers. Must implement clone()
ComponentType<ECS_TYPE, T> Type identifier for components (like a key)
Holder<ECS_TYPE> Builder for assembling entities before adding to store
Ref<ECS_TYPE> Reference to an entity in a store
Store<ECS_TYPE> Contains all entities and their components
Archetype<ECS_TYPE> Defines a set of component types for querying
Query<ECS_TYPE> Filter for finding entities with specific components

Two Store Types

Store Generic Type Use Case
EntityStore Store<EntityStore> Mobile entities (players, NPCs, dropped items)
ChunkStore Store<ChunkStore> World chunks and block data

Summary

Aspect BlockEntity (Entity) Block with Data (Block)
Store EntityStore ChunkStore
Movement Can move Fixed position
Example Falling sand, dropped item Chest, spawn marker
Java Type Component<EntityStore> Component<ChunkStore>
Created via assembleDefaultBlockEntity() JSON "BlockEntity" config

Where do I get..

PlayerRef

  • PlayerRef playerRef = Universe.get().getPlayer(uuid);
  • PlayerRef playerRef = reference.getStore().getComponent(reference, PlayerRef.getComponentType());

Player

  • Player player = reference.getStore().getComponent(reference, Player.getComponentType());

World

  • World world = Universe.get().getWorld(uuid);
  • CompletableFuture<World> future = Universe.get().makeWorld(String name, Path savePath, WorldConfig worldConfig, boolean start);

getNeabryEntities

            Vector3d playerPos = playerTransform.getPosition().clone().add(0, modelcomponent.getModel().getEyeHeight(), 0);
            List<Ref<EntityStore>> nearby = new ArrayList<>();
            SpatialResource<Ref<EntityStore>, EntityStore> itemSpatialResource = commandBuffer.getResource(EntityModule.get().getItemSpatialResourceType());
            itemSpatialResource.getSpatialStructure().collect(playerPos, ItemMagnet.INSTANCE.config.get().pickupRadius(), nearby);
            for (Ref<EntityStore> entityStoreRef : nearby) {
                TransformComponent entityPos = commandBuffer.getComponent(entityStoreRef, TransformComponent.getComponentType());
                ItemComponent pickup = commandBuffer.getComponent(entityStoreRef, ItemComponent.getComponentType());
                if (entityPos != null && pickup != null && pickup.canPickUp()) {
                    entityPos.getPosition().assign(Vector3d.lerp(entityPos.getPosition(), playerPos, ItemMagnet.INSTANCE.config.get().moveSpeed()));
                }
            }

About

Hytale plugin template with gradle and pluginmanifest

Topics

Resources

License

Stars

Watchers

Forks

Languages