Skip to content

Commit

Permalink
updated to 1.19 fully
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Jul 16, 2022
1 parent 7497f8e commit d16294d
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 85 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ You can use `/spells list` at any time to see all the spells, as well as their p
<table align="center">
<tr>
<th><b>Join my Discord</b></th>
<th><b>Join my Patreon!</b></th>
<th><b>Join my Ko-Fi!</b></th>
</tr>
<tr>
<th><a href="https://discord.gg/f5dFYWX"><img src="https://cdn.discordapp.com/attachments/550093973125857290/894993556354240603/discord_logo.png" width="150" height="150" title="Cammie's Corner Discord" alt="Cammie's Corner Discord"></a></th>
<th><a href="https://www.patreon.com/cammies_corner"><img src="https://cdn.discordapp.com/attachments/550093973125857290/894992743263260682/patreon_logo.png" width="150" height="150" title="Cammie's Corner Patreon" alt="Cammie's Corner Patreon"></a></th>
<th><a href="https://discord.gg/f5dFYWX"><img src="https://cammiescorner.dev/images/extras/discord.png" width="150" height="150" title="Cammie's Corner Discord" alt="Cammie's Corner Discord"></a></th>
<th><a href="https://www.ko-fi.com/camellias_"><img src="https://cammiescorner.dev/images/extras/kofi.png" width="150" height="150" title="Cammie's Corner Ko-Fi" alt="Cammie's Corner Ko-Fi"></a></th>
</tr>
</table>
41 changes: 6 additions & 35 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
}
5 changes: 1 addition & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ private Map.Entry<EntityAttribute, EntityAttributeModifier> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
84 changes: 51 additions & 33 deletions src/main/java/dev/cammiescorner/arcanus/core/util/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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) -> {
Expand All @@ -132,25 +150,25 @@ private static ItemEntry.Builder<?> createItemEntry(ItemStack stack) {
return builder;
}

// public static void addStructureProcessors(Registry<StructurePool> 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<StructureProcessor> 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<StructurePool> 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<StructureProcessor> 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);
}
}
}));
}
}
6 changes: 6 additions & 0 deletions src/main/resources/META-INF/arcanus.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -36,8 +38,7 @@
"arcanus:spell_books/arcane_barrier": true
}
}
},
"entity": "this"
}
}
]
}
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,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"
}
}

0 comments on commit d16294d

Please sign in to comment.