mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 02:26:00 +01:00
Use the delegates registry-access instead of creating our own
This commit is contained in:
parent
4ebceb8801
commit
eed8f79e68
@ -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
|
||||
);
|
||||
}
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user