Skip to content

Commit

Permalink
Merge pull request #9 from Akinesis/1.21.1
Browse files Browse the repository at this point in the history
1.21.1
  • Loading branch information
TalonFloof authored Nov 14, 2024
2 parents 6c4f847 + 186109e commit dc7b2d6
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
# Use these Java versions
java: [
17, # Current Java LTS & minimum supported by Minecraft
21, # Current Java LTS & minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-22.04, windows-2022]
Expand All @@ -33,7 +33,7 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
with:
name: Artifacts
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ hs_err_*.log
replay_*.log
*.hprof
*.jfr

src/main/generated/.cache/
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -56,7 +56,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
Expand All @@ -65,8 +65,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand All @@ -75,6 +75,10 @@ jar {
}
}

fabricApi {
configureDataGeneration()
}

// configure the maven publication
publishing {
publications {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.21
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.9

# Mod Properties
mod_version=1.0.1
mod_version=2.0.0
maven_group=sh.talonfox.vulpine
archives_base_name=vulpine

# Dependencies
fabric_version=0.86.1+1.20.1
fabric_version=0.108.0+1.21.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion src/client/resources/vulpine.client.mixins.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"required": true,
"package": "sh.talonfox.vulpine.mixin.client",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"client": [
"FoxEntityModelMixin",
"FoxEntityRendererMixin",
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sh/talonfox/vulpine/FoxFollowPlayerGoal.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private boolean tryTeleportTo(int x, int y, int z) {
}

private boolean canTeleportTo(BlockPos pos) {
PathNodeType pathNodeType = LandPathNodeMaker.getLandNodeType(this.fop.getWorld(), pos.mutableCopy());
PathNodeType pathNodeType = LandPathNodeMaker.getLandNodeType(fop, pos.mutableCopy());
if (pathNodeType != PathNodeType.WALKABLE) {
return false;
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/sh/talonfox/vulpine/FoxVariantTexture.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@

public class FoxVariantTexture {
public static HashMap<FoxEntity.Type, FoxVariantTexture> foxTextures = new HashMap<>();
public static final FoxVariantTexture TALON = new FoxVariantTexture(new Identifier("vulpine","talon"), new Identifier("vulpine","talon_eep"));
public static final FoxVariantTexture TALON = new FoxVariantTexture(Identifier.of("vulpine","talon"), Identifier.of("vulpine","talon_seep"));

public final Identifier normalTexture;
public final Identifier eepTexture;
public final Identifier sleepTexture;

private FoxVariantTexture(Identifier normalTexture, Identifier eepTexture) {
this.normalTexture = new Identifier(normalTexture.getNamespace(), "textures/entity/fox/" + normalTexture.getPath() + ".png");
this.eepTexture = new Identifier(eepTexture.getNamespace(), "textures/entity/fox/" + eepTexture.getPath() + ".png");
private FoxVariantTexture(Identifier normalTexture, Identifier sleepTexture) {
this.normalTexture = Identifier.of(normalTexture.getNamespace(), "textures/entity/fox/" + normalTexture.getPath() + ".png");
this.sleepTexture = Identifier.of(sleepTexture.getNamespace(), "textures/entity/fox/" + sleepTexture.getPath() + ".png");
}

public static Identifier getTexture(FoxEntity fox) {
if("Talon".equals(fox.getName().getString())) {
return fox.isSleeping()?TALON.eepTexture:TALON.normalTexture;
return fox.isSleeping()?TALON.sleepTexture :TALON.normalTexture;
}
if(foxTextures.containsKey(fox.getVariant())) {
return fox.isSleeping()?foxTextures.get(fox.getVariant()).eepTexture:foxTextures.get(fox.getVariant()).normalTexture;
return fox.isSleeping()?foxTextures.get(fox.getVariant()).sleepTexture :foxTextures.get(fox.getVariant()).normalTexture;
}
return null;
}

public static void init() {
foxTextures.put(Vulpine.SILVER_FOX,new FoxVariantTexture(new Identifier("vulpine","silver"),new Identifier("vulpine","silver_eep")));
foxTextures.put(Vulpine.GRAY_FOX,new FoxVariantTexture(new Identifier("vulpine","gray"),new Identifier("vulpine","gray_eep")));
foxTextures.put(Vulpine.CROSS_FOX,new FoxVariantTexture(new Identifier("vulpine","cross"),new Identifier("vulpine","cross_eep")));
foxTextures.put(Vulpine.SILVER_FOX,new FoxVariantTexture(Identifier.of("vulpine","silver"),Identifier.of("vulpine","silver_sleep")));
foxTextures.put(Vulpine.GRAY_FOX,new FoxVariantTexture(Identifier.of("vulpine","gray"),Identifier.of("vulpine","gray_sleep")));
foxTextures.put(Vulpine.CROSS_FOX,new FoxVariantTexture(Identifier.of("vulpine","cross"),Identifier.of("vulpine","cross_sleep")));
}
}
9 changes: 7 additions & 2 deletions src/main/java/sh/talonfox/vulpine/Vulpine.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@

public class Vulpine implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("vulpine");
public static final TrackedData<Integer> TAME_PROGRESS = DataTracker.registerData(net.minecraft.entity.passive.FoxEntity.class, TrackedDataHandlerRegistry.INTEGER);
public static final TrackedData<Integer> TAME_PROGRESS = DataTracker.registerData(FoxEntity.class, TrackedDataHandlerRegistry.INTEGER);

public static FoxEntity.Type SILVER_FOX = null;
public static FoxEntity.Type GRAY_FOX = null;
public static FoxEntity.Type CROSS_FOX = null;
public static ArrayList<FoxEntity.Type> foxes = null;
public static ArrayList<FoxEntity.Type> foxes = new ArrayList<>();
static {
foxes.add(FoxEntity.Type.RED);
foxes.add(FoxEntity.Type.SNOW);
}

@Override
public void onInitialize() {

}


public static void addFoxGoals(FoxEntity entity, int tameProgress) {
if(tameProgress == 4) {
entity.goalSelector.add(1, new FoxSitGoal(entity));
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/sh/talonfox/vulpine/mixin/FoxEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.passive.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
Expand All @@ -22,6 +23,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import sh.talonfox.vulpine.Vulpine;

import java.util.UUID;
Expand All @@ -44,9 +46,9 @@ protected FoxEntityMixin(EntityType<? extends AnimalEntity> entityType, World wo
super(entityType, world);
}

@Inject(at = @At("TAIL"), method = "initDataTracker()V")
protected void addTameProgressTracker(CallbackInfo ci) {
((FoxEntity) (Object) this).getDataTracker().startTracking(Vulpine.TAME_PROGRESS, 0);
@Inject(at = @At("TAIL"), method = "initDataTracker", locals = LocalCapture.CAPTURE_FAILHARD)
protected void addTameProgressTracker(DataTracker.Builder builder, CallbackInfo ci) {
builder.add(Vulpine.TAME_PROGRESS, 0);
}

@Inject(method = "writeCustomDataToNbt", at = @At("TAIL"))
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/sh/talonfox/vulpine/mixin/FoxTypeMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.ArrayList;

import static sh.talonfox.vulpine.Vulpine.SILVER_FOX;
import static sh.talonfox.vulpine.Vulpine.foxes;

@SuppressWarnings("unused")
Expand All @@ -19,16 +20,16 @@ private static FoxEntity.Type makeVariant(String enumName, int ordinal, int id,
throw new AssertionError();
}


/**
* @author TalonFox
* @reason To allow us to add new fox variants
*/
@Overwrite
public static FoxEntity.Type[] values() {
if(foxes == null) {
foxes = new ArrayList<>();
foxes.add(FoxEntity.Type.RED);
foxes.add(FoxEntity.Type.SNOW);
//don't remove this line. It's a hacky way to ensure that TrackedData regiser in correct order.
FoxEntity.toGrowUpAge(0);
if(Vulpine.SILVER_FOX == null) {
Vulpine.SILVER_FOX = IFoxTypeCreator.class.cast(FoxEntity.Type.RED).vulpine$newFoxVariant("SILVER",2,2, "silver");
Vulpine.GRAY_FOX = IFoxTypeCreator.class.cast(FoxEntity.Type.RED).vulpine$newFoxVariant("GRAY",3,3, "gray");
Vulpine.CROSS_FOX = IFoxTypeCreator.class.cast(FoxEntity.Type.RED).vulpine$newFoxVariant("CROSS",4,4, "cross");
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
],
"accessWidener" : "vulpine.accesswidener",
"depends": {
"fabricloader": ">=0.14.21",
"minecraft": "~1.20.1",
"java": ">=17",
"fabricloader": ">=0.16.9",
"minecraft": "~1.21.1",
"java": ">=21",
"fabric-api": "*"
}
}
2 changes: 1 addition & 1 deletion src/main/resources/vulpine.mixins.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"required": true,
"package": "sh.talonfox.vulpine.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [
"FoxEntityMateGoalMixin",
"FoxEntityMixin",
Expand Down

0 comments on commit dc7b2d6

Please sign in to comment.