-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: not being able to extract patterns
They couldn't be extracted as ItemStack does not implement equals/hashCode and that breaks the extract comparison for the stack component.
- Loading branch information
1 parent
82ee865
commit 2e39bd6
Showing
4 changed files
with
47 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 12 additions & 10 deletions
22
...in/java/com/refinedmods/refinedstorage/common/autocrafting/SmithingTablePatternState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
package com.refinedmods.refinedstorage.common.autocrafting; | ||
|
||
import com.refinedmods.refinedstorage.common.support.resource.ItemResource; | ||
import com.refinedmods.refinedstorage.common.support.resource.ResourceCodecs; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
public record SmithingTablePatternState(ItemStack template, | ||
ItemStack base, | ||
ItemStack addition) { | ||
public record SmithingTablePatternState(ItemResource template, | ||
ItemResource base, | ||
ItemResource addition) { | ||
public static final Codec<SmithingTablePatternState> CODEC = RecordCodecBuilder.create(instance -> instance.group( | ||
ItemStack.CODEC.fieldOf("template").forGetter(SmithingTablePatternState::template), | ||
ItemStack.CODEC.fieldOf("base").forGetter(SmithingTablePatternState::base), | ||
ItemStack.CODEC.fieldOf("addition").forGetter(SmithingTablePatternState::addition) | ||
ResourceCodecs.ITEM_CODEC.fieldOf("template").forGetter(SmithingTablePatternState::template), | ||
ResourceCodecs.ITEM_CODEC.fieldOf("base").forGetter(SmithingTablePatternState::base), | ||
ResourceCodecs.ITEM_CODEC.fieldOf("addition").forGetter(SmithingTablePatternState::addition) | ||
).apply(instance, SmithingTablePatternState::new)); | ||
|
||
public static final StreamCodec<RegistryFriendlyByteBuf, SmithingTablePatternState> STREAM_CODEC = | ||
StreamCodec.composite( | ||
ItemStack.STREAM_CODEC, SmithingTablePatternState::template, | ||
ItemStack.STREAM_CODEC, SmithingTablePatternState::base, | ||
ItemStack.STREAM_CODEC, SmithingTablePatternState::addition, | ||
ResourceCodecs.ITEM_STREAM_CODEC, SmithingTablePatternState::template, | ||
ResourceCodecs.ITEM_STREAM_CODEC, SmithingTablePatternState::base, | ||
ResourceCodecs.ITEM_STREAM_CODEC, SmithingTablePatternState::addition, | ||
SmithingTablePatternState::new | ||
); | ||
} |
14 changes: 8 additions & 6 deletions
14
...main/java/com/refinedmods/refinedstorage/common/autocrafting/StonecutterPatternState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
package com.refinedmods.refinedstorage.common.autocrafting; | ||
|
||
import com.refinedmods.refinedstorage.common.support.resource.ItemResource; | ||
import com.refinedmods.refinedstorage.common.support.resource.ResourceCodecs; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
public record StonecutterPatternState(ItemStack input, ItemStack selectedOutput) { | ||
public record StonecutterPatternState(ItemResource input, ItemResource selectedOutput) { | ||
public static final Codec<StonecutterPatternState> CODEC = RecordCodecBuilder.create(instance -> instance.group( | ||
ItemStack.CODEC.fieldOf("input").forGetter(StonecutterPatternState::input), | ||
ItemStack.CODEC.fieldOf("selectedOutput").forGetter(StonecutterPatternState::selectedOutput) | ||
ResourceCodecs.ITEM_CODEC.fieldOf("input").forGetter(StonecutterPatternState::input), | ||
ResourceCodecs.ITEM_CODEC.fieldOf("selectedOutput").forGetter(StonecutterPatternState::selectedOutput) | ||
).apply(instance, StonecutterPatternState::new)); | ||
|
||
public static final StreamCodec<RegistryFriendlyByteBuf, StonecutterPatternState> STREAM_CODEC = | ||
StreamCodec.composite( | ||
ItemStack.STREAM_CODEC, StonecutterPatternState::input, | ||
ItemStack.STREAM_CODEC, StonecutterPatternState::selectedOutput, | ||
ResourceCodecs.ITEM_STREAM_CODEC, StonecutterPatternState::input, | ||
ResourceCodecs.ITEM_STREAM_CODEC, StonecutterPatternState::selectedOutput, | ||
StonecutterPatternState::new | ||
); | ||
} |