mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Optional but important decisions
- Update catnip - Fix compile errors caused by updating catnip - Fix a few crashes
This commit is contained in:
parent
6c35eb18cb
commit
2ed67bf116
11 changed files with 30 additions and 33 deletions
|
@ -37,7 +37,7 @@ jei_minecraft_version = 1.21
|
|||
jei_version = 19.5.0.33
|
||||
curios_minecraft_version = 1.21.1
|
||||
curios_version = 9.0.15
|
||||
catnip_version = 0.8.50
|
||||
catnip_version = 0.8.52
|
||||
ponder_version = 0.8.7
|
||||
catnip_and_ponder_mc_ver = 1.21.1
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.simibubi.create.foundation.blockEntity.ComparatorUtil;
|
|||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.particle.AirParticleData;
|
||||
|
||||
import net.createmod.catnip.codecs.CatnipCodecUtils;
|
||||
import net.createmod.catnip.utility.VecHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
|
@ -18,7 +19,6 @@ import net.minecraft.core.HolderLookup;
|
|||
import net.minecraft.core.component.DataComponentPatch;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.Nameable;
|
||||
|
@ -123,7 +123,7 @@ public class BacktankBlockEntity extends KineticBlockEntity implements Nameable
|
|||
if (this.customName != null)
|
||||
compound.putString("CustomName", Component.Serializer.toJson(this.customName, registries));
|
||||
|
||||
compound.put("Components", DataComponentPatch.CODEC.encodeStart(NbtOps.INSTANCE, componentPatch).getOrThrow());
|
||||
compound.put("Components", CatnipCodecUtils.encode(DataComponentPatch.CODEC, componentPatch).orElseThrow());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,7 +137,7 @@ public class BacktankBlockEntity extends KineticBlockEntity implements Nameable
|
|||
if (compound.contains("CustomName", 8))
|
||||
this.customName = Component.Serializer.fromJson(compound.getString("CustomName"), registries);
|
||||
|
||||
componentPatch = DataComponentPatch.CODEC.decode(NbtOps.INSTANCE, compound).getOrThrow().getFirst();
|
||||
componentPatch = CatnipCodecUtils.decode(DataComponentPatch.CODEC, compound).orElse(DataComponentPatch.EMPTY);
|
||||
if (prev != 0 && prev != airLevel && airLevel == BacktankUtil.maxAir(capacityEnchantLevel) && clientPacket)
|
||||
playFilledEffect();
|
||||
}
|
||||
|
|
|
@ -665,7 +665,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements ITra
|
|||
@Override
|
||||
public void writeSafe(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
super.writeSafe(tag, registries);
|
||||
tag.put("Connections", CatnipCodecUtils.encodeOrThrow(CatnipCodecs.set(BlockPos.CODEC), connections));
|
||||
tag.put("Connections", CatnipCodecUtils.encode(CatnipCodecs.set(BlockPos.CODEC), connections).orElseThrow());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -676,7 +676,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements ITra
|
|||
chainDestroyedEffectToSend = null;
|
||||
}
|
||||
|
||||
compound.put("Connections", CatnipCodecUtils.encodeOrThrow(CatnipCodecs.set(BlockPos.CODEC), connections));
|
||||
compound.put("Connections", CatnipCodecUtils.encode(CatnipCodecs.set(BlockPos.CODEC), connections).orElseThrow());
|
||||
compound.put("TravellingPackages", NBTHelper.writeCompoundList(travellingPackages.entrySet(), entry -> {
|
||||
CompoundTag compoundTag = new CompoundTag();
|
||||
compoundTag.put("Target", NbtUtils.writeBlockPos(entry.getKey()));
|
||||
|
@ -696,7 +696,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements ITra
|
|||
|
||||
int sizeBefore = connections.size();
|
||||
connections.clear();
|
||||
connections.addAll(CatnipCodecUtils.decodeOrThrow(CatnipCodecs.set(BlockPos.CODEC), compound.get("Connections")));
|
||||
CatnipCodecUtils.decode(CatnipCodecs.set(BlockPos.CODEC), compound.get("Connections")).ifPresent(connections::addAll);
|
||||
travellingPackages.clear();
|
||||
NBTHelper.iterateCompoundList(compound.getList("TravellingPackages", Tag.TAG_COMPOUND),
|
||||
c -> travellingPackages.put(NbtUtils.readBlockPos(c, "Target").orElseThrow(),
|
||||
|
@ -706,7 +706,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements ITra
|
|||
connectionStats = null;
|
||||
updateBoxWorldPositions();
|
||||
updateChainShapes();
|
||||
|
||||
|
||||
if (connections.size() != sizeBefore && level != null && level.isClientSide)
|
||||
invalidateRenderBoundingBox();
|
||||
}
|
||||
|
|
|
@ -13,14 +13,13 @@ import java.util.UUID;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
|
||||
import org.joml.Math;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllSoundEvents;
|
||||
import com.simibubi.create.AllTags.AllItemTags;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.logistics.BigItemStack;
|
||||
|
@ -67,6 +66,7 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
||||
|
@ -649,9 +649,9 @@ public class FactoryPanelBehaviour extends FilteringBehaviour {
|
|||
panelTag.putBoolean("PromisedSatisfied", promisedSatisfied);
|
||||
panelTag.putBoolean("Waiting", waitingForNetwork);
|
||||
panelTag.putBoolean("RedstonePowered", redstonePowered);
|
||||
panelTag.put("Targeting", CatnipCodecUtils.encodeOrThrow(CatnipCodecs.set(FactoryPanelPosition.CODEC), targeting));
|
||||
panelTag.put("TargetedBy", CatnipCodecUtils.encodeOrThrow(Codec.list(FactoryPanelConnection.CODEC), new ArrayList<>(targetedBy.values())));
|
||||
panelTag.put("TargetedByLinks", CatnipCodecUtils.encodeOrThrow(Codec.list(FactoryPanelConnection.CODEC), new ArrayList<>(targetedByLinks.values())));
|
||||
panelTag.put("Targeting", CatnipCodecUtils.encode(CatnipCodecs.set(FactoryPanelPosition.CODEC), targeting).orElseThrow());
|
||||
panelTag.put("TargetedBy", CatnipCodecUtils.encode(Codec.list(FactoryPanelConnection.CODEC), new ArrayList<>(targetedBy.values())).orElseThrow());
|
||||
panelTag.put("TargetedByLinks", CatnipCodecUtils.encode(Codec.list(FactoryPanelConnection.CODEC), new ArrayList<>(targetedByLinks.values())).orElseThrow());
|
||||
panelTag.putString("RecipeAddress", recipeAddress);
|
||||
panelTag.putInt("RecipeOutput", recipeOutput);
|
||||
panelTag.putInt("PromiseClearingInterval", promiseClearingInterval);
|
||||
|
@ -688,14 +688,14 @@ public class FactoryPanelBehaviour extends FilteringBehaviour {
|
|||
network = panelTag.getUUID("Freq");
|
||||
|
||||
targeting.clear();
|
||||
targeting = CatnipCodecUtils.decodeOrThrow(CatnipCodecs.set(FactoryPanelPosition.CODEC), panelTag.get("Targeting"));
|
||||
targeting = CatnipCodecUtils.decode(CatnipCodecs.set(FactoryPanelPosition.CODEC), panelTag.get("Targeting")).orElseThrow();
|
||||
|
||||
targetedBy.clear();
|
||||
CatnipCodecUtils.decodeOrThrow(Codec.list(FactoryPanelConnection.CODEC), panelTag.get("TargetedBy"))
|
||||
CatnipCodecUtils.decode(Codec.list(FactoryPanelConnection.CODEC), panelTag.get("TargetedBy")).orElseThrow()
|
||||
.forEach(c -> targetedBy.put(c.from, c));
|
||||
|
||||
targetedByLinks.clear();
|
||||
CatnipCodecUtils.decodeOrThrow(Codec.list(FactoryPanelConnection.CODEC), panelTag.get("TargetedByLinks"))
|
||||
CatnipCodecUtils.decode(Codec.list(FactoryPanelConnection.CODEC), panelTag.get("TargetedByLinks")).orElseThrow()
|
||||
.forEach(c -> targetedByLinks.put(c.from.pos(), c));
|
||||
|
||||
activeCraftingArrangement = NBTHelper.readItemList(panelTag.getList("Craft", Tag.TAG_COMPOUND), registries);
|
||||
|
|
|
@ -126,16 +126,13 @@ public class FactoryPanelSupportBehaviour extends BlockEntityBehaviour {
|
|||
|
||||
@Override
|
||||
public void write(CompoundTag nbt, HolderLookup.Provider registries, boolean clientPacket) {
|
||||
nbt.put("LinkedGauges", CatnipCodecUtils.encodeOrThrow(Codec.list(FactoryPanelPosition.CODEC), linkedPanels));
|
||||
nbt.put("LinkedGauges", CatnipCodecUtils.encode(Codec.list(FactoryPanelPosition.CODEC), linkedPanels).orElseThrow());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundTag nbt, HolderLookup.Provider registries, boolean clientPacket) {
|
||||
linkedPanels.clear();
|
||||
|
||||
List<FactoryPanelPosition> list = CatnipCodecUtils.decode(Codec.list(FactoryPanelPosition.CODEC), nbt.get("LinkedGauges"));
|
||||
if (list != null)
|
||||
linkedPanels.addAll(list);
|
||||
CatnipCodecUtils.decode(Codec.list(FactoryPanelPosition.CODEC), nbt.get("LinkedGauges")).ifPresent(linkedPanels::addAll);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,7 +82,7 @@ public abstract class PackagePortBlockEntity extends SmartBlockEntity implements
|
|||
protected void write(CompoundTag tag, HolderLookup.Provider registries, boolean clientPacket) {
|
||||
super.write(tag, registries, clientPacket);
|
||||
if (target != null)
|
||||
tag.put("Target", CatnipCodecUtils.encodeOrThrow(PackagePortTarget.CODEC, target));
|
||||
tag.put("Target", CatnipCodecUtils.encode(PackagePortTarget.CODEC, target).orElseThrow());
|
||||
tag.putString("AddressFilter", addressFilter);
|
||||
tag.putBoolean("AcceptsPackages", acceptsPackages);
|
||||
tag.put("Inventory", inventory.serializeNBT(registries));
|
||||
|
@ -93,7 +93,7 @@ public abstract class PackagePortBlockEntity extends SmartBlockEntity implements
|
|||
super.read(tag, registries, clientPacket);
|
||||
inventory.deserializeNBT(registries, tag.getCompound("Inventory"));
|
||||
PackagePortTarget prevTarget = target;
|
||||
target = CatnipCodecUtils.decodeOrThrow(PackagePortTarget.CODEC, tag.getCompound("Target"));
|
||||
target = CatnipCodecUtils.decode(PackagePortTarget.CODEC, tag.getCompound("Target")).orElse(null);
|
||||
addressFilter = tag.getString("AddressFilter");
|
||||
acceptsPackages = tag.getBoolean("AcceptsPackages");
|
||||
if (clientPacket && prevTarget != target)
|
||||
|
|
|
@ -181,13 +181,13 @@ public class InventorySummary {
|
|||
List<BigItemStack> all = new ArrayList<>();
|
||||
items.forEach((key, list) -> all.addAll(list));
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("List", CatnipCodecUtils.encodeOrThrow(Codec.list(BigItemStack.CODEC), all));
|
||||
tag.put("List", CatnipCodecUtils.encode(Codec.list(BigItemStack.CODEC), all).orElseThrow());
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static InventorySummary read(CompoundTag tag) {
|
||||
InventorySummary summary = new InventorySummary();
|
||||
summary.addAllBigItemStacks(CatnipCodecUtils.decodeOrThrow(Codec.list(BigItemStack.CODEC), tag.getCompound("List")));
|
||||
summary.addAllBigItemStacks(CatnipCodecUtils.decode(Codec.list(BigItemStack.CODEC), tag.getCompound("List")).orElseThrow());
|
||||
return summary;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,13 +107,13 @@ public class RequestPromiseQueue {
|
|||
|
||||
public CompoundTag write() {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put("List", CatnipCodecUtils.encodeOrThrow(Codec.list(RequestPromise.CODEC), flatten(false)));
|
||||
tag.put("List", CatnipCodecUtils.encode(Codec.list(RequestPromise.CODEC), flatten(false)).orElseThrow());
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static RequestPromiseQueue read(CompoundTag tag, Runnable onChanged) {
|
||||
RequestPromiseQueue queue = new RequestPromiseQueue(onChanged);
|
||||
List<RequestPromise> promises = CatnipCodecUtils.decodeOrThrow(Codec.list(RequestPromise.CODEC), tag.get("List"));
|
||||
List<RequestPromise> promises = CatnipCodecUtils.decode(Codec.list(RequestPromise.CODEC), tag.get("List")).orElseThrow();
|
||||
for (RequestPromise promise : promises) {
|
||||
queue.add(promise);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class RedstoneRequesterBlockEntity extends StockCheckingBlockEntity imple
|
|||
redstonePowered = tag.getBoolean("Powered");
|
||||
lastRequestSucceeded = tag.getBoolean("Success");
|
||||
allowPartialRequests = tag.getBoolean("AllowPartial");
|
||||
encodedRequest = CatnipCodecUtils.decodeOrThrow(PackageOrder.CODEC, tag.getCompound("EncodedRequest"));
|
||||
encodedRequest = CatnipCodecUtils.decode(PackageOrder.CODEC, tag.getCompound("EncodedRequest")).orElse(PackageOrder.empty());
|
||||
encodedTargetAdress = tag.getString("EncodedAddress");
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class RedstoneRequesterBlockEntity extends StockCheckingBlockEntity imple
|
|||
super.writeSafe(tag, registries);
|
||||
tag.putBoolean("AllowPartial", allowPartialRequests);
|
||||
tag.putString("EncodedAddress", encodedTargetAdress);
|
||||
tag.put("EncodedRequest", CatnipCodecUtils.encodeOrThrow(PackageOrder.CODEC, encodedRequest));
|
||||
tag.put("EncodedRequest", CatnipCodecUtils.encode(PackageOrder.CODEC, encodedRequest).orElseThrow());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -109,7 +109,7 @@ public class RedstoneRequesterBlockEntity extends StockCheckingBlockEntity imple
|
|||
tag.putBoolean("Success", lastRequestSucceeded);
|
||||
tag.putBoolean("AllowPartial", allowPartialRequests);
|
||||
tag.putString("EncodedAddress", encodedTargetAdress);
|
||||
tag.put("EncodedRequest", CatnipCodecUtils.encodeOrThrow(PackageOrder.CODEC, encodedRequest));
|
||||
tag.put("EncodedRequest", CatnipCodecUtils.encode(PackageOrder.CODEC, encodedRequest).orElseThrow());
|
||||
}
|
||||
|
||||
public InteractionResult use(Player player) {
|
||||
|
|
|
@ -316,7 +316,7 @@ public class TableClothBlockEntity extends SmartBlockEntity {
|
|||
super.write(tag, registries, clientPacket);
|
||||
tag.put("Items", NBTHelper.writeItemList(manuallyAddedItems, registries));
|
||||
tag.putInt("Facing", facing.get2DDataValue());
|
||||
tag.put("RequestData", CatnipCodecUtils.encodeOrThrow(AutoRequestData.CODEC, requestData));
|
||||
tag.put("RequestData", CatnipCodecUtils.encode(AutoRequestData.CODEC, requestData).orElseThrow());
|
||||
if (owner != null)
|
||||
tag.putUUID("OwnerUUID", owner);
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ public class TableClothBlockEntity extends SmartBlockEntity {
|
|||
protected void read(CompoundTag tag, HolderLookup.Provider registries, boolean clientPacket) {
|
||||
super.read(tag, registries, clientPacket);
|
||||
manuallyAddedItems = NBTHelper.readItemList(tag.getList("Items", Tag.TAG_COMPOUND), registries);
|
||||
requestData = CatnipCodecUtils.decodeOrThrow(AutoRequestData.CODEC, tag.get("RequestData"));
|
||||
requestData = CatnipCodecUtils.decode(AutoRequestData.CODEC, tag.get("RequestData")).orElseThrow();
|
||||
owner = tag.contains("OwnerUUID") ? tag.getUUID("OwnerUUID") : null;
|
||||
facing = Direction.from2DDataValue(Mth.positiveModulo(tag.getInt("Facing"), 4));
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ public class SchematicannonBlockEntity extends SmartBlockEntity implements MenuP
|
|||
}
|
||||
|
||||
// Settings
|
||||
SchematicannonOptions options = CatnipCodecUtils.decodeOrThrow(SchematicannonOptions.CODEC, compound.getCompound("Options"));
|
||||
SchematicannonOptions options = CatnipCodecUtils.decode(SchematicannonOptions.CODEC, compound.getCompound("Options")).orElseThrow();
|
||||
replaceMode = options.replaceMode;
|
||||
skipMissing = options.skipMissing;
|
||||
replaceBlockEntities = options.replaceBlockEntities;
|
||||
|
|
Loading…
Add table
Reference in a new issue