Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Port to 1.21 #42

Merged
merged 8 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Cache Gradle packages
uses: actions/cache@v3
Expand Down
5 changes: 3 additions & 2 deletions Forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
id 'org.spongepowered.mixin' version '0.7.+'
}

Expand Down Expand Up @@ -34,7 +34,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(java_version)
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {
mappings channel: mapping_channel, version: mapping_version

reobf = false
copyIdeResources = true

runs {
Expand Down Expand Up @@ -80,6 +80,7 @@ dependencies {
//runtimeOnly fg.deobf("software.bernie.geckolib:geckolib-forge-${minecraft_version}:${geckolib_version}")
runtimeOnly "curse.maven:geckolib-388172:${geckolib_file}"
compileOnly "curse.maven:geckolib-388172:${geckolib_file}"
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
}

tasks.named('processResources', ProcessResources).configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,10 +34,10 @@
* <p>
* Key Methods:
* <ul>
* <li>{@link #defineSynchedData()} - Defines the synchronized data for the dragon entity, including its variant.</li>
* <li>{@link #defineSynchedData(SynchedEntityData.Builder)} - Defines the synchronized data for the dragon entity, including its variant.</li>
* <li>{@link #addAdditionalSaveData(CompoundTag)} - Adds custom data to the entity's NBT for saving.</li>
* <li>{@link #readAdditionalSaveData(CompoundTag)} - Reads custom data from the entity's NBT for loading.</li>
* <li>{@link #finalizeSpawn(ServerLevelAccessor, DifficultyInstance, MobSpawnType, SpawnGroupData, CompoundTag)} - Finalizes the spawning process and sets up parameters.</li>
* <li>{@link #finalizeSpawn(ServerLevelAccessor, DifficultyInstance, MobSpawnType, SpawnGroupData)} - Finalizes the spawning process and sets up parameters.</li>
* <li>{@link #setVariantName(String)} - Sets the variant name of the dragon.</li>
* <li>{@link #getVariantName()} - Retrieves the current variant name of the dragon.</li>
* </ul>
Expand Down Expand Up @@ -89,9 +90,9 @@ public DragonEntity(EntityType<? extends TamableAnimal> 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");
}

/**
Expand Down Expand Up @@ -140,15 +141,14 @@ 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
* @author MeAlam
* @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())
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class DragonModel extends GeoModel<DragonEntity> {
// 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
Expand All @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
* <p>
* 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.
* </p>
*
* <p>
* Key Methods:
* <ul>
* <li>{@link #defineSynchedData()} - Defines the synchronized data for the rex entity, including its variant.</li>
* <li>{@link #defineSynchedData(SynchedEntityData.Builder)} - Defines the synchronized data for the Rex entity, including its variant.</li>
* <li>{@link #addAdditionalSaveData(CompoundTag)} - Adds custom data to the entity's NBT for saving.</li>
* <li>{@link #readAdditionalSaveData(CompoundTag)} - Reads custom data from the entity's NBT for loading.</li>
* <li>{@link #finalizeSpawn(ServerLevelAccessor, DifficultyInstance, MobSpawnType, SpawnGroupData, CompoundTag)} - Finalizes the spawning process and sets up parameters.</li>
* <li>{@link #setVariantName(String)} - Sets the variant name of the rex.</li>
* <li>{@link #getVariantName()} - Retrieves the current variant name of the rex.</li>
* <li>{@link #finalizeSpawn(ServerLevelAccessor, DifficultyInstance, MobSpawnType, SpawnGroupData)} - Finalizes the spawning process and sets up parameters.</li>
* <li>{@link #setVariantName(String)} - Sets the variant name of the Rex.</li>
* <li>{@link #getVariantName()} - Retrieves the current variant name of the Rex.</li>
* </ul>
* </p>
*
Expand All @@ -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.
* <p>
* This is used to store and retrieve the variant data for synchronization between server and client.
* </p>
Expand Down Expand Up @@ -79,7 +80,7 @@ public RexEntity(EntityType<? extends TamableAnimal> 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.
* <p>
* This method initializes the {@link EntityDataAccessor} to handle the variant data.
* </p>
Expand All @@ -89,9 +90,9 @@ public RexEntity(EntityType<? extends TamableAnimal> 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");
}

/**
Expand Down Expand Up @@ -131,7 +132,7 @@ public void readAdditionalSaveData(@NotNull CompoundTag pCompound) {
}

/**
* Finalizes the spawning of the rex entity.
* Finalizes the spawning of the Rex entity.
* <p>
* This method sets up the variant for the entity and connects parameters if needed.
* </p>
Expand All @@ -140,15 +141,14 @@ 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
* @author MeAlam
* @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())
Expand All @@ -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.
*
Expand All @@ -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.
*
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class RexModel extends GeoModel<RexEntity> {
// 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
Expand All @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ModEntities {
.setUpdateInterval(3)
.fireImmune()
.sized(0.6f, 1.8f)
.build(new ResourceLocation(BlueLib.MODID, "dragon").toString()));
.build(ResourceLocation.fromNamespaceAndPath(BlueLib.MODID, "dragon").toString()));

public static final RegistryObject<EntityType<RexEntity>> REX =
REGISTER.register("example_two", () -> EntityType.Builder.of(RexEntity::new, MobCategory.AMBIENT)
Expand All @@ -34,7 +34,7 @@ public class ModEntities {
.setUpdateInterval(3)
.fireImmune()
.sized(0.6f, 1.8f)
.build(new ResourceLocation(BlueLib.MODID, "rex").toString()));
.build(ResourceLocation.fromNamespaceAndPath(BlueLib.MODID, "rex").toString()));

public static void register(IEventBus eventBus) {
REGISTER.register(eventBus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ license="${mod_license}"
modId="${mod_id}"
version="${mod_version}"
displayName="${mod_name}"
displayURL="https://github.com/MeAlam1/BlueLib/wiki"
#logoFile="examplemod.png"
displayURL="https://mealam1.github.io/BlueLib/"
logoFile="bluelib.png"
credits="Anyone who contributed to the Source Code of BlueLib!"
authors="${mod_authors}"
description='''${mod_description}'''
Expand Down
Binary file added Forge/src/main/resources/bluelib.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading