Compare commits

..

6 Commits

Author SHA1 Message Date
Julian Krings 31615dc052 improve craftengine data provider for normal blocks 2026-07-06 15:56:29 +02:00
Julian Krings 4ddfd9549f store custom blocks in mantle directly until chunk gen 2026-07-06 15:43:11 +02:00
Julian Krings ed67dd6058 fix not resolving block id properly for craftengine 2026-07-04 14:43:51 +02:00
Julian Krings ee7f54429a fix not finding matching provider in processUpdate phase 2026-07-04 14:43:07 +02:00
Julian Krings 1e0628f768 fix runServer tasks 2026-07-04 14:41:55 +02:00
Julian Krings 72faf76269 update to craftengine 26.5 2026-06-16 12:12:14 +02:00
6 changed files with 54 additions and 30 deletions
@@ -1,5 +1,6 @@
package com.volmit.iris.core.link.data;
import com.volmit.iris.Iris;
import com.volmit.iris.core.link.ExternalDataProvider;
import com.volmit.iris.core.link.Identifier;
import com.volmit.iris.core.nms.container.BlockProperty;
@@ -14,9 +15,9 @@ import net.momirealms.craftengine.bukkit.api.CraftEngineBlocks;
import net.momirealms.craftengine.bukkit.api.CraftEngineFurniture;
import net.momirealms.craftengine.bukkit.api.CraftEngineItems;
import net.momirealms.craftengine.core.block.ImmutableBlockState;
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
import net.momirealms.craftengine.core.block.properties.Property;
import net.momirealms.craftengine.core.block.property.BooleanProperty;
import net.momirealms.craftengine.core.block.property.IntegerProperty;
import net.momirealms.craftengine.core.block.property.Property;
import net.momirealms.craftengine.core.util.Key;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -71,13 +72,35 @@ public class CraftEngineDataProvider extends ExternalDataProvider {
public @NotNull ItemStack getItemStack(@NotNull Identifier itemId, @NotNull KMap<String, Object> customNbt) throws MissingResourceException {
var item = CraftEngineItems.byId(Key.of(itemId.namespace(), itemId.key()));
if (item == null) throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
return item.buildItemStack();
return item.buildBukkitItem();
}
@Override
public @NotNull BlockData getBlockData(@NotNull Identifier blockId, @NotNull KMap<String, String> state) throws MissingResourceException {
var key = Key.of(blockId.namespace(), blockId.key());
if (CraftEngineBlocks.byId(key) == null && CraftEngineFurniture.byId(key) == null)
var customBlock = CraftEngineBlocks.byId(key);
if (customBlock != null) {
ImmutableBlockState blockState = customBlock.defaultState();
for (var entry : state.entrySet()) {
var property = customBlock.getProperty(entry.getKey());
if (property == null) {
Iris.warn("Invalid property %s for block %s", entry.getKey(), key);
continue;
}
var tag = property.optional(entry.getValue());
if (tag.isEmpty()) {
Iris.warn("Invalid property %s=%s for block %s", entry.getKey(), entry.getValue(), key);
continue;
}
blockState = ImmutableBlockState.with(blockState, property, tag.get());
}
return CraftEngineBlocks.getBukkitBlockData(blockState);
}
if (CraftEngineFurniture.byId(key) == null)
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
return IrisCustomData.of(B.getAir(), ExternalDataSVC.buildState(blockId, state));
}
@@ -85,26 +108,14 @@ public class CraftEngineDataProvider extends ExternalDataProvider {
@Override
public void processUpdate(@NotNull Engine engine, @NotNull Block block, @NotNull Identifier blockId) {
var pair = ExternalDataSVC.parseState(blockId);
var key = Key.of(blockId.namespace(), blockId.key());
var state = pair.getB();
blockId = pair.getA();
var customBlock = CraftEngineBlocks.byId(key);
if (customBlock != null) {
ImmutableBlockState blockState = customBlock.defaultState();
for (var entry : state.entrySet()) {
var property = customBlock.getProperty(entry.getKey());
if (property == null) continue;
var tag = property.optional(entry.getValue()).orElse(null);
if (tag == null) continue;
blockState = ImmutableBlockState.with(blockState, property, tag);
}
CraftEngineBlocks.place(block.getLocation(), blockState, false);
return;
}
var key = Key.of(blockId.namespace(), blockId.key());
var furniture = CraftEngineFurniture.byId(key);
if (furniture == null) return;
if (furniture == null)
return;
var location = parseYawAndPitch(engine, block, state);
String variant = state.getOrDefault("variant", furniture.anyVariantName());
CraftEngineFurniture.place(location, furniture, variant, false);
@@ -135,7 +135,8 @@ public class ExternalDataSVC implements IrisService {
}
public void processUpdate(Engine engine, Block block, Identifier blockId) {
Optional<ExternalDataProvider> provider = activeProviders.stream().filter(p -> p.isValidProvider(blockId, DataType.BLOCK)).findFirst();
Identifier mod = stripState(blockId);
Optional<ExternalDataProvider> provider = activeProviders.stream().filter(p -> p.isValidProvider(mod, DataType.BLOCK)).findFirst();
if (provider.isEmpty()) {
Iris.warn("No matching Provider found for modded material \"%s\"!", blockId);
return;
@@ -183,6 +184,16 @@ public class ExternalDataSVC implements IrisService {
return new Pair<>(new Identifier(key.namespace(), key.key().split("\\Q[\\E")[0]), stateMap);
}
private static Identifier stripState(Identifier key) {
if (!key.key().contains("[") || !key.key().contains("]"))
return key;
return new Identifier(
key.namespace(),
key.key().split("\\Q[\\E")[0]
);
}
public static Identifier buildState(Identifier key, KMap<String, String> state) {
if (state.isEmpty()) {
return key;
@@ -35,6 +35,7 @@ import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.function.Function3;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.mantle.MantleChunk;
import com.volmit.iris.util.mantle.flag.MantleFlag;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.matter.MatterCavern;
@@ -209,10 +210,10 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
@Override
public void set(int x, int y, int z, BlockData d) {
if (d instanceof IrisCustomData data) {
setData(x, y, z, data.getBase());
setData(x, y, z, data.getCustom());
} else setData(x, y, z, d);
setData(x, y, z, d);
if (d instanceof IrisCustomData) {
acquireChunk(x >> 4, z >> 4).flag(MantleFlag.CUSTOM_ACTIVE, true);
}
}
@Override
@@ -29,6 +29,7 @@ public interface IrisCustomData extends BlockData {
yield false;
yield base.matches(store.getBase()) && custom.equals(store.getCustom());
}
case "getAsString" -> custom.toString();
case "equals" -> {
if (!(args[0] instanceof IrisCustomData store))
yield false;
+2 -2
View File
@@ -7,7 +7,7 @@
shadow = "9.0.0-rc1" # https://plugins.gradle.org/plugin/com.gradleup.shadow
slimjar = "2.1.5" # https://plugins.gradle.org/plugin/de.crazydev22.slimjar
download = "5.6.0" # https://plugins.gradle.org/plugin/de.undercouch.download
runPaper = "2.3.1" # https://plugins.gradle.org/plugin/xyz.jpenilla.run-paper
runPaper = "3.0.2" # https://plugins.gradle.org/plugin/xyz.jpenilla.run-paper
sentryPlugin = "5.8.0" # https://github.com/getsentry/sentry-android-gradle-plugin
grgit = "5.3.2" # https://github.com/ajoberstar/grgit
@@ -55,7 +55,7 @@ mythic = "5.9.5"
mythic-chrucible = "2.1.0"
kgenerators = "7.3" # https://repo.codemc.io/repository/maven-public/me/kryniowesegryderiusz/kgenerators-core/maven-metadata.xml
multiverseCore = "5.1.0"
craftengine = "0.0.67" # https://github.com/Xiao-MoMi/craft-engine/releases
craftengine = "26.5" # https://github.com/Xiao-MoMi/craft-engine/releases
[libraries]
# Core Libraries
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME