diff --git a/build.gradle b/build.gradle index 196b86f..2eb9f85 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ repositories { } dependencies { - annotationProcessor fg.deobf("org.moddingx:LibX:1.19.2-4.2.5") + annotationProcessor fg.deobf("org.moddingx:LibX:1.19.3-4.3.0") - implementation fg.deobf("org.moddingx:LibX:1.19.2-4.2.5") + implementation fg.deobf("org.moddingx:LibX:1.19.3-4.3.0") } diff --git a/gradle.properties b/gradle.properties index 9e92d16..422c496 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.daemon=false modid=travelanchors group=de.castcrafter.travelanchors -base_version=4.1.2 +base_version=4.2.0 -forge_version=1.19.2-43.1.43 -mappings=sugarcane_2022.10.16-1.19.2 +forge_version=1.19.3-44.1.20 +mappings=sugarcane_2023.02.26-1.19.3 license_name=The Apache License, Version 2.0 license_url=https://www.apache.org/licenses/LICENSE-2.0.txt diff --git a/src/main/java/de/castcrafter/travelanchors/ModBlocks.java b/src/main/java/de/castcrafter/travelanchors/ModBlocks.java index 526f5f0..8624771 100644 --- a/src/main/java/de/castcrafter/travelanchors/ModBlocks.java +++ b/src/main/java/de/castcrafter/travelanchors/ModBlocks.java @@ -10,7 +10,7 @@ import org.moddingx.libx.base.tile.MenuBlockBE; import org.moddingx.libx.menu.BlockEntityMenu; -@RegisterClass(registry = "BLOCK_REGISTRY", priority = 1) +@RegisterClass(registry = "BLOCK", priority = 1) public class ModBlocks { public static final MenuBlockBE travelAnchor = new BlockTravelAnchor(TravelAnchors.getInstance(), TileTravelAnchor.class, BlockEntityMenu.createMenuType(MenuTravelAnchor::new), BlockBehaviour.Properties.of(Material.METAL).sound(SoundType.METAL).strength(2.0f)); diff --git a/src/main/java/de/castcrafter/travelanchors/ModEnchantments.java b/src/main/java/de/castcrafter/travelanchors/ModEnchantments.java index 7eb9547..0d8c49a 100644 --- a/src/main/java/de/castcrafter/travelanchors/ModEnchantments.java +++ b/src/main/java/de/castcrafter/travelanchors/ModEnchantments.java @@ -7,7 +7,7 @@ import org.moddingx.libx.annotation.registration.Reg.Exclude; import org.moddingx.libx.annotation.registration.RegisterClass; -@RegisterClass(registry = "ENCHANTMENT_REGISTRY") +@RegisterClass(registry = "ENCHANTMENT") public class ModEnchantments { @Exclude diff --git a/src/main/java/de/castcrafter/travelanchors/ModItems.java b/src/main/java/de/castcrafter/travelanchors/ModItems.java index fcfd967..4a4c685 100644 --- a/src/main/java/de/castcrafter/travelanchors/ModItems.java +++ b/src/main/java/de/castcrafter/travelanchors/ModItems.java @@ -5,7 +5,7 @@ import org.moddingx.libx.annotation.registration.RegisterClass; import org.moddingx.libx.base.ItemBase; -@RegisterClass(registry = "ITEM_REGISTRY") +@RegisterClass(registry = "ITEM") public class ModItems { public static final ItemBase travelStaff = new ItemTravelStaff(TravelAnchors.getInstance(), new Item.Properties().stacksTo(1)); diff --git a/src/main/java/de/castcrafter/travelanchors/Tab.java b/src/main/java/de/castcrafter/travelanchors/Tab.java new file mode 100644 index 0000000..18027a6 --- /dev/null +++ b/src/main/java/de/castcrafter/travelanchors/Tab.java @@ -0,0 +1,24 @@ +package de.castcrafter.travelanchors; + +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import org.moddingx.libx.creativetab.CreativeTabX; +import org.moddingx.libx.mod.ModX; + +public class Tab extends CreativeTabX { + + protected Tab(ModX mod) { + super(mod); + } + + @Override + protected void buildTab(CreativeModeTab.Builder builder) { + super.buildTab(builder); + builder.icon(() -> new ItemStack(ModItems.travelStaff)); + } + + @Override + protected void addItems(TabContext ctx) { + this.addModItems(ctx); + } +} diff --git a/src/main/java/de/castcrafter/travelanchors/TravelAnchors.java b/src/main/java/de/castcrafter/travelanchors/TravelAnchors.java index 44b02b3..bc96ff1 100644 --- a/src/main/java/de/castcrafter/travelanchors/TravelAnchors.java +++ b/src/main/java/de/castcrafter/travelanchors/TravelAnchors.java @@ -2,8 +2,6 @@ import de.castcrafter.travelanchors.network.Networking; import de.castcrafter.travelanchors.render.TravelAnchorRenderer; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.DistExecutor; @@ -24,18 +22,14 @@ public final class TravelAnchors extends ModXRegistration { private static TravelAnchors instance; private static Networking network; + private static Tab tab; public TravelAnchors() { - super(new CreativeModeTab("travelanchors") { - @Nonnull - @Override - public ItemStack makeIcon() { - return new ItemStack(ModItems.travelStaff); - } - }); + super(); instance = this; network = new Networking(this); + tab = new Tab(this); MinecraftForge.EVENT_BUS.register(new EventListener()); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> MinecraftForge.EVENT_BUS.addListener(TravelAnchorRenderer::renderAnchors)); @@ -51,9 +45,14 @@ public static Networking getNetwork() { return network; } + @Nonnull + public static Tab getTab() { + return tab; + } + @Override protected void initRegistration(RegistrationBuilder builder) { - builder.enableRegistryTracking(); + // } @Override diff --git a/src/main/java/de/castcrafter/travelanchors/block/BlockTravelAnchor.java b/src/main/java/de/castcrafter/travelanchors/block/BlockTravelAnchor.java index 392a784..22e1951 100644 --- a/src/main/java/de/castcrafter/travelanchors/block/BlockTravelAnchor.java +++ b/src/main/java/de/castcrafter/travelanchors/block/BlockTravelAnchor.java @@ -3,6 +3,7 @@ import de.castcrafter.travelanchors.ModBlocks; import de.castcrafter.travelanchors.TeleportHandler; import de.castcrafter.travelanchors.TravelAnchorList; +import net.minecraft.ChatFormatting; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.core.BlockPos; @@ -94,7 +95,7 @@ public VoxelShape getOcclusionShape(@Nonnull BlockState state, @Nonnull BlockGet @Override public void appendHoverText(@Nonnull ItemStack stack, @Nullable BlockGetter level, List tooltip, @Nonnull TooltipFlag flag) { - tooltip.add(Component.translatable("tooltip.travelanchors.travel_anchor_block")); + tooltip.add(Component.translatable("tooltip.travelanchors.travel_anchor_block").withStyle(ChatFormatting.GOLD)); } @Nonnull diff --git a/src/main/java/de/castcrafter/travelanchors/block/ScreenTravelAnchor.java b/src/main/java/de/castcrafter/travelanchors/block/ScreenTravelAnchor.java index 99c21d0..fdf36ea 100644 --- a/src/main/java/de/castcrafter/travelanchors/block/ScreenTravelAnchor.java +++ b/src/main/java/de/castcrafter/travelanchors/block/ScreenTravelAnchor.java @@ -30,16 +30,15 @@ public ScreenTravelAnchor(MenuTravelAnchor screenMenu, Inventory inv, Component @Override public void init() { super.init(); - this.getMinecraft().keyboardHandler.setSendRepeatsToGui(true); this.textFieldWidget = new EditBox(this.font, this.width / 2 - 72, this.height / 2 - 63, 100, 16, Component.translatable("screen.travelanchors.search")); this.textFieldWidget.setMaxLength(32767); this.textFieldWidget.changeFocus(true); this.textFieldWidget.setValue(this.menu.getBlockEntity().getName()); - this.addRenderableWidget(new Button(this.width / 2 + 33, this.height / 2 - 65, 44, 20, Component.translatable("travelanchors.lock.button"), btn -> { + this.addRenderableWidget(Button.builder(Component.translatable("travelanchors.lock.button"), btn -> { TravelAnchors.getNetwork().sendLock(this.menu.getLevel(), this.menu.getPos()); this.onClose(); - })); + }).bounds(this.width / 2 + 33, this.height / 2 - 65, 44, 20).build()); } @Override @@ -74,7 +73,6 @@ public GuiEventListener getFocused() { @Override public void removed() { super.removed(); - this.getMinecraft().keyboardHandler.setSendRepeatsToGui(false); if (Minecraft.getInstance().level != null) { TravelAnchors.getNetwork().sendNameChange(this.menu.getLevel(), this.menu.getPos(), this.textFieldWidget.getValue().trim()); } diff --git a/src/main/java/de/castcrafter/travelanchors/block/TileTravelAnchor.java b/src/main/java/de/castcrafter/travelanchors/block/TileTravelAnchor.java index 184d3f7..594198e 100644 --- a/src/main/java/de/castcrafter/travelanchors/block/TileTravelAnchor.java +++ b/src/main/java/de/castcrafter/travelanchors/block/TileTravelAnchor.java @@ -3,6 +3,7 @@ import de.castcrafter.travelanchors.ModBlocks; import de.castcrafter.travelanchors.TravelAnchorList; import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -62,8 +63,8 @@ private void writeMimic(CompoundTag tag) { } private void readMimic(CompoundTag tag) { - if (tag.contains("mimic")) { - BlockState state = NbtUtils.readBlockState(tag.getCompound("mimic")); + if (tag.contains("mimic") && this.level != null) { + BlockState state = NbtUtils.readBlockState(this.level.registryAccess().lookupOrThrow(Registries.BLOCK), tag.getCompound("mimic")); if (state == ModBlocks.travelAnchor.defaultBlockState()) { this.mimic = null; } else { diff --git a/src/main/java/de/castcrafter/travelanchors/data/BlockLootProvider.java b/src/main/java/de/castcrafter/travelanchors/data/BlockLootProvider.java index a64e381..d2f18c7 100644 --- a/src/main/java/de/castcrafter/travelanchors/data/BlockLootProvider.java +++ b/src/main/java/de/castcrafter/travelanchors/data/BlockLootProvider.java @@ -1,6 +1,6 @@ package de.castcrafter.travelanchors.data; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import org.moddingx.libx.annotation.data.Datagen; import org.moddingx.libx.datagen.provider.loot.BlockLootProviderBase; import org.moddingx.libx.mod.ModX; @@ -8,8 +8,8 @@ @Datagen public class BlockLootProvider extends BlockLootProviderBase { - public BlockLootProvider(ModX mod, DataGenerator generator) { - super(mod, generator); + public BlockLootProvider(ModX mod, PackOutput output) { + super(mod, output); } @Override diff --git a/src/main/java/de/castcrafter/travelanchors/data/BlockStatesProvider.java b/src/main/java/de/castcrafter/travelanchors/data/BlockStatesProvider.java index 09df26d..dc65e81 100644 --- a/src/main/java/de/castcrafter/travelanchors/data/BlockStatesProvider.java +++ b/src/main/java/de/castcrafter/travelanchors/data/BlockStatesProvider.java @@ -1,7 +1,7 @@ package de.castcrafter.travelanchors.data; import de.castcrafter.travelanchors.ModBlocks; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraftforge.common.data.ExistingFileHelper; import org.moddingx.libx.annotation.data.Datagen; import org.moddingx.libx.datagen.provider.BlockStateProviderBase; @@ -10,8 +10,8 @@ @Datagen public class BlockStatesProvider extends BlockStateProviderBase { - public BlockStatesProvider(ModX mod, DataGenerator generator, ExistingFileHelper fileHelper) { - super(mod, generator, fileHelper); + public BlockStatesProvider(ModX mod, PackOutput output, ExistingFileHelper fileHelper) { + super(mod, output, fileHelper); } @Override diff --git a/src/main/java/de/castcrafter/travelanchors/data/ItemModelsProvider.java b/src/main/java/de/castcrafter/travelanchors/data/ItemModelsProvider.java index f636cdb..5833d19 100644 --- a/src/main/java/de/castcrafter/travelanchors/data/ItemModelsProvider.java +++ b/src/main/java/de/castcrafter/travelanchors/data/ItemModelsProvider.java @@ -1,6 +1,6 @@ package de.castcrafter.travelanchors.data; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraftforge.common.data.ExistingFileHelper; import org.moddingx.libx.annotation.data.Datagen; import org.moddingx.libx.datagen.provider.ItemModelProviderBase; @@ -9,8 +9,8 @@ @Datagen public class ItemModelsProvider extends ItemModelProviderBase { - public ItemModelsProvider(ModX mod, DataGenerator generator, ExistingFileHelper fileHelper) { - super(mod, generator, fileHelper); + public ItemModelsProvider(ModX mod, PackOutput output, ExistingFileHelper fileHelper) { + super(mod, output, fileHelper); } @Override diff --git a/src/main/java/de/castcrafter/travelanchors/data/RecipesProvider.java b/src/main/java/de/castcrafter/travelanchors/data/RecipesProvider.java index df7dbb4..ca0d5e3 100644 --- a/src/main/java/de/castcrafter/travelanchors/data/RecipesProvider.java +++ b/src/main/java/de/castcrafter/travelanchors/data/RecipesProvider.java @@ -2,7 +2,7 @@ import de.castcrafter.travelanchors.ModBlocks; import de.castcrafter.travelanchors.ModItems; -import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraftforge.common.Tags; import org.moddingx.libx.annotation.data.Datagen; import org.moddingx.libx.datagen.provider.recipe.RecipeProviderBase; @@ -12,8 +12,8 @@ @Datagen public class RecipesProvider extends RecipeProviderBase implements CraftingExtension { - public RecipesProvider(ModX mod, DataGenerator generator) { - super(mod, generator); + public RecipesProvider(ModX mod, PackOutput output) { + super(mod, output); } @Override diff --git a/src/main/java/de/castcrafter/travelanchors/render/TravelAnchorRenderer.java b/src/main/java/de/castcrafter/travelanchors/render/TravelAnchorRenderer.java index 241d5c1..5242ec7 100644 --- a/src/main/java/de/castcrafter/travelanchors/render/TravelAnchorRenderer.java +++ b/src/main/java/de/castcrafter/travelanchors/render/TravelAnchorRenderer.java @@ -4,8 +4,8 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; +import org.joml.Matrix4f; import de.castcrafter.travelanchors.ModBlocks; import de.castcrafter.travelanchors.TeleportHandler; import de.castcrafter.travelanchors.TravelAnchorList; @@ -227,15 +227,15 @@ private record CircleRotation(float y, float z) { public void apply(PoseStack poseStack) { if (!Float.isNaN(this.y)) { - poseStack.mulPose(Vector3f.YP.rotation(this.y)); + poseStack.mulPose(Axis.YP.rotation(this.y)); } - poseStack.mulPose(Vector3f.ZP.rotation(this.z)); + poseStack.mulPose(Axis.ZP.rotation(this.z)); } public void reverse(PoseStack poseStack) { - poseStack.mulPose(Vector3f.ZP.rotation(-this.z)); + poseStack.mulPose(Axis.ZP.rotation(-this.z)); if (!Float.isNaN(this.y)) { - poseStack.mulPose(Vector3f.YP.rotation(-this.y)); + poseStack.mulPose(Axis.YP.rotation(-this.y)); } } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 944a17d..c34f9cd 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[43,)" +loaderVersion="[44,)" license="Apache License 2.0" [[mods]] @@ -17,20 +17,20 @@ Adds a staff of travelling and a travel anchor to teleport around the world. [[dependencies.travelanchors]] modId="forge" mandatory=true - versionRange="[43.1.43,)" + versionRange="[44.1.20,)" ordering="NONE" side="BOTH" [[dependencies.travelanchors]] modId="minecraft" mandatory=true - versionRange="[1.19.2,1.20)" + versionRange="[1.19.3,)" ordering="NONE" side="BOTH" [[dependencies.travelanchors]] modId="libx" mandatory=true - versionRange="[1.19.2-4.2.5,)" + versionRange="[1.19.3-4.3.0,)" ordering="NONE" side="BOTH" diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index 449a0d2..6bd63b9 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { "description": "TravelAnchors resources", - "pack_format": 10, + "pack_format": 12, "forge:data_pack_format": 10, - "forge:resource_pack_format": 9 + "forge:resource_pack_format": 12 } }