mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-10-30 02:40:51 +01:00
small fixes
This commit is contained in:
parent
a8d1a99e28
commit
9f55e87972
9 changed files with 14 additions and 16 deletions
|
@ -42,7 +42,7 @@ public final class Utility {
|
||||||
|
|
||||||
public static final Codec<ItemStackHandler> ITEM_STACK_HANDLER_CODEC = RecordCodecBuilder.create(builder -> builder.group(
|
public static final Codec<ItemStackHandler> ITEM_STACK_HANDLER_CODEC = RecordCodecBuilder.create(builder -> builder.group(
|
||||||
Codec.INT.fieldOf("size").forGetter(h -> h.getSlots()),
|
Codec.INT.fieldOf("size").forGetter(h -> h.getSlots()),
|
||||||
Codec.list(ItemStack.CODEC).fieldOf("items").forGetter(h -> IntStream.range(0, h.getSlots()).mapToObj(h::getStackInSlot).toList())
|
Codec.list(ItemStack.OPTIONAL_CODEC).fieldOf("items").forGetter(h -> IntStream.range(0, h.getSlots()).mapToObj(h::getStackInSlot).toList())
|
||||||
).apply(builder, (size, items) -> {
|
).apply(builder, (size, items) -> {
|
||||||
var ret = new ItemStackHandler(size);
|
var ret = new ItemStackHandler(size);
|
||||||
for (var i = 0; i < items.size(); i++)
|
for (var i = 0; i < items.size(); i++)
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onClientTick(ClientTickEvent event) {
|
public void onClientTick(ClientTickEvent.Pre event) {
|
||||||
if (!PlayerPrefs.get().syncJei)
|
if (!PlayerPrefs.get().syncJei)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||||
|
import joptsimple.internal.Strings;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.component.DataComponentType;
|
import net.minecraft.core.component.DataComponentType;
|
||||||
|
@ -68,13 +69,13 @@ public class DirectionSelector {
|
||||||
if (!this.modified)
|
if (!this.modified)
|
||||||
return;
|
return;
|
||||||
this.modified = false;
|
this.modified = false;
|
||||||
this.stack.set(Data.TYPE, new Data(this.direction.getName()));
|
this.stack.set(Data.TYPE, new Data(this.direction != null ? this.direction.getName() : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
var data = this.stack.get(Data.TYPE);
|
var data = this.stack.get(Data.TYPE);
|
||||||
if (data != null)
|
if (data != null)
|
||||||
this.direction = Direction.byName(data.direction);
|
this.direction = !Strings.isNullOrEmpty(data.direction) ? Direction.byName(data.direction) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Direction[] directions() {
|
public Direction[] directions() {
|
||||||
|
|
|
@ -45,8 +45,7 @@ public class NetworkEdge extends DefaultWeightedEdge implements INBTSerializable
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag nbt) {
|
public void deserializeNBT(HolderLookup.Provider provider, CompoundTag nbt) {
|
||||||
this.pipes.clear();
|
this.pipes.clear();
|
||||||
var list = nbt.getList("pipes", Tag.TAG_COMPOUND);
|
for (var tag : nbt.getList("pipes", Tag.TAG_INT_ARRAY))
|
||||||
for (var tag : list)
|
|
||||||
this.pipes.add(Utility.readBlockPos(tag));
|
this.pipes.add(Utility.readBlockPos(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,8 +274,7 @@ public class PipeItem implements IPipeItem {
|
||||||
this.y = nbt.getFloat("y");
|
this.y = nbt.getFloat("y");
|
||||||
this.z = nbt.getFloat("z");
|
this.z = nbt.getFloat("z");
|
||||||
this.path.clear();
|
this.path.clear();
|
||||||
var list = nbt.getList("path", Tag.TAG_COMPOUND);
|
for (var tag : nbt.getList("path", Tag.TAG_INT_ARRAY))
|
||||||
for (var tag : list)
|
|
||||||
this.path.add(Utility.readBlockPos(tag));
|
this.path.add(Utility.readBlockPos(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,7 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
||||||
|
|
||||||
public PipeNetwork(CompoundTag nbt, HolderLookup.Provider provider) {
|
public PipeNetwork(CompoundTag nbt, HolderLookup.Provider provider) {
|
||||||
this();
|
this();
|
||||||
var nodes = nbt.getList("nodes", Tag.TAG_COMPOUND);
|
for (var node : nbt.getList("nodes", Tag.TAG_INT_ARRAY))
|
||||||
for (var node : nodes)
|
|
||||||
this.graph.addVertex(Utility.readBlockPos(node));
|
this.graph.addVertex(Utility.readBlockPos(node));
|
||||||
var edges = nbt.getList("edges", Tag.TAG_COMPOUND);
|
var edges = nbt.getList("edges", Tag.TAG_COMPOUND);
|
||||||
for (var i = 0; i < edges.size(); i++)
|
for (var i = 0; i < edges.size(); i++)
|
||||||
|
|
|
@ -19,8 +19,8 @@ public record PacketCraftingModuleTransfer(List<ItemStack> inputs, List<ItemStac
|
||||||
|
|
||||||
public static final Type<PacketCraftingModuleTransfer> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "crafting_module_transfer"));
|
public static final Type<PacketCraftingModuleTransfer> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "crafting_module_transfer"));
|
||||||
public static final StreamCodec<RegistryFriendlyByteBuf, PacketCraftingModuleTransfer> CODEC = StreamCodec.composite(
|
public static final StreamCodec<RegistryFriendlyByteBuf, PacketCraftingModuleTransfer> CODEC = StreamCodec.composite(
|
||||||
ByteBufCodecs.collection(ArrayList::new, ItemStack.STREAM_CODEC), PacketCraftingModuleTransfer::inputs,
|
ItemStack.LIST_STREAM_CODEC, PacketCraftingModuleTransfer::inputs,
|
||||||
ByteBufCodecs.collection(ArrayList::new, ItemStack.STREAM_CODEC), PacketCraftingModuleTransfer::outputs,
|
ItemStack.LIST_STREAM_CODEC, PacketCraftingModuleTransfer::outputs,
|
||||||
PacketCraftingModuleTransfer::new);
|
PacketCraftingModuleTransfer::new);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,7 +46,7 @@ public record PacketGhostSlot(BlockPos pos, List<Entry> stacks) implements Custo
|
||||||
public record Entry(List<ItemStack> stacks, TagKey<Item> tag) {
|
public record Entry(List<ItemStack> stacks, TagKey<Item> tag) {
|
||||||
|
|
||||||
public static final StreamCodec<RegistryFriendlyByteBuf, Entry> CODEC = StreamCodec.composite(
|
public static final StreamCodec<RegistryFriendlyByteBuf, Entry> CODEC = StreamCodec.composite(
|
||||||
ByteBufCodecs.collection(ArrayList::new, ItemStack.STREAM_CODEC), Entry::stacks,
|
ItemStack.OPTIONAL_LIST_STREAM_CODEC, Entry::stacks,
|
||||||
ByteBufCodecs.fromCodec(TagKey.codec(Registries.ITEM)), Entry::tag,
|
ByteBufCodecs.fromCodec(TagKey.codec(Registries.ITEM)), Entry::tag,
|
||||||
Entry::new);
|
Entry::new);
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ public record PacketNetworkItems(List<ItemStack> items, List<ItemStack> craftabl
|
||||||
|
|
||||||
public static final Type<PacketNetworkItems> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "network_items"));
|
public static final Type<PacketNetworkItems> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(PrettyPipes.ID, "network_items"));
|
||||||
public static final StreamCodec<RegistryFriendlyByteBuf, PacketNetworkItems> CODEC = StreamCodec.composite(
|
public static final StreamCodec<RegistryFriendlyByteBuf, PacketNetworkItems> CODEC = StreamCodec.composite(
|
||||||
ByteBufCodecs.collection(ArrayList::new, ItemStack.STREAM_CODEC), PacketNetworkItems::items,
|
ItemStack.LIST_STREAM_CODEC, PacketNetworkItems::items,
|
||||||
ByteBufCodecs.collection(ArrayList::new, ItemStack.STREAM_CODEC), PacketNetworkItems::craftables,
|
ItemStack.LIST_STREAM_CODEC, PacketNetworkItems::craftables,
|
||||||
ByteBufCodecs.collection(ArrayList::new, ItemStack.STREAM_CODEC), PacketNetworkItems::currentlyCrafting,
|
ItemStack.LIST_STREAM_CODEC, PacketNetworkItems::currentlyCrafting,
|
||||||
PacketNetworkItems::new);
|
PacketNetworkItems::new);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue