diff --git a/gradle.properties b/gradle.properties index df71095b..94728650 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check https://fabricmc.net/develop/ - minecraft_version=25w06a + minecraft_version=25w07a loader_version=0.16.10 jsr305_version=3.0.2 fabric_version=0.110.5+1.21.4 diff --git a/src/main/java/carpet/script/api/Scoreboards.java b/src/main/java/carpet/script/api/Scoreboards.java index 3e758a70..f903eb0a 100644 --- a/src/main/java/carpet/script/api/Scoreboards.java +++ b/src/main/java/carpet/script/api/Scoreboards.java @@ -26,6 +26,7 @@ import net.minecraft.server.ServerScoreboard; import net.minecraft.server.bossevents.CustomBossEvent; import net.minecraft.server.bossevents.CustomBossEvents; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.StringRepresentable; import net.minecraft.world.BossEvent; import net.minecraft.world.scores.DisplaySlot; import net.minecraft.world.scores.Objective; @@ -579,12 +580,12 @@ public class Scoreboards BossEvent.BossBarColor color = (bossBar).getColor(); return color == null ? Value.NULL : StringValue.of(color.getName()); } - BossEvent.BossBarColor color = BossEvent.BossBarColor.byName(propertyValue.getString()); + BossEvent.BossBarColor color = ((StringRepresentable.EnumCodec)BossEvent.BossBarColor.CODEC).byName(propertyValue.getString()); if (color == null) { return Value.NULL; } - bossBar.setColor(BossEvent.BossBarColor.byName(propertyValue.getString())); + bossBar.setColor(color); return Value.TRUE; } case "max" -> { @@ -662,7 +663,7 @@ public class Scoreboards { return StringValue.of(bossBar.getOverlay().getName()); } - BossEvent.BossBarOverlay style = BossEvent.BossBarOverlay.byName(propertyValue.getString()); + BossEvent.BossBarOverlay style = ((StringRepresentable.EnumCodec)BossEvent.BossBarOverlay.CODEC).byName(propertyValue.getString()); if (style == null) { throw new InternalExpressionException("'" + propertyValue.getString() + "' is not a valid value for property " + property); diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index 5f173ee4..bf000265 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -43,6 +43,7 @@ import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.NbtOps; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.DistanceManager; import net.minecraft.server.level.ServerLevel; @@ -887,7 +888,7 @@ public class WorldAccess ItemStack tool; if (tag != null) { - tool = ItemStack.parseOptional(regs, tag); + tool = ItemStack.CODEC.parse(regs.createSerializationContext(NbtOps.INSTANCE), tag).result().orElse(null); } else { @@ -955,7 +956,7 @@ public class WorldAccess { return Value.NULL; } - return new NBTSerializableValue(() -> tool.saveOptional(regs)); + return new NBTSerializableValue(() -> ItemStack.CODEC.encodeStart(regs.createSerializationContext(NbtOps.INSTANCE), tool).getOrThrow()); }); diff --git a/src/main/java/carpet/script/utils/ShapeDispatcher.java b/src/main/java/carpet/script/utils/ShapeDispatcher.java index 928ec396..5133ab05 100644 --- a/src/main/java/carpet/script/utils/ShapeDispatcher.java +++ b/src/main/java/carpet/script/utils/ShapeDispatcher.java @@ -34,11 +34,13 @@ import net.minecraft.nbt.DoubleTag; import net.minecraft.nbt.FloatTag; import net.minecraft.nbt.IntTag; import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.StringTag; import net.minecraft.nbt.Tag; import net.minecraft.nbt.NumericTag; import net.minecraft.network.chat.Component; +import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; @@ -724,7 +726,7 @@ public class ShapeDispatcher } else { - this.item = ItemStack.parseOptional(regs, ((NBTSerializableValue) options.get("item")).getCompoundTag()); + this.item = ItemStack.CODEC.parse(regs.createSerializationContext(NbtOps.INSTANCE), ((NBTSerializableValue) options.get("item")).getCompoundTag() ).result().orElse(null); } blockLight = NumericValue.asNumber(options.getOrDefault("blocklight", optional.get("blocklight"))).getInt(); if (blockLight > 15) @@ -1661,7 +1663,7 @@ public class ShapeDispatcher public Value validate(Map options, MinecraftServer server, Value value) { ItemStack item = ValueConversions.getItemStackFromValue(value, true, server.registryAccess()); - return new NBTSerializableValue(item.saveOptional(server.registryAccess())); + return new NBTSerializableValue(ItemStack.CODEC.encodeStart(server.registryAccess().createSerializationContext(NbtOps.INSTANCE), item).result().orElse(null)); } @Override diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index 0f30ab68..062a67e1 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -26,8 +26,6 @@ import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.renderer.CoreShaders; -import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; @@ -123,7 +121,7 @@ public class ShapesRenderer } long currentTime = client.level.getGameTime(); RenderSystem.enableDepthTest(); - RenderSystem.setShader(CoreShaders.POSITION_COLOR); + //RenderSystem.setShader(CoreShaders.POSITION_COLOR); RenderSystem.depthFunc(515); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); @@ -619,10 +617,11 @@ public class ShapesRenderer } private static void drawWithShader(MeshData mesh) { - VertexBuffer buffre = mesh.drawState().format().getImmediateDrawVertexBuffer(); - buffre.bind(); - buffre.upload(mesh); - buffre.drawWithShader(RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix(), RenderSystem.getShader()); + RenderType.debugTriangleFan().draw(mesh); + //VertexBuffer buffre = mesh.drawState().format().getImmediateDrawVertexBuffer(); + //buffre.bind(); + //buffre.upload(mesh); + //buffre.drawWithShader(RenderSystem.getModelViewMatrix(), RenderSystem.getProjectionMatrix(), RenderType. RenderSystem.getShader()); } diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index d6a19a1e..801a2e8a 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -530,15 +530,16 @@ public class EntityValue extends Value put("spawn_point", (e, a) -> { if (e instanceof ServerPlayer spe) { - if (spe.getRespawnPosition() == null) + if (spe.getRespawnConfig() == null) { return Value.FALSE; } + ServerPlayer.RespawnConfig spec = spe.getRespawnConfig(); return ListValue.of( - ValueConversions.of(spe.getRespawnPosition()), - ValueConversions.of(spe.getRespawnDimension()), - new NumericValue(spe.getRespawnAngle()), - BooleanValue.of(spe.isRespawnForced()) + ValueConversions.of(spec.pos()), + ValueConversions.of(spec.dimension()), + new NumericValue(spec.angle()), + BooleanValue.of(spec.forced()) ); } return Value.NULL; @@ -1366,7 +1367,7 @@ public class EntityValue extends Value } if (a == null) { - spe.setRespawnPosition(null, null, 0, false, false); + spe.setRespawnPosition(null, false); } else if (a instanceof ListValue lv) { @@ -1389,7 +1390,7 @@ public class EntityValue extends Value } } } - spe.setRespawnPosition(world, pos, angle, forced, false); + spe.setRespawnPosition(new ServerPlayer.RespawnConfig(world, pos, angle, forced), false); } else if (a instanceof BlockValue bv) { @@ -1397,11 +1398,11 @@ public class EntityValue extends Value { throw new InternalExpressionException("block for spawn modification should be localised in the world"); } - spe.setRespawnPosition(bv.getWorld().dimension(), bv.getPos(), e.getYRot(), true, false); // yaw + spe.setRespawnPosition(new ServerPlayer.RespawnConfig(bv.getWorld().dimension(), bv.getPos(), e.getYRot(), true), false); // yaw } else if (a.isNull()) { - spe.setRespawnPosition(null, null, 0, false, false); + spe.setRespawnPosition(null, false); } else { diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index a3258f7c..41535605 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -108,7 +108,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa public static Value fromStack(ItemStack stack, RegistryAccess regs) { NBTSerializableValue value = new NBTSerializableValue(); - value.nbtSupplier = () -> stack.saveOptional(regs); + value.nbtSupplier = () -> ItemStack.CODEC.encodeStart(regs.createSerializationContext(NbtOps.INSTANCE), stack).getOrThrow(); return value; } @@ -346,7 +346,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa public static ItemStack parseItem(String itemString, @Nullable CompoundTag customTag, RegistryAccess regs) { if (customTag != null) { - return ItemStack.parseOptional(regs, customTag); + return ItemStack.CODEC.parse(regs.createSerializationContext(NbtOps.INSTANCE), customTag).resultOrPartial().orElse(null); } try {