20w18a
Some checks failed
SorceryCraft/pipeline/head There was a failure building this commit

This commit is contained in:
TheBrokenRail 2020-05-02 14:42:16 -04:00
parent 504a52597d
commit 48fef73096
10 changed files with 95 additions and 58 deletions

4
API.md
View File

@ -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)
[View JavaDoc](https://jenkins.thebrokenrail.com/job/SorceryCraft/job/master/JavaDoc/)

11
Jenkinsfile vendored
View File

@ -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'
]
}
}
}

View File

@ -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')

View File

@ -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

View File

@ -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<CreateSpellCriterion
public CreateSpellCriterion() {
}
@Override
protected Conditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
return new CreateSpellCriterion.Conditions(playerPredicate);
}
@Override
public Identifier getId() {
return ID;
}
public CreateSpellCriterion.Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
return new CreateSpellCriterion.Conditions();
}
public void trigger(ServerPlayerEntity player) {
test(player.getAdvancementTracker(), (conditions) -> true);
test(player, (conditions) -> true);
}
public static class Conditions extends AbstractCriterionConditions {
public Conditions() {
super(ID);
public Conditions(EntityPredicate.Extended player) {
super(ID, player);
}
}
}

View File

@ -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<DiscoverAllSpe
public DiscoverAllSpellsCriterion() {
}
@Override
public Identifier getId() {
return ID;
}
public DiscoverAllSpellsCriterion.Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
return new DiscoverAllSpellsCriterion.Conditions();
@Override
protected DiscoverAllSpellsCriterion.Conditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
return new DiscoverAllSpellsCriterion.Conditions(playerPredicate);
}
public void trigger(ServerPlayerEntity player) {
test(player.getAdvancementTracker(), (conditions) -> {
test(player, (conditions) -> {
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
Map<Identifier, Integer> spells = spellPlayer.getDiscoveredSpells();
Spell[] maxSpells = SpellRegistry.getMaxSpells();
@ -44,8 +47,8 @@ public class DiscoverAllSpellsCriterion extends AbstractCriterion<DiscoverAllSpe
}
public static class Conditions extends AbstractCriterionConditions {
public Conditions() {
super(ID);
public Conditions(EntityPredicate.Extended player) {
super(ID, player);
}
}
}

View File

@ -17,6 +17,7 @@ import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry;
import net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.LiteralText;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
@ -31,7 +32,7 @@ public class SorceryCraftClient implements ClientModInitializer {
GuiRegistry guiRegistry = AutoConfig.getGuiRegistry(ModConfig.class);
guiRegistry.registerAnnotationProvider((s, field, config, defaults, guiRegistryAccess) -> {
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));

View File

@ -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<CastingTableScreenHandler>
}
@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<CastingTableScreenHandler>
}
@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<CastingTableScreenHandler>
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<CastingTableScreenHandler>
}
}
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<CastingTableScreenHandler>
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);
}
}
}

View File

@ -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());
}
}

View File

@ -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 {