1.14 Support notes and initial work
This commit is contained in:
1 parent
60d9a80ddd
commit
ab086f901b
15 files changed
+145
-143
No files matched your search
-12
@@ -5,8 +5,6 @@ import ac.grim.grimac.platform.api.command.PlayerSelector;
|
||||
import ac.grim.grimac.platform.api.sender.Sender;
|
||||
import ac.grim.grimac.platform.bukkit.sender.BukkitSenderFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class BukkitPlayerSelectorAdapter implements PlayerSelector {
|
||||
private final org.incendo.cloud.bukkit.data.SinglePlayerSelector bukkitSelector;
|
||||
@@ -15,21 +13,11 @@ public class BukkitPlayerSelectorAdapter implements PlayerSelector {
|
||||
this.bukkitSelector = bukkitSelector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sender getSinglePlayer() {
|
||||
return ((BukkitSenderFactory) GrimAPI.INSTANCE.getSenderFactory()).map(bukkitSelector.single());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Sender> getPlayers() {
|
||||
return Collections.singletonList(((BukkitSenderFactory) GrimAPI.INSTANCE.getSenderFactory()).map(bukkitSelector.single()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inputString() {
|
||||
return bukkitSelector.inputString();
|
||||
|
||||
@@ -2,14 +2,9 @@ package ac.grim.grimac.platform.api.command;
|
||||
|
||||
import ac.grim.grimac.platform.api.sender.Sender;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface PlayerSelector {
|
||||
boolean isSingle();
|
||||
|
||||
Sender getSinglePlayer(); // Throws an exception if not a single selection
|
||||
|
||||
Collection<Sender> getPlayers();
|
||||
|
||||
String inputString();
|
||||
}
|
||||
@@ -98,3 +98,7 @@ tasks.remapJar.configure {
|
||||
publishing.publications.create<MavenPublication>("maven") {
|
||||
artifact(tasks["remapJar"])
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
options.release.set(8)
|
||||
}
|
||||
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx7G
|
||||
org.gradle.parallel=true
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.21.4
|
||||
yarn_mappings=1.21.4+build.8:v2
|
||||
minecraft_version=1.14
|
||||
yarn_mappings=1.14+build.21
|
||||
# Fabric API
|
||||
fabric_version=0.118.0+1.21.4
|
||||
fabric_version=0.28.5+1.14
|
||||
-10
@@ -16,21 +16,11 @@ public class Fabric1201PlayerSelectorAdapter implements PlayerSelector {
|
||||
this.fabricSelector = fabricSelector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sender getSinglePlayer() {
|
||||
return ((FabricSenderFactory) GrimAPI.INSTANCE.getSenderFactory()).map(fabricSelector.single().getCommandSource());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Sender> getPlayers() {
|
||||
return Collections.singletonList(getSinglePlayer()); // Assuming your ServerPlayer can be cast to Player
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inputString() {
|
||||
return fabricSelector.inputString();
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package ac.grim.grimac.platform.fabric.mc1211.entity;
|
||||
|
||||
import ac.grim.grimac.platform.fabric.GrimACFabricLoaderPlugin;
|
||||
import ac.grim.grimac.platform.fabric.entity.FabricGrimEntity;
|
||||
import ac.grim.grimac.platform.fabric.world.FabricPlatformWorld;
|
||||
import ac.grim.grimac.utils.math.Location;
|
||||
@@ -33,5 +34,6 @@ public class Fabric1211GrimEntity extends FabricGrimEntity {
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return GrimACFabricLoaderPlugin.FABRIC_SERVER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
GetCommandSource
|
||||
1.14 - 1.21.1
|
||||
Lnet/minecraft/entity/Entity;getCommandSource()Lnet/minecraft/server/command/ServerCommandSource;
|
||||
1.21.2 - 1.21.4
|
||||
ServerPlayerEntity#getCommandSource()
|
||||
|
||||
Inventory methods
|
||||
1.14 - 1.21.4
|
||||
Lnet/minecraft/entity/player/PlayerInventory;getMainHandStack()Lnet/minecraft/item/ItemStack;
|
||||
|
||||
Entity Teleport
|
||||
// TODO 1.14-1.19.3 entity teleport
|
||||
1.19.4 - 1.21.1
|
||||
Lnet/minecraft/entity/Entity;teleport(Lnet/minecraft/server/world/ServerWorld;DDDLjava/util/Set;FF)Z
|
||||
1.21.2 - 1.21.4
|
||||
Lnet/minecraft/entity/Entity;teleport(Lnet/minecraft/server/world/ServerWorld;DDDLjava/util/Set;FFF)Z
|
||||
|
||||
GetTickTime
|
||||
1.14 - 1.20.2
|
||||
getTickTime()
|
||||
// TODO MISSING 1.20.3-1.20.4
|
||||
1.20.6 - latest
|
||||
getAverageTickTime()
|
||||
|
||||
|
||||
1.21.2 - latest
|
||||
- fabricPlayer.sendMessage()
|
||||
|
||||
|
||||
Getting ServerPlayerEntity Inventory
|
||||
1.14 - 1.16.5
|
||||
player.inventory
|
||||
1.17 - 1.21.4
|
||||
PlayerEntity.getInventory()
|
||||
|
||||
1.14 - 1.15.2
|
||||
net.minecraft.entity.player.PlayerInventory#getInvSize
|
||||
net.minecraft.entity.player.PlayerInventory#getInvStack
|
||||
net.minecraft.entity.player.PlayerEntity#container - for getInventoryOpenKey
|
||||
1.16 - 1.21.4
|
||||
net.minecraft.inventory.Inventory#size
|
||||
net.minecraft.entity.player.PlayerInventory#getStack
|
||||
|
||||
1.14 - 1.19
|
||||
net.minecraft.server.command.CommandManager#execute
|
||||
1.19.1 - 1.21.4
|
||||
net.minecraft.server.command.CommandManager#executeWithPrefix
|
||||
@@ -14,12 +14,14 @@ public class FabricPlatformServer implements PlatformServer {
|
||||
return "Fabric " + FabricLoader.getInstance().getModContainer("fabricloader").get().getMetadata().getVersion().getFriendlyString() + " (MC: " + GrimACFabricLoaderPlugin.FABRIC_SERVER.getVersion() + ")";
|
||||
}
|
||||
|
||||
// < 1.14 to 1.19
|
||||
@Override
|
||||
public void dispatchCommand(Sender sender, String command) {
|
||||
ServerCommandSource commandSource = GrimACFabricLoaderPlugin.PLUGIN.getFabricSenderFactory().reverse(sender);
|
||||
GrimACFabricLoaderPlugin.FABRIC_SERVER.getCommandManager().executeWithPrefix(commandSource, command);
|
||||
GrimACFabricLoaderPlugin.FABRIC_SERVER.getCommandManager().execute(commandSource, command);
|
||||
}
|
||||
|
||||
// < 1.14 to 1.21.4
|
||||
@Override
|
||||
public Sender getConsoleSender() {
|
||||
ServerCommandSource consoleSource = GrimACFabricLoaderPlugin.FABRIC_SERVER.getCommandSource();
|
||||
@@ -33,6 +35,7 @@ public class FabricPlatformServer implements PlatformServer {
|
||||
|
||||
@Override
|
||||
public double getTPS() {
|
||||
return GrimACFabricLoaderPlugin.FABRIC_SERVER.getAverageTickTime();
|
||||
// TODO chain-load
|
||||
return GrimACFabricLoaderPlugin.FABRIC_SERVER.getTickTime(); // GrimACFabricLoaderPlugin.FABRIC_SERVER.getAverageTickTime();
|
||||
}
|
||||
}
|
||||
-11
@@ -6,8 +6,6 @@ import ac.grim.grimac.platform.api.command.PlayerSelector;
|
||||
import ac.grim.grimac.platform.api.sender.Sender;
|
||||
import ac.grim.grimac.platform.fabric.sender.FabricSenderFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class FabricPlayerSelectorAdapter implements PlayerSelector {
|
||||
protected final org.incendo.cloud.minecraft.modded.data.SinglePlayerSelector fabricSelector;
|
||||
@@ -16,20 +14,11 @@ public class FabricPlayerSelectorAdapter implements PlayerSelector {
|
||||
this.fabricSelector = fabricSelector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sender getSinglePlayer() {
|
||||
return ((FabricSenderFactory) GrimAPI.INSTANCE.getSenderFactory()).map(fabricSelector.single().getCommandSource());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Sender> getPlayers() {
|
||||
return Collections.singletonList(getSinglePlayer()); // Assuming your ServerPlayer can be cast to Player
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inputString() {
|
||||
|
||||
@@ -7,11 +7,9 @@ import ac.grim.grimac.utils.math.Location;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.network.packet.s2c.play.PositionFlag;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@@ -39,21 +37,22 @@ public class FabricGrimEntity implements GrimEntity {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO chain-load
|
||||
@Override
|
||||
public CompletableFuture<Boolean> teleportAsync(Location location) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
if (entity.getWorld() instanceof ServerWorld) {
|
||||
entity.teleport(
|
||||
((FabricPlatformWorld) location.getWorld()).getFabricWorld(),
|
||||
location.getX(),
|
||||
location.getY(),
|
||||
location.getZ(),
|
||||
EnumSet.noneOf(PositionFlag.class), // todo change to match paper? Do they do this?
|
||||
location.getYaw(),
|
||||
location.getPitch(),
|
||||
true // doesn't seem to be used?
|
||||
|
||||
);
|
||||
// entity.teleport(
|
||||
// ((FabricPlatformWorld) location.getWorld()).getFabricWorld(),
|
||||
// location.getX(),
|
||||
// location.getY(),
|
||||
// location.getZ(),
|
||||
// EnumSet.noneOf(PositionFlag.class), // todo change to match paper? Do they do this?
|
||||
// location.getYaw(),
|
||||
// location.getPitch(),
|
||||
// true // doesn't seem to be used?
|
||||
//
|
||||
// );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+35
-43
@@ -3,14 +3,14 @@ package ac.grim.grimac.platform.fabric.player;
|
||||
import ac.grim.grimac.platform.api.player.PlatformInventory;
|
||||
import ac.grim.grimac.platform.fabric.utils.convert.FabricConversionUtil;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import net.minecraft.container.Container;
|
||||
import net.minecraft.container.ContainerType;
|
||||
import net.minecraft.container.CraftingTableContainer;
|
||||
import net.minecraft.container.Generic3x3Container;
|
||||
import net.minecraft.container.GenericContainer;
|
||||
import net.minecraft.container.ShulkerBoxContainer;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.screen.PlayerScreenHandler;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
||||
public class FabricPlatformInventory implements PlatformInventory {
|
||||
@@ -20,7 +20,8 @@ public class FabricPlatformInventory implements PlatformInventory {
|
||||
|
||||
public FabricPlatformInventory(ServerPlayerEntity player) {
|
||||
this.fabricPlayer = player;
|
||||
this.inventory = player.getInventory();
|
||||
// 1.14 - 1.16.5
|
||||
this.inventory = player.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,9 +34,10 @@ public class FabricPlatformInventory implements PlatformInventory {
|
||||
return FabricConversionUtil.fromFabricItemStack(inventory.offHand.get(0));
|
||||
}
|
||||
|
||||
// 1.14 - 1.15.2
|
||||
@Override
|
||||
public ItemStack getStack(int bukkitSlot, int vanillaSlot) {
|
||||
return FabricConversionUtil.fromFabricItemStack(inventory.getStack(bukkitSlot));
|
||||
return FabricConversionUtil.fromFabricItemStack(inventory.getInvStack(bukkitSlot));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,11 +60,17 @@ public class FabricPlatformInventory implements PlatformInventory {
|
||||
return FabricConversionUtil.fromFabricItemStack(inventory.getArmorStack(0));
|
||||
}
|
||||
|
||||
// 1.14 - 1.15.2
|
||||
@Override
|
||||
public ItemStack[] getContents() {
|
||||
ItemStack[] items = new ItemStack[inventory.size()];
|
||||
for (int i = 0; i < inventory.size(); i++) {
|
||||
items[i] = FabricConversionUtil.fromFabricItemStack(inventory.getStack(i));
|
||||
|
||||
ItemStack[] items = new ItemStack[
|
||||
inventory.getInvSize() // 1.14 - 1.15.2
|
||||
];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = FabricConversionUtil.fromFabricItemStack(
|
||||
inventory.getInvStack(i) // 1.14 - 1.15.2
|
||||
);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
@@ -76,51 +84,35 @@ public class FabricPlatformInventory implements PlatformInventory {
|
||||
// And is slated to be replaced by packet based behaviour, this should do for now
|
||||
@Override
|
||||
public String getOpenInventoryKey() {
|
||||
ScreenHandler handler = fabricPlayer.currentScreenHandler;
|
||||
ScreenHandlerType<?> type = getSafeType(handler);
|
||||
Container container = fabricPlayer.container;
|
||||
|
||||
// Handle null types (player crafting and creative)
|
||||
if (type == null) {
|
||||
|
||||
// Not sure if creative mode check here is correct
|
||||
if (container == null && fabricPlayer.isCreative()) {
|
||||
return "CREATIVE";
|
||||
// 4x4 CRAFTING -> CRAFTING
|
||||
if (handler instanceof PlayerScreenHandler) {
|
||||
return "CRAFTING";
|
||||
// Not sure if creative mode check here is correct
|
||||
} else if (fabricPlayer.isInCreativeMode()) {
|
||||
return "CREATIVE";
|
||||
}
|
||||
} else if (container == fabricPlayer.playerContainer) {
|
||||
return "CRAFTING";
|
||||
}
|
||||
|
||||
// should we handle crafters here also??
|
||||
// CRAFTING -> CRAFTING
|
||||
if (type == ScreenHandlerType.CRAFTING) {
|
||||
if (container instanceof CraftingTableContainer) {
|
||||
return "CRAFTING";
|
||||
// PLAYER -> PLAYER
|
||||
} else if (type == ScreenHandlerType.GENERIC_9X4) {
|
||||
// PLAYER -> PLAYER // I give up on figuring out if this is right or not, ifi t isn't we'll find out
|
||||
} else if (container instanceof GenericContainer && ((GenericContainer) container).getType() == ContainerType.GENERIC_9X4) {
|
||||
return "PLAYER";
|
||||
// SHULKER BOX -> SHULKER_BOX
|
||||
} else if (container instanceof ShulkerBoxContainer) {
|
||||
return "SHULKER_BOX";
|
||||
// CHEST, ENDER_CHEST, or BARREL -> CHEST
|
||||
} else if (type == ScreenHandlerType.GENERIC_9X3) {
|
||||
} else if (container instanceof GenericContainer && (((GenericContainer) container).getType() == ContainerType.GENERIC_9X3 || ((GenericContainer) container).getType() == ContainerType.GENERIC_9X6)) {
|
||||
return "CHEST";
|
||||
// DISPENSER, DROPPER -> DISPENSER
|
||||
} else if (type == ScreenHandlerType.GENERIC_3X3) {
|
||||
} else if (container instanceof Generic3x3Container) {
|
||||
return "DISPENSER";
|
||||
} else {
|
||||
// Registry handles:
|
||||
// SHULKER_BOX -> SHULKER_BOX
|
||||
// CRAFTIING -> CRAFTING
|
||||
Identifier registryKey = Registries.SCREEN_HANDLER.getId(type);
|
||||
if (registryKey != null) {
|
||||
return registryKey.getPath();
|
||||
}
|
||||
|
||||
return handler.getClass().getSimpleName(); // Default fallback
|
||||
}
|
||||
}
|
||||
|
||||
private static @Nullable ScreenHandlerType<?> getSafeType(ScreenHandler handler) {
|
||||
try {
|
||||
return handler.getType();
|
||||
} catch (UnsupportedOperationException e) {
|
||||
return null;
|
||||
return container.getClass().getSimpleName(); // Default fallback
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -20,6 +20,7 @@ public class FabricRegionScheduler implements RegionScheduler {
|
||||
|
||||
public FabricRegionScheduler(GrimPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
// TODO chain-load
|
||||
ServerTickEvents.END_SERVER_TICK.register(this::handleTasks);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ import ac.grim.grimac.platform.api.sender.SenderFactory;
|
||||
import ac.grim.grimac.platform.fabric.GrimACFabricLoaderPlugin;
|
||||
import ac.grim.grimac.platform.fabric.utils.convert.FabricConversionUtil;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.fabricmc.fabric.api.util.TriState;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.command.CommandOutput;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.dedicated.ServerCommandOutput;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.rcon.RconCommandOutput;
|
||||
import net.minecraft.text.Text;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.incendo.cloud.SenderMapper;
|
||||
|
||||
@@ -48,7 +47,7 @@ public class FabricSenderFactory extends SenderFactory<ServerCommandSource> impl
|
||||
|
||||
@Override
|
||||
protected void sendMessage(ServerCommandSource sender, Component message) {
|
||||
sender.sendFeedback(() -> FabricConversionUtil.toNativeText(message), false);
|
||||
sender.sendFeedback(FabricConversionUtil.toNativeText(message), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,8 +90,8 @@ public class FabricSenderFactory extends SenderFactory<ServerCommandSource> impl
|
||||
@Override
|
||||
protected boolean isConsole(ServerCommandSource sender) {
|
||||
CommandOutput output = sender.output;
|
||||
return output == sender.getServer() || // Console
|
||||
output.getClass() == RconCommandOutput.class || // Rcon
|
||||
return output instanceof MinecraftServer || // Console
|
||||
output instanceof ServerCommandOutput || // Rcon
|
||||
(output == CommandOutput.DUMMY && sender.getName().equals("")); // Functions
|
||||
}
|
||||
|
||||
|
||||
+30
-37
@@ -1,53 +1,46 @@
|
||||
package ac.grim.grimac.platform.fabric.utils.convert;
|
||||
|
||||
import ac.grim.grimac.platform.fabric.GrimACFabricLoaderPlugin;
|
||||
import ac.grim.grimac.utils.anticheat.LogUtil;
|
||||
import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import io.github.retrooper.packetevents.adventure.serializer.gson.GsonComponentSerializer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.network.RegistryByteBuf;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class FabricConversionUtil {
|
||||
|
||||
// TODO chain-load
|
||||
private static Function<net.minecraft.item.ItemStack, ItemStack> itemStackMapperFunction = (fabricStack) -> {
|
||||
if (fabricStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
// Allocate a ByteBuf
|
||||
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
|
||||
try {
|
||||
// Obtain the DynamicRegistryManager (you need to provide this from your context)
|
||||
DynamicRegistryManager registryManager = GrimACFabricLoaderPlugin.FABRIC_SERVER.getRegistryManager(); // Replace with actual method to get registry manager
|
||||
|
||||
// Create a RegistryByteBuf
|
||||
RegistryByteBuf registryByteBuf = new RegistryByteBuf(buffer, registryManager);
|
||||
|
||||
// Encode the ItemStack using the appropriate PacketCodec
|
||||
net.minecraft.item.ItemStack.PACKET_CODEC.encode(registryByteBuf, fabricStack);
|
||||
|
||||
// Create a PacketWrapper to read the ItemStack back (if needed)
|
||||
PacketWrapper<?> wrapper = PacketWrapper.createUniversalPacketWrapper(buffer);
|
||||
return wrapper.readItemStack();
|
||||
} catch (Exception e) {
|
||||
// Handle encoding errors
|
||||
LogUtil.error("Failed to encode ItemStack: {}" + fabricStack, e);
|
||||
return ItemStack.EMPTY;
|
||||
} finally {
|
||||
// Release the ByteBuf to prevent memory leaks
|
||||
ByteBufHelper.release(buffer);
|
||||
}
|
||||
// if (fabricStack.isEmpty()) {
|
||||
// return ItemStack.EMPTY;
|
||||
// }
|
||||
//
|
||||
// // Allocate a ByteBuf
|
||||
// ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
|
||||
// try {
|
||||
// // Obtain the DynamicRegistryManager (you need to provide this from your context)
|
||||
// DynamicRegistryManager registryManager = GrimACFabricLoaderPlugin.FABRIC_SERVER.getRegistryManager(); // Replace with actual method to get registry manager
|
||||
//
|
||||
// // Create a RegistryByteBuf
|
||||
// RegistryByteBuf registryByteBuf = new RegistryByteBuf(buffer, registryManager);
|
||||
//
|
||||
// // Encode the ItemStack using the appropriate PacketCodec
|
||||
// net.minecraft.item.ItemStack.PACKET_CODEC.encode(registryByteBuf, fabricStack);
|
||||
//
|
||||
// // Create a PacketWrapper to read the ItemStack back (if needed)
|
||||
// PacketWrapper<?> wrapper = PacketWrapper.createUniversalPacketWrapper(buffer);
|
||||
// return wrapper.readItemStack();
|
||||
// } catch (Exception e) {
|
||||
// // Handle encoding errors
|
||||
// LogUtil.error("Failed to encode ItemStack: {}" + fabricStack, e);
|
||||
// return ItemStack.EMPTY;
|
||||
// } finally {
|
||||
// // Release the ByteBuf to prevent memory leaks
|
||||
// ByteBufHelper.release(buffer);
|
||||
// }
|
||||
return null;
|
||||
};
|
||||
private static Function<Component, Text> nativeTextMapperFunction = (component) -> Text.Serialization.fromJsonTree(GsonComponentSerializer.gson().serializeToTree(component), DynamicRegistryManager.EMPTY);
|
||||
private static Function<Component, Text> nativeTextMapperFunction = (component) -> null; //Text.Serialization.fromJsonTree(GsonComponentSerializer.gson().serializeToTree(component), DynamicRegistryManager.EMPTY);
|
||||
|
||||
public static void setConverters(Function<net.minecraft.item.ItemStack, ItemStack> itemStackMapperFunction,
|
||||
Function<Component, Text> nativeTextMapperFunction) {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
accessWidener v2 named
|
||||
accessible field net/minecraft/server/world/ServerWorld worldProperties Lnet/minecraft/world/level/ServerWorldProperties;
|
||||
#accessible field net/minecraft/server/world/ServerWorld worldProperties Lnet/minecraft/world/level/ServerWorldProperties;
|
||||
accessible field net/minecraft/server/command/ServerCommandSource output Lnet/minecraft/server/command/CommandOutput;
|
||||
Reference in new issue
Block a user