Clipping clipboards

- Fix crash when closing the clipboard window
- Fix runtime generated recipes
This commit is contained in:
IThundxr 2025-01-20 10:30:34 -05:00
parent 7bdc2cb758
commit 1edd6ad2df
No known key found for this signature in database
4 changed files with 18 additions and 9 deletions

View file

@ -132,11 +132,6 @@ repositories {
}
}
// Mirror of maven.createmod.net
if (System.getProperty("os.name").contains("Mac") && System.getenv("USER") == "ithundxr") {
maven { url = "https://maven.ithundxr.dev/mirror" }
}
// todo - temp
maven { url = "https://maven.ithundxr.dev/hidden" } // Flywheel 1.21 PR
}
@ -175,7 +170,9 @@ dependencies {
implementation("dev.ftb.mods:ftb-library-neoforge:2101.1.3")
implementation("maven.modrinth:journeymap:1.21.1-6.0.0-beta.32+neoforge")
implementation("info.journeymap:journeymap-api-neoforge:2.0.0-1.21.1-SNAPSHOT")
implementation("info.journeymap:journeymap-api-neoforge:2.0.0-1.21.1-SNAPSHOT") {
exclude(group: "curse.maven") // Pulls in a old version of journey map which is for forge
}
}
sourceSets.main {

View file

@ -24,6 +24,7 @@ import com.simibubi.create.content.schematics.cannon.SchematicannonBlockEntity.S
import com.simibubi.create.content.trains.track.BezierTrackPointLocation;
import com.simibubi.create.content.trains.track.TrackPlacement.ConnectingFrom;
import net.createmod.catnip.codecs.stream.CatnipStreamCodecBuilders;
import net.createmod.catnip.codecs.stream.CatnipStreamCodecs;
import net.minecraft.core.BlockPos;
import net.minecraft.core.UUIDUtil;
@ -137,7 +138,7 @@ public class AllDataComponents {
public static final DeferredHolder<DataComponentType<?>, DataComponentType<List<List<ClipboardEntry>>>> CLIPBOARD_PAGES = DATA_COMPONENTS.registerComponentType(
"clipboard_pages",
builder -> builder.persistent(ClipboardEntry.CODEC.listOf().listOf()).networkSynchronized(ClipboardEntry.STREAM_CODEC.apply(ByteBufCodecs.list()).apply(ByteBufCodecs.list()))
builder -> builder.persistent(ClipboardEntry.CODEC.listOf().listOf()).networkSynchronized(CatnipStreamCodecBuilders.list(CatnipStreamCodecBuilders.list(ClipboardEntry.STREAM_CODEC)))
);
public static final DeferredHolder<DataComponentType<?>, DataComponentType<Unit>> CLIPBOARD_READ_ONLY = DATA_COMPONENTS.registerComponentType(

View file

@ -1,8 +1,10 @@
package com.simibubi.create.content.equipment.clipboard;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.simibubi.create.AllDataComponents;
@ -17,6 +19,8 @@ import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.UnmodifiableView;
public class ClipboardEntry {
public static final Codec<ClipboardEntry> CODEC = RecordCodecBuilder.create(i -> i.group(
Codec.BOOL.fieldOf("checked").forGetter(c -> c.checked),
@ -63,7 +67,14 @@ public class ClipboardEntry {
}
public static List<List<ClipboardEntry>> readAll(ItemStack clipboardItem) {
return clipboardItem.getOrDefault(AllDataComponents.CLIPBOARD_PAGES, new ArrayList<>());
List<List<ClipboardEntry>> entries = new ArrayList<>();
// Both these lists are immutable, so we unfortunately need to re-create them to make them mutable
List<List<ClipboardEntry>> saved = clipboardItem.getOrDefault(AllDataComponents.CLIPBOARD_PAGES, Collections.emptyList());
for (List<ClipboardEntry> inner : saved)
entries.add(new ArrayList<>(inner));
return entries;
}
public static List<ClipboardEntry> getLastViewedEntries(ItemStack heldItem) {

View file

@ -137,7 +137,7 @@ public class RuntimeDataGenerator {
ResourceLocation id = ResourceLocation.fromNamespaceAndPath(recipe.id.getNamespace(),
typeId.getPath() + "/" + recipe.id.getPath());
Optional<JsonElement> serialized = CatnipCodecUtils.encode(Recipe.CONDITIONAL_CODEC, JsonOps.COMPRESSED, Optional.of(new WithConditions<>(recipe)));
Optional<JsonElement> serialized = CatnipCodecUtils.encode(Recipe.CONDITIONAL_CODEC, JsonOps.INSTANCE, Optional.of(new WithConditions<>(recipe)));
serialized.ifPresent(r -> JSON_FILES.put(id.withPrefix("recipes/"), r));
return recipe;
}