Skip to content

Commit

Permalink
Update to 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nk2IsHere committed Aug 6, 2023
1 parent 3622267 commit f1be249
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Apathy for 1.19.2, requires Fabric API
# Apathy for 1.20.1, requires Fabric API

Make mobs apathetic up until you attack
Literally, thats it.
Expand Down
24 changes: 10 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.1.1'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -24,23 +24,19 @@ dependencies {
}

// shadowing the libraries
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation

shadowJar {
archiveClassifier.set('shadow-dev')
configurations = [project.configurations.shadow]
classifier 'shadow-dev'
enableRelocation true
relocationPrefix "${project.group}.${project.archives_base_name}.shadow"
}

task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = "${project.group}.${project.archives_base_name}.shadow"
}
tasks.shadowJar.dependsOn tasks.relocateShadowJar

remapJar {
dependsOn shadowJar
mustRunAfter shadowJar
input.set shadowJar.archiveFile.get()
input.set shadowJar.archiveFile
archiveClassifier.set(null)
}

processResources {
Expand All @@ -54,15 +50,15 @@ processResources {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
tasks.register('sourcesJar', Jar) {
dependsOn classes
from sourceSets.main.allSource
}

Expand Down
13 changes: 7 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.8
loader_version=0.14.9
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21


# Mod Properties
mod_version = 1.4.0
mod_version = 1.5.0
maven_group = eu.nk2
archives_base_name = apathy

# Dependencies
fabric_version=0.60.0+1.19.2
fabric_version=0.85.0+1.20.1
jankson_version=1.2.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 4 additions & 4 deletions src/main/java/eu/nk2/apathy/ApathyMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import net.minecraft.entity.ai.goal.PrioritizedGoal;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Pair;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -133,7 +133,7 @@ private void updateMobSetApathyGoal(MobEntity entity, Set<Goal> targetSelectorSe

private void updateMobSetApathyGoals(ApathyConfig apathyConfig, MobEntity entity, Set<Goal> targetSelectorSet, int priority, ActiveTargetGoal<PlayerEntity> followTargetGoal) {
List<ApathyConfig.ApathyBehaviourType> defaultApathyBehaviourType = apathyConfig.getApathyBehaviourTypeMap().getOrDefault(null, new ArrayList<>());
List<ApathyConfig.ApathyBehaviourType> mobSpecificApathyBehaviourType = apathyConfig.getApathyBehaviourTypeMap().get(Registry.ENTITY_TYPE.getId(entity.getType()));
List<ApathyConfig.ApathyBehaviourType> mobSpecificApathyBehaviourType = apathyConfig.getApathyBehaviourTypeMap().get(Registries.ENTITY_TYPE.getId(entity.getType()));

if(mobSpecificApathyBehaviourType == null) {
defaultApathyBehaviourType.forEach(apathyBehaviourType -> updateMobSetApathyGoal(
Expand Down Expand Up @@ -166,7 +166,7 @@ public void onInitialize() {
logger.info("Loaded with config: " + apathyConfig);

ApathyConfig finalApathyConfig = apathyConfig;
Registry.ENTITY_TYPE
Registries.ENTITY_TYPE
.streamEntries()
.map(RegistryEntry.Reference::value)
.map((entityType) -> new Pair<>((EntityType<Entity>) entityType, getEntityFactory((EntityType<Entity>) entityType)))
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/eu/nk2/apathy/context/ApathyConfigLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import blue.endless.jankson.api.SyntaxError;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -52,13 +52,13 @@ public static ApathyConfig loadConfig() throws IOException {
case if_block_broken:
return new ApathyConfig.ApathyBehaviourIfBlockBrokenType(
behaviourEntryObject.get(Float.class, "maximal_reaction_distance"),
Registry.BLOCK.get(Identifier.tryParse(behaviourEntryObject.get(String.class, "reaction_block")))
Registries.BLOCK.get(Identifier.tryParse(behaviourEntryObject.get(String.class, "reaction_block")))
);
case if_item_selected:
Integer reactionItemCount = behaviourEntryObject.get(Integer.class, "reaction_item_count");
return new ApathyConfig.ApathyBehaviourIfItemSelectedType(
behaviourEntryObject.get(Float.class, "maximal_reaction_distance"),
Registry.ITEM.get(Identifier.tryParse(behaviourEntryObject.get(String.class, "reaction_item"))),
Registries.ITEM.get(Identifier.tryParse(behaviourEntryObject.get(String.class, "reaction_item"))),
reactionItemCount != null? reactionItemCount : 0
);
}
Expand Down Expand Up @@ -125,14 +125,14 @@ public static void saveConfig(ApathyConfig apathyConfig) throws IOException {
value.put("type", new JsonPrimitive(ApathyBehaviourType.if_block_broken.name()));
value.put("maximal_reaction_distance", new JsonPrimitive(ifBlockBrokenBehaviour.getMaximalReactionDistance()));
value.put("reaction_block", new JsonPrimitive(
Registry.BLOCK.getId(ifBlockBrokenBehaviour.getReactionBlock()).toString()
Registries.BLOCK.getId(ifBlockBrokenBehaviour.getReactionBlock()).toString()
));
} else if(apathyBehaviourType instanceof ApathyConfig.ApathyBehaviourIfItemSelectedType) {
ApathyConfig.ApathyBehaviourIfItemSelectedType ifItemSelectedBehaviour = (ApathyConfig.ApathyBehaviourIfItemSelectedType) apathyBehaviourType;
value.put("type", new JsonPrimitive(ApathyBehaviourType.if_item_selected.name()));
value.put("maximal_reaction_distance", new JsonPrimitive(ifItemSelectedBehaviour.getMaximalReactionDistance()));
value.put("reaction_item", new JsonPrimitive(
Registry.ITEM.getId(ifItemSelectedBehaviour.getReactionItem()).toString()
Registries.ITEM.getId(ifItemSelectedBehaviour.getReactionItem()).toString()
));
value.put("reaction_item_count", new JsonPrimitive(ifItemSelectedBehaviour.getReactionItemCount()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ApathyIfBlockBrokenActiveTargetGoal(
this.reactionBlock = reactionBlock;

this.onBlockBrokenHandlerId = OnBlockBrokenEventRegistry.INSTANCE.registerOnBlockBrokenHandler((pos, state, playerUuid) -> {
PlayerEntity player = this.mob.world.getPlayerByUuid(playerUuid);
PlayerEntity player = this.mob.getWorld().getPlayerByUuid(playerUuid);
if(player == null) return;

logger.info("[" + this.mob + "] Block broken: " + playerUuid + " " + state);
Expand All @@ -63,7 +63,7 @@ public ApathyIfBlockBrokenActiveTargetGoal(
protected void findClosestTarget() {
this.playerMemory.keySet()
.stream()
.map(playerUuid -> mob.world.getPlayerByUuid(playerUuid))
.map(playerUuid -> mob.getWorld().getPlayerByUuid(playerUuid))
.filter(Objects::nonNull)
.map((player) -> new Pair<>(player, mob.distanceTo(player)))
.min(Comparator.comparing(Pair::getRight))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ApathyIfItemSelectedActiveTargetGoal(
protected void findClosestTarget() {
this.playerMemory.keySet()
.stream()
.map(playerUuid -> mob.world.getPlayerByUuid(playerUuid))
.map(playerUuid -> mob.getWorld().getPlayerByUuid(playerUuid))
.filter(Objects::nonNull)
.map((player) -> new Pair<>(player, mob.distanceTo(player)))
.filter((playerDistancePair) -> playerDistancePair.getRight() <= maximalFollowDistance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public class ApathyMixinLivingEntityInjector {
@Inject(method = "onDeath", at=@At("TAIL"))
void onDeathInjection(DamageSource damageSource, CallbackInfo ci) {
LivingEntity livingEntity = (LivingEntity) (Object) this;
OnLivingEntityDeadEventRegistry.INSTANCE.publishOnLivingEntityDeadEvent(livingEntity.world, livingEntity, damageSource);
OnLivingEntityDeadEventRegistry.INSTANCE.publishOnLivingEntityDeadEvent(livingEntity.getWorld(), livingEntity, damageSource);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

"depends": {
"fabricloader": ">=0.14.9",
"minecraft": "1.19.x"
"minecraft": "1.20.x"
},
"suggests": {
"flamingo": "*"
Expand Down

0 comments on commit f1be249

Please sign in to comment.