Skip to content

Commit

Permalink
Update to NeoForge 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
MattCzyr committed Jun 21, 2024
1 parent 605df75 commit 66fb462
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 78 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
## Version 3.0.2
#### NeoForge 1.20.6
#### NeoForge 1.21, 1.20.6
- Updated to NeoForge 1.21
- Fixed uncraftable Nature's Compass recipe

# Version 2.2.5
#### Fabric 1.20.6
#### Fabric 1.21, 1.20.6
- Updated to Fabric 1.21
- Fixed uncraftable Nature's Compass recipe

## Version 1.11.6
#### Forge 1.20.6
#### Forge 1.21, 1.20.6
- Updated to Forge 1.21
- Fixed uncraftable Nature's Compass recipe

## Version 3.0.1
Expand Down
11 changes: 10 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.109'
id 'net.neoforged.gradle.userdev' version '7.0.142'
}

tasks.named('wrapper', Wrapper).configure {
// Define wrapper values here so as to not have to always do so when updating gradlew.properties.
// Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
// documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
// file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
// (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
distributionType = Wrapper.DistributionType.BIN
}

version = mod_version
Expand Down
20 changes: 9 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
#org.gradle.jvmargs=
org.gradle.jvmargs=-Xmx1G
org.gradle.daemon=false
org.gradle.debug=false

#read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
neogradle.subsystems.parchment.minecraftVersion=1.20.4
neogradle.subsystems.parchment.mappingsVersion=2024.04.14
neogradle.subsystems.parchment.minecraftVersion=1.20.6
neogradle.subsystems.parchment.mappingsVersion=2024.05.01
# Environment Properties
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
# The Minecraft version must agree with the Neo version to get a valid artifact
minecraft_version=1.20.6
minecraft_version=1.21
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.6,1.21)
minecraft_version_range=[1.21,1.21.1)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=20.6.42-beta
neo_version=21.0.0-beta
# The Neo version range can use any version of Neo as bounds
neo_version_range=[20.6,)
neo_version_range=[21.0.0-beta,)
# The loader version range can only use the major version of FML as bounds
loader_version_range=[2,)
loader_version_range=[4,)

## Mod Properties

Expand All @@ -32,7 +32,7 @@ mod_name=Nature's Compass
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=CC BY-NC-SA 4.0
# The mod version. See https://semver.org/
mod_version=1.20.6-3.0.2-neoforge
mod_version=1.21-3.0.2-neoforge
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand All @@ -41,5 +41,3 @@ mod_group_id=com.chaosthedude.naturescompass
mod_authors=ChaosTheDude
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Search for a biome and get information about it.
# Pack version - this changes each minecraft release, in general.
pack_format_number=18
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
Expand Down Expand Up @@ -60,15 +59,15 @@ public class NaturesCompass {

public static NaturesCompass instance;

public NaturesCompass(IEventBus bus, Dist dist) {
public NaturesCompass(ModContainer modContainer) {
instance = this;

bus.addListener(this::preInit);
bus.addListener(this::buildCreativeTabContents);
bus.addListener(this::registerPayloads);
modContainer.getEventBus().addListener(this::preInit);
modContainer.getEventBus().addListener(this::buildCreativeTabContents);
modContainer.getEventBus().addListener(this::registerPayloads);

ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ConfigHandler.GENERAL_SPEC);
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ConfigHandler.CLIENT_SPEC);
modContainer.registerConfig(ModConfig.Type.COMMON, ConfigHandler.GENERAL_SPEC);
modContainer.registerConfig(ModConfig.Type.CLIENT, ConfigHandler.CLIENT_SPEC);

NeoForge.EVENT_BUS.register(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class NaturesCompassClient {
@SubscribeEvent
public static void clientInit(FMLClientSetupEvent event) {
event.enqueueWork(() -> {
ItemProperties.register(NaturesCompass.naturesCompass, new ResourceLocation("angle"), new ClampedItemPropertyFunction() {
ItemProperties.register(NaturesCompass.naturesCompass, ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "angle"), new ClampedItemPropertyFunction() {
@OnlyIn(Dist.CLIENT)
private double rotation;
@OnlyIn(Dist.CLIENT)
Expand Down Expand Up @@ -104,7 +104,7 @@ private double getAngle(ClientLevel world, Entity entity, ItemStack stack) {

@SubscribeEvent
public static void registerOverlay(RegisterGuiLayersEvent event) {
event.registerAbove(VanillaGuiLayers.BOSS_OVERLAY, new ResourceLocation(NaturesCompass.MODID, "natures_compass"), new NaturesCompassOverlay());
event.registerAbove(VanillaGuiLayers.BOSS_OVERLAY, ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "natures_compass"), new NaturesCompassOverlay());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.chaosthedude.naturescompass.util.ItemUtils;
import com.chaosthedude.naturescompass.util.RenderUtils;

import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.LayeredDraw;
Expand All @@ -23,7 +24,7 @@ public class NaturesCompassOverlay implements LayeredDraw.Layer {
public static final Minecraft mc = Minecraft.getInstance();

@Override
public void render(GuiGraphics guiGraphics, float partialTick) {
public void render(GuiGraphics guiGraphics, DeltaTracker deltaTracker) {
if (mc.player != null && mc.level != null && !mc.options.hideGui && !mc.getDebugOverlay().showDebugScreen() && (mc.screen == null || (ConfigHandler.CLIENT.displayWithChatOpen.get() && mc.screen instanceof ChatScreen))) {
final Player player = mc.player;
final ItemStack stack = ItemUtils.getHeldNatureCompass(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public BiomeSearchList(NaturesCompassScreen parentScreen, Minecraft mc, int widt

@Override
protected int getScrollbarPosition() {
return super.getScrollbarPosition() + 20;
return getRowLeft() + getRowWidth() - 2;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ public int getFoundBiomeZ(ItemStack stack) {

public ResourceLocation getBiomeKey(ItemStack stack) {
if (stack.getItem() == NaturesCompass.naturesCompass && stack.has(NaturesCompass.BIOME_ID)) {
return new ResourceLocation(stack.get(NaturesCompass.BIOME_ID));
return ResourceLocation.parse(stack.get(NaturesCompass.BIOME_ID));
}

return new ResourceLocation("");
return ResourceLocation.fromNamespaceAndPath("", "");
}

public int getSearchRadius(ItemStack stack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public record SearchPacket(ResourceLocation biomeKey, BlockPos pos) implements CustomPacketPayload {

public static final Type<SearchPacket> TYPE = new Type<SearchPacket>(new ResourceLocation(NaturesCompass.MODID, "search"));
public static final Type<SearchPacket> TYPE = new Type<SearchPacket>(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "search"));

public static final StreamCodec<FriendlyByteBuf, SearchPacket> CODEC = StreamCodec.ofMember(SearchPacket::write, SearchPacket::read);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.neoforge.network.handling.ClientPayloadContext;
import net.neoforged.neoforge.network.handling.IPayloadContext;

public record SyncPacket(boolean canTeleport, List<ResourceLocation> allowedBiomes, ListMultimap<ResourceLocation, ResourceLocation> dimensionKeysForAllowedBiomeKeys) implements CustomPacketPayload {

public static final Type<SyncPacket> TYPE = new Type<SyncPacket>(new ResourceLocation(NaturesCompass.MODID, "sync"));
public static final Type<SyncPacket> TYPE = new Type<SyncPacket>(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "sync"));

public static final StreamCodec<FriendlyByteBuf, SyncPacket> CODEC = StreamCodec.ofMember(SyncPacket::write, SyncPacket::read);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public record TeleportPacket() implements CustomPacketPayload {

public static final Type<TeleportPacket> TYPE = new Type<TeleportPacket>(new ResourceLocation(NaturesCompass.MODID, "teleport"));
public static final Type<TeleportPacket> TYPE = new Type<TeleportPacket>(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "teleport"));

public static final StreamCodec<FriendlyByteBuf, TeleportPacket> CODEC = StreamCodec.ofMember(TeleportPacket::write, TeleportPacket::read);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class NaturesCompassRegistry {
public static void register(RegisterEvent event) {
event.register(BuiltInRegistries.ITEM.key(), registry -> {
NaturesCompass.naturesCompass = new NaturesCompassItem();
registry.register(new ResourceLocation(NaturesCompass.MODID, NaturesCompassItem.NAME), NaturesCompass.naturesCompass);
registry.register(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, NaturesCompassItem.NAME), NaturesCompass.naturesCompass);
});

event.register(BuiltInRegistries.DATA_COMPONENT_TYPE.key(), registry -> {
registry.register(new ResourceLocation(NaturesCompass.MODID, "biome_id"), NaturesCompass.BIOME_ID);
registry.register(new ResourceLocation(NaturesCompass.MODID, "compass_state"), NaturesCompass.COMPASS_STATE);
registry.register(new ResourceLocation(NaturesCompass.MODID, "found_x"), NaturesCompass.FOUND_X);
registry.register(new ResourceLocation(NaturesCompass.MODID, "found_z"), NaturesCompass.FOUND_Z);
registry.register(new ResourceLocation(NaturesCompass.MODID, "search_radius"), NaturesCompass.SEARCH_RADIUS);
registry.register(new ResourceLocation(NaturesCompass.MODID, "samples"), NaturesCompass.SAMPLES);
registry.register(new ResourceLocation(NaturesCompass.MODID, "display_coords"), NaturesCompass.DISPLAY_COORDS);
registry.register(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "biome_id"), NaturesCompass.BIOME_ID);
registry.register(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "compass_state"), NaturesCompass.COMPASS_STATE);
registry.register(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "found_x"), NaturesCompass.FOUND_X);
registry.register(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "found_z"), NaturesCompass.FOUND_Z);
registry.register(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "search_radius"), NaturesCompass.SEARCH_RADIUS);
registry.register(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "samples"), NaturesCompass.SAMPLES);
registry.register(ResourceLocation.fromNamespaceAndPath(NaturesCompass.MODID, "display_coords"), NaturesCompass.DISPLAY_COORDS);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ public static String getBiomeTags(Level level, Biome biome) {
if (fixedPath.contains("/")) {
fixedPath = fixedPath.substring(0, fixedPath.indexOf("/"));
}
String biomeKey = Util.makeDescriptionId("biome", new ResourceLocation(tag.location().getNamespace(), fixedPath));
String biomeKey = Util.makeDescriptionId("biome", ResourceLocation.fromNamespaceAndPath(tag.location().getNamespace(), fixedPath));
String translatedBiomeKey = I18n.get(biomeKey);
if (!biomeKey.equals(translatedBiomeKey)) {
return translatedBiomeKey;
}
String categoryKey = Util.makeDescriptionId("category", new ResourceLocation(tag.location().getNamespace(), fixedPath));
String categoryKey = Util.makeDescriptionId("category", ResourceLocation.fromNamespaceAndPath(tag.location().getNamespace(), fixedPath));
String translatedCategoryKey = I18n.get(categoryKey);
if (!categoryKey.equals(translatedCategoryKey)) {
return translatedCategoryKey;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license="CC BY-NC-SA 4.0"

[[mods]]
modId="naturescompass"
version="1.20.6-3.0.2-neoforge"
version="1.21-3.0.2-neoforge"
displayName="Nature's Compass"
displayURL="https://github.com/MattCzyr/NaturesCompass"
authors="ChaosTheDude"
Expand Down
Loading

0 comments on commit 66fb462

Please sign in to comment.