From d16294d448586d77ed7fe9967093d68119f7563a Mon Sep 17 00:00:00 2001 From: CammiePone Date: Sat, 16 Jul 2022 03:46:48 -0400 Subject: [PATCH] updated to 1.19 fully --- LICENSE | 2 +- README.md | 6 +- build.gradle | 41 ++------- gradle.properties | 5 +- .../arcanus/core/mixin/ItemStackMixin.java | 4 +- .../arcanus/core/mixin/PlayerEntityMixin.java | 2 +- .../arcanus/core/util/EventHandler.java | 84 +++++++++++-------- .../resources/META-INF/arcanus.accesswidener | 6 ++ .../advancements/spell_books/all_spells.json | 7 +- src/main/resources/fabric.mod.json | 6 +- 10 files changed, 78 insertions(+), 85 deletions(-) diff --git a/LICENSE b/LICENSE index 628205a..7eaf66c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2021 Cammie +Copyright (C) 2022 Cammie Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, and/or merge copies of the diff --git a/README.md b/README.md index 6757858..412e516 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,10 @@ You can use `/spells list` at any time to see all the spells, as well as their p - + - - + +
Join my DiscordJoin my Patreon!Join my Ko-Fi!
Cammie's Corner DiscordCammie's Corner PatreonCammie's Corner DiscordCammie's Corner Ko-Fi
diff --git a/build.gradle b/build.gradle index 47dd4ed..e53ea40 100644 --- a/build.gradle +++ b/build.gradle @@ -1,24 +1,15 @@ -import com.modrinth.minotaur.TaskModrinthUpload - plugins { id 'fabric-loom' version '0.12.+' id 'maven-publish' - id "com.modrinth.minotaur" version "1.1.0" } sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 -def ENV = System.getenv() -def buildTime = ENV.BUILD_TIME ?: new Date().format('yyyyMMddHHmmss') - archivesBaseName = project.archives_base_name +version = project.mod_version group = project.maven_group -boolean isPreviewBuild = !ENV.TAG || ENV.TAG.matches(".+-.+") -def buildNumber = !ENV.TAG ? ("${ENV.BUILD_NUMBER ? "build.${ENV.BUILD_NUMBER}" : buildTime}-${project.minecraft_version}") : "" -version = (ENV.TAG ?: "development") + ((isPreviewBuild && !ENV.TAG) ? "+${buildNumber}" : "") - repositories { maven { url "https://maven.shedaniel.me" } maven { url "https://maven.terraformersmc.com" } @@ -72,15 +63,14 @@ jar { from "LICENSE" } -artifacts { - archives(remapJar) - archives(sourcesJar) -} - +// configure the maven publication publishing { publications { mavenJava(MavenPublication) { - artifact(remapJar) + // add all the jars that should be included when publishing to maven + artifact(remapJar) { + builtBy remapJar + } artifact(sourcesJar) { builtBy remapSourcesJar } @@ -93,22 +83,3 @@ publishing { // mavenLocal() } } - -task publishToModrinth(type: TaskModrinthUpload, dependsOn: assemble) { - if (ENV.MODRINTH_TOKEN) { - token = ENV.MODRINTH_TOKEN - } - projectId = project.modrinth_id - uploadFile = remapJar - versionNumber = ENV.TAG ?: version - versionName = versionNumber // need this here because the Modrinth API doesn't do that by default - releaseType = isPreviewBuild ? ((ENV.TAG && ENV.TAG.contains("-beta")) ? "beta" : "alpha") : "release" - "${project.modrinth_game_versions}".split(",").each { - addGameVersion(it) - } - addLoader("fabric") -} - -if (ENV.MODRINTH_TOKEN) { - tasks.publish.dependsOn(publishToModrinth) -} diff --git a/gradle.properties b/gradle.properties index ea6d4e7..1451a62 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,13 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G -# Modrinth Shenanigans -modrinth_id=zgaWtmrV -modrinth_game_versions=1.19 - # Fabric Properties minecraft_version=1.19 yarn_mappings=1.19+build.4 loader_version=0.14.8 # Mod Properties +mod_version=1.30 maven_group=dev.cammiescorner archives_base_name=arcanus diff --git a/src/main/java/dev/cammiescorner/arcanus/core/mixin/ItemStackMixin.java b/src/main/java/dev/cammiescorner/arcanus/core/mixin/ItemStackMixin.java index c54bd1b..38a8796 100644 --- a/src/main/java/dev/cammiescorner/arcanus/core/mixin/ItemStackMixin.java +++ b/src/main/java/dev/cammiescorner/arcanus/core/mixin/ItemStackMixin.java @@ -27,12 +27,12 @@ private Map.Entry captureEntry(Map.Ent return entry; } - @ModifyArg(method = "getTooltip", slice = @Slice(from = @At(value = "CONSTANT", args = "doubleValue=0.0", ordinal = 0)), at = @At(value = "INVOKE", target = "Lnet/minecraft/text/TranslatableText;formatted(Lnet/minecraft/util/Formatting;)Lnet/minecraft/text/MutableText;", ordinal = 0)) + @ModifyArg(method = "getTooltip", slice = @Slice(from = @At(value = "CONSTANT", args = "doubleValue=0.0", ordinal = 0)), at = @At(value = "INVOKE", target = "Lnet/minecraft/text/MutableText;formatted(Lnet/minecraft/util/Formatting;)Lnet/minecraft/text/MutableText;", ordinal = 0)) private Formatting changePositiveFormatting(Formatting value) { return affectCurrentAttribute ? Formatting.RED : value; } - @ModifyArg(method = "getTooltip", slice = @Slice(from = @At(value = "CONSTANT", args = "doubleValue=0.0", ordinal = 1)), at = @At(value = "INVOKE", target = "Lnet/minecraft/text/TranslatableText;formatted(Lnet/minecraft/util/Formatting;)Lnet/minecraft/text/MutableText;", ordinal = 0)) + @ModifyArg(method = "getTooltip", slice = @Slice(from = @At(value = "CONSTANT", args = "doubleValue=0.0", ordinal = 1)), at = @At(value = "INVOKE", target = "Lnet/minecraft/text/MutableText;formatted(Lnet/minecraft/util/Formatting;)Lnet/minecraft/text/MutableText;", ordinal = 0)) private Formatting changeNegativeFormatting(Formatting value) { return affectCurrentAttribute ? Formatting.BLUE : value; } diff --git a/src/main/java/dev/cammiescorner/arcanus/core/mixin/PlayerEntityMixin.java b/src/main/java/dev/cammiescorner/arcanus/core/mixin/PlayerEntityMixin.java index 43b150d..85e193a 100644 --- a/src/main/java/dev/cammiescorner/arcanus/core/mixin/PlayerEntityMixin.java +++ b/src/main/java/dev/cammiescorner/arcanus/core/mixin/PlayerEntityMixin.java @@ -108,7 +108,7 @@ public void tick(CallbackInfo info) { if(manaCooldown != 0 && getMana() < getMaxMana() - getBurnout() && world.getTime() % manaCooldown == 0) addMana(1); - if(burnoutCooldown != 0 && getBurnout() > 0 && hungerManager.getFoodLevel() > 0 && world.getTime() % burnoutCooldown == 0) { + if(burnoutCooldown != 0 && getBurnout() > 0 && world.getTime() % burnoutCooldown == 0) { addBurnout(-1); addExhaustion(5F); } diff --git a/src/main/java/dev/cammiescorner/arcanus/core/util/EventHandler.java b/src/main/java/dev/cammiescorner/arcanus/core/util/EventHandler.java index 892846d..a7f277a 100644 --- a/src/main/java/dev/cammiescorner/arcanus/core/util/EventHandler.java +++ b/src/main/java/dev/cammiescorner/arcanus/core/util/EventHandler.java @@ -3,18 +3,36 @@ import com.mojang.blaze3d.systems.RenderSystem; import dev.cammiescorner.arcanus.Arcanus; import dev.cammiescorner.arcanus.common.items.WandItem; +import dev.cammiescorner.arcanus.common.structure.processor.BookshelfReplacerStructureProcessor; +import dev.cammiescorner.arcanus.common.structure.processor.LecternStructureProcessor; import dev.cammiescorner.arcanus.core.registry.ModCommands; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.fabricmc.fabric.api.loot.v2.LootTableEvents; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.condition.RandomChanceLootCondition; import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.loot.provider.number.ConstantLootNumberProvider; +import net.minecraft.structure.pool.SinglePoolElement; +import net.minecraft.structure.pool.StructurePool; +import net.minecraft.structure.processor.StructureProcessor; +import net.minecraft.structure.processor.StructureProcessorList; import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.RegistryEntry; + +import java.util.ArrayList; +import java.util.List; public class EventHandler { private static final Identifier HUD_ELEMENTS = new Identifier(Arcanus.MOD_ID, "textures/gui/hud_elements.png"); @@ -98,20 +116,20 @@ public static void clientEvents() { public static void commonEvents() { //-----Server Starting Callback-----// -// ServerLifecycleEvents.SERVER_STARTING.register(server -> EventHandler.addStructureProcessors(server.getRegistryManager().get(Registry.STRUCTURE_POOL_KEY))); + ServerLifecycleEvents.SERVER_STARTING.register(server -> EventHandler.addStructureProcessors(server.getRegistryManager().get(Registry.STRUCTURE_POOL_KEY))); //-----Loot Table Callback-----// -// LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> { -// if(Arcanus.getConfig().strongholdsHaveBooks && STRONGHOLD_LIBRARY_LOOT_TABLE.equals(id) && !FabricLoader.getInstance().isModLoaded("betterstrongholds")) { -// FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(4)).withCondition(RandomChanceLootCondition.builder(0.5F).build()).withEntry(createItemEntry(new ItemStack(Items.WRITTEN_BOOK)).build()); -// supplier.withPool(poolBuilder.build()); -// } -// -// if(Arcanus.getConfig().ruinedPortalsHaveBooks && RUINED_PORTAL_LOOT_TABLE.equals(id)) { -// FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).withCondition(RandomChanceLootCondition.builder(0.1F).build()).withEntry(createItemEntry(new ItemStack(Items.WRITTEN_BOOK)).build()); -// supplier.withPool(poolBuilder.build()); -// } -// }); + LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, tableSource) -> { + if(Arcanus.getConfig().strongholdsHaveBooks && STRONGHOLD_LIBRARY_LOOT_TABLE.equals(id) && !FabricLoader.getInstance().isModLoaded("betterstrongholds")) { + LootPool.Builder poolBuilder = LootPool.builder().rolls(ConstantLootNumberProvider.create(4)).conditionally(RandomChanceLootCondition.builder(0.5F).build()).with(createItemEntry(new ItemStack(Items.WRITTEN_BOOK)).build()); + tableBuilder.pool(poolBuilder); + } + + if(Arcanus.getConfig().ruinedPortalsHaveBooks && RUINED_PORTAL_LOOT_TABLE.equals(id)) { + LootPool.Builder poolBuilder = LootPool.builder().rolls(ConstantLootNumberProvider.create(1)).conditionally(RandomChanceLootCondition.builder(0.1F).build()).with(createItemEntry(new ItemStack(Items.WRITTEN_BOOK)).build()); + tableBuilder.pool(poolBuilder); + } + }); //-----Copy Player Data Callback-----// ServerPlayerEvents.COPY_FROM.register((oldPlayer, newPlayer, alive) -> { @@ -132,25 +150,25 @@ private static ItemEntry.Builder createItemEntry(ItemStack stack) { return builder; } -// public static void addStructureProcessors(Registry templatePoolRegistry) { -// templatePoolRegistry.forEach(pool -> pool.elements.forEach(element -> { -// if(element instanceof SinglePoolElement singleElement && singleElement.location.left().isPresent()) { -// String currentElement = singleElement.location.left().get().toString(); -// -// if(Arcanus.getConfig().structuresWithBookshelves.contains(currentElement) || Arcanus.getConfig().structuresWithLecterns.contains(currentElement)) { -// StructureProcessorList originalProcessorList = singleElement.processors.value(); -// List mutableProcessorList = new ArrayList<>(originalProcessorList.getList()); -// -// if(Arcanus.getConfig().doLecternProcessor) -// mutableProcessorList.add(LecternStructureProcessor.INSTANCE); -// if(Arcanus.getConfig().doBookshelfProcessor) -// mutableProcessorList.add(BookshelfReplacerStructureProcessor.INSTANCE); -// -// StructureProcessorList newProcessorList = new StructureProcessorList(mutableProcessorList); -// -// singleElement.processors = RegistryEntry.of(newProcessorList); -// } -// } -// })); -// } + public static void addStructureProcessors(Registry templatePoolRegistry) { + templatePoolRegistry.forEach(pool -> pool.elements.forEach(element -> { + if(element instanceof SinglePoolElement singleElement && singleElement.location.left().isPresent()) { + String currentElement = singleElement.location.left().get().toString(); + + if(Arcanus.getConfig().structuresWithBookshelves.contains(currentElement) || Arcanus.getConfig().structuresWithLecterns.contains(currentElement)) { + StructureProcessorList originalProcessorList = singleElement.processors.value(); + List mutableProcessorList = new ArrayList<>(originalProcessorList.getList()); + + if(Arcanus.getConfig().doLecternProcessor) + mutableProcessorList.add(LecternStructureProcessor.INSTANCE); + if(Arcanus.getConfig().doBookshelfProcessor) + mutableProcessorList.add(BookshelfReplacerStructureProcessor.INSTANCE); + + StructureProcessorList newProcessorList = new StructureProcessorList(mutableProcessorList); + + singleElement.processors = RegistryEntry.of(newProcessorList); + } + } + })); + } } diff --git a/src/main/resources/META-INF/arcanus.accesswidener b/src/main/resources/META-INF/arcanus.accesswidener index 5835f50..66b0a03 100644 --- a/src/main/resources/META-INF/arcanus.accesswidener +++ b/src/main/resources/META-INF/arcanus.accesswidener @@ -6,6 +6,12 @@ accessible method net/minecraft/block/FallingBlock configureFallingBlockEntity ( accessible method net/minecraft/entity/projectile/PersistentProjectileEntity fall ()V +accessible field net/minecraft/structure/pool/StructurePool elements Lit/unimi/dsi/fastutil/objects/ObjectArrayList; + +accessible field net/minecraft/structure/pool/SinglePoolElement processors Lnet/minecraft/util/registry/RegistryEntry; +mutable field net/minecraft/structure/pool/SinglePoolElement processors Lnet/minecraft/util/registry/RegistryEntry; +accessible field net/minecraft/structure/pool/SinglePoolElement location Lcom/mojang/datafixers/util/Either; + accessible method net/minecraft/entity/damage/DamageSource setBypassesArmor ()Lnet/minecraft/entity/damage/DamageSource; accessible method net/minecraft/entity/damage/DamageSource setFallingBlock ()Lnet/minecraft/entity/damage/DamageSource; accessible method net/minecraft/entity/damage/DamageSource setOutOfWorld ()Lnet/minecraft/entity/damage/DamageSource; diff --git a/src/main/resources/data/arcanus/advancements/spell_books/all_spells.json b/src/main/resources/data/arcanus/advancements/spell_books/all_spells.json index 3153645..afe5a42 100644 --- a/src/main/resources/data/arcanus/advancements/spell_books/all_spells.json +++ b/src/main/resources/data/arcanus/advancements/spell_books/all_spells.json @@ -22,8 +22,10 @@ "player": [ { "condition": "minecraft:entity_properties", + "entity": "this", "predicate": { - "player": { + "type_specific": { + "type": "player", "advancements": { "arcanus:wand": true, "arcanus:spell_books/lunge": true, @@ -36,8 +38,7 @@ "arcanus:spell_books/arcane_barrier": true } } - }, - "entity": "this" + } } ] } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7644c27..a562d7b 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,10 +30,10 @@ ], "accessWidener": "META-INF/arcanus.accesswidener", "depends": { - "fabricloader": ">=0.12.5", + "fabricloader": ">=0.14.8", "fabric": "*", - "minecraft": "~1.18.2", - "cloth-config2": ">=6.0.39", + "minecraft": "1.19.x", + "cloth-config2": ">=7.0.72", "java": ">=17" } }