mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-07-24 07:40:56 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 31615dc052 | |||
| 4ddfd9549f | |||
| ed67dd6058 | |||
| ee7f54429a | |||
| 1e0628f768 | |||
| 72faf76269 |
@@ -1,5 +1,6 @@
|
|||||||
package com.volmit.iris.core.link.data;
|
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.ExternalDataProvider;
|
||||||
import com.volmit.iris.core.link.Identifier;
|
import com.volmit.iris.core.link.Identifier;
|
||||||
import com.volmit.iris.core.nms.container.BlockProperty;
|
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.CraftEngineFurniture;
|
||||||
import net.momirealms.craftengine.bukkit.api.CraftEngineItems;
|
import net.momirealms.craftengine.bukkit.api.CraftEngineItems;
|
||||||
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
import net.momirealms.craftengine.core.block.ImmutableBlockState;
|
||||||
import net.momirealms.craftengine.core.block.properties.BooleanProperty;
|
import net.momirealms.craftengine.core.block.property.BooleanProperty;
|
||||||
import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
import net.momirealms.craftengine.core.block.property.IntegerProperty;
|
||||||
import net.momirealms.craftengine.core.block.properties.Property;
|
import net.momirealms.craftengine.core.block.property.Property;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
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 {
|
public @NotNull ItemStack getItemStack(@NotNull Identifier itemId, @NotNull KMap<String, Object> customNbt) throws MissingResourceException {
|
||||||
var item = CraftEngineItems.byId(Key.of(itemId.namespace(), itemId.key()));
|
var item = CraftEngineItems.byId(Key.of(itemId.namespace(), itemId.key()));
|
||||||
if (item == null) throw new MissingResourceException("Failed to find ItemData!", 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
|
@Override
|
||||||
public @NotNull BlockData getBlockData(@NotNull Identifier blockId, @NotNull KMap<String, String> state) throws MissingResourceException {
|
public @NotNull BlockData getBlockData(@NotNull Identifier blockId, @NotNull KMap<String, String> state) throws MissingResourceException {
|
||||||
var key = Key.of(blockId.namespace(), blockId.key());
|
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());
|
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
|
||||||
return IrisCustomData.of(B.getAir(), ExternalDataSVC.buildState(blockId, state));
|
return IrisCustomData.of(B.getAir(), ExternalDataSVC.buildState(blockId, state));
|
||||||
}
|
}
|
||||||
@@ -85,26 +108,14 @@ public class CraftEngineDataProvider extends ExternalDataProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void processUpdate(@NotNull Engine engine, @NotNull Block block, @NotNull Identifier blockId) {
|
public void processUpdate(@NotNull Engine engine, @NotNull Block block, @NotNull Identifier blockId) {
|
||||||
var pair = ExternalDataSVC.parseState(blockId);
|
var pair = ExternalDataSVC.parseState(blockId);
|
||||||
var key = Key.of(blockId.namespace(), blockId.key());
|
|
||||||
var state = pair.getB();
|
var state = pair.getB();
|
||||||
|
blockId = pair.getA();
|
||||||
|
|
||||||
var customBlock = CraftEngineBlocks.byId(key);
|
var key = Key.of(blockId.namespace(), blockId.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 furniture = CraftEngineFurniture.byId(key);
|
var furniture = CraftEngineFurniture.byId(key);
|
||||||
if (furniture == null) return;
|
if (furniture == null)
|
||||||
|
return;
|
||||||
|
|
||||||
var location = parseYawAndPitch(engine, block, state);
|
var location = parseYawAndPitch(engine, block, state);
|
||||||
String variant = state.getOrDefault("variant", furniture.anyVariantName());
|
String variant = state.getOrDefault("variant", furniture.anyVariantName());
|
||||||
CraftEngineFurniture.place(location, furniture, variant, false);
|
CraftEngineFurniture.place(location, furniture, variant, false);
|
||||||
|
|||||||
@@ -135,7 +135,8 @@ public class ExternalDataSVC implements IrisService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void processUpdate(Engine engine, Block block, Identifier blockId) {
|
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()) {
|
if (provider.isEmpty()) {
|
||||||
Iris.warn("No matching Provider found for modded material \"%s\"!", blockId);
|
Iris.warn("No matching Provider found for modded material \"%s\"!", blockId);
|
||||||
return;
|
return;
|
||||||
@@ -183,6 +184,16 @@ public class ExternalDataSVC implements IrisService {
|
|||||||
return new Pair<>(new Identifier(key.namespace(), key.key().split("\\Q[\\E")[0]), stateMap);
|
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) {
|
public static Identifier buildState(Identifier key, KMap<String, String> state) {
|
||||||
if (state.isEmpty()) {
|
if (state.isEmpty()) {
|
||||||
return key;
|
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.function.Function3;
|
||||||
import com.volmit.iris.util.mantle.Mantle;
|
import com.volmit.iris.util.mantle.Mantle;
|
||||||
import com.volmit.iris.util.mantle.MantleChunk;
|
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.math.RNG;
|
||||||
import com.volmit.iris.util.matter.Matter;
|
import com.volmit.iris.util.matter.Matter;
|
||||||
import com.volmit.iris.util.matter.MatterCavern;
|
import com.volmit.iris.util.matter.MatterCavern;
|
||||||
@@ -209,10 +210,10 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(int x, int y, int z, BlockData d) {
|
public void set(int x, int y, int z, BlockData d) {
|
||||||
if (d instanceof IrisCustomData data) {
|
setData(x, y, z, d);
|
||||||
setData(x, y, z, data.getBase());
|
if (d instanceof IrisCustomData) {
|
||||||
setData(x, y, z, data.getCustom());
|
acquireChunk(x >> 4, z >> 4).flag(MantleFlag.CUSTOM_ACTIVE, true);
|
||||||
} else setData(x, y, z, d);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public interface IrisCustomData extends BlockData {
|
|||||||
yield false;
|
yield false;
|
||||||
yield base.matches(store.getBase()) && custom.equals(store.getCustom());
|
yield base.matches(store.getBase()) && custom.equals(store.getCustom());
|
||||||
}
|
}
|
||||||
|
case "getAsString" -> custom.toString();
|
||||||
case "equals" -> {
|
case "equals" -> {
|
||||||
if (!(args[0] instanceof IrisCustomData store))
|
if (!(args[0] instanceof IrisCustomData store))
|
||||||
yield false;
|
yield false;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
shadow = "9.0.0-rc1" # https://plugins.gradle.org/plugin/com.gradleup.shadow
|
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
|
slimjar = "2.1.5" # https://plugins.gradle.org/plugin/de.crazydev22.slimjar
|
||||||
download = "5.6.0" # https://plugins.gradle.org/plugin/de.undercouch.download
|
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
|
sentryPlugin = "5.8.0" # https://github.com/getsentry/sentry-android-gradle-plugin
|
||||||
grgit = "5.3.2" # https://github.com/ajoberstar/grgit
|
grgit = "5.3.2" # https://github.com/ajoberstar/grgit
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ mythic = "5.9.5"
|
|||||||
mythic-chrucible = "2.1.0"
|
mythic-chrucible = "2.1.0"
|
||||||
kgenerators = "7.3" # https://repo.codemc.io/repository/maven-public/me/kryniowesegryderiusz/kgenerators-core/maven-metadata.xml
|
kgenerators = "7.3" # https://repo.codemc.io/repository/maven-public/me/kryniowesegryderiusz/kgenerators-core/maven-metadata.xml
|
||||||
multiverseCore = "5.1.0"
|
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]
|
[libraries]
|
||||||
# Core Libraries
|
# Core Libraries
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
Reference in New Issue
Block a user