Skip to content

Commit

Permalink
Use the delegates registry-access instead of creating our own
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Jul 22, 2024
1 parent 4ebceb8 commit eed8f79
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@
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;

import java.util.Optional;

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;
Expand All @@ -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
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@
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;

import java.util.Optional;

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;
Expand All @@ -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
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit eed8f79

Please sign in to comment.