Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
OverlordsIII committed Jun 14, 2024
1 parent b54d092 commit c513954
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 37 deletions.
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

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

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -67,11 +67,11 @@ dependencies {
exclude module: 'fabric-api' // includes bad Fabric API
}

modApi include("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}")
modApi include("org.ladysnake.cardinal-components-api:cardinal-components-base:${project.cca_version}")

modApi include("dev.onyxstudios.cardinal-components-api:cardinal-components-level:${project.cca_version}")
modApi include("org.ladysnake.cardinal-components-api:cardinal-components-level:${project.cca_version}")

modImplementation 'curse.maven:guardvillagers-571503:4942428'
modImplementation 'curse.maven:guardvillagers-571503:5427036'

modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"

Expand All @@ -92,7 +92,7 @@ processResources {

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
21 changes: 10 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.3
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11

#Fabric api
fabric_version=0.92.0+1.20.4
# Fabric API
fabric_version=0.100.1+1.21


# Mod Properties
mod_version = 4.5.4
maven_group = io.github.overlordsiii
archives_base_name=villagernames-1.20.4
archives_base_name=villagernames-1.21

# Dependencies
mod_menu_version=9.0.0
cloth_config_version=13.0.121
cca_version=5.4.0
midnightlib_version=1.5.0-fabric
port_lib_version = 2.1.1127
mod_menu_version=11.0.0-beta.1
cloth_config_version=15.0.127
cca_version=6.1.0
midnightlib_version=1.5.7-fabric
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import dev.onyxstudios.cca.api.v3.component.ComponentKey;
import dev.onyxstudios.cca.api.v3.component.ComponentRegistry;
import dev.onyxstudios.cca.api.v3.level.LevelComponentFactoryRegistry;
import dev.onyxstudios.cca.api.v3.level.LevelComponentInitializer;
import io.github.overlordsiii.villagernames.command.VillagerNameCommand;
import io.github.overlordsiii.villagernames.config.VillagerConfig;
import io.github.overlordsiii.villagernames.integration.cca.IntComponent;
Expand All @@ -21,6 +17,10 @@
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.ladysnake.cca.api.v3.component.ComponentKey;
import org.ladysnake.cca.api.v3.component.ComponentRegistry;
import org.ladysnake.cca.api.v3.level.LevelComponentFactoryRegistry;
import org.ladysnake.cca.api.v3.level.LevelComponentInitializer;

import net.minecraft.entity.mob.AbstractPiglinEntity;
import net.minecraft.entity.mob.RavagerEntity;
Expand All @@ -44,7 +44,7 @@ public class VillagerNames implements ModInitializer, LevelComponentInitializer
public static ConfigManager<VillagerConfig> CONFIG_MANAGER;
public static VillagerConfig CONFIG;
public static final Logger LOGGER = LogManager.getLogger(VillagerNames.class);
public static final ComponentKey<IntComponent> INT_COMPONENT = ComponentRegistry.getOrCreate(new Identifier("villagernames", "intcomponent"), IntComponent.class);
public static final ComponentKey<IntComponent> INT_COMPONENT = ComponentRegistry.getOrCreate(Identifier.of("villagernames", "intcomponent"), IntComponent.class);

public static final Gson GSON = new GsonBuilder()
.setPrettyPrinting()
Expand Down Expand Up @@ -103,8 +103,6 @@ public void onInitialize() {

}



/**
* Called to register component factories for statically declared component types.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.overlordsiii.villagernames.integration.cca;

import dev.onyxstudios.cca.api.v3.component.Component;
import org.ladysnake.cca.api.v3.component.Component;

public interface IntComponent extends Component {
int getValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.overlordsiii.villagernames.integration.cca;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.world.WorldProperties;

public class RavagerCounterComponent implements IntComponent {
Expand All @@ -21,13 +22,14 @@ public void setValue(int value) {
/**
* Reads this component's properties from a {@link NbtCompound}.
*
* @param tag a {@code NbtCompound} on which this component's serializable data has been written
* @param tag a {@code NbtCompound} on which this component's serializable data has been written
* @param registryLookup access to dynamic registry data
* @implNote implementations should not assert that the data written on the tag corresponds to any
* specific scheme, as saved data is susceptible to external tempering, and may come from an earlier
* version.
*/
@Override
public void readFromNbt(NbtCompound tag) {
public void readFromNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) {
if (tag.contains("ravagerValue")) {
this.value = tag.getInt("ravagerValue");
}
Expand All @@ -36,10 +38,11 @@ public void readFromNbt(NbtCompound tag) {
/**
* Writes this component's properties to a {@link NbtCompound}.
*
* @param tag a {@code NbtCompound} on which to write this component's serializable data
* @param tag a {@code NbtCompound} on which to write this component's serializable data
* @param registryLookup access to dynamic registry data
*/
@Override
public void writeToNbt(NbtCompound tag) {
public void writeToNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) {
tag.putInt("ravagerValue", this.value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ private static Text getFullNameAsText(GuardEntity entity, boolean configFormatti
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected ZombieEntityMixin(EntityType<? extends HostileEntity> entityType, Worl
super(entityType, world);
}

@Inject(method = "onKilledOther", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/ZombieVillagerEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/entity/EntityData;"), locals = LocalCapture.CAPTURE_FAILHARD)
@Inject(method = "onKilledOther", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/ZombieVillagerEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;)Lnet/minecraft/entity/EntityData;"), locals = LocalCapture.CAPTURE_FAILHARD)
private void addZombieNameTag(ServerWorld world, LivingEntity other, CallbackInfoReturnable<Boolean> cir, boolean bl, VillagerEntity villagerEntity, ZombieVillagerEntity zombieVillagerEntity){
VillagerUtil.addZombieVillagerName(villagerEntity, zombieVillagerEntity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public ZombieVillagerEntityMixin(EntityType<? extends ZombieEntity> entityType,
super(entityType, world);
}

@Inject(method = "finishConversion", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/VillagerEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/entity/EntityData;"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void returnOriginalVillagerName(ServerWorld world, CallbackInfo ci, VillagerEntity villagerEntity, EquipmentSlot[] var3, int var4, int var5){
@Inject(method = "finishConversion", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/VillagerEntity;initialize(Lnet/minecraft/world/ServerWorldAccess;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnReason;Lnet/minecraft/entity/EntityData;)Lnet/minecraft/entity/EntityData;"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void returnOriginalVillagerName(ServerWorld world, CallbackInfo ci, VillagerEntity villagerEntity) {
VillagerUtil.removeZombieVillagerName(villagerEntity, (ZombieVillagerEntity)(Object)this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import net.minecraft.entity.mob.PathAwareEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.world.World;

@Mixin(GuardEntity.class)
public abstract class GuardEntityMixin extends PathAwareEntity implements DefaultNameManager {


private String firstName;

private String lastName;
Expand Down Expand Up @@ -125,4 +127,6 @@ private void deserializeData(NbtCompound tag, CallbackInfo ci) {
this.playerName = tag.getString("playerName");
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import net.minecraft.component.DataComponentTypes;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
Expand All @@ -26,7 +27,7 @@ public NameTagItemMixin(Settings settings) {

@Inject(method = "useOnEntity", at = @At("HEAD"))
private void checkPlayerName(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
if (stack.hasCustomName() && !(entity instanceof PlayerEntity)) {
if (stack.get(DataComponentTypes.CUSTOM_NAME) != null && !(entity instanceof PlayerEntity)) {
if (!user.getWorld().isClient && entity.isAlive()) {
String stackName = stack.getName().getString();

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"depends": {
"fabricloader": ">=0.10.3+build.211",
"fabric-api": "*",
"minecraft": "1.20.x"
"minecraft": "1.21.x"
},
"custom": {
"cardinal-components": [
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/villagernames.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"VillagerEntityMixin",
"ZombieEntityMixin",
"ZombieVillagerEntityMixin",
"guard.GuardEntityMixin",
"illager.PatrolEntityMixin",
"illager.RaiderEntityMixin",
"illager.RaidMixin",
"item.NameTagItemMixin",
"item.SpawnEggItemMixin",
"guard.GuardEntityMixin"
],
"client": [
"SelectionListEntryMixin"
Expand Down

0 comments on commit c513954

Please sign in to comment.