-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: Continue port to Minecraft 1.21.3
- Loading branch information
1 parent
b5eefd4
commit 7c48def
Showing
13 changed files
with
127 additions
and
124 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
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
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
39 changes: 39 additions & 0 deletions
39
common/src/main/java/net/blay09/mods/cookingforblockheads/crafting/CraftableWithStatus.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.blay09.mods.cookingforblockheads.crafting; | ||
|
||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.ByteBufCodecs; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public record CraftableWithStatus(ItemStack itemStack, boolean missingIngredients, boolean missingUtensils) { | ||
public static final StreamCodec<RegistryFriendlyByteBuf, CraftableWithStatus> STREAM_CODEC = StreamCodec.composite( | ||
ItemStack.STREAM_CODEC, | ||
CraftableWithStatus::itemStack, | ||
ByteBufCodecs.BOOL, | ||
CraftableWithStatus::missingIngredients, | ||
ByteBufCodecs.BOOL, | ||
CraftableWithStatus::missingUtensils, | ||
CraftableWithStatus::new | ||
); | ||
|
||
public static CraftableWithStatus best(@Nullable CraftableWithStatus first, @Nullable CraftableWithStatus second) { | ||
if (first == null) { | ||
return second; | ||
} else if (second == null) { | ||
return first; | ||
} | ||
|
||
if (!first.missingIngredients && second.missingIngredients) { | ||
return first; | ||
} else if (!second.missingIngredients && first.missingIngredients) { | ||
return second; | ||
} else if (!first.missingUtensils && second.missingUtensils) { | ||
return first; | ||
} else if (!second.missingUtensils && first.missingUtensils) { | ||
return second; | ||
} | ||
|
||
return first; | ||
} | ||
} |
Oops, something went wrong.