mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 12:29:15 +00:00
再此修复stonecutter
This commit is contained in:
@@ -67,7 +67,7 @@ import net.momirealms.craftengine.core.item.behavior.ItemBehavior;
|
||||
import net.momirealms.craftengine.core.item.context.UseOnContext;
|
||||
import net.momirealms.craftengine.core.item.recipe.network.legacy.LegacyRecipeHolder;
|
||||
import net.momirealms.craftengine.core.item.recipe.network.modern.RecipeBookEntry;
|
||||
import net.momirealms.craftengine.core.item.recipe.network.modern.SingleInputDisplay;
|
||||
import net.momirealms.craftengine.core.item.recipe.network.modern.SingleInputButtonDisplay;
|
||||
import net.momirealms.craftengine.core.item.recipe.network.modern.display.RecipeDisplay;
|
||||
import net.momirealms.craftengine.core.item.trade.MerchantOffer;
|
||||
import net.momirealms.craftengine.core.pack.host.ResourcePackDownloadData;
|
||||
@@ -3123,8 +3123,8 @@ public class BukkitNetworkManager implements NetworkManager, Listener, PluginMes
|
||||
FriendlyByteBuf::readKey,
|
||||
b -> b.readCollection(ArrayList::new, FriendlyByteBuf::readVarInt)
|
||||
);
|
||||
List<SingleInputDisplay<ItemStack>> displays = buf.readCollection(ArrayList::new, b -> {
|
||||
SingleInputDisplay<ItemStack> display = SingleInputDisplay.read(b, __ -> itemManager.wrap(FastNMS.INSTANCE.method$FriendlyByteBuf$readItem(friendlyBuf)));
|
||||
List<SingleInputButtonDisplay<ItemStack>> displays = buf.readCollection(ArrayList::new, b -> {
|
||||
SingleInputButtonDisplay<ItemStack> display = SingleInputButtonDisplay.read(b, __ -> itemManager.wrap(FastNMS.INSTANCE.method$FriendlyByteBuf$readItem(friendlyBuf)));
|
||||
display.applyClientboundData(item -> {
|
||||
Optional<Item<ItemStack>> remapped = itemManager.s2c(item, player);
|
||||
if (remapped.isEmpty()) {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.momirealms.craftengine.core.item.recipe.network.modern;
|
||||
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.recipe.network.modern.display.slot.SlotDisplay;
|
||||
import net.momirealms.craftengine.core.util.FriendlyByteBuf;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public record SingleInputButtonDisplay<I>(Either<List<Integer>, Key> ingredients, SlotDisplay<I> display) {
|
||||
|
||||
public static <I> SingleInputButtonDisplay<I> read(FriendlyByteBuf buf, FriendlyByteBuf.Reader<Item<I>> reader) {
|
||||
Either<List<Integer>, Key> ingredients = buf.readHolderSet();
|
||||
SlotDisplay<I> slotDisplay = SlotDisplay.read(buf, reader);
|
||||
return new SingleInputButtonDisplay<>(ingredients, slotDisplay);
|
||||
}
|
||||
|
||||
public void write(FriendlyByteBuf buf, FriendlyByteBuf.Writer<Item<I>> writer) {
|
||||
buf.writeHolderSet(this.ingredients);
|
||||
this.display.write(buf, writer);
|
||||
}
|
||||
|
||||
public void applyClientboundData(Function<Item<I>, Item<I>> function) {
|
||||
this.display.applyClientboundData(function);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package net.momirealms.craftengine.core.item.recipe.network.modern;
|
||||
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.recipe.network.modern.display.slot.SlotDisplay;
|
||||
import net.momirealms.craftengine.core.util.FriendlyByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
public record SingleInputDisplay<I>(List<Integer> ingredients, Optional<SlotDisplay<I>> display) {
|
||||
|
||||
public static <I> SingleInputDisplay<I> read(FriendlyByteBuf buf, FriendlyByteBuf.Reader<Item<I>> reader) {
|
||||
List<Integer> ingredients = buf.readCollection(ArrayList::new, FriendlyByteBuf::readVarInt);
|
||||
Optional<SlotDisplay<I>> slotDisplay = buf.readOptional(b -> SlotDisplay.read(b, reader));
|
||||
return new SingleInputDisplay<>(ingredients, slotDisplay);
|
||||
}
|
||||
|
||||
public void write(FriendlyByteBuf buf, FriendlyByteBuf.Writer<Item<I>> writer) {
|
||||
buf.writeCollection(this.ingredients, FriendlyByteBuf::writeVarInt);
|
||||
buf.writeOptional(this.display, (b, d) -> d.write(buf, writer));
|
||||
}
|
||||
|
||||
public void applyClientboundData(Function<Item<I>, Item<I>> function) {
|
||||
this.display.ifPresent(i -> i.applyClientboundData(function));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user