diff --git a/Forge/src/main/java/software/bluelib/example/entity/rex/RexEntity.java b/Forge/src/main/java/software/bluelib/example/entity/rex/RexEntity.java index 1823e889..fdd27cb4 100644 --- a/Forge/src/main/java/software/bluelib/example/entity/rex/RexEntity.java +++ b/Forge/src/main/java/software/bluelib/example/entity/rex/RexEntity.java @@ -63,7 +63,7 @@ public class RexEntity extends TamableAnimal implements IVariantEntity, GeoEntit * @Co-author MeAlam, Dan * @since 1.0.0 */ - protected final String entityName = "Rex"; + protected final String entityName = "rex"; /** * Constructs a new {@link RexEntity} instance with the specified entity type and level. diff --git a/NeoForge/build.gradle b/NeoForge/build.gradle index 158ee7ed..844cf406 100644 --- a/NeoForge/build.gradle +++ b/NeoForge/build.gradle @@ -1,20 +1,24 @@ - plugins { +plugins { id 'java-library' id 'eclipse' id 'idea' id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.97' + id 'net.neoforged.moddev' version '1.0.19' +} + +tasks.named('wrapper', Wrapper).configure { + distributionType = Wrapper.DistributionType.BIN } version = mod_version group = mod_group_id repositories { + mavenLocal() maven { url "https://cursemaven.com" } mavenCentral() - mavenLocal() } base { @@ -23,34 +27,55 @@ base { java.toolchain.languageVersion = JavaLanguageVersion.of(java_version) -//minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') -//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager +neoForge { + version = project.neo_version + + parchment { + mappingsVersion = project.parchment_mappings_version + minecraftVersion = project.parchment_minecraft_version + } -runs { - configureEach { - systemProperty 'forge.logging.markers', 'REGISTRIES' + runs { + client { + client() - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - systemProperty 'forge.logging.console.level', 'debug' + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + } - modSource project.sourceSets.main - } + server { + server() + programArgument '--nogui' + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + } - client { - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id - } + gameTestServer { + type = "gameTestServer" + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + } - server { - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id - programArgument '--nogui' - } + data { + data() + + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + } - gameTestServer { - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + + configureEach { + + systemProperty 'forge.logging.markers', 'REGISTRIES' + + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels + logLevel = org.slf4j.event.Level.DEBUG + } } - data { - programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + mods { + "${mod_id}" { + sourceSet(sourceSets.main) + } + "geckolib" { + sourceSet(sourceSets.main) + } } } @@ -61,27 +86,11 @@ configurations { } dependencies { - implementation "net.neoforged:neoforge:${neo_version}" runtimeOnly "curse.maven:geckolib-388172:${geckolib_file}" compileOnly "curse.maven:geckolib-388172:${geckolib_file}" } -jar { - manifest { - attributes([ - "Specification-Title" : mod_name, - "Specification-Vendor" : mod_authors, - "Specification-Version" : mod_version, - "Implementation-Title" : mod_name, - "Implementation-Version" : mod_version, - "Implementation-Vendor" : mod_authors, - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), - ]) - } -} - -// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html -tasks.withType(ProcessResources).configureEach { +var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) { var replaceProperties = [ minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range, @@ -96,9 +105,23 @@ tasks.withType(ProcessResources).configureEach { mod_description : mod_description ] inputs.properties replaceProperties - - filesMatching(['META-INF/mods.toml']) { - expand replaceProperties + expand replaceProperties + from "src/main/templates" + into "build/generated/sources/modMetadata" +} +sourceSets.main.resources.srcDir generateModMetadata +neoForge.ideSyncTask generateModMetadata + +publishing { + publications { + register('mavenJava', MavenPublication) { + from components.java + } + } + repositories { + maven { + url "file://${project.projectDir}/repo" + } } } diff --git a/NeoForge/gradle.properties b/NeoForge/gradle.properties index 979cf055..47185ef7 100644 --- a/NeoForge/gradle.properties +++ b/NeoForge/gradle.properties @@ -1,21 +1,25 @@ -#org.gradle.jvmargs= -org.gradle.daemon=false -org.gradle.debug=false +# Sets default memory used for gradle commands. Can be overridden by user or command line properties. +org.gradle.jvmargs=-Xmx1G +org.gradle.daemon=true +org.gradle.parallel=true +org.gradle.caching=true +org.gradle.configuration-cache=true -neogradle.subsystems.parchment.minecraftVersion=1.20.3 -neogradle.subsystems.parchment.mappingsVersion=2023.12.31 -minecraft_version=1.20.4 -minecraft_version_range=[1.20.2,1.21) -neo_version=20.4.237 -neo_version_range=[20.4,) -loader_version_range=[2,) -## geckolib_file is the cursemaven file you get from curseforge -geckolib_file=5188406 -java_version=17 +parchment_minecraft_version=1.21 +parchment_mappings_version=2024.07.28 +minecraft_version=1.21 +minecraft_version_range=[1.21,1.21.1) +neo_version=21.0.167 +neo_version_range=[21.0.0-beta,) +loader_version_range=[4,) + +geckolib_file=5679344 +java_version=21 ## Mod Properties + mod_id=bluelib mod_name=BlueLib mod_license=MIT License diff --git a/NeoForge/src/main/java/software/bluelib/BlueLib.java b/NeoForge/src/main/java/software/bluelib/BlueLib.java index e73d1c98..99d1bc8d 100644 --- a/NeoForge/src/main/java/software/bluelib/BlueLib.java +++ b/NeoForge/src/main/java/software/bluelib/BlueLib.java @@ -4,9 +4,11 @@ import net.neoforged.bus.api.IEventBus; import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.ModContainer; import net.neoforged.fml.common.Mod; import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent; import net.neoforged.fml.loading.FMLEnvironment; +import net.neoforged.neoforge.common.NeoForge; import software.bluelib.example.event.ClientEvents; import software.bluelib.example.init.ModEntities; @@ -24,7 +26,7 @@ *

* Key Methods: *

@@ -61,17 +63,20 @@ public class BlueLib { * Constructs a new {@link BlueLib} instance and registers the mod event bus. * * @param pModEventBus {@link IEventBus} - The event bus to which the mod will register its event handlers. + * @param pModContainer {@link ModContainer} - The mod container for the mod instance. * @author MeAlam * @Co-author Dan * @since 1.0.0 */ - public BlueLib(IEventBus pModEventBus) { + public BlueLib(IEventBus pModEventBus, ModContainer pModContainer) { pModEventBus.register(this); if (isDeveloperMode()) { ModEntities.REGISTRY.register(pModEventBus); - pModEventBus.addListener(ClientEvents::registerAttributes); - pModEventBus.addListener(ClientEvents::registerRenderers); + if (FMLEnvironment.dist.isClient()) { + pModEventBus.addListener(ClientEvents::registerAttributes); + pModEventBus.addListener(ClientEvents::registerRenderers); + } } } diff --git a/NeoForge/src/main/java/software/bluelib/event/ReloadEventHandler.java b/NeoForge/src/main/java/software/bluelib/event/ReloadEventHandler.java index 9a095c52..9da36f9a 100644 --- a/NeoForge/src/main/java/software/bluelib/event/ReloadEventHandler.java +++ b/NeoForge/src/main/java/software/bluelib/event/ReloadEventHandler.java @@ -65,8 +65,8 @@ public class ReloadEventHandler { * @since 1.0.0 */ protected static void registerEntityVariants(MinecraftServer pServer, String pEntityName, String pModID, String pModPathLocation, String pDataPathLocation) { - ResourceLocation modLocation = new ResourceLocation(pModID, pModPathLocation); - ResourceLocation dataLocation = new ResourceLocation(pModID, pDataPathLocation); + ResourceLocation modLocation = ResourceLocation.fromNamespaceAndPath(pModID, pModPathLocation); + ResourceLocation dataLocation = ResourceLocation.fromNamespaceAndPath(pModID, pDataPathLocation); try { VariantLoader.loadVariants(modLocation, dataLocation, pServer, pEntityName); } catch (JsonParseException pException) { diff --git a/NeoForge/src/main/java/software/bluelib/example/entity/dragon/DragonEntity.java b/NeoForge/src/main/java/software/bluelib/example/entity/dragon/DragonEntity.java index 00e15560..56a55393 100644 --- a/NeoForge/src/main/java/software/bluelib/example/entity/dragon/DragonEntity.java +++ b/NeoForge/src/main/java/software/bluelib/example/entity/dragon/DragonEntity.java @@ -11,13 +11,14 @@ import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.ServerLevelAccessor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import software.bernie.geckolib.animatable.GeoEntity; -import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; -import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.animation.AnimatableManager; import software.bernie.geckolib.util.GeckoLibUtil; import software.bluelib.interfaces.variant.IVariantEntity; import software.bluelib.utils.ParameterUtils; @@ -33,10 +34,10 @@ *

* Key Methods: *

@@ -89,9 +90,9 @@ public DragonEntity(EntityType pEntityType, Level pLeve * @Co-author Dan */ @Override - protected void defineSynchedData() { - super.defineSynchedData(); - this.entityData.define(VARIANT, "normal"); + protected void defineSynchedData(SynchedEntityData.@NotNull Builder pBuilder) { + super.defineSynchedData(pBuilder); + pBuilder.define(VARIANT, "normal"); } /** @@ -140,7 +141,6 @@ public void readAdditionalSaveData(@NotNull CompoundTag pCompound) { * @param pDifficulty {@link DifficultyInstance} - The difficulty instance for spawning. * @param pReason {@link MobSpawnType} - The reason for spawning the entity. * @param pSpawnData {@link SpawnGroupData} - Data related to the spawn. - * @param pDataTag {@link CompoundTag} - Additional data for spawning. * @return {@link SpawnGroupData} - Updated spawn data. * * @since 1.0.0 @@ -148,7 +148,7 @@ public void readAdditionalSaveData(@NotNull CompoundTag pCompound) { * @Co-author Dan */ @Override - public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor pLevel, @NotNull DifficultyInstance pDifficulty, @NotNull MobSpawnType pReason, @Nullable SpawnGroupData pSpawnData, @Nullable CompoundTag pDataTag) { + public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor pLevel, @NotNull DifficultyInstance pDifficulty, @NotNull MobSpawnType pReason, @Nullable SpawnGroupData pSpawnData) { if (getVariantName() == null || getVariantName().isEmpty()) { this.setVariantName(getRandomVariant(getEntityVariants(entityName), "normal")); ParameterUtils.ParameterBuilder.forVariant(entityName,this.getVariantName()) @@ -158,7 +158,7 @@ public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor pLevel, @NotNul .withParameter("array") .connect(); } - return super.finalizeSpawn(pLevel, pDifficulty, pReason, pSpawnData, pDataTag); + return super.finalizeSpawn(pLevel, pDifficulty, pReason, pSpawnData); } /** @@ -217,4 +217,9 @@ public AnimatableInstanceCache getAnimatableInstanceCache() { public AgeableMob getBreedOffspring(@NotNull ServerLevel pLevel, @NotNull AgeableMob pOtherParent) { return null; } + + @Override + public boolean isFood(@NotNull ItemStack pItemStack) { + return false; + } } diff --git a/NeoForge/src/main/java/software/bluelib/example/entity/dragon/DragonModel.java b/NeoForge/src/main/java/software/bluelib/example/entity/dragon/DragonModel.java index 67091901..49db6249 100644 --- a/NeoForge/src/main/java/software/bluelib/example/entity/dragon/DragonModel.java +++ b/NeoForge/src/main/java/software/bluelib/example/entity/dragon/DragonModel.java @@ -12,7 +12,7 @@ public class DragonModel extends GeoModel { // Get the Model Location @Override public ResourceLocation getModelResource(DragonEntity pObject) { - return new ResourceLocation(BlueLib.MODID, "geo/dragon.geo.json"); + return ResourceLocation.fromNamespaceAndPath(BlueLib.MODID, "geo/dragon.geo.json"); } // Get the Texture Location @@ -24,6 +24,6 @@ public ResourceLocation getTextureResource(DragonEntity pObject) { // Get the Animation Location @Override public ResourceLocation getAnimationResource(DragonEntity pAnimatable) { - return new ResourceLocation(BlueLib.MODID, "animations/dragon.animation.json"); + return ResourceLocation.fromNamespaceAndPath(BlueLib.MODID, "animations/dragon.animation.json"); } } diff --git a/NeoForge/src/main/java/software/bluelib/example/entity/rex/RexEntity.java b/NeoForge/src/main/java/software/bluelib/example/entity/rex/RexEntity.java index fcb85a52..fdd27cb4 100644 --- a/NeoForge/src/main/java/software/bluelib/example/entity/rex/RexEntity.java +++ b/NeoForge/src/main/java/software/bluelib/example/entity/rex/RexEntity.java @@ -11,13 +11,14 @@ import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.ServerLevelAccessor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import software.bernie.geckolib.animatable.GeoEntity; -import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; -import software.bernie.geckolib.core.animation.AnimatableManager; +import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache; +import software.bernie.geckolib.animation.AnimatableManager; import software.bernie.geckolib.util.GeckoLibUtil; import software.bluelib.interfaces.variant.IVariantEntity; import software.bluelib.utils.ParameterUtils; @@ -26,19 +27,19 @@ * A {@code RexEntity} class representing a Rex entity in the game, which extends {@link TamableAnimal} * and implements {@link IVariantEntity} and {@link GeoEntity}. *

- * This class manages the rex's variant system, its data synchronization, and integrates with the GeckoLib + * This class manages the Rex's variant system, its data synchronization, and integrates with the GeckoLib * animation system. *

* *

* Key Methods: *

*

* @@ -48,7 +49,7 @@ */ public class RexEntity extends TamableAnimal implements IVariantEntity, GeoEntity { /** - * Entity data accessor for the variant of the rex. + * Entity data accessor for the variant of the Rex. *

* This is used to store and retrieve the variant data for synchronization between server and client. *

@@ -79,7 +80,7 @@ public RexEntity(EntityType pEntityType, Level pLevel) } /** - * Defines the synchronized data for this rex entity, including the variant. + * Defines the synchronized data for this Rex entity, including the variant. *

* This method initializes the {@link EntityDataAccessor} to handle the variant data. *

@@ -89,9 +90,9 @@ public RexEntity(EntityType pEntityType, Level pLevel) * @Co-author Dan */ @Override - protected void defineSynchedData() { - super.defineSynchedData(); - this.entityData.define(VARIANT, "normal"); + protected void defineSynchedData(SynchedEntityData.@NotNull Builder pBuilder) { + super.defineSynchedData(pBuilder); + pBuilder.define(VARIANT, "normal"); } /** @@ -131,7 +132,7 @@ public void readAdditionalSaveData(@NotNull CompoundTag pCompound) { } /** - * Finalizes the spawning of the rex entity. + * Finalizes the spawning of the Rex entity. *

* This method sets up the variant for the entity and connects parameters if needed. *

@@ -140,7 +141,6 @@ public void readAdditionalSaveData(@NotNull CompoundTag pCompound) { * @param pDifficulty {@link DifficultyInstance} - The difficulty instance for spawning. * @param pReason {@link MobSpawnType} - The reason for spawning the entity. * @param pSpawnData {@link SpawnGroupData} - Data related to the spawn. - * @param pDataTag {@link CompoundTag} - Additional data for spawning. * @return {@link SpawnGroupData} - Updated spawn data. * * @since 1.0.0 @@ -148,7 +148,7 @@ public void readAdditionalSaveData(@NotNull CompoundTag pCompound) { * @Co-author Dan */ @Override - public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor pLevel, @NotNull DifficultyInstance pDifficulty, @NotNull MobSpawnType pReason, @Nullable SpawnGroupData pSpawnData, @Nullable CompoundTag pDataTag) { + public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor pLevel, @NotNull DifficultyInstance pDifficulty, @NotNull MobSpawnType pReason, @Nullable SpawnGroupData pSpawnData) { if (getVariantName() == null || getVariantName().isEmpty()) { this.setVariantName(getRandomVariant(getEntityVariants(entityName), "normal")); ParameterUtils.ParameterBuilder.forVariant(entityName,this.getVariantName()) @@ -158,11 +158,11 @@ public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor pLevel, @NotNul .withParameter("array") .connect(); } - return super.finalizeSpawn(pLevel, pDifficulty, pReason, pSpawnData, pDataTag); + return super.finalizeSpawn(pLevel, pDifficulty, pReason, pSpawnData); } /** - * Sets the variant name for the rex entity. + * Sets the variant name for the Rex entity. * * @param pName {@link String} - The name of the variant to set. * @@ -175,7 +175,7 @@ public void setVariantName(String pName) { } /** - * Retrieves the current variant name of the rex entity. + * Retrieves the current variant name of the Rex entity. * * @return {@link String} - The current variant name. * @@ -217,4 +217,9 @@ public AnimatableInstanceCache getAnimatableInstanceCache() { public AgeableMob getBreedOffspring(@NotNull ServerLevel pLevel, @NotNull AgeableMob pOtherParent) { return null; } + + @Override + public boolean isFood(@NotNull ItemStack pItemStack) { + return false; + } } diff --git a/NeoForge/src/main/java/software/bluelib/example/entity/rex/RexModel.java b/NeoForge/src/main/java/software/bluelib/example/entity/rex/RexModel.java index 6084892c..1e0f85e3 100644 --- a/NeoForge/src/main/java/software/bluelib/example/entity/rex/RexModel.java +++ b/NeoForge/src/main/java/software/bluelib/example/entity/rex/RexModel.java @@ -12,7 +12,7 @@ public class RexModel extends GeoModel { // Get the Model Location @Override public ResourceLocation getModelResource(RexEntity pObject) { - return new ResourceLocation(BlueLib.MODID, "geo/rex.geo.json"); + return ResourceLocation.fromNamespaceAndPath(BlueLib.MODID, "geo/rex.geo.json"); } // Get the Texture Location @@ -24,6 +24,6 @@ public ResourceLocation getTextureResource(RexEntity pObject) { // Get the Animation Location @Override public ResourceLocation getAnimationResource(RexEntity pAnimatable) { - return new ResourceLocation(BlueLib.MODID, "animations/rex.animation.json"); + return ResourceLocation.fromNamespaceAndPath(BlueLib.MODID, "animations/rex.animation.json"); } } diff --git a/NeoForge/src/main/java/software/bluelib/example/event/ReloadHandler.java b/NeoForge/src/main/java/software/bluelib/example/event/ReloadHandler.java index 5c6bacca..4d36d784 100644 --- a/NeoForge/src/main/java/software/bluelib/example/event/ReloadHandler.java +++ b/NeoForge/src/main/java/software/bluelib/example/event/ReloadHandler.java @@ -4,7 +4,7 @@ import net.minecraft.server.MinecraftServer; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.event.AddReloadListenerEvent; import net.neoforged.neoforge.event.server.ServerStartingEvent; import software.bluelib.BlueLib; @@ -36,7 +36,7 @@ * @author MeAlam * @Co-author Dan */ -@Mod.EventBusSubscriber +@EventBusSubscriber public class ReloadHandler extends ReloadEventHandler { /** diff --git a/NeoForge/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java b/NeoForge/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java index 3b905d28..baecfe62 100644 --- a/NeoForge/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java +++ b/NeoForge/src/main/java/software/bluelib/interfaces/variant/base/IVariantEntityBase.java @@ -41,7 +41,7 @@ public interface IVariantEntityBase { * @since 1.0.0 */ default ResourceLocation getTextureLocation(String pModId, String pPath) { - return new ResourceLocation(pModId, pPath); + return ResourceLocation.fromNamespaceAndPath(pModId, pPath); } /** diff --git a/NeoForge/src/main/resources/META-INF/mods.toml b/NeoForge/src/main/resources/META-INF/neoforge.mods.toml similarity index 89% rename from NeoForge/src/main/resources/META-INF/mods.toml rename to NeoForge/src/main/resources/META-INF/neoforge.mods.toml index d63059f6..711284af 100644 --- a/NeoForge/src/main/resources/META-INF/mods.toml +++ b/NeoForge/src/main/resources/META-INF/neoforge.mods.toml @@ -3,8 +3,8 @@ loaderVersion="${loader_version_range}" license="${mod_license}" issueTrackerURL="https://github.com/MeAlam1/BlueLib/issues" [[mods]] -modId="${mod_id}" -version="${mod_version}" +modId="bluelib" +version="1.0.0" displayName="${mod_name}" # A URL to query for updates for this mod. See the JSON update specification https://docs.neoforged.net/docs/misc/updatechecker/ @@ -16,14 +16,14 @@ authors="${mod_authors}" description='''${mod_description}''' -[[dependencies.${mod_id}]] +[[dependencies.bluelib]] modId="neoforge" type="required" versionRange="${neo_version_range}" ordering="NONE" side="BOTH" -[[dependencies.${mod_id}]] +[[dependencies.bluelib]] modId="minecraft" type="required" versionRange="${minecraft_version_range}" diff --git a/NeoForge/src/main/resources/pack.mcmeta b/NeoForge/src/main/resources/pack.mcmeta index 325d954f..4830e6d5 100644 --- a/NeoForge/src/main/resources/pack.mcmeta +++ b/NeoForge/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 9, + "pack_format": 34, "description": "bluelib" } } \ No newline at end of file