Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ java.sourceCompatibility = JavaVersion.VERSION_25

group = "com.github.SkriptDev"
val projectVersion = "1.6.0"
val hytaleVersion = "2026.03.26-89796e57b"
val hytaleVersion = "2026.04.16-5cbd1e160"
// You can find Hytale versions on their maven repo:
// https://maven.hytale.com/release/com/hypixel/hytale/Server/maven-metadata.xml
// https://maven.hytale.com/pre-release/com/hypixel/hytale/Server/maven-metadata.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.util.ChunkUtil;
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;
Expand All @@ -29,6 +28,8 @@
import io.github.syst3ms.skriptparser.util.color.Color;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.RoundingMode;
import org.joml.Vector3i;

import java.util.Map;
import java.util.function.Predicate;
Expand All @@ -55,11 +56,11 @@ public Block(@NotNull Location location) {
if (world == null) {
throw new IllegalArgumentException("World '" + location.getWorld() + "' not found.");
}
this(world, location.getPosition().toVector3i());
this(world, new Vector3i(location.getPosition(), RoundingMode.FLOOR));
}

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

public WorldChunk getChunk() {
Expand All @@ -72,7 +73,7 @@ public WorldChunk getChunk() {
}

public void setType(@NotNull BlockType type, int settings) {
Runnable r = () -> Block.this.world.setBlock(Block.this.pos.getX(), Block.this.pos.getY(), Block.this.pos.getZ(), type.getId(), settings);
Runnable r = () -> Block.this.world.setBlock(Block.this.pos.x(), Block.this.pos.y(), Block.this.pos.z(), type.getId(), settings);
if (this.world.isInThread()) {
r.run();
} else {
Expand All @@ -95,11 +96,11 @@ public void setRotation(Vector3i rotation) {
BlockChunk blockChunk = chunk.getBlockChunk();
if (blockChunk == null) return;

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

Expand All @@ -109,7 +110,7 @@ public void setRotation(Vector3i rotation) {
* @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());
int blockRotationIndex = getWorld().getBlockRotationIndex(this.pos.x(), this.pos.y(), this.pos.z());
RotationTuple rotationTuple = RotationTuple.get(blockRotationIndex);

int yaw = getIntFromRotation(rotationTuple.yaw());
Expand Down Expand Up @@ -138,8 +139,8 @@ 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 x = this.pos.x() % 32;
int z = this.pos.z() % 32;
int tintInt = blockChunk.getTint(x, z);
return Color.of(tintInt);
}
Expand All @@ -152,8 +153,8 @@ 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;
int x = this.pos.x() % 32;
int z = this.pos.z() % 32;
blockChunk.setTint(x, z, color.toJavaColor().getRGB());
if (updateChunk) {
updateChunk();
Expand All @@ -169,14 +170,14 @@ public byte getFluidLevel() {
ChunkColumn column = store.getComponent(columnRef, ChunkColumn.getComponentType());
if (column == null) return 0;

Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(this.pos.getY()));
Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(this.pos.y()));
if (section == null) {
return 0;
} else {
FluidSection fluidSection = store.getComponent(section, FluidSection.getComponentType());
if (fluidSection == null) return 0;

return fluidSection.getFluidLevel(this.pos.getX(), this.pos.getY(), this.pos.getZ());
return fluidSection.getFluidLevel(this.pos.x(), this.pos.y(), this.pos.z());
}
}

Expand All @@ -187,7 +188,7 @@ public void setFluidLevel(byte level) {
ChunkColumn column = store.getComponent(columnRef, ChunkColumn.getComponentType());
if (column == null) return null;

Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(this.pos.getY()));
Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(this.pos.y()));
if (section == null) {
return null;
} else {
Expand All @@ -196,17 +197,17 @@ public void setFluidLevel(byte level) {
return null;
}

Fluid fluid = fluidSection.getFluid(this.pos.getX(), this.pos.getY(), this.pos.getZ());
Fluid fluid = fluidSection.getFluid(this.pos.x(), this.pos.y(), this.pos.z());
if (fluid == null) return null;
byte fluidLevel = (byte) Math.clamp((int) level, 0, fluid.getMaxFluidLevel());
fluidSection.setFluid(this.pos.getX(), this.pos.getY(), this.pos.getZ(), fluid, fluidLevel);
fluidSection.setFluid(this.pos.x(), this.pos.y(), this.pos.z(), fluid, fluidLevel);
}
return chunk;
});
}

public Fluid getFluid() {
int fluidId = this.world.getFluidId(this.pos.getX(), this.pos.getY(), this.pos.getZ());
int fluidId = this.world.getFluidId(this.pos.x(), this.pos.y(), this.pos.z());
if (fluidId == -1) {
return null;
}
Expand All @@ -220,7 +221,7 @@ public void setFluid(@NotNull Fluid fluid, @Nullable Integer level) {
ChunkColumn column = store.getComponent(columnRef, ChunkColumn.getComponentType());
if (column == null) return null;

Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(this.pos.getY()));
Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(this.pos.y()));
if (section == null) {
return null;
} else {
Expand All @@ -234,18 +235,18 @@ public void setFluid(@NotNull Fluid fluid, @Nullable Integer level) {
if (level != null) {
fluidLevel = level.byteValue();
} else {
fluidLevel = fluidSection.getFluidLevel(this.pos.getX(), this.pos.getY(), this.pos.getZ());
fluidLevel = fluidSection.getFluidLevel(this.pos.x(), this.pos.y(), this.pos.z());
if (fluidLevel <= 0) fluidLevel = (byte) fluid.getMaxFluidLevel();
}
fluidLevel = (byte) Math.clamp((int) fluidLevel, 0, fluid.getMaxFluidLevel());
fluidSection.setFluid(this.pos.getX(), this.pos.getY(), this.pos.getZ(), fluid, fluidLevel);
fluidSection.setFluid(this.pos.x(), this.pos.y(), this.pos.z(), fluid, fluidLevel);
}
return chunk;
});
}

public void breakBlock(int settings) {
this.world.breakBlock(this.pos.getX(), this.pos.getY(), this.pos.getZ(), settings);
this.world.breakBlock(this.pos.x(), this.pos.y(), this.pos.z(), settings);
}

public void damage(@Nullable LivingEntity performer, @Nullable ItemStack itemStack, float damage) {
Expand All @@ -268,7 +269,6 @@ public void damage(@Nullable LivingEntity performer, @Nullable ItemStack itemSta
chunkStore);
} else {
BlockHarvestUtils.performBlockDamage(
performer,
performer.getReference(),
this.pos,
itemStack,
Expand Down Expand Up @@ -312,8 +312,8 @@ public void setBlockHealth(float health) {

if (!blockHealth.isDestroyed()) {
Predicate<PlayerRef> filter = (player) -> true;
world.getNotificationHandler().updateBlockDamage(this.pos.getX(), this.pos.getY(),
this.pos.getZ(), blockHealth.getHealth(), health, filter);
world.getNotificationHandler().updateBlockDamage(this.pos.x(), this.pos.y(),
this.pos.z(), blockHealth.getHealth(), health, filter);
}
}

Expand All @@ -326,16 +326,16 @@ public void setBlockHealth(float health) {
}

public @NotNull Location getLocation() {
return new Location(this.world.getName(), this.pos.getX(), this.pos.getY(), this.pos.getZ());
return new Location(this.world.getName(), this.pos.x(), this.pos.y(), this.pos.z());
}

public String toTypeString() {
return String.format("[%s] block at (%s,%s,%s) in '%s'",
this.getType().getId(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), this.world.getName());
this.getType().getId(), this.pos.x(), this.pos.y(), this.pos.z(), this.world.getName());
}

public String toVariableNameString() {
return String.format("%s_%s_%s_%s_%s", this.world.getName(), this.getType().getId(), this.pos.getX(), this.pos.getY(), this.pos.getZ());
return String.format("%s_%s_%s_%s_%s", this.world.getName(), this.getType().getId(), this.pos.x(), this.pos.y(), this.pos.z());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.github.skriptdev.skript.api.hytale.utils.LocationUtils;
import com.hypixel.hytale.math.vector.Location;
import com.hypixel.hytale.math.vector.Vector3d;
import org.joml.Vector3d;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -53,7 +53,9 @@ public String getVariableName() {

private static Location create(Location location, Number offset, int x, int y, int z) {
double value = offset.doubleValue();
Vector3d add = location.getPosition().clone().add(x * value, y * value, z * value);

Vector3d position = new Vector3d(location.getPosition());
Vector3d add = position.add(x * value, y * value, z * value);
return new Location(location.getWorld(), add);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.skriptdev.skript.api.hytale.objects;

import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.protocol.packets.worldmap.ContextMenuItem;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.user.UserMapMarker;
import org.joml.Vector3d;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -20,8 +20,8 @@ public class UserMapMarkerOverride extends UserMapMarker {
private final List<ContextMenuItem> contextMenuItems = new ArrayList<>();

public void setPosition(Vector3d pos) {
this.blockY = (float) pos.getY();
super.setPosition((float) pos.getX(), (float) pos.getZ());
this.blockY = (float) pos.y();
super.setPosition((float) pos.x(), (float) pos.z());
}

public void addContextMenuItem(ContextMenuItem contextMenuItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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.Entity;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
Expand All @@ -14,6 +13,7 @@
import com.hypixel.hytale.server.npc.entities.NPCEntity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3d;

import javax.annotation.Nonnull;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Location;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.math.vector.Vector3f;
import com.hypixel.hytale.math.vector.Rotation3f;
import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.server.core.asset.type.item.config.Item;
import com.hypixel.hytale.server.core.asset.type.model.config.Model;
Expand Down Expand Up @@ -43,6 +42,8 @@
import io.github.syst3ms.skriptparser.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3d;
import org.joml.Vector3f;

import javax.annotation.Nonnull;
import java.util.UUID;
Expand Down Expand Up @@ -249,10 +250,10 @@ public static <ECS, T extends Component<ECS>> void tryRemoveComponent(Entity ent
}

Vector3d position = location.getPosition();
Vector3f rotation = location.getRotation();
Rotation3f rotation = location.getRotation();

Holder<EntityStore> itemEntityHolder = ItemComponent.generateItemDrop(store, itemStack, position, rotation,
velocity.getX(), velocity.getY(), velocity.getZ());
velocity.x(), velocity.y(), velocity.z());
if (itemEntityHolder == null) {
return new Pair<>(null, null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.skriptdev.skript.api.hytale.utils;

import com.hypixel.hytale.math.vector.Location;
import org.joml.Vector3d;

/**
* Untilities for {@link Location Locations}
Expand All @@ -16,7 +17,7 @@ public class LocationUtils {
*/
public static Location clone(Location location) {
return new Location(location.getWorld(),
location.getPosition().clone(),
new Vector3d(location.getPosition()),
location.getRotation().clone());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.spatial.SpatialResource;
import com.hypixel.hytale.math.vector.Location;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.NameMatching;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
Expand All @@ -14,6 +13,7 @@
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3d;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -147,8 +147,8 @@ public static List<PlayerRef> getPlayerRefs(@Nullable World world) {
Store<EntityStore> store = world.getEntityStore().getStore();
if (store == null) return List.of();

Vector3d min = Vector3d.min(loc1.getPosition(), loc2.getPosition());
Vector3d max = Vector3d.max(loc1.getPosition(), loc2.getPosition());
Vector3d min = loc1.getPosition().min(loc2.getPosition());
Vector3d max = loc1.getPosition().max(loc2.getPosition());

List<Ref<EntityStore>> results = SpatialResource.getThreadLocalReferenceList();
SpatialResource<Ref<EntityStore>, EntityStore> playerSpatialResource = store.getResource(EntityModule.get()
Expand All @@ -163,4 +163,10 @@ public static List<PlayerRef> getPlayerRefs(@Nullable World world) {
return players;
}

public static String getUsername(Player player) {
PlayerRef playerRef = getPlayerRef(player);
assert playerRef != null;
return playerRef.getUsername();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.skriptdev.skript.api.skript.event;

import com.github.skriptdev.skript.api.hytale.utils.PlayerUtils;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import io.github.syst3ms.skriptparser.lang.TriggerContext;

/**
Expand All @@ -10,4 +12,8 @@ public interface PlayerContext extends TriggerContext {

Player getPlayer();

default PlayerRef getPlayerRef() {
return PlayerUtils.getPlayerRef(getPlayer());
}

}
Loading
Loading