diff --git a/buildSrc/src/main/kotlin/cc/tweaked/gradle/ForgeExtensions.kt b/buildSrc/src/main/kotlin/cc/tweaked/gradle/ForgeExtensions.kt
index 9fca2ce6c..232b86d84 100644
--- a/buildSrc/src/main/kotlin/cc/tweaked/gradle/ForgeExtensions.kt
+++ b/buildSrc/src/main/kotlin/cc/tweaked/gradle/ForgeExtensions.kt
@@ -31,9 +31,9 @@ fun JavaExec.setRunConfig(config: Run) {
environment(config.environmentVariables.get())
systemProperties(config.systemProperties.get())
- config.modSources.get().forEach { classpath(it.runtimeClasspath) }
+ config.modSources.all().get().values().forEach { classpath(it.runtimeClasspath) }
classpath(config.classpath)
- classpath(config.dependencies.get().configuration)
+ classpath(config.dependencies.get().runtimeConfiguration)
(config as RunImpl).taskDependencies.forEach { dependsOn(it) }
diff --git a/gradle.properties b/gradle.properties
index 9d1b2e86a..1f95e3f29 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -8,9 +8,11 @@ org.gradle.parallel=true
kotlin.stdlib.default.dependency=false
kotlin.jvm.target.validation.mode=error
+neogradle.subsystems.conventions.runs.enabled=false
+
# Mod properties
isUnstable=true
modVersion=1.111.0
# Minecraft properties: We want to configure this here so we can read it in settings.gradle
-mcVersion=1.20.6
+mcVersion=1.21
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 3c4aa1f50..a0e738f2e 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -7,14 +7,14 @@
# Minecraft
# MC version is specified in gradle.properties, as we need that in settings.gradle.
# Remember to update corresponding versions in fabric.mod.json/neoforge.mods.toml
-fabric-api = "0.98.0+1.20.6"
-fabric-loader = "0.15.10"
-neoForge = "20.6.48-beta"
+fabric-api = "0.100.3+1.21"
+fabric-loader = "0.15.11"
+neoForge = "21.0.21-beta"
neoForgeSpi = "8.0.1"
mixin = "0.8.5"
-parchment = "2024.05.01"
+parchment = "2024.06.16"
parchmentMc = "1.20.6"
-yarn = "1.20.6+build.1"
+yarn = "1.21+build.1"
# Core dependencies (these versions are tied to the version Minecraft uses)
fastutil = "8.5.12"
@@ -36,14 +36,14 @@ kotlin-coroutines = "1.7.3"
nightConfig = "3.6.7"
# Minecraft mods
-emi = "1.1.5+1.20.6"
+emi = "1.1.7+1.21"
fabricPermissions = "0.3.1"
iris = "1.6.14+1.20.4"
-jei = "17.3.0.48"
-modmenu = "9.0.0"
+jei = "19.0.0.1"
+modmenu = "11.0.0-rc.4"
moreRed = "4.0.0.4"
oculus = "1.2.5"
-rei = "15.0.728"
+rei = "16.0.729"
rubidium = "0.6.1"
sodium = "mc1.20-0.4.10"
mixinExtra = "0.3.5"
@@ -67,7 +67,7 @@ ideaExt = "1.1.7"
illuaminate = "0.1.0-73-g43ee16c"
lwjgl = "3.3.3"
minotaur = "2.8.7"
-neoGradle = "7.0.116"
+neoGradle = "7.0.145"
nullAway = "0.10.25"
spotless = "6.23.3"
taskTree = "2.1.1"
@@ -106,9 +106,9 @@ fabric-junit = { module = "net.fabricmc:fabric-loader-junit", version.ref = "fab
fabricPermissions = { module = "me.lucko:fabric-permissions-api", version.ref = "fabricPermissions" }
emi = { module = "dev.emi:emi-xplat-mojmap", version.ref = "emi" }
iris = { module = "maven.modrinth:iris", version.ref = "iris" }
-jei-api = { module = "mezz.jei:jei-1.20.4-common-api", version.ref = "jei" }
-jei-fabric = { module = "mezz.jei:jei-1.20.4-fabric", version.ref = "jei" }
-jei-forge = { module = "mezz.jei:jei-1.20.4-forge", version.ref = "jei" }
+jei-api = { module = "mezz.jei:jei-1.21-common-api", version.ref = "jei" }
+jei-fabric = { module = "mezz.jei:jei-1.21-fabric", version.ref = "jei" }
+jei-forge = { module = "mezz.jei:jei-1.21-neoforge", version.ref = "jei" }
mixin = { module = "org.spongepowered:mixin", version.ref = "mixin" }
mixinExtra = { module = "io.github.llamalad7:mixinextras-common", version.ref = "mixinExtra" }
modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" }
@@ -179,9 +179,9 @@ kotlin = ["kotlin-stdlib", "kotlin-coroutines"]
# Minecraft
externalMods-common = ["jei-api", "nightConfig-core", "nightConfig-toml"]
externalMods-forge-compile = ["moreRed", "oculus", "jei-api"]
-externalMods-forge-runtime = []
+externalMods-forge-runtime = ["jei-forge"]
externalMods-fabric-compile = ["fabricPermissions", "iris", "jei-api", "rei-api", "rei-builtin"]
-externalMods-fabric-runtime = [] # ["jei-fabric", "modmenu"]
+externalMods-fabric-runtime = ["jei-fabric", "modmenu"]
# Testing
test = ["junit-jupiter-api", "junit-jupiter-params", "hamcrest", "jqwik-api"]
diff --git a/projects/common-api/src/client/java/dan200/computercraft/api/client/ModelLocation.java b/projects/common-api/src/client/java/dan200/computercraft/api/client/ModelLocation.java
new file mode 100644
index 000000000..0376fb786
--- /dev/null
+++ b/projects/common-api/src/client/java/dan200/computercraft/api/client/ModelLocation.java
@@ -0,0 +1,84 @@
+// SPDX-FileCopyrightText: 2024 The CC: Tweaked Developers
+//
+// SPDX-License-Identifier: MPL-2.0
+
+package dan200.computercraft.api.client;
+
+import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller;
+import dan200.computercraft.impl.client.ClientPlatformHelper;
+import net.minecraft.client.resources.model.BakedModel;
+import net.minecraft.client.resources.model.ModelManager;
+import net.minecraft.client.resources.model.ModelResourceLocation;
+import net.minecraft.resources.ResourceLocation;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.stream.Stream;
+
+/**
+ * The location of a model to load. This may either be:
+ *
+ *
+ * - A {@link ModelResourceLocation}, referencing an already baked model (such as {@code minecraft:dirt#inventory}).
+ * -
+ * A {@link ResourceLocation}, referencing a path to a model resource (such as {@code minecraft:item/dirt}.
+ * These models will be baked and stored in the {@link ModelManager} in a loader-specific way.
+ *
+ *
+ */
+public final class ModelLocation {
+ /**
+ * The location of the model.
+ *
+ * When {@link #resourceLocation} is null, this is the location of the model to load. When {@link #resourceLocation}
+ * is non-null, this is the "standalone" variant of the model resource — this is used by NeoForge's implementation
+ * of {@link ClientPlatformHelper#getModel(ModelManager, ModelResourceLocation, ResourceLocation)} to fetch the
+ * model from the model manger. It is not used on Fabric.
+ */
+ private final ModelResourceLocation modelLocation;
+ private final @Nullable ResourceLocation resourceLocation;
+
+ private ModelLocation(ModelResourceLocation modelLocation, @Nullable ResourceLocation resourceLocation) {
+ this.modelLocation = modelLocation;
+ this.resourceLocation = resourceLocation;
+ }
+
+ /**
+ * Create a {@link ModelLocation} from model in the model manager.
+ *
+ * @param location The name of the model to load.
+ * @return The new {@link ModelLocation} instance.
+ */
+ public static ModelLocation ofModel(ModelResourceLocation location) {
+ return new ModelLocation(location, null);
+ }
+
+ /**
+ * Create a {@link ModelLocation} from a resource.
+ *
+ * @param location The location of the model resource, such as {@code minecraft:item/dirt}.
+ * @return The new {@link ModelLocation} instance.
+ */
+ public static ModelLocation ofResource(ResourceLocation location) {
+ return new ModelLocation(new ModelResourceLocation(location, "standalone"), location);
+ }
+
+ /**
+ * Get this model from the provided model manager.
+ *
+ * @param manager The model manger.
+ * @return This model, or the missing model if it could not be found.
+ */
+ public BakedModel getModel(ModelManager manager) {
+ return ClientPlatformHelper.get().getModel(manager, modelLocation, resourceLocation);
+ }
+
+ /**
+ * Get the models this model location depends on.
+ *
+ * @return A list of models that this model location depends on.
+ * @see TurtleUpgradeModeller#getDependencies()
+ */
+ public Stream getDependencies() {
+ return resourceLocation == null ? Stream.empty() : Stream.of(resourceLocation);
+ }
+}
diff --git a/projects/common-api/src/client/java/dan200/computercraft/api/client/TransformedModel.java b/projects/common-api/src/client/java/dan200/computercraft/api/client/TransformedModel.java
index d3b58e9a0..a632920b4 100644
--- a/projects/common-api/src/client/java/dan200/computercraft/api/client/TransformedModel.java
+++ b/projects/common-api/src/client/java/dan200/computercraft/api/client/TransformedModel.java
@@ -13,30 +13,47 @@ import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
-import java.util.Objects;
-
/**
* A model to render, combined with a transformation matrix to apply.
+ *
+ * @param model The model.
+ * @param matrix The transformation matrix.
*/
-public final class TransformedModel {
- private final BakedModel model;
- private final Transformation matrix;
-
- public TransformedModel(BakedModel model, Transformation matrix) {
- this.model = Objects.requireNonNull(model);
- this.matrix = Objects.requireNonNull(matrix);
- }
-
+public record TransformedModel(BakedModel model, Transformation matrix) {
public TransformedModel(BakedModel model) {
- this.model = Objects.requireNonNull(model);
- matrix = Transformation.identity();
+ this(model, Transformation.identity());
}
+ /**
+ * Look up a model in the model bakery and construct a {@link TransformedModel} with no transformation.
+ *
+ * @param location The location of the model to load.
+ * @return The new {@link TransformedModel} instance.
+ */
+ public static TransformedModel of(ModelLocation location) {
+ var modelManager = Minecraft.getInstance().getModelManager();
+ return new TransformedModel(location.getModel(modelManager));
+ }
+
+ /**
+ * Look up a model in the model bakery and construct a {@link TransformedModel} with no transformation.
+ *
+ * @param location The location of the model to load.
+ * @return The new {@link TransformedModel} instance.
+ * @see ModelLocation#ofModel(ModelResourceLocation)
+ */
public static TransformedModel of(ModelResourceLocation location) {
var modelManager = Minecraft.getInstance().getModelManager();
return new TransformedModel(modelManager.getModel(location));
}
+ /**
+ * Look up a model in the model bakery and construct a {@link TransformedModel} with no transformation.
+ *
+ * @param location The location of the model to load.
+ * @return The new {@link TransformedModel} instance.
+ * @see ModelLocation#ofResource(ResourceLocation)
+ */
public static TransformedModel of(ResourceLocation location) {
var modelManager = Minecraft.getInstance().getModelManager();
return new TransformedModel(ClientPlatformHelper.get().getModel(modelManager, location));
@@ -46,12 +63,4 @@ public final class TransformedModel {
var model = Minecraft.getInstance().getItemRenderer().getItemModelShaper().getItemModel(item);
return new TransformedModel(model, transform);
}
-
- public BakedModel getModel() {
- return model;
- }
-
- public Transformation getMatrix() {
- return matrix;
- }
}
diff --git a/projects/common-api/src/client/java/dan200/computercraft/api/client/turtle/TurtleUpgradeModeller.java b/projects/common-api/src/client/java/dan200/computercraft/api/client/turtle/TurtleUpgradeModeller.java
index f927547b0..4adfc8d91 100644
--- a/projects/common-api/src/client/java/dan200/computercraft/api/client/turtle/TurtleUpgradeModeller.java
+++ b/projects/common-api/src/client/java/dan200/computercraft/api/client/turtle/TurtleUpgradeModeller.java
@@ -4,6 +4,7 @@
package dan200.computercraft.api.client.turtle;
+import dan200.computercraft.api.client.ModelLocation;
import dan200.computercraft.api.client.TransformedModel;
import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
@@ -77,6 +78,18 @@ public interface TurtleUpgradeModeller {
* @return The constructed modeller.
*/
static TurtleUpgradeModeller sided(ResourceLocation left, ResourceLocation right) {
+ return sided(ModelLocation.ofResource(left), ModelLocation.ofResource(right));
+ }
+
+ /**
+ * Construct a {@link TurtleUpgradeModeller} which has a single model for the left and right side.
+ *
+ * @param left The model to use on the left.
+ * @param right The model to use on the right.
+ * @param The type of the turtle upgrade.
+ * @return The constructed modeller.
+ */
+ static TurtleUpgradeModeller sided(ModelLocation left, ModelLocation right) {
return new TurtleUpgradeModeller<>() {
@Override
public TransformedModel getModel(T upgrade, @Nullable ITurtleAccess turtle, TurtleSide side, DataComponentPatch data) {
@@ -85,7 +98,7 @@ public interface TurtleUpgradeModeller {
@Override
public Stream getDependencies() {
- return Stream.of(left, right);
+ return Stream.of(left, right).flatMap(ModelLocation::getDependencies);
}
};
}
diff --git a/projects/common-api/src/client/java/dan200/computercraft/impl/client/ClientPlatformHelper.java b/projects/common-api/src/client/java/dan200/computercraft/impl/client/ClientPlatformHelper.java
index 2f79ed05d..7d104c0a3 100644
--- a/projects/common-api/src/client/java/dan200/computercraft/impl/client/ClientPlatformHelper.java
+++ b/projects/common-api/src/client/java/dan200/computercraft/impl/client/ClientPlatformHelper.java
@@ -4,6 +4,7 @@
package dan200.computercraft.impl.client;
+import dan200.computercraft.api.client.ModelLocation;
import dan200.computercraft.impl.Services;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.resources.model.BakedModel;
@@ -17,13 +18,28 @@ import javax.annotation.Nullable;
@ApiStatus.Internal
public interface ClientPlatformHelper {
/**
- * Equivalent to {@link ModelManager#getModel(ModelResourceLocation)} but for arbitrary {@link ResourceLocation}s.
+ * Get a model from a resource.
*
- * @param manager The model manager.
- * @param location The model location.
+ * @param manager The model manager.
+ * @param resourceLocation The model resourceLocation.
* @return The baked model.
+ * @see ModelLocation
*/
- BakedModel getModel(ModelManager manager, ResourceLocation location);
+ BakedModel getModel(ModelManager manager, ResourceLocation resourceLocation);
+
+ /**
+ * Set a model from a {@link ModelResourceLocation} or {@link ResourceLocation}.
+ *
+ * This is largely equivalent to {@code resourceLocation == null ? manager.getModel(modelLocation) : getModel(manager, resourceLocation)},
+ * but allows pre-computing {@code modelLocation} (if needed).
+ *
+ * @param manager The model manager.
+ * @param modelLocation The location of the model to load.
+ * @param resourceLocation The location of the resource, if trying to load from a resource.
+ * @return The baked model.
+ * @see ModelLocation
+ */
+ BakedModel getModel(ModelManager manager, ModelResourceLocation modelLocation, @Nullable ResourceLocation resourceLocation);
/**
* Wrap this model in a version which renders a foil/enchantment glint.
diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/ComputerCraftTags.java b/projects/common-api/src/main/java/dan200/computercraft/api/ComputerCraftTags.java
index 469e12407..042ea59c1 100644
--- a/projects/common-api/src/main/java/dan200/computercraft/api/ComputerCraftTags.java
+++ b/projects/common-api/src/main/java/dan200/computercraft/api/ComputerCraftTags.java
@@ -46,7 +46,7 @@ public class ComputerCraftTags {
public static final TagKey- DYEABLE = make("dyeable");
private static TagKey
- make(String name) {
- return TagKey.create(Registries.ITEM, new ResourceLocation(ComputerCraftAPI.MOD_ID, name));
+ return TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, name));
}
}
@@ -91,7 +91,7 @@ public class ComputerCraftTags {
public static final TagKey TURTLE_CAN_USE = make("turtle_can_use");
private static TagKey make(String name) {
- return TagKey.create(Registries.BLOCK, new ResourceLocation(ComputerCraftAPI.MOD_ID, name));
+ return TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, name));
}
}
}
diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/media/IMedia.java b/projects/common-api/src/main/java/dan200/computercraft/api/media/IMedia.java
index 045698aaa..1417a8e2f 100644
--- a/projects/common-api/src/main/java/dan200/computercraft/api/media/IMedia.java
+++ b/projects/common-api/src/main/java/dan200/computercraft/api/media/IMedia.java
@@ -7,11 +7,13 @@ package dan200.computercraft.api.media;
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.filesystem.Mount;
import dan200.computercraft.api.filesystem.WritableMount;
+import net.minecraft.core.Holder;
+import net.minecraft.core.HolderLookup;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
-import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.JukeboxSong;
import javax.annotation.Nullable;
@@ -25,11 +27,12 @@ public interface IMedia {
/**
* Get a string representing the label of this item. Will be called via {@code disk.getLabel()} in lua.
*
- * @param stack The {@link ItemStack} to inspect.
+ * @param registries The currently loaded registries.
+ * @param stack The {@link ItemStack} to inspect.
* @return The label. ie: "Dan's Programs".
*/
@Nullable
- String getLabel(ItemStack stack);
+ String getLabel(HolderLookup.Provider registries, ItemStack stack);
/**
* Set a string representing the label of this item. Will be called vi {@code disk.setLabel()} in lua.
@@ -43,26 +46,15 @@ public interface IMedia {
}
/**
- * If this disk represents an item with audio (like a record), get the readable name of the audio track. ie:
- * "Jonathan Coulton - Still Alive"
+ * If this disk represents an item with audio (like a record), get the corresponding {@link JukeboxSong}.
*
- * @param stack The {@link ItemStack} to modify.
- * @return The name, or null if this item does not represent an item with audio.
+ * @param registries The currently loaded registries.
+ * @param stack The {@link ItemStack} to query.
+ * @return The song, or null if this item does not represent an item with audio.
*/
@Nullable
- default String getAudioTitle(ItemStack stack) {
- return null;
- }
-
- /**
- * If this disk represents an item with audio (like a record), get the resource name of the audio track to play.
- *
- * @param stack The {@link ItemStack} to modify.
- * @return The name, or null if this item does not represent an item with audio.
- */
- @Nullable
- default SoundEvent getAudio(ItemStack stack) {
- return null;
+ default Holder getAudio(HolderLookup.Provider registries, ItemStack stack) {
+ return JukeboxSong.fromStack(registries, stack).orElse(null);
}
/**
diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java b/projects/common-api/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java
index 7cfe90407..1b3c9c42f 100644
--- a/projects/common-api/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java
+++ b/projects/common-api/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java
@@ -48,7 +48,7 @@ import javax.annotation.Nullable;
* }
*/
public interface IPocketUpgrade extends UpgradeBase {
- ResourceKey> REGISTRY = ResourceKey.createRegistryKey(new ResourceLocation(ComputerCraftAPI.MOD_ID, "pocket_upgrade"));
+ ResourceKey> REGISTRY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "pocket_upgrade"));
/**
* The registry key for pocket upgrade types.
diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java
index b5b138343..4241d501a 100644
--- a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java
+++ b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java
@@ -57,7 +57,7 @@ public interface ITurtleUpgrade extends UpgradeBase {
/**
* The registry in which turtle upgrades are stored.
*/
- ResourceKey> REGISTRY = ResourceKey.createRegistryKey(new ResourceLocation(ComputerCraftAPI.MOD_ID, "turtle_upgrade"));
+ ResourceKey> REGISTRY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "turtle_upgrade"));
/**
* Create a {@link ResourceKey} for a turtle upgrade given a {@link ResourceLocation}.
diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleToolBuilder.java b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleToolBuilder.java
index 735718bf1..485dad265 100644
--- a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleToolBuilder.java
+++ b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleToolBuilder.java
@@ -35,7 +35,7 @@ import java.util.Optional;
* import net.minecraft.world.item.Items;
*
* public void registerTool(BootstrapContext upgrades) {
- * TurtleToolBuilder.tool(new ResourceLocation("my_mod", "wooden_pickaxe"), Items.WOODEN_PICKAXE).register(upgrades);
+ * TurtleToolBuilder.tool(ResourceLocation.fromNamespaceAndPath("my_mod", "wooden_pickaxe"), Items.WOODEN_PICKAXE).register(upgrades);
* }
*}
*/
diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeType.java b/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeType.java
index 0d6781e4b..268ae5e2a 100644
--- a/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeType.java
+++ b/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeType.java
@@ -55,7 +55,7 @@ import java.util.function.Function;
* public void generate(DataGenerator.PackGenerator output, CompletableFuture registries) {
* var newRegistries = RegistryPatchGenerator.createLookup(registries, Util.make(new RegistrySetBuilder(), builder -> {
* builder.add(ITurtleUpgrade.REGISTRY, upgrades -> {
- * upgrades.register(ITurtleUpgrade.createKey(new ResourceLocation("my_mod", "my_upgrade")), new MyUpgrade());
+ * upgrades.register(ITurtleUpgrade.createKey(ResourceLocation.fromNamespaceAndPath("my_mod", "my_upgrade")), new MyUpgrade());
* });
* }));
* output.addProvider(o -> new DatapackBuiltinEntriesProvider(o, newRegistries, Set.of("my_mod")));
diff --git a/projects/common/src/client/java/dan200/computercraft/client/ClientRegistry.java b/projects/common/src/client/java/dan200/computercraft/client/ClientRegistry.java
index 3aeb87644..ddc566f17 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/ClientRegistry.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/ClientRegistry.java
@@ -118,12 +118,12 @@ public final class ClientRegistry {
public static void registerTurtleModellers(RegisterTurtleUpgradeModeller register) {
register.register(ModRegistry.TurtleUpgradeTypes.SPEAKER.get(), TurtleUpgradeModeller.sided(
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_speaker_left"),
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_speaker_right")
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_speaker_left"),
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_speaker_right")
));
register.register(ModRegistry.TurtleUpgradeTypes.WORKBENCH.get(), TurtleUpgradeModeller.sided(
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table_left"),
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table_right")
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table_left"),
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table_right")
));
register.register(ModRegistry.TurtleUpgradeTypes.WIRELESS_MODEM.get(), new TurtleModemModeller());
register.register(ModRegistry.TurtleUpgradeTypes.TOOL.get(), TurtleUpgradeModeller.flatItem());
@@ -131,7 +131,7 @@ public final class ClientRegistry {
@SafeVarargs
private static void registerItemProperty(RegisterItemProperty itemProperties, String name, ClampedItemPropertyFunction getter, Supplier extends Item>... items) {
- var id = new ResourceLocation(ComputerCraftAPI.MOD_ID, name);
+ var id = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, name);
for (var item : items) itemProperties.register(item.get(), id, getter);
}
@@ -155,7 +155,7 @@ public final class ClientRegistry {
};
public static void registerExtraModels(Consumer register) {
- for (var model : EXTRA_MODELS) register.accept(new ResourceLocation(ComputerCraftAPI.MOD_ID, model));
+ for (var model : EXTRA_MODELS) register.accept(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, model));
TurtleUpgradeModellers.getDependencies().forEach(register);
}
diff --git a/projects/common/src/client/java/dan200/computercraft/client/gui/DiskDriveScreen.java b/projects/common/src/client/java/dan200/computercraft/client/gui/DiskDriveScreen.java
index 86fcbba52..70a8ed8db 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/gui/DiskDriveScreen.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/gui/DiskDriveScreen.java
@@ -15,7 +15,7 @@ import net.minecraft.world.entity.player.Inventory;
* The GUI for disk drives.
*/
public class DiskDriveScreen extends AbstractContainerScreen {
- private static final ResourceLocation BACKGROUND = new ResourceLocation("computercraft", "textures/gui/disk_drive.png");
+ private static final ResourceLocation BACKGROUND = ResourceLocation.fromNamespaceAndPath("computercraft", "textures/gui/disk_drive.png");
public DiskDriveScreen(DiskDriveMenu container, Inventory player, Component title) {
super(container, player, title);
diff --git a/projects/common/src/client/java/dan200/computercraft/client/gui/GuiSprites.java b/projects/common/src/client/java/dan200/computercraft/client/gui/GuiSprites.java
index 63b152dfe..e6025c221 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/gui/GuiSprites.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/gui/GuiSprites.java
@@ -21,7 +21,7 @@ import java.util.stream.Stream;
* Sprite sheet for all GUI texutres in the mod.
*/
public final class GuiSprites extends TextureAtlasHolder {
- public static final ResourceLocation SPRITE_SHEET = new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui");
+ public static final ResourceLocation SPRITE_SHEET = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui");
public static final ResourceLocation TEXTURE = SPRITE_SHEET.withPath(x -> "textures/atlas/" + x + ".png");
public static final ButtonTextures TURNED_OFF = button("turned_off");
@@ -35,16 +35,16 @@ public final class GuiSprites extends TextureAtlasHolder {
private static ButtonTextures button(String name) {
return new ButtonTextures(
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/buttons/" + name),
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/buttons/" + name + "_hover")
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/buttons/" + name),
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/buttons/" + name + "_hover")
);
}
private static ComputerTextures computer(String name, boolean pocket, boolean sidebar) {
return new ComputerTextures(
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/border_" + name),
- pocket ? new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/pocket_bottom_" + name) : null,
- sidebar ? new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/sidebar_" + name) : null
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/border_" + name),
+ pocket ? ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/pocket_bottom_" + name) : null,
+ sidebar ? ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/sidebar_" + name) : null
);
}
diff --git a/projects/common/src/client/java/dan200/computercraft/client/gui/ItemToast.java b/projects/common/src/client/java/dan200/computercraft/client/gui/ItemToast.java
index 850db86ee..b3bfd4294 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/gui/ItemToast.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/gui/ItemToast.java
@@ -19,7 +19,7 @@ import java.util.List;
* A {@link Toast} implementation which displays an arbitrary message along with an optional {@link ItemStack}.
*/
public class ItemToast implements Toast {
- private static final ResourceLocation TEXTURE = new ResourceLocation("toast/recipe");
+ private static final ResourceLocation TEXTURE = ResourceLocation.withDefaultNamespace("toast/recipe");
public static final Object TRANSFER_NO_RESPONSE_TOKEN = new Object();
private static final long DISPLAY_TIME = 7000L;
diff --git a/projects/common/src/client/java/dan200/computercraft/client/gui/OptionScreen.java b/projects/common/src/client/java/dan200/computercraft/client/gui/OptionScreen.java
index 36e74a698..0cf39fa21 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/gui/OptionScreen.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/gui/OptionScreen.java
@@ -24,7 +24,7 @@ import static dan200.computercraft.core.util.Nullability.assertNonNull;
* When closed, it returns to the previous screen.
*/
public final class OptionScreen extends Screen {
- private static final ResourceLocation BACKGROUND = new ResourceLocation("computercraft", "textures/gui/blank_screen.png");
+ private static final ResourceLocation BACKGROUND = ResourceLocation.fromNamespaceAndPath("computercraft", "textures/gui/blank_screen.png");
public static final int BUTTON_WIDTH = 100;
public static final int BUTTON_HEIGHT = 20;
diff --git a/projects/common/src/client/java/dan200/computercraft/client/gui/PrinterScreen.java b/projects/common/src/client/java/dan200/computercraft/client/gui/PrinterScreen.java
index acc380536..70deac9c2 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/gui/PrinterScreen.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/gui/PrinterScreen.java
@@ -15,7 +15,7 @@ import net.minecraft.world.entity.player.Inventory;
* The GUI for printers.
*/
public class PrinterScreen extends AbstractContainerScreen {
- private static final ResourceLocation BACKGROUND = new ResourceLocation("computercraft", "textures/gui/printer.png");
+ private static final ResourceLocation BACKGROUND = ResourceLocation.fromNamespaceAndPath("computercraft", "textures/gui/printer.png");
public PrinterScreen(PrinterMenu container, Inventory player, Component title) {
super(container, player, title);
diff --git a/projects/common/src/client/java/dan200/computercraft/client/gui/PrintoutScreen.java b/projects/common/src/client/java/dan200/computercraft/client/gui/PrintoutScreen.java
index fa1add725..231faabbb 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/gui/PrintoutScreen.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/gui/PrintoutScreen.java
@@ -4,7 +4,6 @@
package dan200.computercraft.client.gui;
-import com.mojang.blaze3d.vertex.Tesselator;
import dan200.computercraft.core.terminal.TextBuffer;
import dan200.computercraft.shared.ModRegistry;
import dan200.computercraft.shared.common.HeldItemMenu;
@@ -12,7 +11,6 @@ import dan200.computercraft.shared.media.items.PrintoutData;
import dan200.computercraft.shared.media.items.PrintoutItem;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
-import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;
import org.lwjgl.glfw.GLFW;
@@ -90,10 +88,8 @@ public class PrintoutScreen extends AbstractContainerScreen {
graphics.pose().pushPose();
graphics.pose().translate(0, 0, 1);
- var renderer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
- drawBorder(graphics.pose(), renderer, leftPos, topPos, 0, page, pages, book, FULL_BRIGHT_LIGHTMAP);
- drawText(graphics.pose(), renderer, leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, PrintoutData.LINES_PER_PAGE * page, FULL_BRIGHT_LIGHTMAP, text, colours);
- renderer.endBatch();
+ drawBorder(graphics.pose(), graphics.bufferSource(), leftPos, topPos, 0, page, pages, book, FULL_BRIGHT_LIGHTMAP);
+ drawText(graphics.pose(), graphics.bufferSource(), leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, PrintoutData.LINES_PER_PAGE * page, FULL_BRIGHT_LIGHTMAP, text, colours);
graphics.pose().popPose();
}
diff --git a/projects/common/src/client/java/dan200/computercraft/client/gui/TurtleScreen.java b/projects/common/src/client/java/dan200/computercraft/client/gui/TurtleScreen.java
index c401be67a..381bd6219 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/gui/TurtleScreen.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/gui/TurtleScreen.java
@@ -23,8 +23,8 @@ import static dan200.computercraft.shared.turtle.inventory.TurtleMenu.*;
* The GUI for turtles.
*/
public class TurtleScreen extends AbstractComputerScreen {
- private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_normal.png");
- private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_advanced.png");
+ private static final ResourceLocation BACKGROUND_NORMAL = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_normal.png");
+ private static final ResourceLocation BACKGROUND_ADVANCED = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "textures/gui/turtle_advanced.png");
private static final int TEX_WIDTH = 278;
private static final int TEX_HEIGHT = 217;
diff --git a/projects/common/src/client/java/dan200/computercraft/client/gui/widgets/TerminalWidget.java b/projects/common/src/client/java/dan200/computercraft/client/gui/widgets/TerminalWidget.java
index 3b7b69f57..50a0f35d4 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/gui/widgets/TerminalWidget.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/gui/widgets/TerminalWidget.java
@@ -4,7 +4,6 @@
package dan200.computercraft.client.gui.widgets;
-import com.mojang.blaze3d.vertex.Tesselator;
import dan200.computercraft.client.render.RenderTypes;
import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
import dan200.computercraft.core.terminal.Terminal;
@@ -16,7 +15,6 @@ import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.narration.NarratedElementType;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.client.gui.screens.Screen;
-import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.network.chat.Component;
import org.lwjgl.glfw.GLFW;
@@ -259,15 +257,12 @@ public class TerminalWidget extends AbstractWidget {
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
if (!visible) return;
- var bufferSource = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
- var emitter = FixedWidthFontRenderer.toVertexConsumer(graphics.pose(), bufferSource.getBuffer(RenderTypes.TERMINAL));
+ var emitter = FixedWidthFontRenderer.toVertexConsumer(graphics.pose(), graphics.bufferSource().getBuffer(RenderTypes.TERMINAL));
FixedWidthFontRenderer.drawTerminal(
emitter,
(float) innerX, (float) innerY, terminal, (float) MARGIN, (float) MARGIN, (float) MARGIN, (float) MARGIN
);
-
- bufferSource.endBatch();
}
@Override
diff --git a/projects/common/src/client/java/dan200/computercraft/client/model/turtle/ModelTransformer.java b/projects/common/src/client/java/dan200/computercraft/client/model/turtle/ModelTransformer.java
index c512f0c0d..72c7e3bd5 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/model/turtle/ModelTransformer.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/model/turtle/ModelTransformer.java
@@ -4,11 +4,9 @@
package dan200.computercraft.client.model.turtle;
-import com.mojang.blaze3d.vertex.DefaultVertexFormat;
-import com.mojang.blaze3d.vertex.VertexFormat;
-import com.mojang.blaze3d.vertex.VertexFormatElement;
import com.mojang.math.Transformation;
import net.minecraft.client.renderer.block.model.BakedQuad;
+import net.minecraft.client.renderer.block.model.FaceBakery;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction;
import org.joml.Matrix4f;
@@ -29,8 +27,8 @@ import java.util.List;
public class ModelTransformer {
private static final int[] INVERSE_ORDER = new int[]{ 3, 2, 1, 0 };
- private static final int STRIDE = DefaultVertexFormat.BLOCK.getIntegerSize();
- private static final int POS_OFFSET = findOffset(DefaultVertexFormat.BLOCK, DefaultVertexFormat.ELEMENT_POSITION);
+ private static final int STRIDE = FaceBakery.VERTEX_INT_SIZE;
+ private static final int POS_OFFSET = 0;
protected final Matrix4f transformation;
protected final boolean invert;
@@ -91,13 +89,4 @@ public class ModelTransformer {
private record TransformedQuads(List original, List transformed) {
}
-
- private static int findOffset(VertexFormat format, VertexFormatElement element) {
- var offset = 0;
- for (var other : format.getElements()) {
- if (other == element) return offset / Integer.BYTES;
- offset += element.getByteSize();
- }
- throw new IllegalArgumentException("Cannot find " + element + " in " + format);
- }
}
diff --git a/projects/common/src/client/java/dan200/computercraft/client/model/turtle/TurtleModelParts.java b/projects/common/src/client/java/dan200/computercraft/client/model/turtle/TurtleModelParts.java
index f8da518c8..f714a64f2 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/model/turtle/TurtleModelParts.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/model/turtle/TurtleModelParts.java
@@ -85,7 +85,7 @@ public final class TurtleModelParts {
public TurtleModelParts(BakedModel familyModel, BakedModel colourModel, ModelTransformer transformer, Function
, T> combineModel) {
this.familyModel = familyModel;
this.colourModel = colourModel;
- this.transformer = x -> transformer.transform(x.getModel(), x.getMatrix());
+ this.transformer = x -> transformer.transform(x.model(), x.matrix());
buildModel = x -> combineModel.apply(buildModel(x));
}
@@ -127,7 +127,7 @@ public final class TurtleModelParts {
private void addUpgrade(List parts, Transformation transformation, TurtleSide side, @Nullable UpgradeData upgrade) {
if (upgrade == null) return;
var model = TurtleUpgradeModellers.getModel(upgrade.upgrade(), upgrade.data(), side);
- parts.add(transform(model.getModel(), transformation.compose(model.getMatrix())));
+ parts.add(transform(model.model(), transformation.compose(model.matrix())));
}
private BakedModel transform(BakedModel model, Transformation transformation) {
diff --git a/projects/common/src/client/java/dan200/computercraft/client/platform/ClientNetworkContextImpl.java b/projects/common/src/client/java/dan200/computercraft/client/platform/ClientNetworkContextImpl.java
index ca3d9f9e7..45fc090a2 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/platform/ClientNetworkContextImpl.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/platform/ClientNetworkContextImpl.java
@@ -21,10 +21,11 @@ import dan200.computercraft.shared.peripheral.speaker.EncodedAudio;
import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
+import net.minecraft.core.Holder;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.JukeboxSong;
import net.minecraft.world.level.Level;
import javax.annotation.Nullable;
@@ -60,10 +61,12 @@ public final class ClientNetworkContextImpl implements ClientNetworkContext {
}
@Override
- public void handlePlayRecord(BlockPos pos, @Nullable SoundEvent sound, @Nullable String name) {
- var mc = Minecraft.getInstance();
- ClientPlatformHelper.get().playStreamingMusic(pos, sound);
- if (name != null) mc.gui.setNowPlaying(Component.literal(name));
+ public void handlePlayRecord(BlockPos pos, @Nullable Holder song) {
+ if (song == null) {
+ Minecraft.getInstance().levelRenderer.stopJukeboxSongAndNotifyNearby(pos);
+ } else {
+ Minecraft.getInstance().levelRenderer.playJukeboxSong(song, pos);
+ }
}
@Override
diff --git a/projects/common/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelper.java b/projects/common/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelper.java
index 63d956756..665e22da2 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelper.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelper.java
@@ -7,8 +7,6 @@ package dan200.computercraft.client.platform;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.resources.model.BakedModel;
-import net.minecraft.core.BlockPos;
-import net.minecraft.sounds.SoundEvent;
import javax.annotation.Nullable;
@@ -28,13 +26,4 @@ public interface ClientPlatformHelper extends dan200.computercraft.impl.client.C
* @param tints Block colour tints to apply to the model.
*/
void renderBakedModel(PoseStack transform, MultiBufferSource buffers, BakedModel model, int lightmapCoord, int overlayLight, @Nullable int[] tints);
-
- /**
- * Play a record at a particular position.
- *
- * @param pos The position to play this record.
- * @param sound The record to play, or {@code null} to stop it.
- * @see net.minecraft.client.renderer.LevelRenderer#playStreamingMusic(SoundEvent, BlockPos)
- */
- void playStreamingMusic(BlockPos pos, @Nullable SoundEvent sound);
}
diff --git a/projects/common/src/client/java/dan200/computercraft/client/render/CableHighlightRenderer.java b/projects/common/src/client/java/dan200/computercraft/client/render/CableHighlightRenderer.java
index e0a629403..c9208d1f7 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/render/CableHighlightRenderer.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/render/CableHighlightRenderer.java
@@ -62,15 +62,13 @@ public final class CableHighlightRenderer {
zDelta = zDelta / len;
buffer
- .vertex(matrix4f, (float) (x1 + xOffset), (float) (y1 + yOffset), (float) (z1 + zOffset))
- .color(0, 0, 0, 0.4f)
- .normal(transform.last(), xDelta, yDelta, zDelta)
- .endVertex();
+ .addVertex(matrix4f, (float) (x1 + xOffset), (float) (y1 + yOffset), (float) (z1 + zOffset))
+ .setColor(0, 0, 0, 0.4f)
+ .setNormal(transform.last(), xDelta, yDelta, zDelta);
buffer
- .vertex(matrix4f, (float) (x2 + xOffset), (float) (y2 + yOffset), (float) (z2 + zOffset))
- .color(0, 0, 0, 0.4f)
- .normal(transform.last(), xDelta, yDelta, zDelta)
- .endVertex();
+ .addVertex(matrix4f, (float) (x2 + xOffset), (float) (y2 + yOffset), (float) (z2 + zOffset))
+ .setColor(0, 0, 0, 0.4f)
+ .setNormal(transform.last(), xDelta, yDelta, zDelta);
});
return true;
diff --git a/projects/common/src/client/java/dan200/computercraft/client/render/ModelRenderer.java b/projects/common/src/client/java/dan200/computercraft/client/render/ModelRenderer.java
index f054f3f40..4e4019430 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/render/ModelRenderer.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/render/ModelRenderer.java
@@ -50,28 +50,23 @@ public final class ModelRenderer {
if (idx >= 0 && idx < tints.length) tint = tints[bakedquad.getTintIndex()];
}
- var r = (float) (tint >> 16 & 255) / 255.0F;
- var g = (float) (tint >> 8 & 255) / 255.0F;
- var b = (float) (tint & 255) / 255.0F;
- putBulkQuad(buffer, matrix, bakedquad, r, g, b, lightmapCoord, overlayLight, inverted);
+ putBulkQuad(buffer, matrix, bakedquad, tint, lightmapCoord, overlayLight, inverted);
}
}
/**
- * A version of {@link VertexConsumer#putBulkData(PoseStack.Pose, BakedQuad, float, float, float, int, int)} which
+ * A version of {@link VertexConsumer#putBulkData(PoseStack.Pose, BakedQuad, float, float, float, float, int, int)} which
* will reverse vertex order when the matrix is inverted.
*
* @param buffer The buffer to draw to.
* @param pose The current matrix stack.
* @param quad The quad to draw.
- * @param red The red tint of this quad.
- * @param green The green tint of this quad.
- * @param blue The blue tint of this quad.
+ * @param colour The tint for this quad.
* @param lightmapCoord The lightmap coordinate
* @param overlayLight The overlay light.
* @param invert Whether to reverse the order of this quad.
*/
- private static void putBulkQuad(VertexConsumer buffer, PoseStack.Pose pose, BakedQuad quad, float red, float green, float blue, int lightmapCoord, int overlayLight, boolean invert) {
+ private static void putBulkQuad(VertexConsumer buffer, PoseStack.Pose pose, BakedQuad quad, int colour, int lightmapCoord, int overlayLight, boolean invert) {
var matrix = pose.pose();
// It's a little dubious to transform using this matrix rather than the normal matrix. This mirrors the logic in
// Direction.rotate (so not out of nowhere!), but is a little suspicious.
@@ -93,9 +88,9 @@ public final class ModelRenderer {
var u = Float.intBitsToFloat(vertices[i + 4]);
var v = Float.intBitsToFloat(vertices[i + 5]);
- buffer.vertex(
+ buffer.addVertex(
vector.x(), vector.y(), vector.z(),
- red, green, blue, 1.0F, u, v, overlayLight, lightmapCoord,
+ colour, u, v, overlayLight, lightmapCoord,
normalX, normalY, normalZ
);
}
diff --git a/projects/common/src/client/java/dan200/computercraft/client/render/PrintoutRenderer.java b/projects/common/src/client/java/dan200/computercraft/client/render/PrintoutRenderer.java
index f8eec2b96..68bbfaacf 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/render/PrintoutRenderer.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/render/PrintoutRenderer.java
@@ -158,7 +158,7 @@ public final class PrintoutRenderer {
}
private static void vertex(VertexConsumer buffer, Matrix4f matrix, float x, float y, float z, float u, float v, int light) {
- buffer.vertex(matrix, x, y, z).color(255, 255, 255, 255).uv(u, v).uv2(light).endVertex();
+ buffer.addVertex(matrix, x, y, z).setColor(255, 255, 255, 255).setUv(u, v).setLight(light);
}
public static float offsetAt(int page) {
diff --git a/projects/common/src/client/java/dan200/computercraft/client/render/RenderTypes.java b/projects/common/src/client/java/dan200/computercraft/client/render/RenderTypes.java
index 3a701e4ed..3868c472d 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/render/RenderTypes.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/render/RenderTypes.java
@@ -52,7 +52,7 @@ public class RenderTypes {
* Printout's background texture. {@link RenderType#text(ResourceLocation)} is a little questionable, but
* it is what maps use, so should behave the same as vanilla in both item frames and in-hand.
*/
- public static final RenderType PRINTOUT_BACKGROUND = RenderType.text(new ResourceLocation("computercraft", "textures/gui/printout.png"));
+ public static final RenderType PRINTOUT_BACKGROUND = RenderType.text(ResourceLocation.fromNamespaceAndPath("computercraft", "textures/gui/printout.png"));
/**
* Render type for {@linkplain GuiSprites GUI sprites}.
diff --git a/projects/common/src/client/java/dan200/computercraft/client/render/SpriteRenderer.java b/projects/common/src/client/java/dan200/computercraft/client/render/SpriteRenderer.java
index e9cb768f5..bb1a3d02e 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/render/SpriteRenderer.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/render/SpriteRenderer.java
@@ -118,10 +118,10 @@ public class SpriteRenderer {
*/
public void blit(
int x, int y, int width, int height, float u0, float v0, float u1, float v1) {
- builder.vertex(transform, x, y + height, z).color(r, g, b, 255).uv(u0, v1).uv2(light).endVertex();
- builder.vertex(transform, x + width, y + height, z).color(r, g, b, 255).uv(u1, v1).uv2(light).endVertex();
- builder.vertex(transform, x + width, y, z).color(r, g, b, 255).uv(u1, v0).uv2(light).endVertex();
- builder.vertex(transform, x, y, z).color(r, g, b, 255).uv(u0, v0).uv2(light).endVertex();
+ builder.addVertex(transform, x, y + height, z).setColor(r, g, b, 255).setUv(u0, v1).setLight(light);
+ builder.addVertex(transform, x + width, y + height, z).setColor(r, g, b, 255).setUv(u1, v1).setLight(light);
+ builder.addVertex(transform, x + width, y, z).setColor(r, g, b, 255).setUv(u1, v0).setLight(light);
+ builder.addVertex(transform, x, y, z).setColor(r, g, b, 255).setUv(u0, v0).setLight(light);
}
public static float u(TextureAtlasSprite sprite, int x, int width) {
diff --git a/projects/common/src/client/java/dan200/computercraft/client/render/TurtleBlockEntityRenderer.java b/projects/common/src/client/java/dan200/computercraft/client/render/TurtleBlockEntityRenderer.java
index caf56621e..5890d40ad 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/render/TurtleBlockEntityRenderer.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/render/TurtleBlockEntityRenderer.java
@@ -27,8 +27,8 @@ import net.minecraft.world.phys.HitResult;
import javax.annotation.Nullable;
public class TurtleBlockEntityRenderer implements BlockEntityRenderer {
- private static final ResourceLocation COLOUR_TURTLE_MODEL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
- private static final ResourceLocation ELF_OVERLAY_MODEL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_elf_overlay");
+ private static final ResourceLocation COLOUR_TURTLE_MODEL = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
+ private static final ResourceLocation ELF_OVERLAY_MODEL = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_elf_overlay");
private final BlockEntityRenderDispatcher renderer;
private final Font font;
@@ -121,8 +121,8 @@ public class TurtleBlockEntityRenderer implements BlockEntityRenderer {
var backgroundBuffer = assertNonNull(renderState.backgroundBuffer);
@@ -242,13 +245,13 @@ public class MonitorBlockEntityRenderer implements BlockEntityRenderer
* No transformation matrix (not needed for VBOs).
* Only works with {@link DefaultVertexFormat#POSITION_COLOR_TEX_LIGHTMAP}.
- * The buffer MUST be allocated with {@link MemoryTracker}, and not through any other means.
+ * The buffer MUST be allocated with {@link MemoryUtil}, and not through any other means.
*
*
* Note this is almost an exact copy of {@link FixedWidthFontRenderer}. While the code duplication is unfortunate,
diff --git a/projects/common/src/client/java/dan200/computercraft/client/render/text/FixedWidthFontRenderer.java b/projects/common/src/client/java/dan200/computercraft/client/render/text/FixedWidthFontRenderer.java
index 1111d06d3..b2d495ba4 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/render/text/FixedWidthFontRenderer.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/render/text/FixedWidthFontRenderer.java
@@ -32,7 +32,7 @@ import static dan200.computercraft.client.render.RenderTypes.FULL_BRIGHT_LIGHTMA
* {@link DirectFixedWidthFontRenderer}.
*/
public final class FixedWidthFontRenderer {
- public static final ResourceLocation FONT = new ResourceLocation("computercraft", "textures/gui/term_font.png");
+ public static final ResourceLocation FONT = ResourceLocation.fromNamespaceAndPath("computercraft", "textures/gui/term_font.png");
public static final int FONT_HEIGHT = 9;
public static final int FONT_WIDTH = 6;
@@ -221,9 +221,9 @@ public final class FixedWidthFontRenderer {
var consumer = c.consumer();
byte r = rgba[0], g = rgba[1], b = rgba[2], a = rgba[3];
- consumer.vertex(poseMatrix, x1, y1, z).color(r, g, b, a).uv(u1, v1).uv2(light).endVertex();
- consumer.vertex(poseMatrix, x1, y2, z).color(r, g, b, a).uv(u1, v2).uv2(light).endVertex();
- consumer.vertex(poseMatrix, x2, y2, z).color(r, g, b, a).uv(u2, v2).uv2(light).endVertex();
- consumer.vertex(poseMatrix, x2, y1, z).color(r, g, b, a).uv(u2, v1).uv2(light).endVertex();
+ consumer.addVertex(poseMatrix, x1, y1, z).setColor(r, g, b, a).setUv(u1, v1).setLight(light);
+ consumer.addVertex(poseMatrix, x1, y2, z).setColor(r, g, b, a).setUv(u1, v2).setLight(light);
+ consumer.addVertex(poseMatrix, x2, y2, z).setColor(r, g, b, a).setUv(u2, v2).setLight(light);
+ consumer.addVertex(poseMatrix, x2, y1, z).setColor(r, g, b, a).setUv(u2, v1).setLight(light);
}
}
diff --git a/projects/common/src/client/java/dan200/computercraft/client/sound/SpeakerInstance.java b/projects/common/src/client/java/dan200/computercraft/client/sound/SpeakerInstance.java
index c3957168c..c297f5b50 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/sound/SpeakerInstance.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/sound/SpeakerInstance.java
@@ -17,7 +17,7 @@ import javax.annotation.Nullable;
* An instance of a speaker, which is either playing a {@link DfpwmStream} stream or a normal sound.
*/
public class SpeakerInstance {
- public static final ResourceLocation DFPWM_STREAM = new ResourceLocation(ComputerCraftAPI.MOD_ID, "speaker.dfpwm_fake_audio_should_not_be_played");
+ public static final ResourceLocation DFPWM_STREAM = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "speaker.dfpwm_fake_audio_should_not_be_played");
private @Nullable DfpwmStream currentStream;
private @Nullable SpeakerSound sound;
diff --git a/projects/common/src/client/java/dan200/computercraft/client/turtle/TurtleModemModeller.java b/projects/common/src/client/java/dan200/computercraft/client/turtle/TurtleModemModeller.java
index 29367c358..86cb6fc4c 100644
--- a/projects/common/src/client/java/dan200/computercraft/client/turtle/TurtleModemModeller.java
+++ b/projects/common/src/client/java/dan200/computercraft/client/turtle/TurtleModemModeller.java
@@ -5,6 +5,7 @@
package dan200.computercraft.client.turtle;
import dan200.computercraft.api.ComputerCraftAPI;
+import dan200.computercraft.api.client.ModelLocation;
import dan200.computercraft.api.client.TransformedModel;
import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller;
import dan200.computercraft.api.turtle.ITurtleAccess;
@@ -38,23 +39,23 @@ public class TurtleModemModeller implements TurtleUpgradeModeller {
}
private record ModemModels(
- ResourceLocation leftOffModel, ResourceLocation rightOffModel,
- ResourceLocation leftOnModel, ResourceLocation rightOnModel
+ ModelLocation leftOffModel, ModelLocation rightOffModel,
+ ModelLocation leftOnModel, ModelLocation rightOnModel
) {
private static final ModemModels NORMAL = create("normal");
private static final ModemModels ADVANCED = create("advanced");
public static ModemModels create(String type) {
return new ModemModels(
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_off_left"),
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_off_right"),
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_on_left"),
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_on_right")
+ ModelLocation.ofResource(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_off_left")),
+ ModelLocation.ofResource(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_off_right")),
+ ModelLocation.ofResource(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_on_left")),
+ ModelLocation.ofResource(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_modem_" + type + "_on_right"))
);
}
public Stream getDependencies() {
- return Stream.of(leftOffModel, rightOffModel, leftOnModel, rightOnModel);
+ return Stream.of(leftOffModel, rightOffModel, leftOnModel, rightOnModel).flatMap(ModelLocation::getDependencies);
}
}
}
diff --git a/projects/common/src/client/java/dan200/computercraft/data/client/ClientDataProviders.java b/projects/common/src/client/java/dan200/computercraft/data/client/ClientDataProviders.java
index 76891e250..45c188f31 100644
--- a/projects/common/src/client/java/dan200/computercraft/data/client/ClientDataProviders.java
+++ b/projects/common/src/client/java/dan200/computercraft/data/client/ClientDataProviders.java
@@ -28,7 +28,7 @@ public final class ClientDataProviders {
public static void add(DataProviders.GeneratorSink generator) {
generator.addFromCodec("Block atlases", PackType.CLIENT_RESOURCES, "atlases", SpriteSources.FILE_CODEC, out -> {
- out.accept(new ResourceLocation("blocks"), List.of(
+ out.accept(ResourceLocation.withDefaultNamespace("blocks"), List.of(
new SingleFile(UpgradeSlot.LEFT_UPGRADE, Optional.empty()),
new SingleFile(UpgradeSlot.RIGHT_UPGRADE, Optional.empty())
));
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/decorations/skull_cloudy.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/decorations/skull_cloudy.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/decorations/skull_cloudy.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/decorations/skull_cloudy.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/decorations/skull_dan200.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/decorations/skull_dan200.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/decorations/skull_dan200.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/decorations/skull_dan200.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/cable.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/cable.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/cable.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/cable.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/computer_advanced.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/computer_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/computer_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/computer_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/computer_advanced_upgrade.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/computer_advanced_upgrade.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/computer_advanced_upgrade.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/computer_advanced_upgrade.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/computer_command.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/computer_command.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/computer_command.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/computer_command.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/computer_normal.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/computer_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/computer_normal.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/computer_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_1.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_1.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_1.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_1.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_10.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_10.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_10.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_10.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_11.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_11.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_11.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_11.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_12.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_12.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_12.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_12.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_13.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_13.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_13.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_13.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_14.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_14.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_14.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_14.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_15.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_15.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_15.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_15.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_16.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_16.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_16.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_16.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_2.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_2.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_2.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_2.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_3.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_3.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_3.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_3.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_4.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_4.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_4.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_4.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_5.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_5.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_5.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_5.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_6.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_6.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_6.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_6.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_7.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_7.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_7.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_7.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_8.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_8.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_8.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_8.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_9.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_9.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_9.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_9.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_drive.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_drive.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/disk_drive.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/disk_drive.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/monitor_advanced.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/monitor_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/monitor_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/monitor_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/monitor_normal.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/monitor_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/monitor_normal.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/monitor_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_advanced/computercraft/speaker.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_advanced/computercraft/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_advanced/computercraft/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_advanced/computercraft/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_advanced/computercraft/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_advanced/computercraft/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_advanced/computercraft/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_advanced/computercraft/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_advanced/computercraft/wireless_modem_normal.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_advanced/computercraft/wireless_modem_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_advanced/computercraft/wireless_modem_normal.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_advanced/computercraft/wireless_modem_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_computer_advanced.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_computer_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_computer_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_computer_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_computer_advanced_upgrade.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_computer_advanced_upgrade.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_computer_advanced_upgrade.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_computer_advanced_upgrade.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_computer_normal.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_computer_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_computer_normal.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_computer_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_normal/computercraft/speaker.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_normal/computercraft/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_normal/computercraft/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_normal/computercraft/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_normal/computercraft/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_normal/computercraft/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_normal/computercraft/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_normal/computercraft/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_normal/computercraft/wireless_modem_normal.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_normal/computercraft/wireless_modem_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/pocket_normal/computercraft/wireless_modem_normal.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/pocket_normal/computercraft/wireless_modem_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/printed_book.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/printed_book.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/printed_book.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/printed_book.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/printed_pages.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/printed_pages.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/printed_pages.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/printed_pages.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/printer.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/printer.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/printer.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/printer.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/speaker.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/computercraft/speaker.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/computercraft/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/computercraft/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/computercraft/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/computercraft/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/computercraft/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/computercraft/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/computercraft/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/computercraft/wireless_modem_normal.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/computercraft/wireless_modem_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/computercraft/wireless_modem_normal.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/computercraft/wireless_modem_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/crafting_table.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/crafting_table.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/crafting_table.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/crafting_table.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/diamond_axe.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/diamond_axe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/diamond_axe.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/diamond_axe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/diamond_hoe.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/diamond_hoe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/diamond_hoe.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/diamond_hoe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/diamond_pickaxe.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/diamond_pickaxe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/diamond_pickaxe.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/diamond_pickaxe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/diamond_shovel.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/diamond_shovel.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/diamond_shovel.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/diamond_shovel.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/diamond_sword.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/diamond_sword.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced/minecraft/diamond_sword.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced/minecraft/diamond_sword.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced_overlays/turtle_rainbow_overlay.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced_overlays/turtle_rainbow_overlay.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced_overlays/turtle_rainbow_overlay.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced_overlays/turtle_rainbow_overlay.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced_overlays/turtle_trans_overlay.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced_overlays/turtle_trans_overlay.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced_overlays/turtle_trans_overlay.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced_overlays/turtle_trans_overlay.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced_upgrade.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced_upgrade.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_advanced_upgrade.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_advanced_upgrade.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/computercraft/speaker.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/computercraft/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/computercraft/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/computercraft/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/computercraft/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/computercraft/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/computercraft/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/computercraft/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/computercraft/wireless_modem_normal.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/computercraft/wireless_modem_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/computercraft/wireless_modem_normal.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/computercraft/wireless_modem_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/crafting_table.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/crafting_table.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/crafting_table.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/crafting_table.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/diamond_axe.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/diamond_axe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/diamond_axe.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/diamond_axe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/diamond_hoe.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/diamond_hoe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/diamond_hoe.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/diamond_hoe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/diamond_pickaxe.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/diamond_pickaxe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/diamond_pickaxe.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/diamond_pickaxe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/diamond_shovel.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/diamond_shovel.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/diamond_shovel.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/diamond_shovel.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/diamond_sword.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/diamond_sword.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal/minecraft/diamond_sword.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal/minecraft/diamond_sword.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal_overlays/turtle_rainbow_overlay.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal_overlays/turtle_rainbow_overlay.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal_overlays/turtle_rainbow_overlay.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal_overlays/turtle_rainbow_overlay.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal_overlays/turtle_trans_overlay.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal_overlays/turtle_trans_overlay.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/turtle_normal_overlays/turtle_trans_overlay.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/turtle_normal_overlays/turtle_trans_overlay.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/wired_modem.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/wired_modem.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/wired_modem.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/wired_modem.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/wired_modem_full_from.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/wired_modem_full_from.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/wired_modem_full_from.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/wired_modem_full_from.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/wired_modem_full_to.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/wired_modem_full_to.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/wired_modem_full_to.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/wired_modem_full_to.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/wireless_modem_normal.json b/projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/wireless_modem_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/advancements/recipes/redstone/wireless_modem_normal.json
rename to projects/common/src/generated/resources/data/computercraft/advancement/recipes/redstone/wireless_modem_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/cable.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/cable.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/cable.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/cable.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/computer_advanced.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/computer_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/computer_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/computer_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/computer_command.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/computer_command.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/computer_command.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/computer_command.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/computer_normal.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/computer_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/computer_normal.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/computer_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/disk_drive.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/disk_drive.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/disk_drive.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/disk_drive.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/monitor_advanced.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/monitor_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/monitor_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/monitor_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/monitor_normal.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/monitor_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/monitor_normal.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/monitor_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/printer.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/printer.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/printer.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/printer.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/speaker.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_advanced.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/turtle_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/turtle_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_normal.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/turtle_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/turtle_normal.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/turtle_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/wired_modem_full.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/wired_modem_full.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/wired_modem_full.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/wired_modem_full.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/wireless_modem_normal.json b/projects/common/src/generated/resources/data/computercraft/loot_table/blocks/wireless_modem_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/blocks/wireless_modem_normal.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/blocks/wireless_modem_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/loot_tables/treasure_disk.json b/projects/common/src/generated/resources/data/computercraft/loot_table/treasure_disk.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/loot_tables/treasure_disk.json
rename to projects/common/src/generated/resources/data/computercraft/loot_table/treasure_disk.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/cable.json b/projects/common/src/generated/resources/data/computercraft/recipe/cable.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/cable.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/cable.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/clear_colour.json b/projects/common/src/generated/resources/data/computercraft/recipe/clear_colour.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/clear_colour.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/clear_colour.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/colour.json b/projects/common/src/generated/resources/data/computercraft/recipe/colour.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/colour.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/colour.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/computer_advanced.json b/projects/common/src/generated/resources/data/computercraft/recipe/computer_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/computer_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/computer_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/computer_advanced_upgrade.json b/projects/common/src/generated/resources/data/computercraft/recipe/computer_advanced_upgrade.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/computer_advanced_upgrade.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/computer_advanced_upgrade.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/computer_command.json b/projects/common/src/generated/resources/data/computercraft/recipe/computer_command.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/computer_command.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/computer_command.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/computer_normal.json b/projects/common/src/generated/resources/data/computercraft/recipe/computer_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/computer_normal.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/computer_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_1.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_1.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_1.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_1.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_10.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_10.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_10.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_10.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_11.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_11.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_11.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_11.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_12.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_12.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_12.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_12.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_13.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_13.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_13.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_13.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_14.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_14.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_14.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_14.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_15.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_15.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_15.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_15.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_16.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_16.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_16.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_16.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_2.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_2.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_2.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_2.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_3.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_3.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_3.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_3.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_4.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_4.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_4.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_4.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_5.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_5.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_5.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_5.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_6.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_6.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_6.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_6.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_7.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_7.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_7.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_7.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_8.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_8.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_8.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_8.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_9.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_9.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_9.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_9.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/disk_drive.json b/projects/common/src/generated/resources/data/computercraft/recipe/disk_drive.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/disk_drive.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/disk_drive.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/monitor_advanced.json b/projects/common/src/generated/resources/data/computercraft/recipe/monitor_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/monitor_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/monitor_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/monitor_normal.json b/projects/common/src/generated/resources/data/computercraft/recipe/monitor_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/monitor_normal.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/monitor_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/pocket_advanced/computercraft/speaker.json b/projects/common/src/generated/resources/data/computercraft/recipe/pocket_advanced/computercraft/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/pocket_advanced/computercraft/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/pocket_advanced/computercraft/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/pocket_advanced/computercraft/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/recipe/pocket_advanced/computercraft/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/pocket_advanced/computercraft/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/pocket_advanced/computercraft/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/pocket_advanced/computercraft/wireless_modem_normal.json b/projects/common/src/generated/resources/data/computercraft/recipe/pocket_advanced/computercraft/wireless_modem_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/pocket_advanced/computercraft/wireless_modem_normal.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/pocket_advanced/computercraft/wireless_modem_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/pocket_computer_advanced.json b/projects/common/src/generated/resources/data/computercraft/recipe/pocket_computer_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/pocket_computer_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/pocket_computer_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/pocket_computer_advanced_upgrade.json b/projects/common/src/generated/resources/data/computercraft/recipe/pocket_computer_advanced_upgrade.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/pocket_computer_advanced_upgrade.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/pocket_computer_advanced_upgrade.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/pocket_computer_normal.json b/projects/common/src/generated/resources/data/computercraft/recipe/pocket_computer_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/pocket_computer_normal.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/pocket_computer_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/pocket_computer_upgrade.json b/projects/common/src/generated/resources/data/computercraft/recipe/pocket_computer_upgrade.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/pocket_computer_upgrade.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/pocket_computer_upgrade.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/pocket_normal/computercraft/speaker.json b/projects/common/src/generated/resources/data/computercraft/recipe/pocket_normal/computercraft/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/pocket_normal/computercraft/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/pocket_normal/computercraft/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/pocket_normal/computercraft/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/recipe/pocket_normal/computercraft/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/pocket_normal/computercraft/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/pocket_normal/computercraft/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/pocket_normal/computercraft/wireless_modem_normal.json b/projects/common/src/generated/resources/data/computercraft/recipe/pocket_normal/computercraft/wireless_modem_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/pocket_normal/computercraft/wireless_modem_normal.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/pocket_normal/computercraft/wireless_modem_normal.json
diff --git a/projects/forge/src/generated/resources/data/computercraft/recipes/printed_book.json b/projects/common/src/generated/resources/data/computercraft/recipe/printed_book.json
similarity index 100%
rename from projects/forge/src/generated/resources/data/computercraft/recipes/printed_book.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/printed_book.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/printed_pages.json b/projects/common/src/generated/resources/data/computercraft/recipe/printed_pages.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/printed_pages.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/printed_pages.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/printer.json b/projects/common/src/generated/resources/data/computercraft/recipe/printer.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/printer.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/printer.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/skull_cloudy.json b/projects/common/src/generated/resources/data/computercraft/recipe/skull_cloudy.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/skull_cloudy.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/skull_cloudy.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/skull_dan200.json b/projects/common/src/generated/resources/data/computercraft/recipe/skull_dan200.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/skull_dan200.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/skull_dan200.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/speaker.json b/projects/common/src/generated/resources/data/computercraft/recipe/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/computercraft/speaker.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/computercraft/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/computercraft/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/computercraft/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/computercraft/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/computercraft/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/computercraft/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/computercraft/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/computercraft/wireless_modem_normal.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/computercraft/wireless_modem_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/computercraft/wireless_modem_normal.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/computercraft/wireless_modem_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/crafting_table.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/crafting_table.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/crafting_table.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/crafting_table.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/diamond_axe.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/diamond_axe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/diamond_axe.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/diamond_axe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/diamond_hoe.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/diamond_hoe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/diamond_hoe.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/diamond_hoe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/diamond_pickaxe.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/diamond_pickaxe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/diamond_pickaxe.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/diamond_pickaxe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/diamond_shovel.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/diamond_shovel.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/diamond_shovel.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/diamond_shovel.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/diamond_sword.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/diamond_sword.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced/minecraft/diamond_sword.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced/minecraft/diamond_sword.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced_overlays/turtle_rainbow_overlay.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced_overlays/turtle_rainbow_overlay.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced_overlays/turtle_rainbow_overlay.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced_overlays/turtle_rainbow_overlay.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced_overlays/turtle_trans_overlay.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced_overlays/turtle_trans_overlay.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced_overlays/turtle_trans_overlay.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced_overlays/turtle_trans_overlay.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced_upgrade.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced_upgrade.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_advanced_upgrade.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_advanced_upgrade.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/computercraft/speaker.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/computercraft/speaker.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/computercraft/speaker.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/computercraft/speaker.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/computercraft/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/computercraft/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/computercraft/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/computercraft/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/computercraft/wireless_modem_normal.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/computercraft/wireless_modem_normal.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/computercraft/wireless_modem_normal.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/computercraft/wireless_modem_normal.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/crafting_table.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/crafting_table.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/crafting_table.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/crafting_table.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/diamond_axe.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/diamond_axe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/diamond_axe.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/diamond_axe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/diamond_hoe.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/diamond_hoe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/diamond_hoe.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/diamond_hoe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/diamond_pickaxe.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/diamond_pickaxe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/diamond_pickaxe.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/diamond_pickaxe.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/diamond_shovel.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/diamond_shovel.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/diamond_shovel.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/diamond_shovel.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/diamond_sword.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/diamond_sword.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal/minecraft/diamond_sword.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal/minecraft/diamond_sword.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal_overlays/turtle_rainbow_overlay.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal_overlays/turtle_rainbow_overlay.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal_overlays/turtle_rainbow_overlay.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal_overlays/turtle_rainbow_overlay.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal_overlays/turtle_trans_overlay.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal_overlays/turtle_trans_overlay.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_normal_overlays/turtle_trans_overlay.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_normal_overlays/turtle_trans_overlay.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/turtle_upgrade.json b/projects/common/src/generated/resources/data/computercraft/recipe/turtle_upgrade.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/turtle_upgrade.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/turtle_upgrade.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/wired_modem.json b/projects/common/src/generated/resources/data/computercraft/recipe/wired_modem.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/wired_modem.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/wired_modem.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/wired_modem_full_from.json b/projects/common/src/generated/resources/data/computercraft/recipe/wired_modem_full_from.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/wired_modem_full_from.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/wired_modem_full_from.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/wired_modem_full_to.json b/projects/common/src/generated/resources/data/computercraft/recipe/wired_modem_full_to.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/wired_modem_full_to.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/wired_modem_full_to.json
diff --git a/projects/common/src/generated/resources/data/computercraft/recipes/wireless_modem_advanced.json b/projects/common/src/generated/resources/data/computercraft/recipe/wireless_modem_advanced.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/recipes/wireless_modem_advanced.json
rename to projects/common/src/generated/resources/data/computercraft/recipe/wireless_modem_advanced.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/blocks/computer.json b/projects/common/src/generated/resources/data/computercraft/tags/block/computer.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/blocks/computer.json
rename to projects/common/src/generated/resources/data/computercraft/tags/block/computer.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/blocks/monitor.json b/projects/common/src/generated/resources/data/computercraft/tags/block/monitor.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/blocks/monitor.json
rename to projects/common/src/generated/resources/data/computercraft/tags/block/monitor.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/blocks/peripheral_hub_ignore.json b/projects/common/src/generated/resources/data/computercraft/tags/block/peripheral_hub_ignore.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/blocks/peripheral_hub_ignore.json
rename to projects/common/src/generated/resources/data/computercraft/tags/block/peripheral_hub_ignore.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle.json b/projects/common/src/generated/resources/data/computercraft/tags/block/turtle.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle.json
rename to projects/common/src/generated/resources/data/computercraft/tags/block/turtle.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle_always_breakable.json b/projects/common/src/generated/resources/data/computercraft/tags/block/turtle_always_breakable.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle_always_breakable.json
rename to projects/common/src/generated/resources/data/computercraft/tags/block/turtle_always_breakable.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle_can_use.json b/projects/common/src/generated/resources/data/computercraft/tags/block/turtle_can_use.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle_can_use.json
rename to projects/common/src/generated/resources/data/computercraft/tags/block/turtle_can_use.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle_hoe_harvestable.json b/projects/common/src/generated/resources/data/computercraft/tags/block/turtle_hoe_harvestable.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle_hoe_harvestable.json
rename to projects/common/src/generated/resources/data/computercraft/tags/block/turtle_hoe_harvestable.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle_shovel_harvestable.json b/projects/common/src/generated/resources/data/computercraft/tags/block/turtle_shovel_harvestable.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle_shovel_harvestable.json
rename to projects/common/src/generated/resources/data/computercraft/tags/block/turtle_shovel_harvestable.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle_sword_harvestable.json b/projects/common/src/generated/resources/data/computercraft/tags/block/turtle_sword_harvestable.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/blocks/turtle_sword_harvestable.json
rename to projects/common/src/generated/resources/data/computercraft/tags/block/turtle_sword_harvestable.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/blocks/wired_modem.json b/projects/common/src/generated/resources/data/computercraft/tags/block/wired_modem.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/blocks/wired_modem.json
rename to projects/common/src/generated/resources/data/computercraft/tags/block/wired_modem.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/items/computer.json b/projects/common/src/generated/resources/data/computercraft/tags/item/computer.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/items/computer.json
rename to projects/common/src/generated/resources/data/computercraft/tags/item/computer.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/items/dyeable.json b/projects/common/src/generated/resources/data/computercraft/tags/item/dyeable.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/items/dyeable.json
rename to projects/common/src/generated/resources/data/computercraft/tags/item/dyeable.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/items/monitor.json b/projects/common/src/generated/resources/data/computercraft/tags/item/monitor.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/items/monitor.json
rename to projects/common/src/generated/resources/data/computercraft/tags/item/monitor.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/items/turtle.json b/projects/common/src/generated/resources/data/computercraft/tags/item/turtle.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/items/turtle.json
rename to projects/common/src/generated/resources/data/computercraft/tags/item/turtle.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/items/turtle_can_place.json b/projects/common/src/generated/resources/data/computercraft/tags/item/turtle_can_place.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/items/turtle_can_place.json
rename to projects/common/src/generated/resources/data/computercraft/tags/item/turtle_can_place.json
diff --git a/projects/common/src/generated/resources/data/computercraft/tags/items/wired_modem.json b/projects/common/src/generated/resources/data/computercraft/tags/item/wired_modem.json
similarity index 100%
rename from projects/common/src/generated/resources/data/computercraft/tags/items/wired_modem.json
rename to projects/common/src/generated/resources/data/computercraft/tags/item/wired_modem.json
diff --git a/projects/common/src/generated/resources/data/create/tags/blocks/brittle.json b/projects/common/src/generated/resources/data/create/tags/block/brittle.json
similarity index 100%
rename from projects/common/src/generated/resources/data/create/tags/blocks/brittle.json
rename to projects/common/src/generated/resources/data/create/tags/block/brittle.json
diff --git a/projects/common/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/projects/common/src/generated/resources/data/minecraft/tags/block/mineable/pickaxe.json
similarity index 100%
rename from projects/common/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json
rename to projects/common/src/generated/resources/data/minecraft/tags/block/mineable/pickaxe.json
diff --git a/projects/common/src/generated/resources/data/minecraft/tags/blocks/wither_immune.json b/projects/common/src/generated/resources/data/minecraft/tags/block/wither_immune.json
similarity index 100%
rename from projects/common/src/generated/resources/data/minecraft/tags/blocks/wither_immune.json
rename to projects/common/src/generated/resources/data/minecraft/tags/block/wither_immune.json
diff --git a/projects/common/src/generated/resources/data/minecraft/tags/items/bookshelf_books.json b/projects/common/src/generated/resources/data/minecraft/tags/item/bookshelf_books.json
similarity index 100%
rename from projects/common/src/generated/resources/data/minecraft/tags/items/bookshelf_books.json
rename to projects/common/src/generated/resources/data/minecraft/tags/item/bookshelf_books.json
diff --git a/projects/common/src/generated/resources/data/minecraft/tags/items/piglin_loved.json b/projects/common/src/generated/resources/data/minecraft/tags/item/piglin_loved.json
similarity index 100%
rename from projects/common/src/generated/resources/data/minecraft/tags/items/piglin_loved.json
rename to projects/common/src/generated/resources/data/minecraft/tags/item/piglin_loved.json
diff --git a/projects/common/src/main/java/dan200/computercraft/data/BlockModelProvider.java b/projects/common/src/main/java/dan200/computercraft/data/BlockModelProvider.java
index c0c9f3491..cce81f774 100644
--- a/projects/common/src/main/java/dan200/computercraft/data/BlockModelProvider.java
+++ b/projects/common/src/main/java/dan200/computercraft/data/BlockModelProvider.java
@@ -43,33 +43,33 @@ class BlockModelProvider {
private static final TextureSlot BACKPACK = TextureSlot.create("backpack");
private static final ModelTemplate COMPUTER_ON = new ModelTemplate(
- Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/computer_on")),
+ Optional.of(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/computer_on")),
Optional.empty(),
TextureSlot.FRONT, TextureSlot.SIDE, TextureSlot.TOP, CURSOR
);
private static final ModelTemplate MONITOR_BASE = new ModelTemplate(
- Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/monitor_base")),
+ Optional.of(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/monitor_base")),
Optional.empty(),
TextureSlot.FRONT, TextureSlot.SIDE, TextureSlot.TOP, TextureSlot.BACK
);
private static final ModelTemplate MODEM = new ModelTemplate(
- Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/modem")),
+ Optional.of(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/modem")),
Optional.empty(),
TextureSlot.FRONT, TextureSlot.BACK
);
private static final ModelTemplate TURTLE = new ModelTemplate(
- Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_base")),
+ Optional.of(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_base")),
Optional.empty(),
TextureSlot.FRONT, TextureSlot.BACK, TextureSlot.TOP, TextureSlot.BOTTOM, LEFT, RIGHT, BACKPACK
);
private static final ModelTemplate TURTLE_UPGRADE_LEFT = new ModelTemplate(
- Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_upgrade_base_left")),
+ Optional.of(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_upgrade_base_left")),
Optional.of("_left"),
TextureSlot.TEXTURE
);
private static final ModelTemplate TURTLE_UPGRADE_RIGHT = new ModelTemplate(
- Optional.of(new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_upgrade_base_right")),
+ Optional.of(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_upgrade_base_right")),
Optional.of("_left"),
TextureSlot.TEXTURE
);
@@ -161,7 +161,7 @@ class BlockModelProvider {
);
case ON, BLINKING -> COMPUTER_ON.createWithSuffix(
block, "_" + state.getSerializedName(),
- TextureMapping.orientableCube(block).put(CURSOR, new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/computer" + state.getTexture())),
+ TextureMapping.orientableCube(block).put(CURSOR, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/computer" + state.getTexture())),
generators.modelOutput
);
}))
@@ -207,10 +207,10 @@ class BlockModelProvider {
generators.blockStateOutput.accept(MultiVariantGenerator.multiVariant(fullBlock)
.with(createModelDispatch(WiredModemFullBlock.MODEM_ON, WiredModemFullBlock.PERIPHERAL_ON, (on, peripheral) -> {
var suffix = (on ? "_on" : "_off") + (peripheral ? "_peripheral" : "");
- var faceTexture = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/wired_modem_face" + (peripheral ? "_peripheral" : "") + (on ? "_on" : ""));
+ var faceTexture = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/wired_modem_face" + (peripheral ? "_peripheral" : "") + (on ? "_on" : ""));
// TODO: Do this somewhere more elegant!
- modemModel(generators, new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/wired_modem" + suffix), faceTexture);
+ modemModel(generators, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/wired_modem" + suffix), faceTexture);
return ModelTemplates.CUBE_ALL.create(
getModelLocation(fullBlock, suffix),
@@ -220,7 +220,7 @@ class BlockModelProvider {
})));
generators.delegateItemModel(fullBlock, getModelLocation(fullBlock, "_off"));
- generators.delegateItemModel(ModRegistry.Items.WIRED_MODEM.get(), new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/wired_modem_off"));
+ generators.delegateItemModel(ModRegistry.Items.WIRED_MODEM.get(), ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/wired_modem_off"));
}
private static ResourceLocation modemModel(BlockModelGenerators generators, ResourceLocation name, ResourceLocation texture) {
@@ -228,7 +228,7 @@ class BlockModelProvider {
name,
new TextureMapping()
.put(TextureSlot.FRONT, texture)
- .put(TextureSlot.BACK, new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/modem_back")),
+ .put(TextureSlot.BACK, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/modem_back")),
generators.modelOutput
);
}
@@ -275,7 +275,7 @@ class BlockModelProvider {
var generator = MultiPartGenerator.multiPart(ModRegistry.Blocks.CABLE.get());
// When a cable only has a neighbour in a single direction, we redirect the core to face that direction.
- var coreFacing = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/cable_core_facing");
+ var coreFacing = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/cable_core_facing");
// Up/Down
generator.with(
Condition.or(
@@ -305,7 +305,7 @@ class BlockModelProvider {
);
// Find all other possibilities and emit a "solid" core which doesn't have a facing direction.
- var core = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/cable_core_any");
+ var core = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/cable_core_any");
List rightAngles = new ArrayList<>();
for (var i = 0; i < DirectionUtil.FACINGS.length; i++) {
for (var j = i; j < DirectionUtil.FACINGS.length; j++) {
@@ -319,7 +319,7 @@ class BlockModelProvider {
generator.with(Condition.or(rightAngles.toArray(new Condition[0])), Variant.variant().with(VariantProperties.MODEL, core));
// Then emit the actual cable arms
- var arm = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/cable_arm");
+ var arm = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/cable_arm");
for (var direction : DirectionUtil.FACINGS) {
generator.with(
new Condition.TerminalCondition().term(CABLE_DIRECTIONS[direction.ordinal()], true),
@@ -338,7 +338,7 @@ class BlockModelProvider {
generator.with(
new Condition.TerminalCondition().term(CableBlock.MODEM, CableModemVariant.from(direction, on, peripheral)),
Variant.variant()
- .with(VariantProperties.MODEL, new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/wired_modem" + suffix))
+ .with(VariantProperties.MODEL, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/wired_modem" + suffix))
.with(VariantProperties.X_ROT, toXAngle(direction))
.with(VariantProperties.Y_ROT, toYAngle(direction))
);
@@ -360,13 +360,13 @@ class BlockModelProvider {
private static void registerTurtleUpgrade(BlockModelGenerators generators, String name, String texture) {
TURTLE_UPGRADE_LEFT.create(
- new ResourceLocation(ComputerCraftAPI.MOD_ID, name + "_left"),
- TextureMapping.defaultTexture(new ResourceLocation(ComputerCraftAPI.MOD_ID, texture)),
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, name + "_left"),
+ TextureMapping.defaultTexture(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, texture)),
generators.modelOutput
);
TURTLE_UPGRADE_RIGHT.create(
- new ResourceLocation(ComputerCraftAPI.MOD_ID, name + "_right"),
- TextureMapping.defaultTexture(new ResourceLocation(ComputerCraftAPI.MOD_ID, texture)),
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, name + "_right"),
+ TextureMapping.defaultTexture(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, texture)),
generators.modelOutput
);
}
diff --git a/projects/common/src/main/java/dan200/computercraft/data/ItemModelProvider.java b/projects/common/src/main/java/dan200/computercraft/data/ItemModelProvider.java
index 4d0e990c8..f483641bb 100644
--- a/projects/common/src/main/java/dan200/computercraft/data/ItemModelProvider.java
+++ b/projects/common/src/main/java/dan200/computercraft/data/ItemModelProvider.java
@@ -28,7 +28,7 @@ public final class ItemModelProvider {
registerPocketComputer(generators, getModelLocation(ModRegistry.Items.POCKET_COMPUTER_NORMAL.get()), false);
registerPocketComputer(generators, getModelLocation(ModRegistry.Items.POCKET_COMPUTER_ADVANCED.get()), false);
- registerPocketComputer(generators, new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_colour"), true);
+ registerPocketComputer(generators, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "item/pocket_computer_colour"), true);
generators.generateFlatItem(ModRegistry.Items.PRINTED_BOOK.get(), ModelTemplates.FLAT_ITEM);
generators.generateFlatItem(ModRegistry.Items.PRINTED_PAGE.get(), ModelTemplates.FLAT_ITEM);
@@ -37,21 +37,21 @@ public final class ItemModelProvider {
private static void registerPocketComputer(ItemModelGenerators generators, ResourceLocation id, boolean off) {
createFlatItem(generators, id.withSuffix("_blinking"),
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_blink"),
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "item/pocket_computer_blink"),
id,
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_light")
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "item/pocket_computer_light")
);
createFlatItem(generators, id.withSuffix("_on"),
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_on"),
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "item/pocket_computer_on"),
id,
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_light")
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "item/pocket_computer_light")
);
// Don't emit the default/off state for advanced/normal pocket computers, as they have item overrides.
if (off) {
createFlatItem(generators, id,
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/pocket_computer_frame"),
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "item/pocket_computer_frame"),
id
);
}
@@ -59,8 +59,8 @@ public final class ItemModelProvider {
private static void registerDisk(ItemModelGenerators generators, Item item) {
createFlatItem(generators, item,
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/disk_frame"),
- new ResourceLocation(ComputerCraftAPI.MOD_ID, "item/disk_colour")
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "item/disk_frame"),
+ ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "item/disk_colour")
);
}
@@ -91,7 +91,7 @@ public final class ItemModelProvider {
mapping.put(slot, textures[i]);
}
- new ModelTemplate(Optional.of(new ResourceLocation("item/generated")), Optional.empty(), slots)
+ new ModelTemplate(Optional.of(ResourceLocation.withDefaultNamespace("item/generated")), Optional.empty(), slots)
.create(model, mapping, generators.output);
}
}
diff --git a/projects/common/src/main/java/dan200/computercraft/data/LootTableProvider.java b/projects/common/src/main/java/dan200/computercraft/data/LootTableProvider.java
index 90fc2733b..c407d1c18 100644
--- a/projects/common/src/main/java/dan200/computercraft/data/LootTableProvider.java
+++ b/projects/common/src/main/java/dan200/computercraft/data/LootTableProvider.java
@@ -12,7 +12,6 @@ import dan200.computercraft.shared.data.PlayerCreativeLootCondition;
import dan200.computercraft.shared.peripheral.modem.wired.CableBlock;
import dan200.computercraft.shared.peripheral.modem.wired.CableModemVariant;
import net.minecraft.advancements.critereon.StatePropertiesPredicate;
-import net.minecraft.core.HolderLookup;
import net.minecraft.data.loot.LootTableProvider.SubProviderEntry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.block.Block;
@@ -36,12 +35,12 @@ import java.util.function.Supplier;
class LootTableProvider {
public static List getTables() {
return List.of(
- new SubProviderEntry(() -> LootTableProvider::registerBlocks, LootContextParamSets.BLOCK),
- new SubProviderEntry(() -> LootTableProvider::registerGeneric, LootContextParamSets.ALL_PARAMS)
+ new SubProviderEntry(r -> LootTableProvider::registerBlocks, LootContextParamSets.BLOCK),
+ new SubProviderEntry(r -> LootTableProvider::registerGeneric, LootContextParamSets.ALL_PARAMS)
);
}
- private static void registerBlocks(HolderLookup.Provider registries, BiConsumer, LootTable.Builder> add) {
+ private static void registerBlocks(BiConsumer, LootTable.Builder> add) {
namedBlockDrop(add, ModRegistry.Blocks.DISK_DRIVE);
selfDrop(add, ModRegistry.Blocks.MONITOR_NORMAL);
selfDrop(add, ModRegistry.Blocks.MONITOR_ADVANCED);
@@ -78,7 +77,7 @@ class LootTableProvider {
));
}
- private static void registerGeneric(HolderLookup.Provider registries, BiConsumer, LootTable.Builder> add) {
+ private static void registerGeneric(BiConsumer, LootTable.Builder> add) {
add.accept(CommonHooks.TREASURE_DISK_LOOT, LootTable.lootTable());
}
diff --git a/projects/common/src/main/java/dan200/computercraft/data/PocketUpgradeProvider.java b/projects/common/src/main/java/dan200/computercraft/data/PocketUpgradeProvider.java
index 7481598d0..ec9de0c49 100644
--- a/projects/common/src/main/java/dan200/computercraft/data/PocketUpgradeProvider.java
+++ b/projects/common/src/main/java/dan200/computercraft/data/PocketUpgradeProvider.java
@@ -23,6 +23,6 @@ class PocketUpgradeProvider {
}
private static ResourceKey id(String id) {
- return ResourceKey.create(IPocketUpgrade.REGISTRY, new ResourceLocation(ComputerCraftAPI.MOD_ID, id));
+ return ResourceKey.create(IPocketUpgrade.REGISTRY, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, id));
}
}
diff --git a/projects/common/src/main/java/dan200/computercraft/data/RecipeProvider.java b/projects/common/src/main/java/dan200/computercraft/data/RecipeProvider.java
index 8d7233077..b62e1384d 100644
--- a/projects/common/src/main/java/dan200/computercraft/data/RecipeProvider.java
+++ b/projects/common/src/main/java/dan200/computercraft/data/RecipeProvider.java
@@ -14,7 +14,6 @@ import dan200.computercraft.api.upgrades.UpgradeData;
import dan200.computercraft.core.util.Colour;
import dan200.computercraft.data.recipe.ShapedSpecBuilder;
import dan200.computercraft.data.recipe.ShapelessSpecBuilder;
-import dan200.computercraft.shared.util.RegistryHelper;
import dan200.computercraft.shared.ModRegistry;
import dan200.computercraft.shared.common.ClearColourRecipe;
import dan200.computercraft.shared.common.ColourableRecipe;
@@ -33,6 +32,7 @@ import dan200.computercraft.shared.turtle.items.TurtleItem;
import dan200.computercraft.shared.turtle.recipes.TurtleUpgradeRecipe;
import dan200.computercraft.shared.util.ColourUtils;
import dan200.computercraft.shared.util.DataComponentUtil;
+import dan200.computercraft.shared.util.RegistryHelper;
import net.minecraft.advancements.Criterion;
import net.minecraft.advancements.critereon.InventoryChangeTrigger;
import net.minecraft.advancements.critereon.ItemPredicate;
@@ -120,7 +120,7 @@ final class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {
.group("computercraft:disk")
.unlockedBy("has_drive", inventoryChange(ModRegistry.Items.DISK_DRIVE.get()))
.build(ImpostorShapelessRecipe::new)
- .save(output, new ResourceLocation(ComputerCraftAPI.MOD_ID, "disk_" + (colour.ordinal() + 1)));
+ .save(output, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "disk_" + (colour.ordinal() + 1)));
}
}
@@ -211,7 +211,7 @@ final class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {
}
private void turtleOverlay(RecipeOutput add, String overlay, Consumer build) {
- var overlayId = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/" + overlay);
+ var overlayId = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/" + overlay);
for (var turtleItem : turtleItems()) {
var name = RegistryHelper.getKeyOrThrow(BuiltInRegistries.ITEM, turtleItem);
@@ -274,7 +274,7 @@ final class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {
.define('C', ModRegistry.Items.COMPUTER_NORMAL.get())
.unlockedBy("has_components", inventoryChange(itemPredicate(ModRegistry.Items.COMPUTER_NORMAL.get()), itemPredicate(ingredients.goldIngot())))
.build(x -> new TransformShapedRecipe(x, List.of(new CopyComponents(ModRegistry.Items.COMPUTER_NORMAL.get()))))
- .save(add, new ResourceLocation(ComputerCraftAPI.MOD_ID, "computer_advanced_upgrade"));
+ .save(add, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "computer_advanced_upgrade"));
ShapedRecipeBuilder
.shaped(RecipeCategory.REDSTONE, ModRegistry.Items.COMPUTER_COMMAND.get())
@@ -321,7 +321,7 @@ final class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {
.define('B', ingredients.goldBlock())
.unlockedBy("has_components", inventoryChange(itemPredicate(ModRegistry.Items.TURTLE_NORMAL.get()), itemPredicate(ingredients.goldIngot())))
.build(x -> new TransformShapedRecipe(x, List.of(new CopyComponents(ModRegistry.Items.TURTLE_NORMAL.get()))))
- .save(add, new ResourceLocation(ComputerCraftAPI.MOD_ID, "turtle_advanced_upgrade"));
+ .save(add, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "turtle_advanced_upgrade"));
ShapedRecipeBuilder
.shaped(RecipeCategory.REDSTONE, ModRegistry.Items.DISK_DRIVE.get())
@@ -386,7 +386,7 @@ final class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {
.define('C', ModRegistry.Items.POCKET_COMPUTER_NORMAL.get())
.unlockedBy("has_components", inventoryChange(itemPredicate(ModRegistry.Items.POCKET_COMPUTER_NORMAL.get()), itemPredicate(ingredients.goldIngot())))
.build(x -> new TransformShapedRecipe(x, List.of(new CopyComponents(ModRegistry.Items.POCKET_COMPUTER_NORMAL.get()))))
- .save(add, new ResourceLocation(ComputerCraftAPI.MOD_ID, "pocket_computer_advanced_upgrade"));
+ .save(add, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "pocket_computer_advanced_upgrade"));
ShapedRecipeBuilder
.shaped(RecipeCategory.REDSTONE, ModRegistry.Items.PRINTER.get())
@@ -425,12 +425,12 @@ final class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {
.shapeless(RecipeCategory.REDSTONE, ModRegistry.Items.WIRED_MODEM_FULL.get())
.requires(ModRegistry.Items.WIRED_MODEM.get())
.unlockedBy("has_modem", inventoryChange(WIRED_MODEM))
- .save(add, new ResourceLocation(ComputerCraftAPI.MOD_ID, "wired_modem_full_from"));
+ .save(add, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "wired_modem_full_from"));
ShapelessRecipeBuilder
.shapeless(RecipeCategory.REDSTONE, ModRegistry.Items.WIRED_MODEM.get())
.requires(ModRegistry.Items.WIRED_MODEM_FULL.get())
.unlockedBy("has_modem", inventoryChange(WIRED_MODEM))
- .save(add, new ResourceLocation(ComputerCraftAPI.MOD_ID, "wired_modem_full_to"));
+ .save(add, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "wired_modem_full_to"));
ShapedRecipeBuilder
.shaped(RecipeCategory.REDSTONE, ModRegistry.Items.WIRELESS_MODEM_NORMAL.get())
@@ -459,7 +459,7 @@ final class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {
.requires(ModRegistry.Items.MONITOR_NORMAL.get())
.unlockedBy("has_monitor", inventoryChange(ModRegistry.Items.MONITOR_NORMAL.get()))
.build()
- .save(add, new ResourceLocation(ComputerCraftAPI.MOD_ID, "skull_cloudy"));
+ .save(add, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "skull_cloudy"));
ShapelessSpecBuilder
.shapeless(RecipeCategory.DECORATIONS, playerHead("dan200", "f3c8d69b-0776-4512-8434-d1b2165909eb"))
@@ -467,7 +467,7 @@ final class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {
.requires(ModRegistry.Items.COMPUTER_ADVANCED.get())
.unlockedBy("has_computer", inventoryChange(ModRegistry.Items.COMPUTER_ADVANCED.get()))
.build()
- .save(add, new ResourceLocation(ComputerCraftAPI.MOD_ID, "skull_dan200"));
+ .save(add, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "skull_dan200"));
var pages = Ingredient.of(
ModRegistry.Items.PRINTED_PAGE.get(),
@@ -523,7 +523,7 @@ final class RecipeProvider extends net.minecraft.data.recipes.RecipeProvider {
var item = ItemStack.SIMPLE_ITEM_CODEC.parse(JsonOps.INSTANCE, object).getOrThrow();
return itemPredicate(item.getItem());
} else if (object.has("tag")) {
- return itemPredicate(TagKey.create(Registries.ITEM, new ResourceLocation(GsonHelper.getAsString(object, "tag"))));
+ return itemPredicate(TagKey.create(Registries.ITEM, ResourceLocation.parse(GsonHelper.getAsString(object, "tag"))));
} else {
throw new IllegalArgumentException("Unknown ingredient " + json);
}
diff --git a/projects/common/src/main/java/dan200/computercraft/data/TurtleUpgradeProvider.java b/projects/common/src/main/java/dan200/computercraft/data/TurtleUpgradeProvider.java
index 001ca3485..2ecf48a2b 100644
--- a/projects/common/src/main/java/dan200/computercraft/data/TurtleUpgradeProvider.java
+++ b/projects/common/src/main/java/dan200/computercraft/data/TurtleUpgradeProvider.java
@@ -34,11 +34,11 @@ class TurtleUpgradeProvider {
}
private static ResourceKey id(String id) {
- return ITurtleUpgrade.createKey(new ResourceLocation(ComputerCraftAPI.MOD_ID, id));
+ return ITurtleUpgrade.createKey(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, id));
}
private static ResourceKey vanilla(String id) {
// Naughty, please don't do this. Mostly here for some semblance of backwards compatibility.
- return ITurtleUpgrade.createKey(new ResourceLocation("minecraft", id));
+ return ITurtleUpgrade.createKey(ResourceLocation.fromNamespaceAndPath("minecraft", id));
}
}
diff --git a/projects/common/src/main/java/dan200/computercraft/impl/AbstractComputerCraftAPI.java b/projects/common/src/main/java/dan200/computercraft/impl/AbstractComputerCraftAPI.java
index 4652c35e0..0cf968bc8 100644
--- a/projects/common/src/main/java/dan200/computercraft/impl/AbstractComputerCraftAPI.java
+++ b/projects/common/src/main/java/dan200/computercraft/impl/AbstractComputerCraftAPI.java
@@ -48,12 +48,12 @@ public abstract class AbstractComputerCraftAPI implements ComputerCraftAPIServic
private final DetailRegistry itemStackDetails = new DetailRegistryImpl<>(ItemDetails::fillBasic);
private final DetailRegistry blockDetails = new DetailRegistryImpl<>(BlockDetails::fillBasic);
- protected static final ResourceKey>> turtleUpgradeRegistryId = ResourceKey.createRegistryKey(new ResourceLocation(ComputerCraftAPI.MOD_ID, "turtle_upgrade_type"));
- protected static final ResourceKey>> pocketUpgradeRegistryId = ResourceKey.createRegistryKey(new ResourceLocation(ComputerCraftAPI.MOD_ID, "pocket_upgrade_type"));
+ protected static final ResourceKey>> turtleUpgradeRegistryId = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "turtle_upgrade_type"));
+ protected static final ResourceKey>> pocketUpgradeRegistryId = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "pocket_upgrade_type"));
public static @Nullable InputStream getResourceFile(MinecraftServer server, String domain, String subPath) {
var manager = server.getResourceManager();
- var resource = manager.getResource(new ResourceLocation(domain, subPath)).orElse(null);
+ var resource = manager.getResource(ResourceLocation.fromNamespaceAndPath(domain, subPath)).orElse(null);
if (resource == null) return null;
try {
return resource.open();
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/CommonHooks.java b/projects/common/src/main/java/dan200/computercraft/shared/CommonHooks.java
index 3b077f3b2..615849473 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/CommonHooks.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/CommonHooks.java
@@ -92,7 +92,7 @@ public final class CommonHooks {
TickScheduler.onChunkTicketChanged(level, chunkPos, oldLevel, newLevel);
}
- public static final ResourceKey TREASURE_DISK_LOOT = ResourceKey.create(Registries.LOOT_TABLE, new ResourceLocation(ComputerCraftAPI.MOD_ID, "treasure_disk"));
+ public static final ResourceKey TREASURE_DISK_LOOT = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "treasure_disk"));
private static final Set> TREASURE_DISK_LOOT_TABLES = Set.of(
BuiltInLootTables.SIMPLE_DUNGEON,
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java b/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java
index a46489491..0c7fd6df1 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java
@@ -100,7 +100,10 @@ import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.inventory.MenuType;
-import net.minecraft.world.item.*;
+import net.minecraft.world.item.BlockItem;
+import net.minecraft.world.item.CreativeModeTab;
+import net.minecraft.world.item.Item;
+import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.DyedItemColor;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.Recipe;
@@ -580,9 +583,8 @@ public final class ModRegistry {
ComputerCraftAPI.registerBundledRedstoneProvider(new DefaultBundledRedstoneProvider());
ComputerCraftAPI.registerRefuelHandler(new FurnaceRefuelHandler());
ComputerCraftAPI.registerMediaProvider(stack -> {
- var item = stack.getItem();
- if (item instanceof IMedia media) return media;
- if (item instanceof RecordItem) return RecordMedia.INSTANCE;
+ if (stack.getItem() instanceof IMedia media) return media;
+ if (stack.has(net.minecraft.core.component.DataComponents.JUKEBOX_PLAYABLE)) return RecordMedia.INSTANCE;
return null;
});
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/common/ClearColourRecipe.java b/projects/common/src/main/java/dan200/computercraft/shared/common/ClearColourRecipe.java
index 05a53a87a..396c30a9f 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/common/ClearColourRecipe.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/common/ClearColourRecipe.java
@@ -10,10 +10,10 @@ import dan200.computercraft.shared.util.DataComponentUtil;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.NonNullList;
import net.minecraft.core.component.DataComponents;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.CraftingBookCategory;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;
@@ -27,10 +27,10 @@ public final class ClearColourRecipe extends CustomRecipe {
}
@Override
- public boolean matches(CraftingContainer inv, Level world) {
+ public boolean matches(CraftingInput inv, Level world) {
var hasColourable = false;
var hasSponge = false;
- for (var i = 0; i < inv.getContainerSize(); i++) {
+ for (var i = 0; i < inv.size(); i++) {
var stack = inv.getItem(i);
if (stack.isEmpty()) continue;
@@ -50,10 +50,10 @@ public final class ClearColourRecipe extends CustomRecipe {
}
@Override
- public ItemStack assemble(CraftingContainer inv, HolderLookup.Provider registryAccess) {
+ public ItemStack assemble(CraftingInput inv, HolderLookup.Provider registryAccess) {
var colourable = ItemStack.EMPTY;
- for (var i = 0; i < inv.getContainerSize(); i++) {
+ for (var i = 0; i < inv.size(); i++) {
var stack = inv.getItem(i);
if (stack.is(ComputerCraftTags.Items.DYEABLE)) colourable = stack;
}
@@ -64,8 +64,8 @@ public final class ClearColourRecipe extends CustomRecipe {
}
@Override
- public NonNullList getRemainingItems(CraftingContainer container) {
- var remaining = NonNullList.withSize(container.getContainerSize(), ItemStack.EMPTY);
+ public NonNullList getRemainingItems(CraftingInput container) {
+ var remaining = NonNullList.withSize(container.size(), ItemStack.EMPTY);
for (var i = 0; i < remaining.size(); i++) {
if (container.getItem(i).getItem() == Items.WET_SPONGE) remaining.set(i, new ItemStack(Items.WET_SPONGE));
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/common/ColourableRecipe.java b/projects/common/src/main/java/dan200/computercraft/shared/common/ColourableRecipe.java
index dda9564f3..e643b8a41 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/common/ColourableRecipe.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/common/ColourableRecipe.java
@@ -11,10 +11,10 @@ import dan200.computercraft.shared.util.ColourUtils;
import dan200.computercraft.shared.util.DataComponentUtil;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponents;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.DyedItemColor;
import net.minecraft.world.item.crafting.CraftingBookCategory;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;
@@ -25,10 +25,10 @@ public final class ColourableRecipe extends CustomRecipe {
}
@Override
- public boolean matches(CraftingContainer inv, Level world) {
+ public boolean matches(CraftingInput inv, Level world) {
var hasColourable = false;
var hasDye = false;
- for (var i = 0; i < inv.getContainerSize(); i++) {
+ for (var i = 0; i < inv.size(); i++) {
var stack = inv.getItem(i);
if (stack.isEmpty()) continue;
@@ -46,12 +46,12 @@ public final class ColourableRecipe extends CustomRecipe {
}
@Override
- public ItemStack assemble(CraftingContainer inv, HolderLookup.Provider registryAccess) {
+ public ItemStack assemble(CraftingInput inv, HolderLookup.Provider registryAccess) {
var colourable = ItemStack.EMPTY;
var tracker = new ColourTracker();
- for (var i = 0; i < inv.getContainerSize(); i++) {
+ for (var i = 0; i < inv.size(); i++) {
var stack = inv.getItem(i);
if (stack.isEmpty()) continue;
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/common/HorizontalContainerBlock.java b/projects/common/src/main/java/dan200/computercraft/shared/common/HorizontalContainerBlock.java
index d9392c962..07a1f5472 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/common/HorizontalContainerBlock.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/common/HorizontalContainerBlock.java
@@ -62,13 +62,7 @@ public abstract class HorizontalContainerBlock extends BaseEntityBlock {
@Override
protected final void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
- if (state.is(newState.getBlock())) return;
-
- if (level.getBlockEntity(pos) instanceof BaseContainerBlockEntity container) {
- Containers.dropContents(level, pos, container);
- level.updateNeighbourForOutputSignal(pos, this);
- }
-
+ Containers.dropContentsOnDestroy(state, newState, level, pos);
super.onRemove(state, level, pos, newState, isMoving);
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ResourceMount.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ResourceMount.java
index 2171ac6d4..3fc81f9b2 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ResourceMount.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ResourceMount.java
@@ -41,7 +41,7 @@ public final class ResourceMount extends ArchiveMount {
private ResourceManager manager;
public static ResourceMount get(String namespace, String subPath, ResourceManager manager) {
- var path = new ResourceLocation(namespace, subPath);
+ var path = ResourceLocation.fromNamespaceAndPath(namespace, subPath);
synchronized (MOUNT_CACHE) {
var mount = MOUNT_CACHE.get(path);
if (mount == null) MOUNT_CACHE.put(path, mount = new ResourceMount(namespace, subPath, manager));
@@ -60,7 +60,7 @@ public final class ResourceMount extends ArchiveMount {
var hasAny = false;
String existingNamespace = null;
- var newRoot = new FileEntry(new ResourceLocation(namespace, subPath));
+ var newRoot = new FileEntry(ResourceLocation.fromNamespaceAndPath(namespace, subPath));
for (var file : manager.listResources(subPath, s -> true).keySet()) {
existingNamespace = file.getNamespace();
@@ -88,7 +88,7 @@ public final class ResourceMount extends ArchiveMount {
}
private FileEntry createEntry(String path) {
- return new FileEntry(new ResourceLocation(namespace, subPath + "/" + path));
+ return new FileEntry(ResourceLocation.fromNamespaceAndPath(namespace, subPath + "/" + path));
}
@Override
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/items/AbstractComputerItem.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/items/AbstractComputerItem.java
index 73ff33c56..4c86246ee 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/computer/items/AbstractComputerItem.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/items/AbstractComputerItem.java
@@ -12,6 +12,7 @@ import dan200.computercraft.shared.computer.blocks.AbstractComputerBlock;
import dan200.computercraft.shared.config.Config;
import dan200.computercraft.shared.util.DataComponentUtil;
import net.minecraft.ChatFormatting;
+import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
@@ -39,7 +40,7 @@ public class AbstractComputerItem extends BlockItem implements IMedia {
}
@Override
- public @Nullable String getLabel(ItemStack stack) {
+ public @Nullable String getLabel(HolderLookup.Provider registries, ItemStack stack) {
return DataComponentUtil.getCustomName(stack);
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/container/BasicContainer.java b/projects/common/src/main/java/dan200/computercraft/shared/container/BasicContainer.java
index 8541329b8..e250a8923 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/container/BasicContainer.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/container/BasicContainer.java
@@ -4,16 +4,17 @@
package dan200.computercraft.shared.container;
-import net.minecraft.core.NonNullList;
import net.minecraft.world.Container;
import net.minecraft.world.ContainerHelper;
import net.minecraft.world.item.ItemStack;
+import java.util.List;
+
/**
* A basic implementation of {@link Container} which operates on a {@linkplain #getItems() list of stacks}.
*/
public interface BasicContainer extends Container {
- NonNullList getItems();
+ List getItems();
@Override
default int getContainerSize() {
@@ -55,7 +56,7 @@ public interface BasicContainer extends Container {
getItems().clear();
}
- static void defaultSetItems(NonNullList inventory, NonNullList items) {
+ static void defaultSetItems(List inventory, List items) {
var i = 0;
for (; i < items.size(); i++) inventory.set(i, items.get(i));
for (; i < inventory.size(); i++) inventory.set(i, ItemStack.EMPTY);
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/container/ListContainer.java b/projects/common/src/main/java/dan200/computercraft/shared/container/ListContainer.java
new file mode 100644
index 000000000..303557ec6
--- /dev/null
+++ b/projects/common/src/main/java/dan200/computercraft/shared/container/ListContainer.java
@@ -0,0 +1,31 @@
+// SPDX-FileCopyrightText: 2024 The CC: Tweaked Developers
+//
+// SPDX-License-Identifier: MPL-2.0
+
+package dan200.computercraft.shared.container;
+
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.ItemStack;
+
+import java.util.List;
+
+/**
+ * A container backed by a simple list.
+ *
+ * @param items The items backing this list.
+ */
+public record ListContainer(List items) implements BasicContainer {
+ @Override
+ public List getItems() {
+ return items;
+ }
+
+ @Override
+ public void setChanged() {
+ }
+
+ @Override
+ public boolean stillValid(Player player) {
+ return true;
+ }
+}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/details/ItemDetails.java b/projects/common/src/main/java/dan200/computercraft/shared/details/ItemDetails.java
index 7d16804c2..1ff92aef4 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/details/ItemDetails.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/details/ItemDetails.java
@@ -13,6 +13,7 @@ import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.ItemEnchantments;
@@ -112,9 +113,9 @@ public class ItemDetails {
var enchantment = entry.getKey();
var level = entry.getIntValue();
var enchant = new HashMap(3);
- enchant.put("name", DetailHelpers.getId(BuiltInRegistries.ENCHANTMENT, enchantment.value()));
+ enchant.put("name", enchantment.getRegisteredName());
enchant.put("level", level);
- enchant.put("displayName", enchantment.value().getFullname(level).getString());
+ enchant.put("displayName", Enchantment.getFullname(enchantment, level).getString());
enchants.add(enchant);
}
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/integration/ExternalModTags.java b/projects/common/src/main/java/dan200/computercraft/shared/integration/ExternalModTags.java
index 29a666217..8d3cc6d23 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/integration/ExternalModTags.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/integration/ExternalModTags.java
@@ -31,7 +31,7 @@ public final class ExternalModTags {
public static final TagKey CREATE_BRITTLE = make("create", "brittle");
private static TagKey make(String mod, String name) {
- return TagKey.create(Registries.BLOCK, new ResourceLocation(mod, name));
+ return TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(mod, name));
}
}
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java b/projects/common/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java
index 730778631..7e0fc4f5a 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java
@@ -28,7 +28,7 @@ import java.util.List;
public class JEIComputerCraft implements IModPlugin {
@Override
public ResourceLocation getPluginUid() {
- return new ResourceLocation(ComputerCraftAPI.MOD_ID, "jei");
+ return ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "jei");
}
@Override
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/integration/jei/RecipeResolver.java b/projects/common/src/main/java/dan200/computercraft/shared/integration/jei/RecipeResolver.java
index f7addc311..9e9246753 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/integration/jei/RecipeResolver.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/integration/jei/RecipeResolver.java
@@ -22,7 +22,7 @@ import net.minecraft.world.item.crafting.RecipeHolder;
import java.util.List;
class RecipeResolver implements IRecipeManagerPlugin {
- private static final ResourceLocation RECIPE_ID = new ResourceLocation(ComputerCraftAPI.MOD_ID, "upgrade");
+ private static final ResourceLocation RECIPE_ID = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "upgrade");
private final UpgradeRecipeGenerator> resolver = new UpgradeRecipeGenerator<>(x -> new RecipeHolder<>(RECIPE_ID, x), RecipeModHelpers.getEmptyRegistryAccess());
@Override
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/media/items/DiskItem.java b/projects/common/src/main/java/dan200/computercraft/shared/media/items/DiskItem.java
index 59fbbbf33..b5be0a559 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/media/items/DiskItem.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/media/items/DiskItem.java
@@ -14,6 +14,7 @@ import dan200.computercraft.shared.config.Config;
import dan200.computercraft.shared.util.NonNegativeId;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
+import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
@@ -49,7 +50,7 @@ public class DiskItem extends Item implements IMedia {
}
@Override
- public @Nullable String getLabel(ItemStack stack) {
+ public @Nullable String getLabel(HolderLookup.Provider registries, ItemStack stack) {
var label = stack.get(DataComponents.CUSTOM_NAME);
return label != null ? label.getString() : null;
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/media/items/RecordMedia.java b/projects/common/src/main/java/dan200/computercraft/shared/media/items/RecordMedia.java
index 8442d7d17..b15e6489e 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/media/items/RecordMedia.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/media/items/RecordMedia.java
@@ -5,14 +5,14 @@
package dan200.computercraft.shared.media.items;
import dan200.computercraft.api.media.IMedia;
-import net.minecraft.sounds.SoundEvent;
+import net.minecraft.core.HolderLookup;
import net.minecraft.world.item.ItemStack;
-import net.minecraft.world.item.RecordItem;
+import net.minecraft.world.item.JukeboxSong;
import javax.annotation.Nullable;
/**
- * An implementation of {@link IMedia} for {@link RecordItem}.
+ * An implementation of {@link IMedia} for items with a {@link JukeboxSong}.
*/
public final class RecordMedia implements IMedia {
public static final RecordMedia INSTANCE = new RecordMedia();
@@ -21,19 +21,8 @@ public final class RecordMedia implements IMedia {
}
@Override
- public @Nullable String getLabel(ItemStack stack) {
- return getAudioTitle(stack);
- }
-
- @Override
- public @Nullable String getAudioTitle(ItemStack stack) {
- var item = stack.getItem();
- return item instanceof RecordItem record ? record.getDisplayName().getString() : null;
- }
-
- @Override
- public @Nullable SoundEvent getAudio(ItemStack stack) {
- var item = stack.getItem();
- return item instanceof RecordItem record ? record.getSound() : null;
+ public @Nullable String getLabel(HolderLookup.Provider registries, ItemStack stack) {
+ var song = getAudio(registries, stack);
+ return song == null ? null : song.value().description().getString();
}
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/media/items/TreasureDiskItem.java b/projects/common/src/main/java/dan200/computercraft/shared/media/items/TreasureDiskItem.java
index 0d768b813..86a990863 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/media/items/TreasureDiskItem.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/media/items/TreasureDiskItem.java
@@ -11,6 +11,7 @@ import dan200.computercraft.api.media.IMedia;
import dan200.computercraft.core.filesystem.SubMount;
import dan200.computercraft.shared.ModRegistry;
import net.minecraft.core.BlockPos;
+import net.minecraft.core.HolderLookup;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
@@ -39,7 +40,7 @@ public class TreasureDiskItem extends Item implements IMedia {
}
@Override
- public String getLabel(ItemStack stack) {
+ public String getLabel(HolderLookup.Provider registries, ItemStack stack) {
return TreasureDisk.getTitle(stack);
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java b/projects/common/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java
index 5f478cc5e..1c7586bed 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/media/recipes/DiskRecipe.java
@@ -12,14 +12,10 @@ import dan200.computercraft.shared.util.ColourUtils;
import dan200.computercraft.shared.util.DataComponentUtil;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponents;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.component.DyedItemColor;
-import net.minecraft.world.item.crafting.CraftingBookCategory;
-import net.minecraft.world.item.crafting.CustomRecipe;
-import net.minecraft.world.item.crafting.Ingredient;
-import net.minecraft.world.item.crafting.RecipeSerializer;
+import net.minecraft.world.item.crafting.*;
import net.minecraft.world.level.Level;
public class DiskRecipe extends CustomRecipe {
@@ -31,11 +27,11 @@ public class DiskRecipe extends CustomRecipe {
}
@Override
- public boolean matches(CraftingContainer inv, Level world) {
+ public boolean matches(CraftingInput inv, Level world) {
var paperFound = false;
var redstoneFound = false;
- for (var i = 0; i < inv.getContainerSize(); i++) {
+ for (var i = 0; i < inv.size(); i++) {
var stack = inv.getItem(i);
if (!stack.isEmpty()) {
@@ -55,10 +51,10 @@ public class DiskRecipe extends CustomRecipe {
}
@Override
- public ItemStack assemble(CraftingContainer inv, HolderLookup.Provider registryAccess) {
+ public ItemStack assemble(CraftingInput inv, HolderLookup.Provider registryAccess) {
var tracker = new ColourTracker();
- for (var i = 0; i < inv.getContainerSize(); i++) {
+ for (var i = 0; i < inv.size(); i++) {
var stack = inv.getItem(i);
if (stack.isEmpty()) continue;
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java b/projects/common/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java
index a99635f0f..8837e3256 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/media/recipes/PrintoutRecipe.java
@@ -18,8 +18,8 @@ import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.util.ExtraCodecs;
import net.minecraft.world.entity.player.StackedContents;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.ShapelessRecipe;
@@ -93,7 +93,7 @@ public final class PrintoutRecipe extends ShapelessRecipe {
}
@Override
- public boolean matches(CraftingContainer inv, Level world) {
+ public boolean matches(CraftingInput inv, Level world) {
var stackedContents = new StackedContents();
var inputs = 0;
@@ -101,7 +101,7 @@ public final class PrintoutRecipe extends ShapelessRecipe {
var pages = 0;
var hasPrintout = false;
- for (var j = 0; j < inv.getContainerSize(); ++j) {
+ for (var j = 0; j < inv.size(); ++j) {
var stack = inv.getItem(j);
if (stack.isEmpty()) continue;
if (printout.test(stack)) {
@@ -125,9 +125,9 @@ public final class PrintoutRecipe extends ShapelessRecipe {
}
@Override
- public ItemStack assemble(CraftingContainer inv, HolderLookup.Provider registries) {
+ public ItemStack assemble(CraftingInput inv, HolderLookup.Provider registries) {
List data = new ArrayList<>();
- for (var j = 0; j < inv.getContainerSize(); ++j) {
+ for (var j = 0; j < inv.size(); ++j) {
var stack = inv.getItem(j);
if (!stack.isEmpty() && printout.test(stack)) data.add(PrintoutData.getOrEmpty(stack));
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/network/NetworkMessages.java b/projects/common/src/main/java/dan200/computercraft/shared/network/NetworkMessages.java
index 216a39ca4..1abe0498a 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/network/NetworkMessages.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/network/NetworkMessages.java
@@ -51,7 +51,7 @@ public final class NetworkMessages {
String channel, StreamCodec codec
) {
if (!seenChannel.add(channel)) throw new IllegalArgumentException("Duplicate channel " + channel);
- var type = new CustomPacketPayload.Type(new ResourceLocation(ComputerCraftAPI.MOD_ID, channel));
+ var type = new CustomPacketPayload.Type(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, channel));
messages.add(new CustomPacketPayload.TypeAndCodec<>(type, codec));
return type;
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/network/client/ClientNetworkContext.java b/projects/common/src/main/java/dan200/computercraft/shared/network/client/ClientNetworkContext.java
index d5822536d..5dc5bc3f7 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/network/client/ClientNetworkContext.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/network/client/ClientNetworkContext.java
@@ -11,9 +11,10 @@ import dan200.computercraft.shared.computer.upload.UploadResult;
import dan200.computercraft.shared.peripheral.speaker.EncodedAudio;
import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition;
import net.minecraft.core.BlockPos;
+import net.minecraft.core.Holder;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.sounds.SoundEvent;
+import net.minecraft.world.item.JukeboxSong;
import javax.annotation.Nullable;
import java.util.UUID;
@@ -28,7 +29,7 @@ public interface ClientNetworkContext {
void handleMonitorData(BlockPos pos, @Nullable TerminalState terminal);
- void handlePlayRecord(BlockPos pos, @Nullable SoundEvent sound, @Nullable String name);
+ void handlePlayRecord(BlockPos pos, @Nullable Holder sound);
void handlePocketComputerData(UUID instanceId, ComputerState state, int lightState, @Nullable TerminalState terminal);
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java b/projects/common/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java
index a40b3b608..e9b294e89 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/network/client/PlayRecordClientMessage.java
@@ -13,37 +13,35 @@ import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
-import net.minecraft.sounds.SoundEvent;
+import net.minecraft.world.item.JukeboxSong;
import java.util.Optional;
/**
- * Starts or stops a record on the client, depending on if {@link #soundEvent} is {@code null}.
+ * Starts or stops a record on the client, depending on if {@link #song} is {@code null}.
*
* Used by disk drives to play record items.
*
- * @param pos The position of the speaker, where we should play this sound.
- * @param soundEvent The sound to play, or {@link Optional#empty()} if we should stop playing.
- * @param name The title of the audio to play.
+ * @param pos The position of the speaker, where we should play this sound.
+ * @param song The sound to play, or {@link Optional#empty()} if we should stop playing.
* @see DiskDriveBlockEntity
*/
public record PlayRecordClientMessage(
- BlockPos pos, Optional> soundEvent, Optional name
+ BlockPos pos, Optional> song
) implements NetworkMessage {
public static final StreamCodec STREAM_CODEC = StreamCodec.composite(
BlockPos.STREAM_CODEC, PlayRecordClientMessage::pos,
- ByteBufCodecs.optional(SoundEvent.STREAM_CODEC), PlayRecordClientMessage::soundEvent,
- ByteBufCodecs.optional(ByteBufCodecs.STRING_UTF8), PlayRecordClientMessage::name,
+ ByteBufCodecs.optional(JukeboxSong.STREAM_CODEC), PlayRecordClientMessage::song,
PlayRecordClientMessage::new
);
public PlayRecordClientMessage(BlockPos pos) {
- this(pos, Optional.empty(), Optional.empty());
+ this(pos, Optional.empty());
}
@Override
public void handle(ClientNetworkContext context) {
- context.handlePlayRecord(pos, soundEvent.map(Holder::value).orElse(null), name.orElse(null));
+ context.handlePlayRecord(pos, song.orElse(null));
}
@Override
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/network/codec/MoreStreamCodecs.java b/projects/common/src/main/java/dan200/computercraft/shared/network/codec/MoreStreamCodecs.java
index f20f92014..893980b68 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/network/codec/MoreStreamCodecs.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/network/codec/MoreStreamCodecs.java
@@ -48,7 +48,7 @@ public class MoreStreamCodecs {
@Override
public void encode(B buffer, NonNullList list) {
- var count = buffer.writeVarInt(list.size());
+ buffer.writeVarInt(list.size());
for (var entry : list) codec.encode(buffer, entry);
}
};
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveBlockEntity.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveBlockEntity.java
index 870355e5a..80be04f06 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveBlockEntity.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveBlockEntity.java
@@ -15,7 +15,10 @@ import dan200.computercraft.shared.container.BasicContainer;
import dan200.computercraft.shared.network.client.PlayRecordClientMessage;
import dan200.computercraft.shared.network.server.ServerNetworking;
import dan200.computercraft.shared.util.WorldUtil;
-import net.minecraft.core.*;
+import net.minecraft.core.BlockPos;
+import net.minecraft.core.Direction;
+import net.minecraft.core.HolderLookup;
+import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Inventory;
@@ -131,11 +134,10 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity imp
switch (recordQueued) {
case PLAY -> {
var media = getMedia();
- var record = media.getAudio();
+ var record = media.getAudio(getLevel().registryAccess());
if (record != null) {
recordPlaying = true;
- var title = media.getAudioTitle();
- sendMessage(new PlayRecordClientMessage(getBlockPos(), Optional.of(Holder.direct(record)), Optional.ofNullable(title)));
+ sendMessage(new PlayRecordClientMessage(getBlockPos(), Optional.of(record)));
}
}
case STOP -> {
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDrivePeripheral.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDrivePeripheral.java
index d103baf96..2c1b1630c 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDrivePeripheral.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDrivePeripheral.java
@@ -64,7 +64,7 @@ public class DiskDrivePeripheral implements IPeripheral {
@LuaFunction
public final Object[] getDiskLabel() {
var media = diskDrive.getMedia();
- return media.media() == null ? null : new Object[]{ media.media().getLabel(media.stack()) };
+ return media.media() == null ? null : new Object[]{ media.media().getLabel(diskDrive.getLevel().registryAccess(), media.stack()) };
}
/**
@@ -117,7 +117,7 @@ public class DiskDrivePeripheral implements IPeripheral {
*/
@LuaFunction
public final boolean hasAudio() {
- return diskDrive.getMedia().getAudio() != null;
+ return diskDrive.getMedia().getAudio(diskDrive.getLevel().registryAccess()) != null;
}
/**
@@ -130,7 +130,10 @@ public class DiskDrivePeripheral implements IPeripheral {
@Nullable
public final Object getAudioTitle() {
var stack = diskDrive.getMedia();
- return stack.media() != null ? stack.getAudioTitle() : false;
+ if (stack.media() == null) return false;
+
+ var audio = stack.getAudio(diskDrive.getLevel().registryAccess());
+ return audio == null ? null : audio.value().description().getString();
}
/**
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/MediaStack.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/MediaStack.java
index dc56eabcc..e3c5a15e8 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/MediaStack.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/MediaStack.java
@@ -6,8 +6,10 @@ package dan200.computercraft.shared.peripheral.diskdrive;
import dan200.computercraft.api.media.IMedia;
import dan200.computercraft.impl.MediaProviders;
-import net.minecraft.sounds.SoundEvent;
+import net.minecraft.core.Holder;
+import net.minecraft.core.HolderLookup;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.JukeboxSong;
import javax.annotation.Nullable;
@@ -28,12 +30,7 @@ record MediaStack(ItemStack stack, @Nullable IMedia media) {
}
@Nullable
- SoundEvent getAudio() {
- return media != null ? media.getAudio(stack) : null;
- }
-
- @Nullable
- String getAudioTitle() {
- return media != null ? media.getAudioTitle(stack) : null;
+ Holder getAudio(HolderLookup.Provider registries) {
+ return media != null ? media.getAudio(registries, stack) : null;
}
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java
index 4df09543d..2477174ae 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java
@@ -22,13 +22,13 @@ import dan200.computercraft.shared.util.PauseAwareTimer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.core.registries.Registries;
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
-import net.minecraft.world.item.RecordItem;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import javax.annotation.Nullable;
@@ -258,7 +258,11 @@ public abstract class SpeakerPeripheral implements IPeripheral {
// Prevent playing music discs.
var soundEvent = BuiltInRegistries.SOUND_EVENT.get(identifier);
- if (soundEvent != null && RecordItem.getBySound(soundEvent) != null) return false;
+ // TODO: Build a set of sound events at server startup, and cache this.
+ var level = Objects.requireNonNull(getPosition().level());
+ if (soundEvent != null && level.registryAccess().registry(Registries.JUKEBOX_SONG).orElseThrow().stream().anyMatch(x -> x.soundEvent().value() == soundEvent)) {
+ return false;
+ }
synchronized (lock) {
if (pendingSound != null || (dfpwmState != null && dfpwmState.isPlaying())) return false;
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java b/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java
index 278e34f51..9f1e821b1 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java
@@ -28,12 +28,12 @@ import net.minecraft.world.*;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
@@ -217,7 +217,7 @@ public interface PlatformHelper {
* @param container The crafting container.
* @return A list of items to return to the player after crafting.
*/
- List getRecipeRemainingItems(ServerPlayer player, Recipe recipe, CraftingContainer container);
+ List getRecipeRemainingItems(ServerPlayer player, Recipe recipe, CraftingInput container);
/**
* Fire an event after crafting has occurred.
@@ -226,7 +226,7 @@ public interface PlatformHelper {
* @param container The current crafting container.
* @param stack The resulting stack from crafting.
*/
- void onItemCrafted(ServerPlayer player, CraftingContainer container, ItemStack stack);
+ void onItemCrafted(ServerPlayer player, CraftingInput container, ItemStack stack);
/**
* Check whether we should notify neighbours in a particular direction.
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/pocket/items/PocketComputerItem.java b/projects/common/src/main/java/dan200/computercraft/shared/pocket/items/PocketComputerItem.java
index 6bc675687..99f5c93fd 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/pocket/items/PocketComputerItem.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/pocket/items/PocketComputerItem.java
@@ -25,6 +25,7 @@ import dan200.computercraft.shared.util.DataComponentUtil;
import dan200.computercraft.shared.util.IDAssigner;
import dan200.computercraft.shared.util.NonNegativeId;
import net.minecraft.ChatFormatting;
+import net.minecraft.core.HolderLookup;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
@@ -189,11 +190,15 @@ public class PocketComputerItem extends Item implements IMedia {
// IMedia
- @Override
- public @Nullable String getLabel(ItemStack stack) {
+ private @Nullable String getLabel(ItemStack stack) {
return DataComponentUtil.getCustomName(stack);
}
+ @Override
+ public @Nullable String getLabel(HolderLookup.Provider registries, ItemStack stack) {
+ return getLabel(stack);
+ }
+
@Override
public boolean setLabel(ItemStack stack, @Nullable String label) {
DataComponentUtil.setCustomName(stack, label);
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java b/projects/common/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java
index 30ff8cc05..89927be37 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/pocket/recipes/PocketComputerUpgradeRecipe.java
@@ -10,9 +10,9 @@ import dan200.computercraft.impl.PocketUpgrades;
import dan200.computercraft.shared.ModRegistry;
import dan200.computercraft.shared.pocket.items.PocketComputerItem;
import net.minecraft.core.HolderLookup;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingBookCategory;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;
@@ -33,20 +33,20 @@ public final class PocketComputerUpgradeRecipe extends CustomRecipe {
}
@Override
- public boolean matches(CraftingContainer inventory, Level world) {
+ public boolean matches(CraftingInput inventory, Level world) {
return !assemble(inventory, world.registryAccess()).isEmpty();
}
@Override
- public ItemStack assemble(CraftingContainer inventory, HolderLookup.Provider registryAccess) {
+ public ItemStack assemble(CraftingInput inventory, HolderLookup.Provider registryAccess) {
// Scan the grid for a pocket computer
var computer = ItemStack.EMPTY;
var computerX = -1;
var computerY = -1;
computer:
- for (var y = 0; y < inventory.getHeight(); y++) {
- for (var x = 0; x < inventory.getWidth(); x++) {
- var item = inventory.getItem(x + y * inventory.getWidth());
+ for (var y = 0; y < inventory.height(); y++) {
+ for (var x = 0; x < inventory.width(); x++) {
+ var item = inventory.getItem(x, y);
if (!item.isEmpty() && item.getItem() instanceof PocketComputerItem) {
computer = item;
computerX = x;
@@ -58,14 +58,13 @@ public final class PocketComputerUpgradeRecipe extends CustomRecipe {
if (computer.isEmpty()) return ItemStack.EMPTY;
- var itemComputer = (PocketComputerItem) computer.getItem();
if (PocketComputerItem.getUpgradeWithData(computer) != null) return ItemStack.EMPTY;
// Check for upgrades around the item
UpgradeData upgrade = null;
- for (var y = 0; y < inventory.getHeight(); y++) {
- for (var x = 0; x < inventory.getWidth(); x++) {
- var item = inventory.getItem(x + y * inventory.getWidth());
+ for (var y = 0; y < inventory.height(); y++) {
+ for (var x = 0; x < inventory.width(); x++) {
+ var item = inventory.getItem(x, y);
if (x == computerX && y == computerY) continue;
if (x == computerX && y == computerY - 1) {
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/recipe/ImpostorShapedRecipe.java b/projects/common/src/main/java/dan200/computercraft/shared/recipe/ImpostorShapedRecipe.java
index f2eabcfc0..4639df6a5 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/recipe/ImpostorShapedRecipe.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/recipe/ImpostorShapedRecipe.java
@@ -6,8 +6,8 @@ package dan200.computercraft.shared.recipe;
import dan200.computercraft.shared.ModRegistry;
import net.minecraft.core.HolderLookup;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.ShapedRecipe;
@@ -24,12 +24,12 @@ public final class ImpostorShapedRecipe extends CustomShapedRecipe {
}
@Override
- public boolean matches(CraftingContainer inv, Level world) {
+ public boolean matches(CraftingInput inv, Level world) {
return false;
}
@Override
- public ItemStack assemble(CraftingContainer inventory, HolderLookup.Provider registryAccess) {
+ public ItemStack assemble(CraftingInput inventory, HolderLookup.Provider registryAccess) {
return ItemStack.EMPTY;
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/recipe/ImpostorShapelessRecipe.java b/projects/common/src/main/java/dan200/computercraft/shared/recipe/ImpostorShapelessRecipe.java
index 1bb329251..c81d94153 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/recipe/ImpostorShapelessRecipe.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/recipe/ImpostorShapelessRecipe.java
@@ -6,8 +6,8 @@ package dan200.computercraft.shared.recipe;
import dan200.computercraft.shared.ModRegistry;
import net.minecraft.core.HolderLookup;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.ShapelessRecipe;
@@ -24,12 +24,12 @@ public final class ImpostorShapelessRecipe extends CustomShapelessRecipe {
}
@Override
- public boolean matches(CraftingContainer inv, Level world) {
+ public boolean matches(CraftingInput inv, Level world) {
return false;
}
@Override
- public ItemStack assemble(CraftingContainer inventory, HolderLookup.Provider access) {
+ public ItemStack assemble(CraftingInput inventory, HolderLookup.Provider access) {
return ItemStack.EMPTY;
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/recipe/TransformShapedRecipe.java b/projects/common/src/main/java/dan200/computercraft/shared/recipe/TransformShapedRecipe.java
index 358bee2ab..c6dad2f08 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/recipe/TransformShapedRecipe.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/recipe/TransformShapedRecipe.java
@@ -11,8 +11,8 @@ import dan200.computercraft.shared.recipe.function.RecipeFunction;
import net.minecraft.core.HolderLookup;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.ShapedRecipe;
@@ -42,7 +42,7 @@ public final class TransformShapedRecipe extends CustomShapedRecipe {
}
@Override
- public ItemStack assemble(CraftingContainer inventory, HolderLookup.Provider registryAccess) {
+ public ItemStack assemble(CraftingInput inventory, HolderLookup.Provider registryAccess) {
var result = super.assemble(inventory, registryAccess);
for (var function : functions) result = function.apply(inventory, result);
return result;
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/recipe/TransformShapelessRecipe.java b/projects/common/src/main/java/dan200/computercraft/shared/recipe/TransformShapelessRecipe.java
index f3a8b8f2b..dcc2d125c 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/recipe/TransformShapelessRecipe.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/recipe/TransformShapelessRecipe.java
@@ -11,8 +11,8 @@ import dan200.computercraft.shared.recipe.function.RecipeFunction;
import net.minecraft.core.HolderLookup;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.ShapelessRecipe;
@@ -41,7 +41,7 @@ public class TransformShapelessRecipe extends CustomShapelessRecipe {
}
@Override
- public ItemStack assemble(CraftingContainer inventory, HolderLookup.Provider registryAccess) {
+ public ItemStack assemble(CraftingInput inventory, HolderLookup.Provider registryAccess) {
var result = super.assemble(inventory, registryAccess);
for (var function : functions) result = function.apply(inventory, result);
return result;
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/recipe/function/CopyComponents.java b/projects/common/src/main/java/dan200/computercraft/shared/recipe/function/CopyComponents.java
index 09f9653e6..8d7425304 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/recipe/function/CopyComponents.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/recipe/function/CopyComponents.java
@@ -12,8 +12,8 @@ import net.minecraft.core.component.DataComponentType;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.storage.loot.functions.CopyComponentsFunction;
@@ -83,8 +83,8 @@ public final class CopyComponents implements RecipeFunction {
}
@Override
- public ItemStack apply(CraftingContainer container, ItemStack result) {
- for (var item : container.getItems()) {
+ public ItemStack apply(CraftingInput container, ItemStack result) {
+ for (var item : container.items()) {
if (from.test(item)) {
applyPatch(item.getComponentsPatch(), result);
break;
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/recipe/function/RecipeFunction.java b/projects/common/src/main/java/dan200/computercraft/shared/recipe/function/RecipeFunction.java
index 08f603733..ae4ebe767 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/recipe/function/RecipeFunction.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/recipe/function/RecipeFunction.java
@@ -16,8 +16,8 @@ import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.level.storage.loot.functions.LootItemFunction;
import java.util.List;
@@ -39,7 +39,7 @@ public interface RecipeFunction {
/**
* The registry where {@link RecipeFunction}s are registered.
*/
- ResourceKey>> REGISTRY = ResourceKey.createRegistryKey(new ResourceLocation(ComputerCraftAPI.MOD_ID, "recipe_function"));
+ ResourceKey>> REGISTRY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "recipe_function"));
/**
* The codec to read and write {@link RecipeFunction}s with.
@@ -75,7 +75,7 @@ public interface RecipeFunction {
* @param result The result item to modify. This may be mutated in place.
* @return The new result item. This may be {@code result}.
*/
- ItemStack apply(CraftingContainer container, ItemStack result);
+ ItemStack apply(CraftingInput container, ItemStack result);
/**
* Properties about a type of {@link RecipeFunction}. These are stored in {@linkplain #REGISTRY a Minecraft
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java
index c4799d3fa..d5c91da3f 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java
@@ -134,7 +134,7 @@ public class TurtleBrain implements TurtleAccessInternal {
// Read fields
colourHex = nbt.contains(NBT_COLOUR) ? nbt.getInt(NBT_COLOUR) : -1;
fuelLevel = nbt.contains(NBT_FUEL) ? nbt.getInt(NBT_FUEL) : 0;
- overlay = nbt.contains(NBT_OVERLAY) ? new ResourceLocation(nbt.getString(NBT_OVERLAY)) : null;
+ overlay = nbt.contains(NBT_OVERLAY) ? ResourceLocation.parse(nbt.getString(NBT_OVERLAY)) : null;
// Read upgrades
setUpgradeDirect(TurtleSide.LEFT, NBTUtil.decodeFrom(TurtleUpgrades.instance().upgradeDataCodec(), registries, nbt, NBT_LEFT_UPGRADE));
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java
index 2d7125d26..015c74168 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java
@@ -21,8 +21,7 @@ public class TurtleCraftCommand implements TurtleCommand {
@Override
public TurtleCommandResult execute(ITurtleAccess turtle) {
// Craft the item
- var crafting = new TurtleInventoryCrafting(turtle);
- var results = crafting.doCrafting(turtle.getLevel(), limit);
+ var results = TurtleInventoryCrafting.craft(turtle, limit);
if (results == null) return TurtleCommandResult.failure("No matching recipes");
// Store or drop any remainders
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/inventory/UpgradeSlot.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/inventory/UpgradeSlot.java
index fb9e42810..4664414c6 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/inventory/UpgradeSlot.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/inventory/UpgradeSlot.java
@@ -23,8 +23,8 @@ import javax.annotation.Nullable;
* @see TurtleMenu
*/
public class UpgradeSlot extends Slot {
- public static final ResourceLocation LEFT_UPGRADE = new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/turtle_upgrade_left");
- public static final ResourceLocation RIGHT_UPGRADE = new ResourceLocation(ComputerCraftAPI.MOD_ID, "gui/turtle_upgrade_right");
+ public static final ResourceLocation LEFT_UPGRADE = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/turtle_upgrade_left");
+ public static final ResourceLocation RIGHT_UPGRADE = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "gui/turtle_upgrade_right");
private final HolderLookup.Provider registries;
private final TurtleSide side;
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java
index 61095eb5e..095bb29b6 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/recipes/TurtleUpgradeRecipe.java
@@ -11,9 +11,9 @@ import dan200.computercraft.impl.TurtleUpgrades;
import dan200.computercraft.shared.ModRegistry;
import dan200.computercraft.shared.turtle.items.TurtleItem;
import net.minecraft.core.HolderLookup;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingBookCategory;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;
@@ -34,23 +34,23 @@ public final class TurtleUpgradeRecipe extends CustomRecipe {
}
@Override
- public boolean matches(CraftingContainer inventory, Level world) {
+ public boolean matches(CraftingInput inventory, Level world) {
return !assemble(inventory, world.registryAccess()).isEmpty();
}
@Override
- public ItemStack assemble(CraftingContainer inventory, HolderLookup.Provider registryAccess) {
+ public ItemStack assemble(CraftingInput inventory, HolderLookup.Provider registryAccess) {
// Scan the grid for a row containing a turtle and 1 or 2 items
var leftItem = ItemStack.EMPTY;
var turtle = ItemStack.EMPTY;
var rightItem = ItemStack.EMPTY;
- for (var y = 0; y < inventory.getHeight(); y++) {
+ for (var y = 0; y < inventory.height(); y++) {
if (turtle.isEmpty()) {
// Search this row for potential turtles
var finishedRow = false;
- for (var x = 0; x < inventory.getWidth(); x++) {
- var item = inventory.getItem(x + y * inventory.getWidth());
+ for (var x = 0; x < inventory.width(); x++) {
+ var item = inventory.getItem(x, y);
if (!item.isEmpty()) {
if (finishedRow) {
return ItemStack.EMPTY;
@@ -87,8 +87,8 @@ public final class TurtleUpgradeRecipe extends CustomRecipe {
}
} else {
// Turtle is already found, just check this row is empty
- for (var x = 0; x < inventory.getWidth(); x++) {
- var item = inventory.getItem(x + y * inventory.getWidth());
+ for (var x = 0; x < inventory.width(); x++) {
+ var item = inventory.getItem(x, y);
if (!item.isEmpty()) {
return ItemStack.EMPTY;
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleInventoryCrafting.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleInventoryCrafting.java
index f550f7b5d..224d07395 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleInventoryCrafting.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleInventoryCrafting.java
@@ -9,12 +9,10 @@ import dan200.computercraft.shared.platform.PlatformHelper;
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
import dan200.computercraft.shared.turtle.core.TurtlePlayer;
import net.minecraft.server.level.ServerLevel;
-import net.minecraft.world.entity.player.Player;
-import net.minecraft.world.entity.player.StackedContents;
-import net.minecraft.world.inventory.CraftingContainer;
+import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.Recipe;
-import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
@@ -24,87 +22,101 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-public class TurtleInventoryCrafting implements CraftingContainer {
+public final class TurtleInventoryCrafting {
public static final int WIDTH = 3;
public static final int HEIGHT = 3;
- public static final int SIZE = WIDTH * HEIGHT;
- private final ITurtleAccess turtle;
- private int xStart = 0;
- private int yStart = 0;
-
- @SuppressWarnings("ConstantConditions")
- public TurtleInventoryCrafting(ITurtleAccess turtle) {
- this.turtle = turtle;
+ private TurtleInventoryCrafting() {
}
- @Nullable
- private Recipe tryCrafting(int xStart, int yStart) {
- this.xStart = xStart;
- this.yStart = yStart;
-
+ private static @Nullable FoundRecipe tryCrafting(Level level, Container inventory, int xStart, int yStart) {
// Check the non-relevant parts of the inventory are empty
for (var x = 0; x < TurtleBlockEntity.INVENTORY_WIDTH; x++) {
for (var y = 0; y < TurtleBlockEntity.INVENTORY_HEIGHT; y++) {
- if (x < this.xStart || x >= this.xStart + 3 ||
- y < this.yStart || y >= this.yStart + 3) {
- if (!turtle.getInventory().getItem(x + y * TurtleBlockEntity.INVENTORY_WIDTH).isEmpty()) {
+ if (x < xStart || x >= xStart + WIDTH || y < yStart || y >= yStart + HEIGHT) {
+ if (!inventory.getItem(x + y * TurtleBlockEntity.INVENTORY_WIDTH).isEmpty()) {
return null;
}
}
}
}
- // Check the actual crafting
- return turtle.getLevel().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this, turtle.getLevel()).map(RecipeHolder::value).orElse(null);
+ var input = CraftingInput.ofPositioned(WIDTH, HEIGHT, new AbstractList<>() {
+ @Override
+ public ItemStack get(int index) {
+ var x = xStart + index % WIDTH;
+ var y = yStart + index / WIDTH;
+ return x >= 0 && x < TurtleBlockEntity.INVENTORY_WIDTH && y >= 0 && y < TurtleBlockEntity.INVENTORY_HEIGHT
+ ? inventory.getItem(x + y * TurtleBlockEntity.INVENTORY_WIDTH)
+ : ItemStack.EMPTY;
+ }
+
+ @Override
+ public int size() {
+ return WIDTH * HEIGHT;
+ }
+ });
+ var recipe = level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, input.input(), level).orElse(null);
+ return recipe == null ? null : new FoundRecipe(recipe.value(), input.input(), input.left() + xStart, input.top() + yStart);
}
@Nullable
- public List doCrafting(Level world, int maxCount) {
- if (world.isClientSide || !(world instanceof ServerLevel)) return null;
+ public static List craft(ITurtleAccess turtle, int maxCount) {
+ var level = turtle.getLevel();
+ if (level.isClientSide || !(level instanceof ServerLevel)) return null;
+
+ var inventory = turtle.getInventory();
// Find out what we can craft
- var recipe = tryCrafting(0, 0);
- if (recipe == null) recipe = tryCrafting(0, 1);
- if (recipe == null) recipe = tryCrafting(1, 0);
- if (recipe == null) recipe = tryCrafting(1, 1);
- if (recipe == null) return null;
+ var candidate = tryCrafting(level, inventory, 0, 0);
+ if (candidate == null) candidate = tryCrafting(level, inventory, 0, 1);
+ if (candidate == null) candidate = tryCrafting(level, inventory, 1, 0);
+ if (candidate == null) candidate = tryCrafting(level, inventory, 1, 1);
+ if (candidate == null) return null;
// Special case: craft(0) just returns an empty list if crafting was possible
if (maxCount == 0) return List.of();
+ var recipe = candidate.recipe();
+ var input = candidate.input();
+ var xStart = candidate.xStart();
+ var yStart = candidate.xStart();
+
var player = TurtlePlayer.get(turtle).player();
var results = new ArrayList();
- for (var i = 0; i < maxCount && recipe.matches(this, world); i++) {
- var result = recipe.assemble(this, world.registryAccess());
+ for (var i = 0; i < maxCount && recipe.matches(input, level); i++) {
+ var result = recipe.assemble(input, level.registryAccess());
if (result.isEmpty()) break;
results.add(result);
- result.onCraftedBy(world, player, result.getCount());
- PlatformHelper.get().onItemCrafted(player, this, result);
+ result.onCraftedBy(level, player, result.getCount());
+ PlatformHelper.get().onItemCrafted(player, input, result);
- var remainders = PlatformHelper.get().getRecipeRemainingItems(player, recipe, this);
- for (var slot = 0; slot < remainders.size(); slot++) {
- var existing = getItem(slot);
- var remainder = remainders.get(slot);
+ var remainders = PlatformHelper.get().getRecipeRemainingItems(player, recipe, input);
+ for (var y = 0; y < input.height(); y++) {
+ for (var x = 0; x < input.width(); x++) {
+ var slot = xStart + x + (y + yStart) * TurtleBlockEntity.INVENTORY_WIDTH;
+ var existing = inventory.getItem(slot);
+ var remainder = remainders.get(x + y * input.width());
- if (!existing.isEmpty()) {
- removeItem(slot, 1);
- existing = getItem(slot);
- }
+ if (!existing.isEmpty()) {
+ inventory.removeItem(slot, 1);
+ existing = inventory.getItem(slot);
+ }
- if (remainder.isEmpty()) continue;
+ if (remainder.isEmpty()) continue;
- // Either update the current stack or add it to the remainder list (to be inserted into the inventory
- // afterwards).
- if (existing.isEmpty()) {
- setItem(slot, remainder);
- } else if (ItemStack.isSameItemSameComponents(existing, remainder)) {
- remainder.grow(existing.getCount());
- setItem(slot, remainder);
- } else {
- results.add(remainder);
+ // Either update the current stack or add it to the remainder list (to be inserted into the inventory
+ // afterwards).
+ if (existing.isEmpty()) {
+ inventory.setItem(slot, existing);
+ } else if (ItemStack.isSameItemSameComponents(existing, remainder)) {
+ remainder.grow(existing.getCount());
+ inventory.setItem(slot, remainder);
+ } else {
+ results.add(remainder);
+ }
}
}
}
@@ -112,102 +124,6 @@ public class TurtleInventoryCrafting implements CraftingContainer {
return Collections.unmodifiableList(results);
}
- @Override
- public int getWidth() {
- return WIDTH;
- }
-
- @Override
- public int getHeight() {
- return HEIGHT;
- }
-
- private int modifyIndex(int index) {
- var x = xStart + index % getWidth();
- var y = yStart + index / getHeight();
- return x >= 0 && x < TurtleBlockEntity.INVENTORY_WIDTH && y >= 0 && y < TurtleBlockEntity.INVENTORY_HEIGHT
- ? x + y * TurtleBlockEntity.INVENTORY_WIDTH
- : -1;
- }
-
- @Override
- public boolean isEmpty() {
- for (int i = 0; i < SIZE; i++) {
- if (!getItem(i).isEmpty()) return false;
- }
- return true;
- }
-
- @Override
- public int getContainerSize() {
- return SIZE;
- }
-
- @Override
- public ItemStack getItem(int i) {
- return turtle.getInventory().getItem(modifyIndex(i));
- }
-
- @Override
- public ItemStack removeItemNoUpdate(int i) {
- return turtle.getInventory().removeItemNoUpdate(modifyIndex(i));
- }
-
- @Override
- public ItemStack removeItem(int i, int size) {
- return turtle.getInventory().removeItem(modifyIndex(i), size);
- }
-
- @Override
- public void setItem(int i, ItemStack stack) {
- turtle.getInventory().setItem(modifyIndex(i), stack);
- }
-
- @Override
- public int getMaxStackSize() {
- return turtle.getInventory().getMaxStackSize();
- }
-
- @Override
- public void setChanged() {
- turtle.getInventory().setChanged();
- }
-
- @Override
- public boolean stillValid(Player player) {
- return true;
- }
-
- @Override
- public boolean canPlaceItem(int i, ItemStack stack) {
- return turtle.getInventory().canPlaceItem(modifyIndex(i), stack);
- }
-
- @Override
- public void clearContent() {
- for (var i = 0; i < SIZE; i++) {
- var j = modifyIndex(i);
- turtle.getInventory().setItem(j, ItemStack.EMPTY);
- }
- }
-
- @Override
- public void fillStackedContents(StackedContents contents) {
- for (int i = 0; i < SIZE; i++) contents.accountSimpleStack(getItem(i));
- }
-
- @Override
- public List getItems() {
- return new AbstractList<>() {
- @Override
- public ItemStack get(int index) {
- return getItem(index);
- }
-
- @Override
- public int size() {
- return SIZE;
- }
- };
+ private record FoundRecipe(Recipe recipe, CraftingInput input, int xStart, int yStart) {
}
}
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java
index e29d85335..afac649d5 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java
@@ -21,8 +21,10 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.component.DataComponents;
+import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.tags.EntityTypeTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
@@ -31,6 +33,8 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.entity.projectile.Projectile;
+import net.minecraft.world.entity.projectile.ProjectileDeflection;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.level.BlockGetter;
@@ -207,32 +211,30 @@ public class TurtleTool extends AbstractTurtleUpgrade {
*/
private boolean attack(ServerPlayer player, Direction direction, Entity entity) {
var baseDamage = (float) player.getAttributeValue(Attributes.ATTACK_DAMAGE) * spec.damageMultiplier();
- var bonusDamage = EnchantmentHelper.getDamageBonus(player.getItemInHand(InteractionHand.MAIN_HAND), entity.getType());
- var damage = baseDamage + bonusDamage;
- if (damage <= 0) return false;
-
- var knockBack = EnchantmentHelper.getKnockbackBonus(player);
-
- // We follow the logic in Player.attack of setting the entity on fire before attacking, so it's burning when it
- // (possibly) dies.
- var fireAspect = EnchantmentHelper.getFireAspect(player);
- var onFire = false;
- if (entity instanceof LivingEntity target && fireAspect > 0 && !target.isOnFire()) {
- onFire = true;
- target.igniteForSeconds(1);
- }
-
+ var tool = player.getWeaponItem();
var source = player.damageSources().playerAttack(player);
- if (!entity.hurt(source, damage)) {
- // If we failed to damage the entity, undo us setting the entity on fire.
- if (onFire) entity.clearFire();
- return false;
+ var bonusDamage = EnchantmentHelper.modifyDamage(player.serverLevel(), tool, entity, source, baseDamage) - baseDamage;
+
+ // If this is a projectile, attempt to deflect it instead.
+ if (entity.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && entity instanceof Projectile projectile &&
+ projectile.deflect(ProjectileDeflection.AIM_DEFLECT, player, player, true)
+ ) {
+ return true;
}
+ if (baseDamage <= 0 && bonusDamage <= 0) return false;
+
+ var entityVelocity = entity.getDeltaMovement();
+
+ // Compute the total damage, and deal it out.
+ var damage = baseDamage + bonusDamage + tool.getItem().getAttackDamageBonus(entity, baseDamage, source);
+ if (!entity.hurt(source, damage)) return false;
+
// Special case for armor stands: attack twice to guarantee destroy
if (entity.isAlive() && entity instanceof ArmorStand) entity.hurt(source, damage);
// Apply knockback
+ var knockBack = EnchantmentHelper.modifyKnockback(player.serverLevel(), tool, entity, source, (float) player.getAttributeValue(Attributes.ATTACK_KNOCKBACK));
if (knockBack > 0) {
if (entity instanceof LivingEntity target) {
target.knockback(knockBack * 0.5, -direction.getStepX(), -direction.getStepZ());
@@ -241,18 +243,20 @@ public class TurtleTool extends AbstractTurtleUpgrade {
}
}
- // Apply remaining enchantments
- if (entity instanceof LivingEntity target) EnchantmentHelper.doPostHurtEffects(target, player);
- EnchantmentHelper.doPostDamageEffects(player, entity);
-
- // Damage the original item stack.
- if (entity instanceof LivingEntity target) {
- player.getItemInHand(InteractionHand.MAIN_HAND).hurtEnemy(target, player);
+ if (entity instanceof ServerPlayer otherPlayer && entity.hurtMarked) {
+ otherPlayer.connection.send(new ClientboundSetEntityMotionPacket(entity));
+ entity.hurtMarked = false;
+ entity.setDeltaMovement(entityVelocity);
}
- // Apply fire aspect
- if (entity instanceof LivingEntity target && fireAspect > 0 && !target.isOnFire()) {
- target.igniteForSeconds(4 * fireAspect);
+ var didHurt = entity instanceof LivingEntity target && tool.hurtEnemy(target, player);
+
+ // Apply remaining enchantments
+ EnchantmentHelper.doPostAttackEffects(player.serverLevel(), entity, source);
+
+ // Damage the original item stack.
+ if (!tool.isEmpty() && entity instanceof LivingEntity && didHurt) {
+ tool.postHurtEnemy((LivingEntity) entity, player);
}
return true;
diff --git a/projects/common/src/main/java/dan200/computercraft/shared/util/ArgumentHelpers.java b/projects/common/src/main/java/dan200/computercraft/shared/util/ArgumentHelpers.java
index 8f4b96f04..f4c4fb257 100644
--- a/projects/common/src/main/java/dan200/computercraft/shared/util/ArgumentHelpers.java
+++ b/projects/common/src/main/java/dan200/computercraft/shared/util/ArgumentHelpers.java
@@ -22,7 +22,7 @@ public final class ArgumentHelpers {
public static T getRegistryEntry(String name, String typeName, Registry registry) throws LuaException {
ResourceLocation id;
try {
- id = new ResourceLocation(name);
+ id = ResourceLocation.parse(name);
} catch (ResourceLocationException e) {
id = null;
}
diff --git a/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java b/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java
index 36cf80a8e..ab7cb71d0 100644
--- a/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java
+++ b/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java
@@ -30,11 +30,11 @@ import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
@@ -156,12 +156,12 @@ public class TestPlatformHelper extends AbstractComputerCraftAPI implements Plat
}
@Override
- public List getRecipeRemainingItems(ServerPlayer player, Recipe recipe, CraftingContainer container) {
+ public List getRecipeRemainingItems(ServerPlayer player, Recipe recipe, CraftingInput container) {
throw new UnsupportedOperationException("Cannot query recipes inside tests");
}
@Override
- public void onItemCrafted(ServerPlayer player, CraftingContainer container, ItemStack stack) {
+ public void onItemCrafted(ServerPlayer player, CraftingInput container, ItemStack stack) {
throw new UnsupportedOperationException("Cannot interact with the world inside tests");
}
diff --git a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Recipe_Test.kt b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Recipe_Test.kt
index 699075d9d..9186ef2a3 100644
--- a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Recipe_Test.kt
+++ b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Recipe_Test.kt
@@ -8,18 +8,16 @@ import com.mojang.authlib.GameProfile
import dan200.computercraft.gametest.api.Structures
import dan200.computercraft.gametest.api.sequence
import dan200.computercraft.shared.ModRegistry
+import net.minecraft.core.NonNullList
import net.minecraft.core.component.DataComponentPatch
import net.minecraft.core.component.DataComponents
import net.minecraft.gametest.framework.GameTest
import net.minecraft.gametest.framework.GameTestAssertException
import net.minecraft.gametest.framework.GameTestHelper
-import net.minecraft.world.entity.player.Player
-import net.minecraft.world.inventory.AbstractContainerMenu
-import net.minecraft.world.inventory.MenuType
-import net.minecraft.world.inventory.TransientCraftingContainer
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.item.component.ResolvableProfile
+import net.minecraft.world.item.crafting.CraftingInput
import net.minecraft.world.item.crafting.RecipeType
import org.junit.jupiter.api.Assertions.assertEquals
import java.util.*
@@ -33,9 +31,10 @@ class Recipe_Test {
@GameTest(template = Structures.DEFAULT)
fun Craft_result_has_nbt(context: GameTestHelper) = context.sequence {
thenExecute {
- val container = TransientCraftingContainer(DummyMenu, 3, 3)
- container.setItem(0, ItemStack(Items.SKELETON_SKULL))
- container.setItem(1, ItemStack(ModRegistry.Items.COMPUTER_ADVANCED.get()))
+ val items = NonNullList.withSize(3 * 3, ItemStack.EMPTY)
+ items[0] = ItemStack(Items.SKELETON_SKULL)
+ items[1] = ItemStack(ModRegistry.Items.COMPUTER_ADVANCED.get())
+ val container = CraftingInput.of(3, 3, items)
val recipe = context.level.server.recipeManager
.getRecipeFor(RecipeType.CRAFTING, container, context.level)
@@ -49,9 +48,4 @@ class Recipe_Test {
assertEquals(tag, result.componentsPatch, "Expected NBT tags to be the same")
}
}
-
- object DummyMenu : AbstractContainerMenu(MenuType.GENERIC_9x1, 0) {
- override fun quickMoveStack(player: Player, slot: Int): ItemStack = ItemStack.EMPTY
- override fun stillValid(p0: Player): Boolean = true
- }
}
diff --git a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Speaker_Test.kt b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Speaker_Test.kt
index 8a2d9572f..778b2f0b9 100644
--- a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Speaker_Test.kt
+++ b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Speaker_Test.kt
@@ -36,7 +36,7 @@ class Speaker_Test {
@GameTest
fun Will_not_play_record(helper: GameTestHelper) = helper.sequence {
thenOnComputer {
- callPeripheral("right", "playSound", SoundEvents.MUSIC_DISC_PIGSTEP.location.toString())
+ callPeripheral("right", "playSound", SoundEvents.MUSIC_DISC_PIGSTEP.key().location().toString())
.assertArrayEquals(false)
}
}
diff --git a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Turtle_Test.kt b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Turtle_Test.kt
index b99606217..3fde0e6ce 100644
--- a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Turtle_Test.kt
+++ b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/Turtle_Test.kt
@@ -27,6 +27,7 @@ import dan200.computercraft.test.core.assertArrayEquals
import dan200.computercraft.test.core.computer.LuaTaskContext
import dan200.computercraft.test.core.computer.getApi
import net.minecraft.core.BlockPos
+import net.minecraft.core.registries.Registries
import net.minecraft.gametest.framework.GameTest
import net.minecraft.gametest.framework.GameTestHelper
import net.minecraft.resources.ResourceLocation
@@ -234,7 +235,7 @@ class Turtle_Test {
val upgrade = turtle.getUpgrade(TurtleSide.LEFT)
assertEquals(
helper.level.registryAccess().registryOrThrow(ITurtleUpgrade.REGISTRY)
- .get(ResourceLocation("cctest", "wooden_pickaxe")),
+ .get(ResourceLocation.fromNamespaceAndPath("cctest", "wooden_pickaxe")),
upgrade,
"Upgrade is a wooden pickaxe",
)
@@ -263,7 +264,7 @@ class Turtle_Test {
ItemStack(Items.WOODEN_PICKAXE),
UpgradeData.ofDefault(
helper.level.registryAccess().registryOrThrow(ITurtleUpgrade.REGISTRY)
- .getHolder(ResourceLocation("cctest", "wooden_pickaxe")).orElseThrow(),
+ .getHolder(ResourceLocation.fromNamespaceAndPath("cctest", "wooden_pickaxe")).orElseThrow(),
),
)
}
@@ -284,14 +285,18 @@ class Turtle_Test {
val upgrade = turtle.getUpgrade(TurtleSide.LEFT)
assertEquals(
helper.level.registryAccess().registryOrThrow(ITurtleUpgrade.REGISTRY)
- .get(ResourceLocation("cctest", "netherite_pickaxe")),
+ .get(ResourceLocation.fromNamespaceAndPath("cctest", "netherite_pickaxe")),
upgrade,
"Upgrade is a netherite pickaxe",
)
val item = ItemStack(Items.NETHERITE_PICKAXE)
item.damageValue = 1
- item.enchant(Enchantments.SILK_TOUCH, 1)
+ item.enchant(
+ helper.level.registryAccess().registryOrThrow(Registries.ENCHANTMENT)
+ .getHolderOrThrow(Enchantments.SILK_TOUCH),
+ 1,
+ )
helper.assertUpgradeItem(item, turtle.getUpgradeWithData(TurtleSide.LEFT)!!)
}
diff --git a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/api/TestExtensions.kt b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/api/TestExtensions.kt
index 60fecc0f4..f636682e2 100644
--- a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/api/TestExtensions.kt
+++ b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/api/TestExtensions.kt
@@ -177,7 +177,7 @@ fun > GameTestHelper.assertBlockHas(pos: BlockPos, property: P
* Get a [Container] at a given position.
*/
fun GameTestHelper.getContainerAt(pos: BlockPos): Container =
- when (val container = getBlockEntity(pos)) {
+ when (val container: BlockEntity = getBlockEntity(pos)) {
is Container -> container
null -> failVerbose("Expected a container at $pos, found nothing", pos)
else -> failVerbose("Expected a container at $pos, found ${getName(container.type)}", pos)
@@ -226,7 +226,7 @@ private fun GameTestHelper.assertContainerExactlyImpl(pos: BlockPos, container:
*/
private fun GameTestHelper.getPeripheralAt(pos: BlockPos, direction: Direction): IPeripheral? {
val be = BarrelBlockEntity(absolutePos(pos).relative(direction), Blocks.BARREL.defaultBlockState())
- be.level = level
+ be.setLevel(level)
return PlatformHelper.get().createPeripheralAccess(be) { }.get(direction.opposite)
}
@@ -260,10 +260,9 @@ private fun getName(type: BlockEntityType<*>): ResourceLocation =
* Get a [BlockEntity] of a specific type.
*/
fun GameTestHelper.getBlockEntity(pos: BlockPos, type: BlockEntityType): T {
- val tile = getBlockEntity(pos)
+ val tile: BlockEntity = getBlockEntity(pos)
@Suppress("UNCHECKED_CAST")
return when {
- tile == null -> failVerbose("Expected ${getName(type)}, but no tile was there", pos)
tile.type != type -> failVerbose("Expected ${getName(type)} but got ${getName(tile.type)}", pos)
else -> tile as T
}
diff --git a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/core/ClientTestHooks.kt b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/core/ClientTestHooks.kt
index e42b19ae9..2240934da 100644
--- a/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/core/ClientTestHooks.kt
+++ b/projects/common/src/testMod/kotlin/dan200/computercraft/gametest/core/ClientTestHooks.kt
@@ -125,7 +125,7 @@ object ClientTestHooks {
GameTestBatchFactory.fromTestFunction(GameTestRegistry.getAllTestFunctions(), server.overworld()),
server.overworld(),
)
- .newStructureSpawner(StructureGridSpawner(TestHooks.getTestOrigin(server), 8))
+ .newStructureSpawner(StructureGridSpawner(TestHooks.getTestOrigin(server), 8, false))
.build()
val testTracker = MultipleTestTracker(tests.testInfos)
diff --git a/projects/fabric-api/src/main/java/dan200/computercraft/api/network/wired/WiredElementLookup.java b/projects/fabric-api/src/main/java/dan200/computercraft/api/network/wired/WiredElementLookup.java
index 73cde4d01..6e5023ef7 100644
--- a/projects/fabric-api/src/main/java/dan200/computercraft/api/network/wired/WiredElementLookup.java
+++ b/projects/fabric-api/src/main/java/dan200/computercraft/api/network/wired/WiredElementLookup.java
@@ -14,7 +14,7 @@ import net.minecraft.resources.ResourceLocation;
* from a block.
*/
public final class WiredElementLookup {
- public static final ResourceLocation ID = new ResourceLocation(ComputerCraftAPI.MOD_ID, "wired_node");
+ public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "wired_node");
private static final BlockApiLookup lookup = BlockApiLookup.get(ID, WiredElement.class, Direction.class);
diff --git a/projects/fabric-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralLookup.java b/projects/fabric-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralLookup.java
index 439beb341..f5256cca1 100644
--- a/projects/fabric-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralLookup.java
+++ b/projects/fabric-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralLookup.java
@@ -14,7 +14,7 @@ import net.minecraft.resources.ResourceLocation;
* for a block. It should NOT be used to query peripherals.
*/
public final class PeripheralLookup {
- public static final ResourceLocation ID = new ResourceLocation(ComputerCraftAPI.MOD_ID, "peripheral");
+ public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "peripheral");
private static final BlockApiLookup lookup = BlockApiLookup.get(ID, IPeripheral.class, Direction.class);
diff --git a/projects/fabric/src/client/java/dan200/computercraft/client/model/CustomModelLoader.java b/projects/fabric/src/client/java/dan200/computercraft/client/model/CustomModelLoader.java
index bc2c28650..cd2b8e287 100644
--- a/projects/fabric/src/client/java/dan200/computercraft/client/model/CustomModelLoader.java
+++ b/projects/fabric/src/client/java/dan200/computercraft/client/model/CustomModelLoader.java
@@ -106,10 +106,11 @@ public final class CustomModelLoader {
* @return The wrapped model.
*/
public BakedModel wrapModel(ModelModifier.AfterBake.Context ctx, BakedModel baked) {
- if (!ctx.id().getNamespace().equals(ComputerCraftAPI.MOD_ID)) return baked;
+ var id = ctx.resourceId();
+ if (id == null || !id.getNamespace().equals(ComputerCraftAPI.MOD_ID)) return baked;
if (!(ctx.sourceModel() instanceof BlockModel model)) return baked;
- var emissive = getEmissive(ctx.id(), model);
+ var emissive = getEmissive(id, model);
return emissive == null ? baked : EmissiveBakedModel.wrap(baked, ctx.textureGetter().apply(model.getMaterial(emissive)));
}
diff --git a/projects/fabric/src/client/java/dan200/computercraft/client/model/turtle/UnbakedTurtleModel.java b/projects/fabric/src/client/java/dan200/computercraft/client/model/turtle/UnbakedTurtleModel.java
index 4a8806735..e04a7da2c 100644
--- a/projects/fabric/src/client/java/dan200/computercraft/client/model/turtle/UnbakedTurtleModel.java
+++ b/projects/fabric/src/client/java/dan200/computercraft/client/model/turtle/UnbakedTurtleModel.java
@@ -22,7 +22,7 @@ import java.util.function.Function;
* {@link TurtleModel}.
*/
public final class UnbakedTurtleModel implements UnbakedModel {
- private static final ResourceLocation COLOUR_TURTLE_MODEL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
+ private static final ResourceLocation COLOUR_TURTLE_MODEL = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
private final ResourceLocation model;
@@ -31,7 +31,7 @@ public final class UnbakedTurtleModel implements UnbakedModel {
}
public static UnbakedModel parse(JsonObject json) {
- var model = new ResourceLocation(GsonHelper.getAsString(json, "model"));
+ var model = ResourceLocation.parse(GsonHelper.getAsString(json, "model"));
return new UnbakedTurtleModel(model);
}
@@ -47,7 +47,7 @@ public final class UnbakedTurtleModel implements UnbakedModel {
}
@Override
- public BakedModel bake(ModelBaker bakery, Function spriteGetter, ModelState transform, ResourceLocation location) {
+ public BakedModel bake(ModelBaker bakery, Function spriteGetter, ModelState transform) {
var mainModel = bakery.bake(model, transform);
if (mainModel == null) throw new NullPointerException(model + " failed to bake");
diff --git a/projects/fabric/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelperImpl.java b/projects/fabric/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelperImpl.java
index 58a072006..b8eaee2d2 100644
--- a/projects/fabric/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelperImpl.java
+++ b/projects/fabric/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelperImpl.java
@@ -9,15 +9,13 @@ import com.mojang.blaze3d.vertex.PoseStack;
import dan200.computercraft.client.model.FoiledModel;
import dan200.computercraft.client.render.ModelRenderer;
import net.fabricmc.fabric.api.renderer.v1.model.ModelHelper;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelManager;
-import net.minecraft.core.BlockPos;
+import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.RandomSource;
import javax.annotation.Nullable;
@@ -27,11 +25,16 @@ public class ClientPlatformHelperImpl implements ClientPlatformHelper {
private static final RandomSource random = RandomSource.create(0);
@Override
- public BakedModel getModel(ModelManager manager, ResourceLocation location) {
- var model = manager.getModel(location);
+ public BakedModel getModel(ModelManager manager, ResourceLocation resourceLocation) {
+ var model = manager.getModel(resourceLocation);
return model == null ? manager.getMissingModel() : model;
}
+ @Override
+ public BakedModel getModel(ModelManager manager, ModelResourceLocation modelLocation, @Nullable ResourceLocation resourceLocation) {
+ return resourceLocation == null ? manager.getModel(modelLocation) : getModel(manager, resourceLocation);
+ }
+
@Override
public BakedModel createdFoiledModel(BakedModel model) {
return new FoiledModel(model);
@@ -49,9 +52,4 @@ public class ClientPlatformHelperImpl implements ClientPlatformHelper {
ModelRenderer.renderQuads(transform, buffer, model.getQuads(null, face, random), lightmapCoord, overlayLight, tints);
}
}
-
- @Override
- public void playStreamingMusic(BlockPos pos, @Nullable SoundEvent sound) {
- Minecraft.getInstance().levelRenderer.playStreamingMusic(sound, pos);
- }
}
diff --git a/projects/fabric/src/generated/resources/data/computercraft/recipes/wireless_modem_normal.json b/projects/fabric/src/generated/resources/data/computercraft/recipe/wireless_modem_normal.json
similarity index 100%
rename from projects/fabric/src/generated/resources/data/computercraft/recipes/wireless_modem_normal.json
rename to projects/fabric/src/generated/resources/data/computercraft/recipe/wireless_modem_normal.json
diff --git a/projects/fabric/src/generated/resources/data/computercraft/recipes/printed_book.json b/projects/fabric/src/generated/resources/data/computercraft/recipes/printed_book.json
deleted file mode 100644
index 44c5aafa6..000000000
--- a/projects/fabric/src/generated/resources/data/computercraft/recipes/printed_book.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "type": "computercraft:printout",
- "category": "redstone",
- "ingredients": [{"item": "minecraft:leather"}, {"tag": "c:strings"}],
- "min_printouts": 1,
- "printout": [
- {"item": "computercraft:printed_page"},
- {"item": "computercraft:printed_pages"},
- {"item": "minecraft:paper"}
- ],
- "result": {"count": 1, "id": "computercraft:printed_book"}
-}
diff --git a/projects/fabric/src/main/java/dan200/computercraft/shared/ComputerCraft.java b/projects/fabric/src/main/java/dan200/computercraft/shared/ComputerCraft.java
index 4a459cf2e..ab9f4bf71 100644
--- a/projects/fabric/src/main/java/dan200/computercraft/shared/ComputerCraft.java
+++ b/projects/fabric/src/main/java/dan200/computercraft/shared/ComputerCraft.java
@@ -148,7 +148,7 @@ public class ComputerCraft {
@Override
public ResourceLocation getFabricId() {
- return new ResourceLocation(ComputerCraftAPI.MOD_ID, name);
+ return ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, name);
}
@Override
diff --git a/projects/fabric/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java b/projects/fabric/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java
index c38c23a2d..1136a29cc 100644
--- a/projects/fabric/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java
+++ b/projects/fabric/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java
@@ -51,10 +51,10 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.*;
import net.minecraft.world.item.context.UseOnContext;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.Level;
@@ -142,7 +142,7 @@ public class PlatformHelperImpl implements PlatformHelper {
return new RecipeIngredients(
Ingredient.of(ConventionalItemTags.REDSTONE_DUSTS),
Ingredient.of(ConventionalItemTags.STRINGS),
- Ingredient.of(Items.LEATHER),
+ Ingredient.of(ConventionalItemTags.LEATHERS),
Ingredient.of(ConventionalItemTags.GLASS_PANES),
Ingredient.of(ConventionalItemTags.GOLD_INGOTS),
Ingredient.of(ConventionalItemTags.STORAGE_BLOCKS_GOLD),
@@ -192,12 +192,12 @@ public class PlatformHelperImpl implements PlatformHelper {
}
@Override
- public List getRecipeRemainingItems(ServerPlayer player, Recipe recipe, CraftingContainer container) {
+ public List getRecipeRemainingItems(ServerPlayer player, Recipe recipe, CraftingInput container) {
return recipe.getRemainingItems(container);
}
@Override
- public void onItemCrafted(ServerPlayer player, CraftingContainer container, ItemStack stack) {
+ public void onItemCrafted(ServerPlayer player, CraftingInput container, ItemStack stack) {
}
@Override
@@ -256,7 +256,7 @@ public class PlatformHelperImpl implements PlatformHelper {
@Override
public RegistryEntry register(String name, Supplier create) {
- var entry = new RegistryEntryImpl<>(new ResourceLocation(ComputerCraftAPI.MOD_ID, name), create);
+ var entry = new RegistryEntryImpl<>(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, name), create);
entries.add(entry);
return entry;
}
diff --git a/projects/fabric/src/main/resources/fabric.mod.json b/projects/fabric/src/main/resources/fabric.mod.json
index 63268f2b8..f110a9f5a 100644
--- a/projects/fabric/src/main/resources/fabric.mod.json
+++ b/projects/fabric/src/main/resources/fabric.mod.json
@@ -46,8 +46,8 @@
],
"depends": {
"fabricloader": ">=0.15.10",
- "fabric-api": ">=0.97.3",
- "minecraft": "=1.20.6"
+ "fabric-api": ">=0.100.3",
+ "minecraft": "=1.21"
},
"accessWidener": "computercraft.accesswidener"
}
diff --git a/projects/fabric/src/testMod/java/dan200/computercraft/gametest/core/TestMod.java b/projects/fabric/src/testMod/java/dan200/computercraft/gametest/core/TestMod.java
index 4a2ba819d..6d82feef2 100644
--- a/projects/fabric/src/testMod/java/dan200/computercraft/gametest/core/TestMod.java
+++ b/projects/fabric/src/testMod/java/dan200/computercraft/gametest/core/TestMod.java
@@ -22,7 +22,7 @@ public class TestMod implements ModInitializer, ClientModInitializer {
public void onInitialize() {
TestHooks.init();
- var phase = new ResourceLocation(ComputerCraftAPI.MOD_ID, "test_mod");
+ var phase = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "test_mod");
ServerLifecycleEvents.SERVER_STARTED.addPhaseOrdering(Event.DEFAULT_PHASE, phase);
ServerLifecycleEvents.SERVER_STARTED.register(phase, TestHooks::onServerStarted);
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> CCTestCommand.register(dispatcher));
diff --git a/projects/forge-api/src/main/java/dan200/computercraft/api/network/wired/WiredElementCapability.java b/projects/forge-api/src/main/java/dan200/computercraft/api/network/wired/WiredElementCapability.java
index 6ce9a1ffd..db8cdce9e 100644
--- a/projects/forge-api/src/main/java/dan200/computercraft/api/network/wired/WiredElementCapability.java
+++ b/projects/forge-api/src/main/java/dan200/computercraft/api/network/wired/WiredElementCapability.java
@@ -14,7 +14,7 @@ import net.neoforged.neoforge.capabilities.BlockCapability;
* from a block.
*/
public final class WiredElementCapability {
- public static final ResourceLocation ID = new ResourceLocation(ComputerCraftAPI.MOD_ID, "wired_node");
+ public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "wired_node");
private static final BlockCapability capability = BlockCapability.create(ID, WiredElement.class, Direction.class);
diff --git a/projects/forge-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralCapability.java b/projects/forge-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralCapability.java
index e4067beb0..462c374d4 100644
--- a/projects/forge-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralCapability.java
+++ b/projects/forge-api/src/main/java/dan200/computercraft/api/peripheral/PeripheralCapability.java
@@ -14,7 +14,7 @@ import net.neoforged.neoforge.capabilities.BlockCapability;
* for a block. It should NOT be used to query peripherals.
*/
public final class PeripheralCapability {
- public static final ResourceLocation ID = new ResourceLocation(ComputerCraftAPI.MOD_ID, "peripheral");
+ public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "peripheral");
private static final BlockCapability capability = BlockCapability.create(ID, IPeripheral.class, Direction.class);
diff --git a/projects/forge/src/client/java/dan200/computercraft/client/ForgeClientRegistry.java b/projects/forge/src/client/java/dan200/computercraft/client/ForgeClientRegistry.java
index 81279dbf0..64ea01d23 100644
--- a/projects/forge/src/client/java/dan200/computercraft/client/ForgeClientRegistry.java
+++ b/projects/forge/src/client/java/dan200/computercraft/client/ForgeClientRegistry.java
@@ -10,6 +10,7 @@ import dan200.computercraft.client.model.turtle.TurtleModelLoader;
import dan200.computercraft.client.turtle.TurtleUpgradeModellers;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.item.ItemProperties;
+import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
@@ -33,7 +34,7 @@ public final class ForgeClientRegistry {
@SubscribeEvent
public static void registerModelLoaders(ModelEvent.RegisterGeometryLoaders event) {
- event.register(new ResourceLocation(ComputerCraftAPI.MOD_ID, "turtle"), TurtleModelLoader.INSTANCE);
+ event.register(ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "turtle"), TurtleModelLoader.INSTANCE);
}
/**
@@ -56,7 +57,7 @@ public final class ForgeClientRegistry {
@SubscribeEvent
public static void registerModels(ModelEvent.RegisterAdditional event) {
gatherModellers();
- ClientRegistry.registerExtraModels(event::register);
+ ClientRegistry.registerExtraModels(x -> event.register(ModelResourceLocation.standalone(x)));
}
@SubscribeEvent
diff --git a/projects/forge/src/client/java/dan200/computercraft/client/model/FoiledModel.java b/projects/forge/src/client/java/dan200/computercraft/client/model/FoiledModel.java
index 1da96866f..430582937 100644
--- a/projects/forge/src/client/java/dan200/computercraft/client/model/FoiledModel.java
+++ b/projects/forge/src/client/java/dan200/computercraft/client/model/FoiledModel.java
@@ -35,7 +35,7 @@ public final class FoiledModel extends BakedModelWrapper {
@Override
public List getRenderTypes(ItemStack itemStack, boolean fabulous) {
- return new ConsList<>(fabulous ? RenderType.glintDirect() : RenderType.glint(), super.getRenderTypes(itemStack, fabulous));
+ return new ConsList<>(fabulous ? RenderType.glintTranslucent() : RenderType.glint(), super.getRenderTypes(itemStack, fabulous));
}
@Override
diff --git a/projects/forge/src/client/java/dan200/computercraft/client/model/turtle/TurtleModelLoader.java b/projects/forge/src/client/java/dan200/computercraft/client/model/turtle/TurtleModelLoader.java
index 6ebed3b6a..34a042428 100644
--- a/projects/forge/src/client/java/dan200/computercraft/client/model/turtle/TurtleModelLoader.java
+++ b/projects/forge/src/client/java/dan200/computercraft/client/model/turtle/TurtleModelLoader.java
@@ -28,7 +28,7 @@ import java.util.function.Function;
* {@link TurtleModel}.
*/
public final class TurtleModelLoader implements IGeometryLoader {
- private static final ResourceLocation COLOUR_TURTLE_MODEL = new ResourceLocation(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
+ private static final ResourceLocation COLOUR_TURTLE_MODEL = ResourceLocation.fromNamespaceAndPath(ComputerCraftAPI.MOD_ID, "block/turtle_colour");
public static final TurtleModelLoader INSTANCE = new TurtleModelLoader();
@@ -37,7 +37,7 @@ public final class TurtleModelLoader implements IGeometryLoader spriteGetter, ModelState transform, ItemOverrides overrides, ResourceLocation modelLocation) {
+ public BakedModel bake(IGeometryBakingContext owner, ModelBaker bakery, Function spriteGetter, ModelState transform, ItemOverrides overrides) {
var mainModel = bakery.bake(family, transform, spriteGetter);
if (mainModel == null) throw new NullPointerException(family + " failed to bake");
diff --git a/projects/forge/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelperImpl.java b/projects/forge/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelperImpl.java
index 381b8dd7c..2e1c72ed6 100644
--- a/projects/forge/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelperImpl.java
+++ b/projects/forge/src/client/java/dan200/computercraft/client/platform/ClientPlatformHelperImpl.java
@@ -8,14 +8,12 @@ import com.google.auto.service.AutoService;
import com.mojang.blaze3d.vertex.PoseStack;
import dan200.computercraft.client.model.FoiledModel;
import dan200.computercraft.client.render.ModelRenderer;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelManager;
-import net.minecraft.core.BlockPos;
+import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.client.model.data.ModelData;
@@ -29,8 +27,13 @@ public class ClientPlatformHelperImpl implements ClientPlatformHelper {
private static final Direction[] directions = Arrays.copyOf(Direction.values(), 7);
@Override
- public BakedModel getModel(ModelManager manager, ResourceLocation location) {
- return manager.getModel(location);
+ public BakedModel getModel(ModelManager manager, ResourceLocation resourceLocation) {
+ return manager.getModel(ModelResourceLocation.standalone(resourceLocation));
+ }
+
+ @Override
+ public BakedModel getModel(ModelManager manager, ModelResourceLocation modelLocation, @Nullable ResourceLocation resourceLocation) {
+ return manager.getModel(modelLocation);
}
@Override
@@ -49,9 +52,4 @@ public class ClientPlatformHelperImpl implements ClientPlatformHelper {
}
}
}
-
- @Override
- public void playStreamingMusic(BlockPos pos, @Nullable SoundEvent sound) {
- Minecraft.getInstance().levelRenderer.playStreamingMusic(sound, pos, null);
- }
}
diff --git a/projects/forge/src/generated/resources/data/computercraft/recipes/wireless_modem_normal.json b/projects/forge/src/generated/resources/data/computercraft/recipe/wireless_modem_normal.json
similarity index 100%
rename from projects/forge/src/generated/resources/data/computercraft/recipes/wireless_modem_normal.json
rename to projects/forge/src/generated/resources/data/computercraft/recipe/wireless_modem_normal.json
diff --git a/projects/forge/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java b/projects/forge/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java
index c841d4aab..68b47c5ee 100644
--- a/projects/forge/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java
+++ b/projects/forge/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java
@@ -15,6 +15,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.PeripheralCapability;
import dan200.computercraft.impl.Peripherals;
import dan200.computercraft.shared.config.ConfigFile;
+import dan200.computercraft.shared.container.ListContainer;
import dan200.computercraft.shared.network.container.ContainerData;
import dan200.computercraft.shared.util.InventoryUtil;
import net.minecraft.commands.synchronization.ArgumentTypeInfo;
@@ -36,12 +37,12 @@ import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
-import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
+import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.Level;
@@ -49,7 +50,6 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
-import net.neoforged.bus.api.Event;
import net.neoforged.neoforge.capabilities.BlockCapability;
import net.neoforged.neoforge.capabilities.BlockCapabilityCache;
import net.neoforged.neoforge.capabilities.Capabilities;
@@ -187,7 +187,7 @@ public class PlatformHelperImpl implements PlatformHelper {
}
@Override
- public List getRecipeRemainingItems(ServerPlayer player, Recipe recipe, CraftingContainer container) {
+ public List getRecipeRemainingItems(ServerPlayer player, Recipe recipe, CraftingInput container) {
CommonHooks.setCraftingPlayer(player);
var result = recipe.getRemainingItems(container);
CommonHooks.setCraftingPlayer(null);
@@ -195,8 +195,8 @@ public class PlatformHelperImpl implements PlatformHelper {
}
@Override
- public void onItemCrafted(ServerPlayer player, CraftingContainer container, ItemStack stack) {
- EventHooks.firePlayerCraftingEvent(player, stack, container);
+ public void onItemCrafted(ServerPlayer player, CraftingInput container, ItemStack stack) {
+ EventHooks.firePlayerCraftingEvent(player, stack, new ListContainer(container.items()));
}
@Override
@@ -239,18 +239,18 @@ public class PlatformHelperImpl implements PlatformHelper {
if (event.isCanceled()) return event.getCancellationResult();
var context = new UseOnContext(player, InteractionHand.MAIN_HAND, hit);
- if (event.getUseItem() != Event.Result.DENY) {
+ if (!event.getUseItem().isFalse()) {
var result = stack.onItemUseFirst(context);
if (result != InteractionResult.PASS) return result;
}
var block = level.getBlockState(hit.getBlockPos());
- if (event.getUseBlock() != Event.Result.DENY && !block.isAir() && canUseBlock.test(block)) {
+ if (!event.getUseBlock().isFalse() && !block.isAir() && canUseBlock.test(block)) {
var useResult = block.useItemOn(stack, level, player, InteractionHand.MAIN_HAND, hit);
if (useResult.consumesAction()) return useResult.result();
}
- return event.getUseItem() == Event.Result.DENY ? InteractionResult.PASS : stack.useOn(context);
+ return event.getUseItem().isFalse() ? InteractionResult.PASS : stack.useOn(context);
}
private record RegistrationHelperImpl(DeferredRegister registry) implements RegistrationHelper {
diff --git a/projects/forge/src/main/resources/META-INF/neoforge.mods.toml b/projects/forge/src/main/resources/META-INF/neoforge.mods.toml
index 726ecfe82..fe851f3e5 100644
--- a/projects/forge/src/main/resources/META-INF/neoforge.mods.toml
+++ b/projects/forge/src/main/resources/META-INF/neoforge.mods.toml
@@ -26,7 +26,7 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a
[[dependencies.computercraft]]
modId="neoforge"
type="required"
- versionRange="[${neoVersion},20.7)"
+ versionRange="[${neoVersion},21.1)"
ordering="NONE"
side="BOTH"