Port WorldHandler to Minecraft 1.21.1
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -130,3 +130,8 @@ bin/
|
||||
|
||||
### Changelog ###
|
||||
changelog.txt
|
||||
|
||||
### Local Codex build runtime ###
|
||||
.codex-jdk/
|
||||
.gradle-home/
|
||||
temurin-jdk21.zip
|
||||
|
||||
@@ -8,7 +8,7 @@ plugins {
|
||||
archivesBaseName = "${mod_name}-${minecraft_version}"
|
||||
version = mod_version
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
|
||||
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + ' (' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# WorldHandler
|
||||
mod_id = worldhandler
|
||||
mod_name = WorldHandler
|
||||
mod_version = 3.5.1
|
||||
minecraft_version = 1.20.4
|
||||
mod_version = 3.5.2
|
||||
minecraft_version = 1.21.1
|
||||
group = exopandora.worldhandler
|
||||
main_class = exopandora.worldhandler.Main
|
||||
author = Exopandora
|
||||
|
||||
# Forge
|
||||
forge_version = 49.0.3
|
||||
forge_compatible_minecraft_versions = 1.20.3,1.20.4
|
||||
forge_version = 52.1.14
|
||||
forge_compatible_minecraft_versions = 1.21.1
|
||||
|
||||
# Publishing
|
||||
curse_project_id = 228970
|
||||
|
||||
@@ -15,7 +15,7 @@ import exopandora.worldhandler.builder.argument.PrimitiveArgument.Operation;
|
||||
import exopandora.worldhandler.builder.argument.PrimitiveArgument.Relation;
|
||||
import exopandora.worldhandler.builder.argument.PrimitiveArgument.Type;
|
||||
import exopandora.worldhandler.util.EnumHelper;
|
||||
import net.minecraft.Util;
|
||||
import exopandora.worldhandler.util.RegistryHelper;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.commands.ParserUtils;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument.Anchor;
|
||||
@@ -160,7 +160,7 @@ public class Arguments
|
||||
|
||||
public static PrimitiveArgument<ResourceLocation> resourceLocation()
|
||||
{
|
||||
return PrimitiveArgument.builder(string -> string.isEmpty() ? null : new ResourceLocation(string)).build();
|
||||
return PrimitiveArgument.<ResourceLocation>builder(string -> string.isEmpty() ? null : ResourceLocation.parse(string)).build();
|
||||
}
|
||||
|
||||
public static ItemArgument item()
|
||||
@@ -292,13 +292,13 @@ public class Arguments
|
||||
{
|
||||
try
|
||||
{
|
||||
return Component.Serializer.fromJson(string);
|
||||
return Component.Serializer.fromJson(string, RegistryHelper.registryAccess());
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return Component.literal(string);
|
||||
}
|
||||
}).serializer(Component.Serializer::toJson).build();
|
||||
}).serializer(component -> Component.Serializer.toJson(component, RegistryHelper.registryAccess())).build();
|
||||
}
|
||||
|
||||
public static PrimitiveArgument<PrimitiveArgument.Relation> relation()
|
||||
@@ -355,14 +355,14 @@ public class Arguments
|
||||
{
|
||||
try
|
||||
{
|
||||
return ParserUtils.parseJson(new StringReader(string), Style.Serializer.CODEC);
|
||||
return ParserUtils.parseJson(RegistryHelper.registryAccess(), new StringReader(string), Style.Serializer.CODEC);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.serializer(style -> GSON.toJson(Util.getOrThrow(Style.Serializer.CODEC.encodeStart(JsonOps.INSTANCE, style), JsonParseException::new)))
|
||||
.serializer(style -> GSON.toJson(Style.Serializer.CODEC.encodeStart(JsonOps.INSTANCE, style).getOrThrow(JsonParseException::new)))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package exopandora.worldhandler.builder.argument;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.util.RegistryHelper;
|
||||
import exopandora.worldhandler.util.ResourceHelper;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class EnchantmentArgument implements IDeserializableArgument
|
||||
{
|
||||
@@ -25,7 +25,7 @@ public class EnchantmentArgument implements IDeserializableArgument
|
||||
{
|
||||
if(enchantment != null)
|
||||
{
|
||||
this.set(ForgeRegistries.ENCHANTMENTS.getValue(enchantment));
|
||||
this.set(RegistryHelper.getEnchantment(enchantment));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -54,7 +54,7 @@ public class EnchantmentArgument implements IDeserializableArgument
|
||||
return null;
|
||||
}
|
||||
|
||||
return ForgeRegistries.ENCHANTMENTS.getKey(this.enchantment).toString();
|
||||
return RegistryHelper.getEnchantmentKey(this.enchantment).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package exopandora.worldhandler.builder.argument.tag;
|
||||
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import exopandora.worldhandler.util.UserStylableComponent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
@@ -19,7 +20,7 @@ public class DisplayTag implements ITagProvider
|
||||
|
||||
if(this.name.getText() != null && !this.name.getText().isEmpty())
|
||||
{
|
||||
display.putString("Name", Component.Serializer.toJson(this.name));
|
||||
display.putString("Name", TextUtils.toJson(this.name));
|
||||
}
|
||||
|
||||
ListTag lore = new ListTag();
|
||||
@@ -28,7 +29,7 @@ public class DisplayTag implements ITagProvider
|
||||
{
|
||||
if(this.lore[x] != null && !this.lore[x].getString().isEmpty())
|
||||
{
|
||||
lore.add(StringTag.valueOf(Component.Serializer.toJson(this.lore[x])));
|
||||
lore.add(StringTag.valueOf(TextUtils.toJson(this.lore[x])));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.util.RegistryHelper;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class EnchantmentsTag implements ITagProvider
|
||||
{
|
||||
@@ -29,7 +29,7 @@ public class EnchantmentsTag implements ITagProvider
|
||||
{
|
||||
CompoundTag enchantment = new CompoundTag();
|
||||
|
||||
enchantment.putString("id", ForgeRegistries.ENCHANTMENTS.getKey(entry.getKey()).toString());
|
||||
enchantment.putString("id", RegistryHelper.getEnchantmentKey(entry.getKey()).toString());
|
||||
enchantment.putShort("lvl", entry.getValue());
|
||||
|
||||
enchantments.add(enchantment);
|
||||
|
||||
@@ -11,6 +11,7 @@ import javax.annotation.Nullable;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import exopandora.worldhandler.util.NBTHelper;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import exopandora.worldhandler.util.UserStylableComponent;
|
||||
import net.minecraft.nbt.ByteTag;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -405,7 +406,7 @@ public class EntityTag implements ITagProvider
|
||||
|
||||
if(this.customName.getText() != null && !this.customName.getText().isEmpty())
|
||||
{
|
||||
NBTHelper.append(nbt, "CustomName", StringTag.valueOf(Component.Serializer.toJson(this.customName)));
|
||||
NBTHelper.append(nbt, "CustomName", StringTag.valueOf(TextUtils.toJson(this.customName)));
|
||||
}
|
||||
|
||||
NBTHelper.append(nbt, this.potion);
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Arrays;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import exopandora.worldhandler.util.UserStylableComponent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
@@ -36,7 +37,7 @@ public class SidedSignTextTag implements ITagProvider
|
||||
|
||||
for(UserStylableComponent text : this.lines)
|
||||
{
|
||||
messages.add(StringTag.valueOf(Component.Serializer.toJson(text)));
|
||||
messages.add(StringTag.valueOf(TextUtils.toJson(text)));
|
||||
}
|
||||
|
||||
CompoundTag tag = new CompoundTag();
|
||||
|
||||
@@ -41,7 +41,8 @@ public class ClientEventHandler
|
||||
|
||||
if(aabb.getCenter().distanceTo(projected) < 96)
|
||||
{
|
||||
PoseStack matrix = event.getPoseStack();
|
||||
PoseStack matrix = new PoseStack();
|
||||
matrix.mulPose(event.getPoseStack());
|
||||
matrix.pushPose();
|
||||
matrix.translate(-projected.x(), -projected.y(), -projected.z());
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class Categories
|
||||
|
||||
public static Category getRegisteredCategory(String name)
|
||||
{
|
||||
Category category = Category.REGISTRY.getValue(new ResourceLocation(Main.MODID, name));
|
||||
Category category = Category.REGISTRY.getValue(ResourceLocation.fromNamespaceAndPath(Main.MODID, name));
|
||||
|
||||
if(category == null)
|
||||
{
|
||||
@@ -27,6 +27,6 @@ public class Categories
|
||||
|
||||
public static boolean isRegistered(String name)
|
||||
{
|
||||
return Category.REGISTRY.containsKey(new ResourceLocation(Main.MODID, name));
|
||||
return Category.REGISTRY.containsKey(ResourceLocation.fromNamespaceAndPath(Main.MODID, name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraftforge.registries.RegistryBuilder;
|
||||
public class Category
|
||||
{
|
||||
public static IForgeRegistry<Category> REGISTRY;
|
||||
public static final ResourceKey<Registry<Category>> REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(Main.MODID, "category"));
|
||||
public static final ResourceKey<Registry<Category>> REGISTRY_KEY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(Main.MODID, "category"));
|
||||
public static final Map<String, List<String>> DEFAULT_CATEGORIES = new CategoriesBuilder()
|
||||
.add("main", "main", "containers", "multiplayer")
|
||||
.add("entities", "summon", "butcher")
|
||||
@@ -65,7 +65,7 @@ public class Category
|
||||
|
||||
public Category add(int index, String key)
|
||||
{
|
||||
return this.add(index, new ResourceLocation(Main.MODID, key));
|
||||
return this.add(index, ResourceLocation.fromNamespaceAndPath(Main.MODID, key));
|
||||
}
|
||||
|
||||
public List<ResourceLocation> getContents()
|
||||
@@ -103,7 +103,7 @@ public class Category
|
||||
RegistryHelper.register(event, REGISTRY_KEY, entry.getKey(), () ->
|
||||
{
|
||||
var keys = entry.getValue().stream()
|
||||
.map(key -> new ResourceLocation(Main.MODID, key))
|
||||
.map(key -> ResourceLocation.fromNamespaceAndPath(Main.MODID, key))
|
||||
.collect(Collectors.toList());
|
||||
return new Category(keys);
|
||||
});
|
||||
@@ -125,7 +125,7 @@ public class Category
|
||||
{
|
||||
if(!Categories.isRegistered(tab.getCategory()))
|
||||
{
|
||||
RegistryHelper.register(event, REGISTRY_KEY, tab.getCategory(), () -> new Category(new ResourceLocation(Main.MODID, id)));
|
||||
RegistryHelper.register(event, REGISTRY_KEY, tab.getCategory(), () -> new Category(ResourceLocation.fromNamespaceAndPath(Main.MODID, id)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ public class GuiWorldHandler extends Container
|
||||
widgets.add(new WidgetCommandSyntax());
|
||||
widgets.add(new WidgetShortcuts());
|
||||
});
|
||||
private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation("textures/gui/demo_background.png");
|
||||
private static final ResourceLocation BACKGROUND_TEXTURE = ResourceLocation.parse("textures/gui/demo_background.png");
|
||||
|
||||
private final Content content;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ import net.minecraftforge.registries.RegistryBuilder;
|
||||
public abstract class Content implements IContent
|
||||
{
|
||||
public static IForgeRegistry<Content> REGISTRY;
|
||||
public static final ResourceKey<Registry<Content>> REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(Main.MODID, "content"));
|
||||
public static final ResourceKey<Registry<Content>> REGISTRY_KEY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(Main.MODID, "content"));
|
||||
|
||||
@SubscribeEvent
|
||||
public static void createRegistry(NewRegistryEvent event)
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Contents
|
||||
|
||||
public static Content getRegisteredContent(String name)
|
||||
{
|
||||
Content content = Content.REGISTRY.getValue(new ResourceLocation(Main.MODID, name));
|
||||
Content content = Content.REGISTRY.getValue(ResourceLocation.fromNamespaceAndPath(Main.MODID, name));
|
||||
|
||||
if(content == null)
|
||||
{
|
||||
@@ -58,6 +58,6 @@ public class Contents
|
||||
|
||||
public static boolean isRegistered(String name)
|
||||
{
|
||||
return Content.REGISTRY.containsKey(new ResourceLocation(Main.MODID, name));
|
||||
return Content.REGISTRY.containsKey(ResourceLocation.fromNamespaceAndPath(Main.MODID, name));
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,13 @@ import exopandora.worldhandler.util.IConnection.DedicatedConnection;
|
||||
import exopandora.worldhandler.util.IConnection.IntegratedConnection;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.ConnectScreen;
|
||||
import net.minecraft.client.gui.screens.GenericDirtMessageScreen;
|
||||
import net.minecraft.client.gui.screens.GenericMessageScreen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
|
||||
import net.minecraft.client.gui.screens.multiplayer.SafetyScreen;
|
||||
import net.minecraft.client.gui.screens.worldselection.SelectWorldScreen;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.multiplayer.TransferState;
|
||||
import net.minecraft.client.multiplayer.resolver.ServerAddress;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
@@ -62,7 +63,7 @@ public class ContentChangeWorld extends ContentChild
|
||||
if(isIntegrated)
|
||||
{
|
||||
String folder = minecraft.getSingleplayerServer().storageSource.getLevelId();
|
||||
minecraft.disconnect(new GenericDirtMessageScreen(Component.translatable("menu.savingLevel")));
|
||||
minecraft.disconnect(new GenericMessageScreen(Component.translatable("menu.savingLevel")));
|
||||
return new IntegratedConnection(folder);
|
||||
}
|
||||
else
|
||||
@@ -86,7 +87,7 @@ public class ContentChangeWorld extends ContentChild
|
||||
}
|
||||
else if(connection instanceof IntegratedConnection integrated)
|
||||
{
|
||||
Minecraft.getInstance().createWorldOpenFlows().checkForBackupAndLoad(integrated.getFolder(), () ->
|
||||
Minecraft.getInstance().createWorldOpenFlows().openWorld(integrated.getFolder(), () ->
|
||||
{
|
||||
Minecraft.getInstance().setScreen(new TitleScreen());
|
||||
});
|
||||
@@ -95,7 +96,7 @@ public class ContentChangeWorld extends ContentChild
|
||||
else if(connection instanceof DedicatedConnection dedicated)
|
||||
{
|
||||
ServerData data = dedicated.getData();
|
||||
ConnectScreen.startConnecting(new TitleScreen(), Minecraft.getInstance(), ServerAddress.parseString(data.ip), data, false);
|
||||
ConnectScreen.startConnecting(new TitleScreen(), Minecraft.getInstance(), ServerAddress.parseString(data.ip), data, false, (TransferState) null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,14 +24,15 @@ import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuColorField;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.RegistryHelper;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ContentCustomItem extends Content
|
||||
{
|
||||
@@ -131,18 +132,18 @@ public class ContentCustomItem extends Content
|
||||
}
|
||||
else if(Page.ENCHANT.equals(this.page))
|
||||
{
|
||||
MenuPageList<Enchantment> enchantments = new MenuPageList<Enchantment>(x + 118, y, new ArrayList<Enchantment>(ForgeRegistries.ENCHANTMENTS.getValues()), 114, 20, 3, container, new ILogicPageList<Enchantment>()
|
||||
MenuPageList<Enchantment> enchantments = new MenuPageList<Enchantment>(x + 118, y, new ArrayList<Enchantment>(RegistryHelper.enchantmentValues()), 114, 20, 3, container, new ILogicPageList<Enchantment>()
|
||||
{
|
||||
@Override
|
||||
public MutableComponent translate(Enchantment item)
|
||||
{
|
||||
return Component.translatable(item.getDescriptionId());
|
||||
return RegistryHelper.getEnchantmentDescription(item).copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Enchantment item)
|
||||
{
|
||||
return Component.literal(ForgeRegistries.ENCHANTMENTS.getKey(item).toString());
|
||||
return Component.literal(RegistryHelper.getEnchantmentKey(item).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,7 +155,7 @@ public class ContentCustomItem extends Content
|
||||
@Override
|
||||
public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, Enchantment item, ActionHandler actionHandler)
|
||||
{
|
||||
return new GuiSlider(x, y, width, height, 0, Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderSimple(ForgeRegistries.ENCHANTMENTS.getKey(item).toString(), text, value ->
|
||||
return new GuiSlider(x, y, width, height, 0, Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderSimple(RegistryHelper.getEnchantmentKey(item).toString(), text, value ->
|
||||
{
|
||||
ContentCustomItem.this.enchantments.set(item, value.shortValue());
|
||||
}));
|
||||
|
||||
@@ -14,13 +14,13 @@ import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.RegistryHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
|
||||
public class ContentEnchantment extends Content
|
||||
{
|
||||
@@ -36,18 +36,18 @@ public class ContentEnchantment extends Content
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
MenuPageList<Enchantment> enchantments = new MenuPageList<Enchantment>(x, y, new ArrayList<Enchantment>(ForgeRegistries.ENCHANTMENTS.getValues()), 114, 20, 3, container, new ILogicPageList<Enchantment>()
|
||||
MenuPageList<Enchantment> enchantments = new MenuPageList<Enchantment>(x, y, new ArrayList<Enchantment>(RegistryHelper.enchantmentValues()), 114, 20, 3, container, new ILogicPageList<Enchantment>()
|
||||
{
|
||||
@Override
|
||||
public MutableComponent translate(Enchantment enchantment)
|
||||
{
|
||||
return Component.translatable(enchantment.getDescriptionId());
|
||||
return RegistryHelper.getEnchantmentDescription(enchantment).copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableComponent toTooltip(Enchantment enchantment)
|
||||
{
|
||||
return Component.literal(ForgeRegistries.ENCHANTMENTS.getKey(enchantment).toString());
|
||||
return Component.literal(RegistryHelper.getEnchantmentKey(enchantment).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ContentLocate extends Content
|
||||
.thenAccept(structures -> this.structures.set(structures.getList().stream()
|
||||
.map(Suggestion::getText)
|
||||
.filter(suggestion -> !suggestion.startsWith("#"))
|
||||
.map(ResourceLocation::new)
|
||||
.map(ResourceLocation::parse)
|
||||
.collect(Collectors.toList())))
|
||||
.thenRun(container::init);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
|
||||
|
||||
public class ContentNoteEditor extends Content
|
||||
{
|
||||
private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png");
|
||||
private static final ResourceLocation NOTE = ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/misc/note.png");
|
||||
|
||||
private final SetBlockCommandBuilder builderNoteEditor = new SetBlockCommandBuilder();
|
||||
private final CommandPreview preview = new CommandPreview(this.builderNoteEditor, SetBlockCommandBuilder.Label.REPLACE);
|
||||
|
||||
@@ -61,7 +61,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ContentSummon extends Content
|
||||
{
|
||||
private static final ResourceLocation BEACON_LOCATION = new ResourceLocation("textures/gui/container/beacon.png");
|
||||
private static final ResourceLocation BEACON_LOCATION = ResourceLocation.parse("textures/gui/container/beacon.png");
|
||||
private static final Item[] HELMETS =
|
||||
{
|
||||
Items.AIR,
|
||||
|
||||
@@ -39,13 +39,13 @@ public class ContentWorldInfo extends Content
|
||||
IntegratedServer server = Minecraft.getInstance().getSingleplayerServer();
|
||||
|
||||
this.posXField = new GuiHintTextField(x + 118, y + 12, 114, 20);
|
||||
this.posXField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " X: " + ContentWorldInfo.format(level, object -> object.getLevelData().getXSpawn()));
|
||||
this.posXField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " X: " + ContentWorldInfo.format(level, object -> object.getLevelData().getSpawnPos().getX()));
|
||||
|
||||
this.posYField = new GuiHintTextField(x + 118, y + 36, 114, 20);
|
||||
this.posYField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " Y: " + ContentWorldInfo.format(level, object -> object.getLevelData().getYSpawn()));
|
||||
this.posYField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " Y: " + ContentWorldInfo.format(level, object -> object.getLevelData().getSpawnPos().getY()));
|
||||
|
||||
this.posZField = new GuiHintTextField(x + 118, y + 60, 114, 20);
|
||||
this.posZField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " Z: " + ContentWorldInfo.format(level, object -> object.getLevelData().getZSpawn()));
|
||||
this.posZField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " Z: " + ContentWorldInfo.format(level, object -> object.getLevelData().getSpawnPos().getZ()));
|
||||
|
||||
this.worldField = new GuiHintTextField(x + 118, y + 12, 114, 20);
|
||||
this.worldField.setValue(I18n.get("gui.worldhandler.world_info.world.name") + ": " + ContentWorldInfo.format(server, object -> object.getWorldData().getLevelName()));
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.util.Mth;
|
||||
|
||||
public class WidgetTabRenderer implements IContainerWidget
|
||||
{
|
||||
private static final ResourceLocation TAB_TEXTURE = new ResourceLocation("textures/gui/demo_background.png");
|
||||
private static final ResourceLocation TAB_TEXTURE = ResourceLocation.parse("textures/gui/demo_background.png");
|
||||
private static final int SPACING = 2;
|
||||
private static final int WEDGE_HEIGHT = 10;
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ public class GuiButtonBase extends AbstractButton
|
||||
{
|
||||
protected static final WidgetSprites VANILLA_BUTTON_SPRITES = new WidgetSprites
|
||||
(
|
||||
new ResourceLocation(Main.MODID, "textures/skins/vanilla/button.png"),
|
||||
new ResourceLocation(Main.MODID, "textures/skins/vanilla/button_disabled.png"),
|
||||
new ResourceLocation(Main.MODID, "textures/skins/vanilla/button_highlighted.png")
|
||||
ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/skins/vanilla/button.png"),
|
||||
ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/skins/vanilla/button_disabled.png"),
|
||||
ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/skins/vanilla/button_highlighted.png")
|
||||
);
|
||||
|
||||
private final ActionHandler actionHandler;
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.sounds.SoundEvent;
|
||||
|
||||
public class GuiButtonPiano extends GuiButtonBase
|
||||
{
|
||||
private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png");
|
||||
private static final ResourceLocation NOTE = ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/misc/note.png");
|
||||
private final Type type;
|
||||
private final SoundEvent sound;
|
||||
private final float pitch;
|
||||
|
||||
@@ -17,9 +17,9 @@ import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class GuiSlider extends GuiButtonBase
|
||||
{
|
||||
private static final ResourceLocation SLIDER_SPRITE = new ResourceLocation("widget/slider");
|
||||
private static final ResourceLocation SLIDER_HANDLE_SPRITE = new ResourceLocation("widget/slider_handle");
|
||||
private static final ResourceLocation SLIDER_HANDLE_HIGHLIGHTED_SPRITE = new ResourceLocation("widget/slider_handle_highlighted");
|
||||
private static final ResourceLocation SLIDER_SPRITE = ResourceLocation.parse("widget/slider");
|
||||
private static final ResourceLocation SLIDER_HANDLE_SPRITE = ResourceLocation.parse("widget/slider_handle");
|
||||
private static final ResourceLocation SLIDER_HANDLE_HIGHLIGHTED_SPRITE = ResourceLocation.parse("widget/slider_handle_highlighted");
|
||||
private final Persistence persistence;
|
||||
private final ILogicSlider logic;
|
||||
private final Container container;
|
||||
|
||||
@@ -171,7 +171,7 @@ public class UsercontentLoader
|
||||
private static boolean isValidPathName(Path path)
|
||||
{
|
||||
String name = path.getFileName().toString();
|
||||
boolean valid = ResourceLocation.isValidResourceLocation(name);
|
||||
boolean valid = ResourceLocation.tryParse(name) != null;
|
||||
|
||||
if(!valid)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ public class WidgetFactory extends AbstractWidgetFactory
|
||||
widget.getLayout().getY() + y,
|
||||
widget.getLayout().getWidth(),
|
||||
widget.getLayout().getHeight(),
|
||||
ForgeRegistries.ITEMS.getValue(new ResourceLocation(widget.getAttributes().getItem())),
|
||||
ForgeRegistries.ITEMS.getValue(ResourceLocation.parse(widget.getAttributes().getItem())),
|
||||
this.getActionHandlerFactory().createActionHandler(content, widget.getAction(), container::getPlayer)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,13 +17,12 @@ import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.level.storage.loot.LootDataManager;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition.IContext;
|
||||
|
||||
public class AdvancementHelper implements PreparableReloadListener
|
||||
{
|
||||
private static final AdvancementHelper INSTANCE = new AdvancementHelper();
|
||||
private final ServerAdvancementManager manager = new ServerAdvancementManager(new LootDataManager(), IContext.EMPTY);
|
||||
private final ServerAdvancementManager manager = new ServerAdvancementManager(RegistryHelper.registryAccess(), IContext.EMPTY);
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> reload(PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor)
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BlockPredicateParser
|
||||
private static final ResourceLocation AIR_RESOURCE_LOCATION = ForgeRegistries.BLOCKS.getKey(Blocks.AIR);
|
||||
private final StringReader reader;
|
||||
private final Map<String, String> vagueProperties = Maps.newHashMap();
|
||||
private ResourceLocation block = new ResourceLocation("");
|
||||
private ResourceLocation block = null;
|
||||
@Nullable
|
||||
private CompoundTag nbt;
|
||||
private boolean isTag;
|
||||
|
||||
@@ -5,11 +5,13 @@ import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.commands.arguments.item.ItemParser;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.TagParser;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
@@ -17,8 +19,9 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class ItemPredicateParser
|
||||
{
|
||||
private static final SimpleCommandExceptionType ERROR_NO_TAGS_ALLOWED = new SimpleCommandExceptionType(Component.translatable("argument.item.tag.disallowed"));
|
||||
private final StringReader reader;
|
||||
private ResourceLocation item = new ResourceLocation("");
|
||||
private ResourceLocation item = null;
|
||||
@Nullable
|
||||
private CompoundTag nbt;
|
||||
private boolean isTag;
|
||||
@@ -39,7 +42,7 @@ public class ItemPredicateParser
|
||||
{
|
||||
if(!allowTags)
|
||||
{
|
||||
throw ItemParser.ERROR_NO_TAGS_ALLOWED.createWithContext(this.reader);
|
||||
throw ERROR_NO_TAGS_ALLOWED.createWithContext(this.reader);
|
||||
}
|
||||
|
||||
this.readTag();
|
||||
|
||||
@@ -1,17 +1,63 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
|
||||
public class RegistryHelper
|
||||
{
|
||||
public static <T> void register(RegisterEvent event, ResourceKey<Registry<T>> key, String location, Supplier<T> valueSupplier)
|
||||
{
|
||||
event.register(key, new ResourceLocation(Main.MODID, location), valueSupplier);
|
||||
event.register(key, RegistryHelper.location(location), valueSupplier);
|
||||
}
|
||||
|
||||
public static ResourceLocation location(String location)
|
||||
{
|
||||
return ResourceLocation.fromNamespaceAndPath(Main.MODID, location);
|
||||
}
|
||||
|
||||
public static RegistryAccess registryAccess()
|
||||
{
|
||||
if(Minecraft.getInstance().level != null)
|
||||
{
|
||||
return Minecraft.getInstance().level.registryAccess();
|
||||
}
|
||||
|
||||
return RegistryAccess.EMPTY;
|
||||
}
|
||||
|
||||
public static Registry<Enchantment> enchantments()
|
||||
{
|
||||
return RegistryHelper.registryAccess().registryOrThrow(Registries.ENCHANTMENT);
|
||||
}
|
||||
|
||||
public static Collection<Enchantment> enchantmentValues()
|
||||
{
|
||||
return RegistryHelper.enchantments().stream().toList();
|
||||
}
|
||||
|
||||
public static Enchantment getEnchantment(ResourceLocation location)
|
||||
{
|
||||
return RegistryHelper.enchantments().get(location);
|
||||
}
|
||||
|
||||
public static ResourceLocation getEnchantmentKey(Enchantment enchantment)
|
||||
{
|
||||
return RegistryHelper.enchantments().getKey(enchantment);
|
||||
}
|
||||
|
||||
public static Component getEnchantmentDescription(Enchantment enchantment)
|
||||
{
|
||||
return enchantment.description();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,6 @@ public class ResourceHelper
|
||||
|
||||
public static ResourceLocation iconTexture()
|
||||
{
|
||||
return new ResourceLocation(Main.MODID, "textures/icons/icons_" + Config.getSkin().getIconSize().name() + ".png");
|
||||
return ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/icons/icons_" + Config.getSkin().getIconSize().name() + ".png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@ public class TextUtils
|
||||
public static final MutableComponent ARROW_LEFT_BOLD = Component.literal("<").withStyle(ChatFormatting.BOLD);
|
||||
public static final MutableComponent ARROW_RIGHT_BOLD = Component.literal(">").withStyle(ChatFormatting.BOLD);
|
||||
|
||||
public static String toJson(Component component)
|
||||
{
|
||||
return Component.Serializer.toJson(component, RegistryHelper.registryAccess());
|
||||
}
|
||||
|
||||
public static MutableComponent stripText(MutableComponent string, int maxWidth, Font font)
|
||||
{
|
||||
return TextUtils.stripText(string, Component.empty(), maxWidth, font);
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
@@ -25,7 +24,6 @@ public class TranslationHelper
|
||||
registerRegistry(ForgeRegistries.ITEMS, Item::getDescriptionId);
|
||||
registerRegistry(ForgeRegistries.MOB_EFFECTS, MobEffect::getDescriptionId);
|
||||
registerRegistry(ForgeRegistries.BIOMES, biome -> ForgeRegistries.BIOMES.getKey(biome).toLanguageKey("biome"));
|
||||
registerRegistry(ForgeRegistries.ENCHANTMENTS, Enchantment::getDescriptionId);
|
||||
registerRegistry(ForgeRegistries.ENTITY_TYPES, EntityType::getDescriptionId);
|
||||
registerRegistry(ForgeRegistries.STAT_TYPES, stat -> "stat." + stat.toString().replace(':', '.'));
|
||||
registerRegistry(ForgeRegistries.VILLAGER_PROFESSIONS, profession ->
|
||||
@@ -44,6 +42,11 @@ public class TranslationHelper
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> String translate(ResourceLocation resource)
|
||||
{
|
||||
if(RegistryHelper.getEnchantment(resource) != null)
|
||||
{
|
||||
return RegistryHelper.getEnchantmentDescription(RegistryHelper.getEnchantment(resource)).getString();
|
||||
}
|
||||
|
||||
for(IForgeRegistry<?> registry : FORGE.keySet())
|
||||
{
|
||||
if(registry.containsKey(resource))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
modLoader="javafml"
|
||||
loaderVersion="[49,)"
|
||||
loaderVersion="[52,)"
|
||||
updateJSONURL="https://raw.githubusercontent.com/Exopandora/worldhandler/master/version.json"
|
||||
issueTrackerURL="https://github.com/Exopandora/WorldHandler/issues"
|
||||
displayURL="https://minecraft.curseforge.com/projects/world-handler-command-gui"
|
||||
@@ -11,13 +11,13 @@ license="GPL v3.0"
|
||||
|
||||
[[mods]]
|
||||
modId="worldhandler"
|
||||
version="1.20.4-${version}"
|
||||
version="1.21.1-${version}"
|
||||
displayName="World Handler"
|
||||
description="The World Handler provides a simple and easy to use graphical user interface for commands. It lets you create powerful and complex sub-commands alongside NBT-structures within seconds."
|
||||
|
||||
[[dependencies.worldhandler]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.20.3,)"
|
||||
versionRange="[1.21.1,1.21.2)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
Reference in New Issue
Block a user