From 48fef73096a8c7f9d0cf2cb640071f1bd5d99cdc Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sat, 2 May 2020 14:42:16 -0400 Subject: [PATCH] 20w18a --- API.md | 4 +- Jenkinsfile | 11 +++- build.gradle | 18 ++++++ gradle.properties | 12 ++-- .../advancement/CreateSpellCriterion.java | 19 +++--- .../DiscoverAllSpellsCriterion.java | 15 +++-- .../client/SorceryCraftClient.java | 3 +- .../client/gui/CastingTableScreen.java | 60 ++++++++++--------- .../sorcerycraft/spell/api/Spell.java | 8 +-- .../sorcerycraft/spell/util/SpellHelper.java | 3 +- 10 files changed, 95 insertions(+), 58 deletions(-) diff --git a/API.md b/API.md index ac0b58e..d26871a 100644 --- a/API.md +++ b/API.md @@ -4,7 +4,7 @@ 1. Add Dependency to Gradle ```gradle repositories { - maven { url 'https://jitpack.io' } + maven { url 'https://maven.thebrokenrail.com' } } dependencies { modImplementation 'com.thebrokenrail:sorcerycraft:VERSION' @@ -112,4 +112,4 @@ APIs are only guaranteed to be stable in the ```com.thebrokenrail.sorcerycraft.a Spell levels are 0-indexed, if you have a level 1 Example Spell, ```Spell.getLevel()``` wil return 0, and if it is level 2 ```Spell.getLevel()``` wil return 1, ```Spell.getMaxSpell()``` should be the maximum-acceptable value of ```Spell.getLevel() + 1```, so if Example Spell has levels 1-2, ```Spell.getMaxLevel()``` should return 2. ## JavaDoc -[View JavaDoc](https://javadoc.jitpack.io/com/thebrokenrail/sorcerycraft/latest/javadoc/index.html) \ No newline at end of file +[View JavaDoc](https://jenkins.thebrokenrail.com/job/SorceryCraft/job/master/JavaDoc/) \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 1673e44..464e1db 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,11 +7,20 @@ pipeline { stages { stage('Build') { steps { - sh './gradlew build' + sh './gradlew build javadoc publish' } post { success { archiveArtifacts artifacts: 'build/libs/*', fingerprint: true + + publishHTML target: [ + allowMissing: false, + alwaysLinkToLastBuild: false, + keepAll: false, + reportDir: 'build/javadoc', + reportFiles: 'index.html', + reportName: 'JavaDoc' + ] } } } diff --git a/build.gradle b/build.gradle index e119ef9..e07efa8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { id 'fabric-loom' version '0.2.7-SNAPSHOT' id 'com.matthewprenger.cursegradle' version '1.4.0' + id 'maven-publish' } compileJava { @@ -79,6 +80,23 @@ jar { from "LICENSE" } +publishing { + publications { + mavenJava(MavenPublication) { + artifactId archivesBaseName + + artifact(remapJar) { + builtBy remapJar + } + } + } + repositories { + maven { + url '/data/maven' + } + } +} + if (project.hasProperty('curseforge.api_key')) { curseforge { apiKey = project.getProperty('curseforge.api_key') diff --git a/gradle.properties b/gradle.properties index d0bf431..c484109 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.jvmargs = -Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version = 20w15a + minecraft_version = 20w18a curseforge_id = 365308 simple_minecraft_version = 1.16-Snapshot - yarn_build = 4 + yarn_build = 13 fabric_loader_version = 0.8.2+build.194 # Mod Properties @@ -16,7 +16,7 @@ org.gradle.jvmargs = -Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_api_version = 0.5.9+build.319-1.16 - cloth_config_version = 3.2.1-unstable - auto_config_version = 1.2.4 - mod_menu_version = 1.11.1+build.3 + fabric_api_version = 0.10.1+build.336-1.16 + cloth_config_version = 4.0.5-unstable + auto_config_version = 2.0.1 + mod_menu_version = 1.11.2+build.6 diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/advancement/CreateSpellCriterion.java b/src/main/java/com/thebrokenrail/sorcerycraft/advancement/CreateSpellCriterion.java index 4c50f9a..8d60ca1 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/advancement/CreateSpellCriterion.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/advancement/CreateSpellCriterion.java @@ -1,10 +1,11 @@ package com.thebrokenrail.sorcerycraft.advancement; -import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.thebrokenrail.sorcerycraft.SorceryCraft; import net.minecraft.advancement.criterion.AbstractCriterion; import net.minecraft.advancement.criterion.AbstractCriterionConditions; +import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer; +import net.minecraft.predicate.entity.EntityPredicate; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; @@ -14,21 +15,23 @@ public class CreateSpellCriterion extends AbstractCriterion true); + test(player, (conditions) -> true); } public static class Conditions extends AbstractCriterionConditions { - public Conditions() { - super(ID); + public Conditions(EntityPredicate.Extended player) { + super(ID, player); } } } \ No newline at end of file diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/advancement/DiscoverAllSpellsCriterion.java b/src/main/java/com/thebrokenrail/sorcerycraft/advancement/DiscoverAllSpellsCriterion.java index c1e7ded..2c0b043 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/advancement/DiscoverAllSpellsCriterion.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/advancement/DiscoverAllSpellsCriterion.java @@ -1,6 +1,5 @@ package com.thebrokenrail.sorcerycraft.advancement; -import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.thebrokenrail.sorcerycraft.SorceryCraft; import com.thebrokenrail.sorcerycraft.spell.api.Spell; @@ -8,6 +7,8 @@ import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry; import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity; import net.minecraft.advancement.criterion.AbstractCriterion; import net.minecraft.advancement.criterion.AbstractCriterionConditions; +import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer; +import net.minecraft.predicate.entity.EntityPredicate; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; @@ -19,16 +20,18 @@ public class DiscoverAllSpellsCriterion extends AbstractCriterion { + test(player, (conditions) -> { SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player; Map spells = spellPlayer.getDiscoveredSpells(); Spell[] maxSpells = SpellRegistry.getMaxSpells(); @@ -44,8 +47,8 @@ public class DiscoverAllSpellsCriterion extends AbstractCriterion { ModConfig.UsePercentage bounds = field.getAnnotation(ModConfig.UsePercentage.class); - return Collections.singletonList(ConfigEntryBuilder.create().startIntSlider(s, MathHelper.ceil(Utils.getUnsafely(field, config, 0.0) * 100), MathHelper.ceil(bounds.min() * 100), MathHelper.ceil(bounds.max() * 100)).setDefaultValue(() -> MathHelper.ceil((double) Utils.getUnsafely(field, defaults) * 100)).setSaveConsumer((newValue) -> Utils.setUnsafely(field, config, newValue / 100d)).setTextGetter(integer -> String.format("%d%%", integer)).build()); + return Collections.singletonList(ConfigEntryBuilder.create().startIntSlider(new LiteralText(s), MathHelper.ceil(Utils.getUnsafely(field, config, 0.0) * 100), MathHelper.ceil(bounds.min() * 100), MathHelper.ceil(bounds.max() * 100)).setDefaultValue(() -> MathHelper.ceil((double) Utils.getUnsafely(field, defaults) * 100)).setSaveConsumer((newValue) -> Utils.setUnsafely(field, config, newValue / 100d)).setTextGetter(integer -> new LiteralText(String.format("%d%%", integer))).build()); }, field -> field.getType() == Double.TYPE || field.getType() == Double.class, ModConfig.UsePercentage.class); EntityRendererRegistry.INSTANCE.register(SorceryCraft.SPELL_ENTITY, (entityRenderDispatcher, context) -> new SpellEntityRenderer(entityRenderDispatcher)); diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/client/gui/CastingTableScreen.java b/src/main/java/com/thebrokenrail/sorcerycraft/client/gui/CastingTableScreen.java index 26f12ba..95f6b34 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/client/gui/CastingTableScreen.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/client/gui/CastingTableScreen.java @@ -11,8 +11,10 @@ import net.fabricmc.api.Environment; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; @@ -31,13 +33,13 @@ public class CastingTableScreen extends HandledScreen } @Override - protected void drawForeground(int mouseX, int mouseY) { + protected void drawForeground(MatrixStack matrixStack, int i, int j) { int titleY = backgroundHeight - 94; - textRenderer.draw(title.asFormattedString(), (float) (49 + this.backgroundWidth / 2 - textRenderer.getStringWidth(title.asFormattedString()) / 2), 6.0F, 4210752); - textRenderer.draw(playerInventory.getDisplayName().asFormattedString(), 107.0F, (float) titleY, 4210752); - String spells = new TranslatableText("container." + SorceryCraft.NAMESPACE + ".spells").getString(); - textRenderer.draw(spells, (float) (5 - textRenderer.getStringWidth(spells) / 2 + 48), 6.0F, 4210752); - renderXPCost(); + textRenderer.draw(matrixStack, title, (float) (49 + this.backgroundWidth / 2 - textRenderer.getStringWidth(title) / 2), 6.0F, 4210752); + textRenderer.draw(matrixStack, playerInventory.getDisplayName(), 107.0F, (float) titleY, 4210752); + Text spells = new TranslatableText("container." + SorceryCraft.NAMESPACE + ".spells"); + textRenderer.draw(matrixStack, spells, (float) (5 - textRenderer.getStringWidth(spells) / 2 + 48), 6.0F, 4210752); + renderXPCost(matrixStack); } public void resetIndex() { @@ -46,37 +48,37 @@ public class CastingTableScreen extends HandledScreen } @Override - protected void drawBackground(float delta, int mouseX, int mouseY) { + protected void drawBackground(MatrixStack matrixStack, float delta, int mouseX, int mouseY) { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); assert client != null; client.getTextureManager().bindTexture(TEXTURE); int i = (width - backgroundWidth) / 2; int j = (height - backgroundHeight) / 2; - drawTexture(i, j, getZOffset(), 0.0F, 0.0F, backgroundWidth, backgroundHeight, 256, 512); + drawTexture(matrixStack, i, j, getZOffset(), 0.0F, 0.0F, backgroundWidth, backgroundHeight, 256, 512); } @Override - public void render(int mouseX, int mouseY, float delta) { - renderBackground(); - super.render(mouseX, mouseY, delta); - drawMouseoverTooltip(mouseX, mouseY); + public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) { + renderBackground(matrixStack); + super.render(matrixStack, mouseX, mouseY, delta); + drawMouseoverTooltip(matrixStack, mouseX, mouseY); - renderScrollbar(); + renderScrollbar(matrixStack); renderItems(); for (WidgetButtonPage button : buttons) { if (button.isHovered()) { - button.renderToolTip(mouseX, mouseY); + button.renderToolTip(matrixStack, mouseX, mouseY); } button.visible = button.index < handler.getRecipes().length; if (button.visible) { Spell spell = handler.getRecipes()[button.getIndex() + indexStartOffset]; - button.setMessage(SpellHelper.getTranslatedSpell(spell.getID(), spell.getLevel()).getString()); + button.setMessage(SpellHelper.getTranslatedSpell(spell.getID(), spell.getLevel())); } } } - private void renderScrollbar() { + private void renderScrollbar(MatrixStack matrixStack) { Spell[] spells = handler.getRecipes(); assert client != null; client.getTextureManager().bindTexture(TEXTURE); @@ -86,9 +88,9 @@ public class CastingTableScreen extends HandledScreen if (k > 0) { int modifier = (int) (((float) indexStartOffset / k) * (1 + 139 - 27)); - drawTexture(i + 94, j + 18 + modifier, getZOffset(), 0.0F, 199.0F, 6, 27, 256, 512); + drawTexture(matrixStack, i + 94, j + 18 + modifier, getZOffset(), 0.0F, 199.0F, 6, 27, 256, 512); } else { - drawTexture(i + 94, j + 18, getZOffset(), 6.0F, 199.0F, 6, 27, 256, 512); + drawTexture(matrixStack, i + 94, j + 18, getZOffset(), 6.0F, 199.0F, 6, 27, 256, 512); } } @@ -112,21 +114,21 @@ public class CastingTableScreen extends HandledScreen } } - private void renderXPCost() { + private void renderXPCost(MatrixStack matrixStack) { if (handler.getRecipes().length > 0) { int cost = handler.getRecipes()[selectedIndex].getXPCost(); int color = 8453920; assert client != null; assert client.player != null; - String string = new TranslatableText("container.repair.cost", cost).getString(); + Text string = new TranslatableText("container.repair.cost", cost); if (!handler.canTakeResult(playerInventory.player)) { color = 16736352; } int x2 = backgroundWidth - 8; int x1 = x2 - textRenderer.getStringWidth(string); - fill(x1, 65, x2, 77, 1325400064); - textRenderer.drawWithShadow(string, (float) x1, 67.0F, color); + fill(matrixStack, x1, 65, x2, 77, 1325400064); + textRenderer.drawWithShadow(matrixStack, string, (float) x1, 67.0F, color); } } @@ -203,33 +205,33 @@ public class CastingTableScreen extends HandledScreen final int index; public WidgetButtonPage(int i, int j, int k, PressAction pressAction) { - super(i, j, 89, 20, "", pressAction); + super(i, j, 89, 20, new LiteralText(""), pressAction); index = k; visible = false; } @Override - public void render(int mouseX, int mouseY, float delta) { + public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) { active = (index + CastingTableScreen.this.indexStartOffset) != CastingTableScreen.this.selectedIndex; - super.render(mouseX, mouseY, delta); + super.render(matrixStack, mouseX, mouseY, delta); } public int getIndex() { return this.index; } - public void renderToolTip(int mouseX, int mouseY) { + public void renderToolTip(MatrixStack matrixStack, int mouseX, int mouseY) { if (hovered && handler.getRecipes().length > index + indexStartOffset && mouseX > this.x + 65) { ItemStack itemStack = handler.getRecipes()[index + indexStartOffset].getItemCost(); if (!itemStack.isEmpty()) { - renderTooltip(itemStack, mouseX, mouseY); + renderTooltip(matrixStack, itemStack, mouseX, mouseY); } } } @Override - public void drawCenteredString(TextRenderer textRenderer, String str, int centerX, int y, int color) { - drawString(textRenderer, str, x + 5, y, color); + public void drawCenteredString(MatrixStack matrixStack, TextRenderer textRenderer, String str, int centerX, int y, int color) { + drawString(matrixStack, textRenderer, str, x + 5, y, color); } } } diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/api/Spell.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/api/Spell.java index 117ba7f..bfc4622 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/api/Spell.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/api/Spell.java @@ -3,7 +3,7 @@ package com.thebrokenrail.sorcerycraft.spell.api; import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; -import net.minecraft.text.Text; +import net.minecraft.text.MutableText; import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.util.hit.BlockHitResult; @@ -83,8 +83,8 @@ public abstract class Spell { * @param level Spell Level * @return Translated Display Name */ - public static Text getDefaultTranslation(Identifier id, int level) { - Text text = new TranslatableText("spell." + id.getNamespace() + '.' + id.getPath()); + public static MutableText getDefaultTranslation(Identifier id, int level) { + MutableText text = new TranslatableText("spell." + id.getNamespace() + '.' + id.getPath()); if (level != 0 || SpellRegistry.getMaxLevel(id) != 1) { text.append(" ").append(new TranslatableText("enchantment.level." + (level + 1))); } @@ -95,7 +95,7 @@ public abstract class Spell { * Get Translated Display Name * @return Translated Display Name */ - public Text getTranslation() { + public MutableText getTranslation() { return getDefaultTranslation(getID(), getLevel()); } } diff --git a/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/SpellHelper.java b/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/SpellHelper.java index 484c5c1..32ca298 100644 --- a/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/SpellHelper.java +++ b/src/main/java/com/thebrokenrail/sorcerycraft/spell/util/SpellHelper.java @@ -10,6 +10,7 @@ import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.LiteralText; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; @@ -85,7 +86,7 @@ public class SpellHelper { public static Text getTranslatedSpell(Identifier id, int level) { Spell spell = SpellRegistry.getSpell(id, level); - Text text; + MutableText text; if (spell != null) { text = spell.getTranslation(); } else {