Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6294cc2
Types - move types into their own classes for better organization
ShaneBeee Jan 30, 2026
e451f4f
TypesServer - add serializer for Location
ShaneBeee Jan 30, 2026
cc9a043
build.gradle.kts - update skript-parser to dev/patch branch
ShaneBeee Jan 30, 2026
e3aec5f
BlockType expressions - add ability to set
ShaneBeee Jan 30, 2026
5a609ae
CondPlayerIsCrouching - add condition for crouching
ShaneBeee Jan 30, 2026
802a9f0
ExpressionHandler - reorganize
ShaneBeee Jan 30, 2026
73c5876
Skript - add name after changing upstream
ShaneBeee Jan 31, 2026
d0f0be3
Docs - add json doc printer and updated SkriptCommand to match
ShaneBeee Jan 31, 2026
6f50fd2
BlockExpresssions - added examples to include 'empty' (Hytale's 'air')
ShaneBeee Jan 31, 2026
1578492
Markdown doc changes
ShaneBeee Jan 31, 2026
dd4a409
TypesAssetStore - add patchline to autoGenMessage
ShaneBeee Jan 31, 2026
5a04f70
Merge branch 'master' into dev/patch
ShaneBeee Jan 31, 2026
cc09874
Add fluid/fluid level expressions
ShaneBeee Jan 31, 2026
dd9a5c5
Block - add some changes
ShaneBeee Jan 31, 2026
b570103
CondHasPermission - some updates
ShaneBeee Jan 31, 2026
a93aafe
Add target block/entity expressions
ShaneBeee Jan 31, 2026
78f7139
Block - add constructor
ShaneBeee Jan 31, 2026
143148e
JsonVariableStorage - fix primitive saving
ShaneBeee Jan 31, 2026
7aad781
JsonVariableStorage - remove debug
ShaneBeee Jan 31, 2026
45f65d6
ExprLocationOf - add Block
ShaneBeee Jan 31, 2026
4674f64
Block - add getLocation
ShaneBeee Jan 31, 2026
9b2b6f3
MouseEvents - make note that this seems to be broken internally
ShaneBeee Jan 31, 2026
a128738
Add some more inventory expressions
ShaneBeee Jan 31, 2026
d6ec4dc
ExprClassInfoOf - get Type (classinfo) instead of class name
ShaneBeee Jan 31, 2026
4f7f4ce
DefaultComparators - add some inventory comparators
ShaneBeee Jan 31, 2026
6c94100
EvtPlayerBreakBlock - change context values
ShaneBeee Jan 31, 2026
0fb7db4
DefaultConverters - add a few converters
ShaneBeee Jan 31, 2026
9130c02
ExprLocationOf - switch to regular Expression since PropertyExpressio…
ShaneBeee Jan 31, 2026
b1e2621
MarkdownDocPrinter - split up variations
ShaneBeee Jan 31, 2026
552648d
DefaultComparators - add item/blocktype comparators
ShaneBeee Feb 1, 2026
71fbf98
EvtEntityDeath - change up context values for items
ShaneBeee Feb 1, 2026
129c43b
Events - change more context values
ShaneBeee Feb 1, 2026
fbb1e1f
Add drop item
ShaneBeee Feb 1, 2026
f7b370d
CondInventoryCanHold - add condition to check if inv can hold items
ShaneBeee Feb 1, 2026
e1a5955
AAdd effect commands (for chat)
ShaneBeee Feb 1, 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 build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {
dependencies {
compileOnly("com.hypixel.hytale:Server:${hytaleVersion}")
compileOnly("org.jetbrains:annotations:26.0.2")
implementation("com.github.SkriptDev:skript-parser:master-SNAPSHOT") {
implementation("com.github.SkriptDev:skript-parser:dev~patch-SNAPSHOT") { // TODO (change after release)
isTransitive = false
}
implementation("com.github.Zoltus:TinyMessage:2.0.1") {
Expand Down
105 changes: 105 additions & 0 deletions src/main/java/com/github/skriptdev/skript/api/hytale/Block.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
package com.github.skriptdev.skript.api.hytale;

import com.hypixel.hytale.component.Ref;
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.fluid.Fluid;
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.ChunkColumn;
import com.hypixel.hytale.server.core.universe.world.chunk.section.FluidSection;
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

/**
* Represents a block in a world.
* Hytale doesn't appear to have a representation of a block in a world.
Expand All @@ -18,12 +29,28 @@ public class Block {
private @NotNull BlockType type;
private final @NotNull Vector3i pos;

public Block(@NotNull World world, @NotNull Vector3i pos) {
this.world = world;
this.pos = pos;
this.type = Objects.requireNonNull(world.getBlockType(pos));
}

public Block(@NotNull World world, @NotNull Vector3i pos, @NotNull BlockType type) {
this.world = world;
this.pos = pos;
this.type = type;
}

public Block(@NotNull Location location) {
World world = Universe.get().getWorld(location.getWorld());
if (world == null) {
throw new IllegalArgumentException("World '" + location.getWorld() + "' not found.");
}
BlockType blockType = world.getBlockType(location.getPosition().toVector3i());
assert blockType != null;
this(world, location.getPosition().toVector3i(), blockType);
}

public @NotNull BlockType getType() {
return this.type;
}
Expand All @@ -33,6 +60,80 @@ public void setType(@NotNull BlockType type) {
this.world.setBlock(this.pos.getX(), this.pos.getY(), this.pos.getZ(), type.getId());
}

public byte getFluidLevel() {
long index = ChunkUtil.indexChunkFromBlock(this.pos.getX(), this.pos.getZ());
Ref<ChunkStore> columnRef = this.world.getChunk(index).getReference();
Store<ChunkStore> store = columnRef.getStore();
ChunkColumn column = store.getComponent(columnRef, ChunkColumn.getComponentType());
Ref<ChunkStore> section = column.getSection(ChunkUtil.chunkCoordinate(this.pos.getY()));
if (section == null) {
return 0;
} else {
FluidSection fluidSection = store.getComponent(section, FluidSection.getComponentType());
return fluidSection.getFluidLevel(this.pos.getX(), this.pos.getY(), this.pos.getZ());
}
}

public void setFluidLevel(byte level) {
long index = ChunkUtil.indexChunkFromBlock(this.pos.getX(), this.pos.getZ());
this.world.getChunkAsync(index).thenApply((chunk) -> {
Ref<ChunkStore> columnRef = chunk.getReference();
Store<ChunkStore> store = columnRef.getStore();
ChunkColumn column = store.getComponent(columnRef, ChunkColumn.getComponentType());
if (column == null) return null;

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


Fluid fluid = fluidSection.getFluid(this.pos.getX(), this.pos.getY(), this.pos.getZ());
if (fluid == null) return null;
fluidSection.setFluid(this.pos.getX(), this.pos.getY(), this.pos.getZ(), fluid, level);
}
return chunk;
});
}

public Fluid getFluid() {
int fluidId = this.world.getFluidId(this.pos.getX(), this.pos.getY(), this.pos.getZ());
if (fluidId == -1) {
return null;
}
return Fluid.getAssetMap().getAsset(fluidId);
}

public void setFluid(@NotNull Fluid fluid) {
long index = ChunkUtil.indexChunkFromBlock(this.pos.getX(), this.pos.getZ());
this.world.getChunkAsync(index).thenApply((chunk) -> {
Ref<ChunkStore> columnRef = chunk.getReference();
Store<ChunkStore> store = columnRef.getStore();
ChunkColumn column = store.getComponent(columnRef, ChunkColumn.getComponentType());
if (column == null) return null;

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


byte level = fluidSection.getFluidLevel(this.pos.getX(), this.pos.getY(), this.pos.getZ());
if (level <= 0) level = 8;
fluidSection.setFluid(this.pos.getX(), this.pos.getY(), this.pos.getZ(), fluid, level);
}
return chunk;
});
}

public void breakBlock() {
int setting = 0; // TODO not sure what to actually use here
this.world.breakBlock(this.pos.getX(), this.pos.getY(), this.pos.getZ(), setting);
Expand All @@ -46,6 +147,10 @@ public void breakBlock() {
return this.pos;
}

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

public String toTypeString() {
return String.format("[%s] block at (%s,%s,%s) in '%s'",
this.type.getId(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), this.world.getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
package com.github.skriptdev.skript.api.hytale;

import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.Holder;
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.server.core.entity.Entity;
import com.hypixel.hytale.server.core.entity.EntityUtils;
import com.hypixel.hytale.server.core.entity.LivingEntity;
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.item.ItemComponent;
import com.hypixel.hytale.server.core.modules.entitystats.EntityStatMap;
import com.hypixel.hytale.server.core.modules.entitystats.EntityStatsModule;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import io.github.syst3ms.skriptparser.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* Quick utility class for accessing entity components.
*/
@SuppressWarnings("UnusedReturnValue")
public class EntityComponentUtils {

/**
Expand All @@ -31,4 +44,43 @@ public class EntityComponentUtils {
return store.getComponent(reference, EntityStatsModule.get().getEntityStatMapComponentType());
}

/**
* Get the MovementStatesComponent of an entity.
*
* @param entity Entity to get component from
* @return MovementStatesComponent of the entity, or null if not found
*/
public static @Nullable MovementStatesComponent getMovementStatesComponent(Entity entity) {
Ref<EntityStore> reference = entity.getReference();
if (reference == null) return null;

Store<EntityStore> store = reference.getStore();
return store.getComponent(reference, MovementStatesComponent.getComponentType());
}

@SuppressWarnings({"DataFlowIssue", "deprecation"})
public static @NotNull Pair<Entity, ItemComponent> dropItem(Store<EntityStore> store, ItemStack itemStack, Location location, Vector3f velocity, float pickupDelay) {
if (itemStack.isEmpty() || !itemStack.isValid()) {
return new Pair<>(null, null);
}

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

Holder<EntityStore> itemEntityHolder = ItemComponent.generateItemDrop(store, itemStack, position, rotation, velocity.getX(), velocity.getY(), velocity.getZ());
if (itemEntityHolder == null) {
return new Pair<>(null, null);
}
;

ItemComponent itemComponent = itemEntityHolder.getComponent(ItemComponent.getComponentType());
if (itemComponent != null) {
itemComponent.setPickupDelay(pickupDelay);
}

store.addEntity(itemEntityHolder, AddReason.SPAWN);

return new Pair<>(EntityUtils.getEntity(itemEntityHolder), itemComponent);
}

}
Loading
Loading