diff --git a/gradle.properties b/gradle.properties index db3e9eed..f5c0c906 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,12 +4,12 @@ minecraft_version=1.21.1 neoforge_version=21.1.2 parchment_version=2024.07.07 parchment_minecraft_version=1.21 -cyclopscore_version=1.19.10-538 -integrateddynamics_version=1.23.1-828 +cyclopscore_version=1.19.10-539 +integrateddynamics_version=1.23.1-830 release_type=release fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44 -commoncapabilities_version=2.9.2-143 +commoncapabilities_version=2.9.2-145 # Workaround for Spotless bug # https://github.com/diffplug/spotless/issues/834 diff --git a/src/main/java/org/cyclops/integratedcrafting/api/crafting/CraftingJob.java b/src/main/java/org/cyclops/integratedcrafting/api/crafting/CraftingJob.java index c7b4dcd5..7e6146b6 100644 --- a/src/main/java/org/cyclops/integratedcrafting/api/crafting/CraftingJob.java +++ b/src/main/java/org/cyclops/integratedcrafting/api/crafting/CraftingJob.java @@ -3,6 +3,7 @@ import com.google.common.collect.Maps; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.IntArrayTag; import net.minecraft.nbt.Tag; @@ -142,16 +143,16 @@ public boolean isIgnoreDependencyCheck() { return ignoreDependencyCheck; } - public static CompoundTag serialize(CraftingJob craftingJob) { + public static CompoundTag serialize(HolderLookup.Provider lookupProvider, CraftingJob craftingJob) { CompoundTag tag = new CompoundTag(); tag.putInt("id", craftingJob.id); tag.putInt("channel", craftingJob.channel); - tag.put("recipe", IRecipeDefinition.serialize(craftingJob.recipe)); + tag.put("recipe", IRecipeDefinition.serialize(lookupProvider, craftingJob.recipe)); tag.put("dependencies", new IntArrayTag(craftingJob.getDependencyCraftingJobs())); tag.put("dependents", new IntArrayTag(craftingJob.getDependentCraftingJobs())); tag.putInt("amount", craftingJob.amount); - tag.put("ingredientsStorage", IMixedIngredients.serialize(craftingJob.ingredientsStorage)); - tag.put("lastMissingIngredients", MissingIngredients.serialize(craftingJob.lastMissingIngredients)); + tag.put("ingredientsStorage", IMixedIngredients.serialize(lookupProvider, craftingJob.ingredientsStorage)); + tag.put("lastMissingIngredients", MissingIngredients.serialize(lookupProvider, craftingJob.lastMissingIngredients)); tag.putLong("startTick", craftingJob.startTick); tag.putBoolean("invalidInputs", craftingJob.invalidInputs); if (craftingJob.initiatorUuid != null) { @@ -161,7 +162,7 @@ public static CompoundTag serialize(CraftingJob craftingJob) { return tag; } - public static CraftingJob deserialize(CompoundTag tag) { + public static CraftingJob deserialize(HolderLookup.Provider lookupProvider, CompoundTag tag) { if (!tag.contains("id", Tag.TAG_INT)) { throw new IllegalArgumentException("Could not find an id entry in the given tag"); } @@ -194,9 +195,9 @@ public static CraftingJob deserialize(CompoundTag tag) { } int id = tag.getInt("id"); int channel = tag.getInt("channel"); - IRecipeDefinition recipe = IRecipeDefinition.deserialize(tag.getCompound("recipe")); + IRecipeDefinition recipe = IRecipeDefinition.deserialize(lookupProvider, tag.getCompound("recipe")); int amount = tag.getInt("amount"); - IMixedIngredients ingredientsStorage = IMixedIngredients.deserialize(tag.getCompound("ingredientsStorage")); + IMixedIngredients ingredientsStorage = IMixedIngredients.deserialize(lookupProvider, tag.getCompound("ingredientsStorage")); CraftingJob craftingJob = new CraftingJob(id, channel, recipe, amount, ingredientsStorage); for (int dependency : tag.getIntArray("dependencies")) { craftingJob.dependencyCraftingJobs.add(dependency); @@ -205,7 +206,7 @@ public static CraftingJob deserialize(CompoundTag tag) { craftingJob.dependentCraftingJobs.add(dependent); } Map, MissingIngredients> lastMissingIngredients = MissingIngredients - .deserialize(tag.getCompound("lastMissingIngredients")); + .deserialize(lookupProvider, tag.getCompound("lastMissingIngredients")); craftingJob.setLastMissingIngredients(lastMissingIngredients); craftingJob.setStartTick(tag.getLong("startTick")); craftingJob.setInvalidInputs(tag.getBoolean("invalidInputs")); diff --git a/src/main/java/org/cyclops/integratedcrafting/api/crafting/CraftingJobDependencyGraph.java b/src/main/java/org/cyclops/integratedcrafting/api/crafting/CraftingJobDependencyGraph.java index 9a50df35..aa875709 100644 --- a/src/main/java/org/cyclops/integratedcrafting/api/crafting/CraftingJobDependencyGraph.java +++ b/src/main/java/org/cyclops/integratedcrafting/api/crafting/CraftingJobDependencyGraph.java @@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntCollection; import it.unimi.dsi.fastutil.ints.IntIterator; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.IntArrayTag; import net.minecraft.nbt.ListTag; @@ -239,12 +240,12 @@ public void mergeCraftingJobs(CraftingJob target, CraftingJob mergee, boolean ma } } - public static CompoundTag serialize(CraftingJobDependencyGraph graph) { + public static CompoundTag serialize(HolderLookup.Provider lookupProvider, CraftingJobDependencyGraph graph) { CompoundTag tag = new CompoundTag(); ListTag craftingJobs = new ListTag(); for (CraftingJob craftingJob : graph.getCraftingJobs()) { - craftingJobs.add(CraftingJob.serialize(craftingJob)); + craftingJobs.add(CraftingJob.serialize(lookupProvider, craftingJob)); } tag.put("craftingJobs", craftingJobs); @@ -269,7 +270,7 @@ public static CompoundTag serialize(CraftingJobDependencyGraph graph) { return tag; } - public static CraftingJobDependencyGraph deserialize(CompoundTag tag) { + public static CraftingJobDependencyGraph deserialize(HolderLookup.Provider lookupProvider, CompoundTag tag) { if (!tag.contains("craftingJobs", Tag.TAG_LIST)) { throw new IllegalArgumentException("Could not find a craftingJobs entry in the given tag"); } @@ -283,7 +284,7 @@ public static CraftingJobDependencyGraph deserialize(CompoundTag tag) { Int2ObjectMap craftingJobs = new Int2ObjectOpenHashMap<>(); ListTag craftingJobsTag = tag.getList("craftingJobs", Tag.TAG_COMPOUND); for (int i = 0; i < craftingJobsTag.size(); i++) { - CraftingJob craftingJob = CraftingJob.deserialize(craftingJobsTag.getCompound(i)); + CraftingJob craftingJob = CraftingJob.deserialize(lookupProvider, craftingJobsTag.getCompound(i)); craftingJobs.put(craftingJob.getId(), craftingJob); } diff --git a/src/main/java/org/cyclops/integratedcrafting/core/CraftingJobHandler.java b/src/main/java/org/cyclops/integratedcrafting/core/CraftingJobHandler.java index f335a685..3a1b6abe 100644 --- a/src/main/java/org/cyclops/integratedcrafting/core/CraftingJobHandler.java +++ b/src/main/java/org/cyclops/integratedcrafting/core/CraftingJobHandler.java @@ -9,6 +9,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; @@ -92,13 +93,13 @@ public CraftingJobHandler(int maxProcessingJobs, boolean blockingJobsMode, this.nonBlockingJobsRunningAmount = new Int2IntOpenHashMap(); } - public void writeToNBT(CompoundTag tag) { + public void writeToNBT(HolderLookup.Provider lookupProvider, CompoundTag tag) { tag.putBoolean("blockingJobsMode", this.blockingJobsMode); ListTag processingCraftingJobs = new ListTag(); for (CraftingJob processingCraftingJob : this.processingCraftingJobs.values()) { CompoundTag entriesTag = new CompoundTag(); - entriesTag.put("craftingJob", CraftingJob.serialize(processingCraftingJob)); + entriesTag.put("craftingJob", CraftingJob.serialize(lookupProvider, processingCraftingJob)); List, List>>> ingredientsEntries = this.processingCraftingJobsPendingIngredients.get(processingCraftingJob.getId()); ListTag pendingEntries = new ListTag(); @@ -114,7 +115,7 @@ public void writeToNBT(CompoundTag tag) { IIngredientSerializer serializer = ingredientComponent.getSerializer(); for (IPrototypedIngredient prototypedIngredient : ingredientComponentListEntry.getValue()) { CompoundTag instance = new CompoundTag(); - instance.put("prototype", serializer.serializeInstance(prototypedIngredient.getPrototype())); + instance.put("prototype", serializer.serializeInstance(lookupProvider, prototypedIngredient.getPrototype())); instance.put("condition", serializer.serializeCondition(prototypedIngredient.getCondition())); instances.add(instance); } @@ -131,7 +132,7 @@ public void writeToNBT(CompoundTag tag) { ListTag pendingCraftingJobs = new ListTag(); for (CraftingJob craftingJob : this.pendingCraftingJobs.values()) { - pendingCraftingJobs.add(CraftingJob.serialize(craftingJob)); + pendingCraftingJobs.add(CraftingJob.serialize(lookupProvider, craftingJob)); } tag.put("pendingCraftingJobs", pendingCraftingJobs); @@ -148,7 +149,7 @@ public void writeToNBT(CompoundTag tag) { tag.put("nonBlockingJobsRunningAmount", nonBlockingJobsRunningAmount); } - public void readFromNBT(CompoundTag tag) { + public void readFromNBT(HolderLookup.Provider lookupProvider, CompoundTag tag) { if (tag.contains("blockingJobsMode")) { this.blockingJobsMode = tag.getBoolean("blockingJobsMode"); } @@ -174,7 +175,7 @@ public void readFromNBT(CompoundTag tag) { List> pendingIngredients = Lists.newArrayList(); for (Tag instanceTagUnsafe : pendingIngredientTag.getList("instances", Tag.TAG_COMPOUND)) { CompoundTag instanceTag = (CompoundTag) instanceTagUnsafe; - Object instance = serializer.deserializeInstance(instanceTag.get("prototype")); + Object instance = serializer.deserializeInstance(lookupProvider, instanceTag.get("prototype")); Object condition = serializer.deserializeCondition(instanceTag.get("condition")); pendingIngredients.add(new PrototypedIngredient(ingredientComponent, instance, condition)); } @@ -200,7 +201,7 @@ public void readFromNBT(CompoundTag tag) { List> pendingIngredients = Lists.newArrayList(); for (Tag instanceTagUnsafe : pendingIngredientTag.getList("instances", Tag.TAG_COMPOUND)) { CompoundTag instanceTag = (CompoundTag) instanceTagUnsafe; - Object instance = serializer.deserializeInstance(instanceTag.get("prototype")); + Object instance = serializer.deserializeInstance(lookupProvider, instanceTag.get("prototype")); Object condition = serializer.deserializeCondition(instanceTag.get("condition")); pendingIngredients.add(new PrototypedIngredient(ingredientComponent, instance, condition)); } @@ -212,7 +213,7 @@ public void readFromNBT(CompoundTag tag) { } } - CraftingJob craftingJob = CraftingJob.deserialize(entryTag.getCompound("craftingJob")); + CraftingJob craftingJob = CraftingJob.deserialize(lookupProvider, entryTag.getCompound("craftingJob")); this.processingCraftingJobs.put(craftingJob.getId(), craftingJob); this.allCraftingJobs.put(craftingJob.getId(), craftingJob); @@ -224,7 +225,7 @@ public void readFromNBT(CompoundTag tag) { ListTag pendingCraftingJobs = tag.getList("pendingCraftingJobs", Tag.TAG_COMPOUND); for (Tag craftingJob : pendingCraftingJobs) { - CraftingJob craftingJobInstance = CraftingJob.deserialize((CompoundTag) craftingJob); + CraftingJob craftingJobInstance = CraftingJob.deserialize(lookupProvider, (CompoundTag) craftingJob); this.pendingCraftingJobs.put(craftingJobInstance.getId(), craftingJobInstance); this.allCraftingJobs.put(craftingJobInstance.getId(), craftingJobInstance); } diff --git a/src/main/java/org/cyclops/integratedcrafting/core/MissingIngredients.java b/src/main/java/org/cyclops/integratedcrafting/core/MissingIngredients.java index aa43a126..7ebf4e6e 100644 --- a/src/main/java/org/cyclops/integratedcrafting/core/MissingIngredients.java +++ b/src/main/java/org/cyclops/integratedcrafting/core/MissingIngredients.java @@ -2,6 +2,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; @@ -45,7 +46,7 @@ public String toString() { * @param ingredients Ingredients. * @return An NBT representation of the given ingredients. */ - public static CompoundTag serialize(Map, MissingIngredients> ingredients) { + public static CompoundTag serialize(HolderLookup.Provider lookupProvider, Map, MissingIngredients> ingredients) { CompoundTag tag = new CompoundTag(); for (Map.Entry, MissingIngredients> entry : ingredients.entrySet()) { ListTag missingIngredientsTag = new ListTag(); @@ -53,7 +54,7 @@ public static CompoundTag serialize(Map, MissingIngred ListTag elementsTag = new ListTag(); for (PrototypedWithRequested alternative : element.getAlternatives()) { CompoundTag alternativeTag = new CompoundTag(); - alternativeTag.put("requestedPrototype", IPrototypedIngredient.serialize(alternative.getRequestedPrototype())); + alternativeTag.put("requestedPrototype", IPrototypedIngredient.serialize(lookupProvider, alternative.getRequestedPrototype())); alternativeTag.putLong("quantityMissing", alternative.getQuantityMissing()); alternativeTag.putBoolean("inputReusable", element.isInputReusable()); // Hack, should actually be one level higher, but this is for backwards-compat elementsTag.add(alternativeTag); @@ -71,7 +72,7 @@ public static CompoundTag serialize(Map, MissingIngred * @return A new mixed ingredients instance. * @throws IllegalArgumentException If the given tag is invalid or does not contain data on the given ingredients. */ - public static Map, MissingIngredients> deserialize(CompoundTag tag) + public static Map, MissingIngredients> deserialize(HolderLookup.Provider lookupProvider, CompoundTag tag) throws IllegalArgumentException { Map, MissingIngredients> map = Maps.newIdentityHashMap(); for (String componentName : tag.getAllKeys()) { @@ -89,7 +90,7 @@ public static CompoundTag serialize(Map, MissingIngred boolean inputReusable = false; for (int j = 0; j < elementsTag.size(); j++) { CompoundTag alternativeTag = elementsTag.getCompound(j); - IPrototypedIngredient requestedPrototype = IPrototypedIngredient.deserialize(alternativeTag.getCompound("requestedPrototype")); + IPrototypedIngredient requestedPrototype = IPrototypedIngredient.deserialize(lookupProvider, alternativeTag.getCompound("requestedPrototype")); long quantityMissing = alternativeTag.getLong("quantityMissing"); inputReusable = alternativeTag.getBoolean("inputReusable"); alternatives.add(new PrototypedWithRequested<>(requestedPrototype, quantityMissing)); diff --git a/src/main/java/org/cyclops/integratedcrafting/part/PartTypeInterfaceCrafting.java b/src/main/java/org/cyclops/integratedcrafting/part/PartTypeInterfaceCrafting.java index 6ed247fe..1b03744b 100644 --- a/src/main/java/org/cyclops/integratedcrafting/part/PartTypeInterfaceCrafting.java +++ b/src/main/java/org/cyclops/integratedcrafting/part/PartTypeInterfaceCrafting.java @@ -369,12 +369,12 @@ public void writeToNBT(ValueDeseralizationContext valueDeseralizationContext, Co for (IngredientInstanceWrapper instanceWrapper : inventoryOutputBuffer) { CompoundTag instanceTag = new CompoundTag(); instanceTag.putString("component", IngredientComponent.REGISTRY.getKey(instanceWrapper.getComponent()).toString()); - instanceTag.put("instance", instanceWrapper.getComponent().getSerializer().serializeInstance(instanceWrapper.getInstance())); + instanceTag.put("instance", instanceWrapper.getComponent().getSerializer().serializeInstance(valueDeseralizationContext.holderLookupProvider(), instanceWrapper.getInstance())); instanceTags.add(instanceTag); } tag.put("inventoryOutputBuffer", instanceTags); - this.craftingJobHandler.writeToNBT(tag); + this.craftingJobHandler.writeToNBT(valueDeseralizationContext.holderLookupProvider(), tag); tag.putInt("channelCrafting", channelCrafting); CompoundTag recipeSlotErrorsTag = new CompoundTag(); @@ -403,10 +403,10 @@ public void readFromNBT(ValueDeseralizationContext valueDeseralizationContext, C String componentName = instanceTag.getString("component"); IngredientComponent component = IngredientComponent.REGISTRY.get(ResourceLocation.parse(componentName)); this.inventoryOutputBuffer.add(new IngredientInstanceWrapper(component, - component.getSerializer().deserializeInstance(instanceTag.get("instance")))); + component.getSerializer().deserializeInstance(valueDeseralizationContext.holderLookupProvider(), instanceTag.get("instance")))); } - this.craftingJobHandler.readFromNBT(tag); + this.craftingJobHandler.readFromNBT(valueDeseralizationContext.holderLookupProvider(), tag); this.channelCrafting = tag.getInt("channelCrafting"); this.recipeSlotMessages.clear(); diff --git a/src/test/java/org/cyclops/integratedcrafting/ingredient/IngredientSerializerLong.java b/src/test/java/org/cyclops/integratedcrafting/ingredient/IngredientSerializerLong.java index c274a650..10a709ca 100644 --- a/src/test/java/org/cyclops/integratedcrafting/ingredient/IngredientSerializerLong.java +++ b/src/test/java/org/cyclops/integratedcrafting/ingredient/IngredientSerializerLong.java @@ -1,5 +1,6 @@ package org.cyclops.integratedcrafting.ingredient; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.ByteTag; import net.minecraft.nbt.LongTag; import net.minecraft.nbt.Tag; @@ -8,12 +9,12 @@ public class IngredientSerializerLong implements IIngredientSerializer { @Override - public Tag serializeInstance(Long instance) { + public Tag serializeInstance(HolderLookup.Provider lookupProvider, Long instance) { return LongTag.valueOf(instance); } @Override - public Long deserializeInstance(Tag tag) throws IllegalArgumentException { + public Long deserializeInstance(HolderLookup.Provider lookupProvider, Tag tag) throws IllegalArgumentException { if (!(tag instanceof LongTag)) { throw new IllegalArgumentException("This deserializer only accepts NBTTagInt"); } diff --git a/src/test/java/org/cyclops/integratedcrafting/ingredient/IngredientSerializerStub.java b/src/test/java/org/cyclops/integratedcrafting/ingredient/IngredientSerializerStub.java index bd91cad1..60e148fb 100644 --- a/src/test/java/org/cyclops/integratedcrafting/ingredient/IngredientSerializerStub.java +++ b/src/test/java/org/cyclops/integratedcrafting/ingredient/IngredientSerializerStub.java @@ -1,16 +1,17 @@ package org.cyclops.integratedcrafting.ingredient; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.Tag; import org.cyclops.commoncapabilities.api.ingredient.IIngredientSerializer; public class IngredientSerializerStub implements IIngredientSerializer { @Override - public Tag serializeInstance(T instance) { + public Tag serializeInstance(HolderLookup.Provider lookupProvider, T instance) { return null; } @Override - public T deserializeInstance(Tag tag) throws IllegalArgumentException { + public T deserializeInstance(HolderLookup.Provider lookupProvider, Tag tag) throws IllegalArgumentException { return null; }