Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f3c9a54
Add particles
ShaneBeee Feb 22, 2026
c4991fb
Checkstyle...
ShaneBeee Feb 22, 2026
add92b4
PlayerUtils - add util to get players in radius/cuboid
ShaneBeee Feb 22, 2026
30ae613
PlayerUtils - checkstyle
ShaneBeee Feb 22, 2026
c8f5870
ExprEntitiesInRadius - add players as well
ShaneBeee Feb 22, 2026
2bd808a
build.gradle.kts - switch to dev/patch parser
ShaneBeee Feb 22, 2026
c7e1858
TypesItem - fix item container codecs
ShaneBeee Feb 22, 2026
b55fbce
Block - add rotation
ShaneBeee Feb 22, 2026
ff5b5d7
ExprBlockRotation - add
ShaneBeee Feb 22, 2026
126bb19
Merge branch 'master' into dev/feature
ShaneBeee Feb 22, 2026
aecc16d
command-vault.sk - another sample
ShaneBeee Feb 23, 2026
cc22456
SecExecuteInWorld - fix not loading variables correctly
ShaneBeee Feb 23, 2026
58d0778
EffTeleport - handle teleports on the correct world thread
ShaneBeee Feb 23, 2026
9b7a379
Add some world stuff
ShaneBeee Feb 23, 2026
9981137
Merge branch 'master' into dev/feature
ShaneBeee Feb 23, 2026
ad30e87
build.gradle.kts - da ferq happened here
ShaneBeee Feb 23, 2026
a5eb62e
Use shaded bstats
ShaneBeee Feb 24, 2026
dbdf1a8
JsonDocPrinter - fix missing context values when they extend another …
ShaneBeee Feb 24, 2026
8fae45e
TypesAssetStore - missing docs for particle
ShaneBeee Feb 24, 2026
7e043d8
EvtPlayerUseBlock - add example
ShaneBeee Feb 24, 2026
b9af655
EffCancelEvent - fix wrong check
ShaneBeee Feb 24, 2026
fc45026
BstatsMetrics - add plugin version/addons
ShaneBeee Feb 25, 2026
69ae65a
EntityUtils - change naming of put comp
ShaneBeee Feb 25, 2026
f12d635
Add model stuff
ShaneBeee Feb 25, 2026
172fb99
Ref - add some ref stuff
ShaneBeee Feb 26, 2026
fa6d2d1
Block - add more methods
ShaneBeee Feb 26, 2026
922e974
ExprBlockTint - add
ShaneBeee Feb 26, 2026
72e5e32
Attitude and locked target
ShaneBeee Feb 28, 2026
bfb3d77
EvtBoot - fix not being triggered
ShaneBeee Feb 28, 2026
89a12cb
EvtPeriodical - move over from skript-parser:
ShaneBeee Feb 28, 2026
49a8c8b
BstatsMetrics - update version string to end with ".x"
ShaneBeee Feb 28, 2026
2d452e2
config.yml - update doc link
ShaneBeee Feb 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
blank_issues_enabled: false
contact_links:
- name: 📖 HySkript Docs
url: https://github.com/SkriptDev/HySkript/wiki
url: https://skripthub.net/hyskript/docs/
about: Find HySkript's docs and 100's of examples
- name: 💻 Support
url: https://discord.gg/phpWHGU
Expand Down
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ dependencies {
compileOnly("com.hypixel.hytale:Server:${hytaleVersion}")
compileOnly("org.jetbrains:annotations:26.0.2")
testImplementation("com.google.code.gson:gson:2.13.2")

// bStats
implementation("org.bstats:bstats-hytale:3.2.1")

// Skript-Parser
implementation("com.github.SkriptDev:skript-parser:1.0.10") {
isTransitive = false
}
Expand Down Expand Up @@ -77,6 +82,7 @@ tasks {
archiveClassifier.set("")
relocate("io.github.syst3ms", "com.github.skriptdev.skript")
relocate("fi.sulku.hytale", "com.github.skriptdev.skript.tinymessage")
relocate("org.bstats", "com.github.skriptdev.skript.bstats")
}
jar {
dependsOn(shadowJar)
Expand Down
107 changes: 98 additions & 9 deletions src/main/java/com/github/skriptdev/skript/api/hytale/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.hypixel.hytale.math.vector.Location;
import com.hypixel.hytale.math.vector.Vector3i;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.Rotation;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.RotationTuple;
import com.hypixel.hytale.server.core.asset.type.fluid.Fluid;
import com.hypixel.hytale.server.core.entity.LivingEntity;
import com.hypixel.hytale.server.core.inventory.ItemStack;
Expand All @@ -18,11 +20,13 @@
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.chunk.BlockChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.ChunkColumn;
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
import com.hypixel.hytale.server.core.universe.world.chunk.section.FluidSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import io.github.syst3ms.skriptparser.util.color.Color;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -54,6 +58,14 @@ public Block(@NotNull Location location) {
this(world, location.getPosition().toVector3i());
}

public long getChunkIndex() {
return ChunkUtil.indexChunkFromBlock(this.pos.getX(), this.pos.getZ());
}

public WorldChunk getChunk() {
return this.world.getChunk(getChunkIndex());
}

public @NotNull BlockType getType() {
BlockType blockType = this.world.getBlockType(this.pos);
return blockType != null ? blockType : BlockType.EMPTY;
Expand All @@ -68,9 +80,88 @@ public void setType(@NotNull BlockType type, int settings) {
}
}

public void updateChunk() {
getWorld().getNotificationHandler().updateChunk(getChunkIndex());
}

/**
* Set the rotation of this block.
*
* @param rotation Rotation of block represented by a Vector3i(yaw, pitch, roll).
*/
public void setRotation(Vector3i rotation) {
int blockId = BlockType.getAssetMap().getIndex(getType().getId());
WorldChunk chunk = getChunk();
BlockChunk blockChunk = chunk.getBlockChunk();
if (blockChunk == null) return;

Rotation pitch = getRotationFromInt(rotation.getX());
Rotation yaw = getRotationFromInt(rotation.getY());
Rotation roll = getRotationFromInt(rotation.getZ());
int rotationIndex = RotationTuple.of(yaw, pitch, roll).index();
blockChunk.setBlock(this.pos.getX(), this.pos.getY(), this.pos.getZ(),
blockId, rotationIndex, 0);
}

/**
* Get the rotation of this block.
*
* @return Rotation of block represented as a Vector3i(yaw, pitch, roll).
*/
public Vector3i getRotation() {
int blockRotationIndex = getWorld().getBlockRotationIndex(this.pos.getX(), this.pos.getY(), this.pos.getZ());
RotationTuple rotationTuple = RotationTuple.get(blockRotationIndex);

int yaw = getIntFromRotation(rotationTuple.yaw());
int pitch = getIntFromRotation(rotationTuple.pitch());
int roll = getIntFromRotation(rotationTuple.roll());
return new Vector3i(pitch, yaw, roll);
}

private Rotation getRotationFromInt(int v) {
if (v < 90) return Rotation.None;
else if (v < 180) return Rotation.Ninety;
else if (v < 270) return Rotation.OneEighty;
else return Rotation.TwoSeventy;
}

private int getIntFromRotation(Rotation rotation) {
return switch (rotation) {
case None -> 0;
case Ninety -> 90;
case OneEighty -> 180;
case TwoSeventy -> 270;
};
}

public Color getTint() {
BlockChunk blockChunk = getChunk().getBlockChunk();
if (blockChunk == null) return null;

int x = this.pos.getX() % 32;
int z = this.pos.getZ() % 32;
int tintInt = blockChunk.getTint(x, z);
return Color.of(tintInt);
}

public void setTint(Color color) {
setTint(color, true);
}

public void setTint(Color color, boolean updateChunk) {
BlockChunk blockChunk = getChunk().getBlockChunk();
if (blockChunk == null) return;

int x = this.pos.getX() % 32;
int z = this.pos.getZ() % 32;
blockChunk.setTint(x, z, color.toJavaColor().getRGB());
if (updateChunk) {
updateChunk();
}
}

public byte getFluidLevel() {
long index = ChunkUtil.indexChunkFromBlock(this.pos.getX(), this.pos.getZ());
WorldChunk chunk = this.world.getChunk(index);
WorldChunk chunk = this.world.getChunk(getChunkIndex());
if (chunk == null) return 0;

Ref<ChunkStore> columnRef = chunk.getReference();
Expand All @@ -90,8 +181,7 @@ public byte getFluidLevel() {
}

public void setFluidLevel(byte level) {
long index = ChunkUtil.indexChunkFromBlock(this.pos.getX(), this.pos.getZ());
this.world.getChunkAsync(index).thenApply((chunk) -> {
this.world.getChunkAsync(getChunkIndex()).thenApply((chunk) -> {
Ref<ChunkStore> columnRef = chunk.getReference();
Store<ChunkStore> store = columnRef.getStore();
ChunkColumn column = store.getComponent(columnRef, ChunkColumn.getComponentType());
Expand Down Expand Up @@ -124,8 +214,7 @@ public Fluid getFluid() {
}

public void setFluid(@NotNull Fluid fluid, @Nullable Integer level) {
long index = ChunkUtil.indexChunkFromBlock(this.pos.getX(), this.pos.getZ());
this.world.getChunkAsync(index).thenApply((chunk) -> {
this.world.getChunkAsync(getChunkIndex()).thenApply((chunk) -> {
Ref<ChunkStore> columnRef = chunk.getReference();
Store<ChunkStore> store = columnRef.getStore();
ChunkColumn column = store.getComponent(columnRef, ChunkColumn.getComponentType());
Expand Down Expand Up @@ -160,7 +249,7 @@ public void breakBlock(int settings) {
}

public void damage(@Nullable LivingEntity performer, @Nullable ItemStack itemStack, float damage) {
WorldChunk chunk = this.world.getChunk(ChunkUtil.indexChunkFromBlock(this.pos.getX(), this.pos.getZ()));
WorldChunk chunk = this.world.getChunk(getChunkIndex());
if (chunk == null) return;

Ref<ChunkStore> ref = chunk.getReference();
Expand Down Expand Up @@ -195,7 +284,7 @@ public void damage(@Nullable LivingEntity performer, @Nullable ItemStack itemSta
}

public float getBlockHealth() {
WorldChunk chunk = this.world.getChunk(ChunkUtil.indexChunkFromBlock(this.pos.getX(), this.pos.getZ()));
WorldChunk chunk = getChunk();
if (chunk == null) return 0;

Ref<ChunkStore> ref = chunk.getReference();
Expand All @@ -208,7 +297,7 @@ public float getBlockHealth() {
}

public void setBlockHealth(float health) {
WorldChunk chunk = this.world.getChunk(ChunkUtil.indexChunkFromBlock(this.pos.getX(), this.pos.getZ()));
WorldChunk chunk = getChunk();
if (chunk == null) return;

Ref<ChunkStore> ref = chunk.getReference();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.github.skriptdev.skript.api.hytale.utils;

import com.hypixel.hytale.component.Component;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.spatial.SpatialResource;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.server.core.modules.entity.item.ItemComponent;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.server.npc.entities.NPCEntity;
import it.unimi.dsi.fastutil.objects.ObjectList;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Utilities for {@link EntityStore} {@link Ref References}
*/
@SuppressWarnings("unused")
public class EntityReferenceUtils {

private static final List<ReferenceType<?>> TYPES = new ArrayList<>();
private static final Map<Class<? extends Component<?>>, ReferenceType<?>> TYPES_MAP = new HashMap<>();

public static final ReferenceType<Player> PLAYER = new ReferenceType<>(
"player", Player.class, Player.getComponentType());
public static final ReferenceType<NPCEntity> NPC_ENTITY = new ReferenceType<>(
"npcentity", NPCEntity.class, NPCEntity.getComponentType());
public static final ReferenceType<ItemComponent> ITEM = new ReferenceType<>(
"item", ItemComponent.class, ItemComponent.getComponentType());

public static List<ReferenceType<?>> getTypes() {
return TYPES;
}

public static ReferenceType<?> getType(Class<? extends Component<?>> componentClass) {
return TYPES_MAP.get(componentClass);
}

public static List<Ref<EntityStore>> getRefsInSphere(@Nonnull Vector3d pos, double radius, @Nonnull Store<EntityStore> store) {
ObjectList<Ref<EntityStore>> results = SpatialResource.getThreadLocalReferenceList();
EntityModule entityModule = EntityModule.get();
SpatialResource<Ref<EntityStore>, EntityStore> entities = store.getResource(entityModule.getEntitySpatialResourceType());
entities.getSpatialStructure().collect(pos, (float) radius, results);
SpatialResource<Ref<EntityStore>, EntityStore> players = store.getResource(entityModule.getPlayerSpatialResourceType());
players.getSpatialStructure().collect(pos, (float) radius, results);
SpatialResource<Ref<EntityStore>, EntityStore> items = store.getResource(entityModule.getItemSpatialResourceType());
items.getSpatialStructure().collect(pos, (float) radius, results);
return results;
}

@Nonnull
public static List<Ref<EntityStore>> getRefsInBox(@Nonnull Vector3d min, @Nonnull Vector3d max, @Nonnull Store<EntityStore> store) {
ObjectList<Ref<EntityStore>> results = SpatialResource.getThreadLocalReferenceList();
EntityModule entityModule = EntityModule.get();
SpatialResource<Ref<EntityStore>, EntityStore> entities = store.getResource(entityModule.getEntitySpatialResourceType());
entities.getSpatialStructure().collectBox(min, max, results);
SpatialResource<Ref<EntityStore>, EntityStore> players = store.getResource(entityModule.getPlayerSpatialResourceType());
players.getSpatialStructure().collectBox(min, max, results);
SpatialResource<Ref<EntityStore>, EntityStore> items = store.getResource(entityModule.getItemSpatialResourceType());
items.getSpatialStructure().collectBox(min, max, results);
return results;
}

public static class ReferenceType<E extends Component<EntityStore>> {


private final String name;
private final Class<E> componentClass;
private final ComponentType<EntityStore, ?> componentType;

public ReferenceType(String name, Class<E> componentClass, ComponentType<EntityStore, ?> componentType) {
this.name = name;
this.componentClass = componentClass;
this.componentType = componentType;
EntityReferenceUtils.TYPES.add(this);
EntityReferenceUtils.TYPES_MAP.put(componentClass, this);
}

public String getName() {
return this.name;
}

public Class<E> getComponentClass() {
return this.componentClass;
}

@SuppressWarnings("unchecked")
public @Nullable E getComponent(Ref<EntityStore> ref) {
Store<EntityStore> store = ref.getStore();
return (E) store.getComponent(ref, this.componentType);
}
}

}
Loading
Loading