Use the delegates registry-access instead of creating our own

This commit is contained in:
Lukas Rieger (Blue) 2024-07-22 17:59:07 +02:00
parent 4ebceb8801
commit eed8f79e68
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6
5 changed files with 5 additions and 25 deletions

View File

@ -31,8 +31,6 @@
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
import de.bluecolored.bluemap.core.world.World;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.registry.BuiltinRegistries;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.math.Vec3d;
@ -40,8 +38,6 @@
public class FabricCommandSource implements CommandSource {
private static final RegistryWrapper.WrapperLookup lookup = BuiltinRegistries.createWrapperLookup();
private final FabricMod mod;
private final Plugin plugin;
private final ServerCommandSource delegate;
@ -56,7 +52,7 @@ public FabricCommandSource(FabricMod mod, Plugin plugin, ServerCommandSource del
public void sendMessage(Text text) {
delegate.sendFeedback(
() -> net.minecraft.text.Text.Serialization
.fromJson(text.toJSONString(), lookup),
.fromJson(text.toJSONString(), delegate.getRegistryManager()),
false
);
}

View File

@ -31,8 +31,6 @@
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
import de.bluecolored.bluemap.core.world.World;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.registry.BuiltinRegistries;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.math.Vec3d;
@ -40,8 +38,6 @@
public class FabricCommandSource implements CommandSource {
private static final RegistryWrapper.WrapperLookup lookup = BuiltinRegistries.createWrapperLookup();
private final FabricMod mod;
private final Plugin plugin;
private final ServerCommandSource delegate;
@ -56,7 +52,7 @@ public FabricCommandSource(FabricMod mod, Plugin plugin, ServerCommandSource del
public void sendMessage(Text text) {
delegate.sendFeedback(
() -> net.minecraft.text.Text.Serialization
.fromJson(text.toJSONString(), lookup),
.fromJson(text.toJSONString(), delegate.getRegistryManager()),
false
);
}

View File

@ -31,16 +31,12 @@
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
import de.bluecolored.bluemap.core.world.World;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.registries.VanillaRegistries;
import net.minecraft.network.chat.Component;
import java.util.Optional;
public class ForgeCommandSource implements CommandSource {
private static final HolderLookup.Provider lookup = VanillaRegistries.createLookup();
private final ForgeMod mod;
private final Plugin plugin;
private final CommandSourceStack delegate;
@ -53,7 +49,7 @@ public ForgeCommandSource(ForgeMod mod, Plugin plugin, CommandSourceStack delega
@Override
public void sendMessage(Text text) {
var component = Component.Serializer.fromJsonLenient(text.toJSONString(), lookup);
var component = Component.Serializer.fromJsonLenient(text.toJSONString(), delegate.registryAccess());
if (component != null)
delegate.sendSuccess(() -> component, false);
}

View File

@ -31,16 +31,12 @@
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
import de.bluecolored.bluemap.core.world.World;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.registries.VanillaRegistries;
import net.minecraft.network.chat.Component;
import java.util.Optional;
public class ForgeCommandSource implements CommandSource {
private static final HolderLookup.Provider lookup = VanillaRegistries.createLookup();
private final ForgeMod mod;
private final Plugin plugin;
private final CommandSourceStack delegate;
@ -53,7 +49,7 @@ public ForgeCommandSource(ForgeMod mod, Plugin plugin, CommandSourceStack delega
@Override
public void sendMessage(Text text) {
var component = Component.Serializer.fromJsonLenient(text.toJSONString(), lookup);
var component = Component.Serializer.fromJsonLenient(text.toJSONString(), delegate.registryAccess());
if (component != null)
delegate.sendSuccess(() -> component, false);
}

View File

@ -31,16 +31,12 @@
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
import de.bluecolored.bluemap.core.world.World;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.registries.VanillaRegistries;
import net.minecraft.network.chat.Component;
import java.util.Optional;
public class ForgeCommandSource implements CommandSource {
private static final HolderLookup.Provider lookup = VanillaRegistries.createLookup();
private final ForgeMod mod;
private final Plugin plugin;
private final CommandSourceStack delegate;
@ -53,7 +49,7 @@ public ForgeCommandSource(ForgeMod mod, Plugin plugin, CommandSourceStack delega
@Override
public void sendMessage(Text text) {
var component = Component.Serializer.fromJsonLenient(text.toJSONString(), lookup);
var component = Component.Serializer.fromJsonLenient(text.toJSONString(), delegate.registryAccess());
if (component != null)
delegate.sendSuccess(() -> component, false);
}