This commit is contained in:
parent
504a52597d
commit
48fef73096
4
API.md
4
API.md
@ -4,7 +4,7 @@
|
|||||||
1. Add Dependency to Gradle
|
1. Add Dependency to Gradle
|
||||||
```gradle
|
```gradle
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://maven.thebrokenrail.com' }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
modImplementation 'com.thebrokenrail:sorcerycraft:VERSION'
|
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.
|
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
|
## 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
11
Jenkinsfile
vendored
@ -7,11 +7,20 @@ pipeline {
|
|||||||
stages {
|
stages {
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
steps {
|
steps {
|
||||||
sh './gradlew build'
|
sh './gradlew build javadoc publish'
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
archiveArtifacts artifacts: 'build/libs/*', fingerprint: true
|
archiveArtifacts artifacts: 'build/libs/*', fingerprint: true
|
||||||
|
|
||||||
|
publishHTML target: [
|
||||||
|
allowMissing: false,
|
||||||
|
alwaysLinkToLastBuild: false,
|
||||||
|
keepAll: false,
|
||||||
|
reportDir: 'build/javadoc',
|
||||||
|
reportFiles: 'index.html',
|
||||||
|
reportName: 'JavaDoc'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
build.gradle
18
build.gradle
@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.2.7-SNAPSHOT'
|
id 'fabric-loom' version '0.2.7-SNAPSHOT'
|
||||||
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
id 'com.matthewprenger.cursegradle' version '1.4.0'
|
||||||
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
@ -79,6 +80,23 @@ jar {
|
|||||||
from "LICENSE"
|
from "LICENSE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
artifactId archivesBaseName
|
||||||
|
|
||||||
|
artifact(remapJar) {
|
||||||
|
builtBy remapJar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url '/data/maven'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (project.hasProperty('curseforge.api_key')) {
|
if (project.hasProperty('curseforge.api_key')) {
|
||||||
curseforge {
|
curseforge {
|
||||||
apiKey = project.getProperty('curseforge.api_key')
|
apiKey = project.getProperty('curseforge.api_key')
|
||||||
|
@ -3,10 +3,10 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version = 20w15a
|
minecraft_version = 20w18a
|
||||||
curseforge_id = 365308
|
curseforge_id = 365308
|
||||||
simple_minecraft_version = 1.16-Snapshot
|
simple_minecraft_version = 1.16-Snapshot
|
||||||
yarn_build = 4
|
yarn_build = 13
|
||||||
fabric_loader_version = 0.8.2+build.194
|
fabric_loader_version = 0.8.2+build.194
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
@ -16,7 +16,7 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# 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
|
fabric_api_version = 0.10.1+build.336-1.16
|
||||||
cloth_config_version = 3.2.1-unstable
|
cloth_config_version = 4.0.5-unstable
|
||||||
auto_config_version = 1.2.4
|
auto_config_version = 2.0.1
|
||||||
mod_menu_version = 1.11.1+build.3
|
mod_menu_version = 1.11.2+build.6
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.advancement;
|
package com.thebrokenrail.sorcerycraft.advancement;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
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.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
@ -14,21 +15,23 @@ public class CreateSpellCriterion extends AbstractCriterion<CreateSpellCriterion
|
|||||||
public CreateSpellCriterion() {
|
public CreateSpellCriterion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Conditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||||
|
return new CreateSpellCriterion.Conditions(playerPredicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Identifier getId() {
|
public Identifier getId() {
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateSpellCriterion.Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
|
|
||||||
return new CreateSpellCriterion.Conditions();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void trigger(ServerPlayerEntity player) {
|
public void trigger(ServerPlayerEntity player) {
|
||||||
test(player.getAdvancementTracker(), (conditions) -> true);
|
test(player, (conditions) -> true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Conditions extends AbstractCriterionConditions {
|
public static class Conditions extends AbstractCriterionConditions {
|
||||||
public Conditions() {
|
public Conditions(EntityPredicate.Extended player) {
|
||||||
super(ID);
|
super(ID, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.advancement;
|
package com.thebrokenrail.sorcerycraft.advancement;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
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 com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
import net.minecraft.advancement.criterion.AbstractCriterion;
|
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||||
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
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.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
@ -19,16 +20,18 @@ public class DiscoverAllSpellsCriterion extends AbstractCriterion<DiscoverAllSpe
|
|||||||
public DiscoverAllSpellsCriterion() {
|
public DiscoverAllSpellsCriterion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Identifier getId() {
|
public Identifier getId() {
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscoverAllSpellsCriterion.Conditions conditionsFromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
|
@Override
|
||||||
return new DiscoverAllSpellsCriterion.Conditions();
|
protected DiscoverAllSpellsCriterion.Conditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
|
||||||
|
return new DiscoverAllSpellsCriterion.Conditions(playerPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void trigger(ServerPlayerEntity player) {
|
public void trigger(ServerPlayerEntity player) {
|
||||||
test(player.getAdvancementTracker(), (conditions) -> {
|
test(player, (conditions) -> {
|
||||||
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
|
||||||
Map<Identifier, Integer> spells = spellPlayer.getDiscoveredSpells();
|
Map<Identifier, Integer> spells = spellPlayer.getDiscoveredSpells();
|
||||||
Spell[] maxSpells = SpellRegistry.getMaxSpells();
|
Spell[] maxSpells = SpellRegistry.getMaxSpells();
|
||||||
@ -44,8 +47,8 @@ public class DiscoverAllSpellsCriterion extends AbstractCriterion<DiscoverAllSpe
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Conditions extends AbstractCriterionConditions {
|
public static class Conditions extends AbstractCriterionConditions {
|
||||||
public Conditions() {
|
public Conditions(EntityPredicate.Extended player) {
|
||||||
super(ID);
|
super(ID, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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.api.client.screen.ScreenProviderRegistry;
|
||||||
import net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl;
|
import net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
@ -31,7 +32,7 @@ public class SorceryCraftClient implements ClientModInitializer {
|
|||||||
GuiRegistry guiRegistry = AutoConfig.getGuiRegistry(ModConfig.class);
|
GuiRegistry guiRegistry = AutoConfig.getGuiRegistry(ModConfig.class);
|
||||||
guiRegistry.registerAnnotationProvider((s, field, config, defaults, guiRegistryAccess) -> {
|
guiRegistry.registerAnnotationProvider((s, field, config, defaults, guiRegistryAccess) -> {
|
||||||
ModConfig.UsePercentage bounds = field.getAnnotation(ModConfig.UsePercentage.class);
|
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);
|
}, field -> field.getType() == Double.TYPE || field.getType() == Double.class, ModConfig.UsePercentage.class);
|
||||||
|
|
||||||
EntityRendererRegistry.INSTANCE.register(SorceryCraft.SPELL_ENTITY, (entityRenderDispatcher, context) -> new SpellEntityRenderer(entityRenderDispatcher));
|
EntityRendererRegistry.INSTANCE.register(SorceryCraft.SPELL_ENTITY, (entityRenderDispatcher, context) -> new SpellEntityRenderer(entityRenderDispatcher));
|
||||||
|
@ -11,8 +11,10 @@ import net.fabricmc.api.Environment;
|
|||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
@ -31,13 +33,13 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawForeground(int mouseX, int mouseY) {
|
protected void drawForeground(MatrixStack matrixStack, int i, int j) {
|
||||||
int titleY = backgroundHeight - 94;
|
int titleY = backgroundHeight - 94;
|
||||||
textRenderer.draw(title.asFormattedString(), (float) (49 + this.backgroundWidth / 2 - textRenderer.getStringWidth(title.asFormattedString()) / 2), 6.0F, 4210752);
|
textRenderer.draw(matrixStack, title, (float) (49 + this.backgroundWidth / 2 - textRenderer.getStringWidth(title) / 2), 6.0F, 4210752);
|
||||||
textRenderer.draw(playerInventory.getDisplayName().asFormattedString(), 107.0F, (float) titleY, 4210752);
|
textRenderer.draw(matrixStack, playerInventory.getDisplayName(), 107.0F, (float) titleY, 4210752);
|
||||||
String spells = new TranslatableText("container." + SorceryCraft.NAMESPACE + ".spells").getString();
|
Text spells = new TranslatableText("container." + SorceryCraft.NAMESPACE + ".spells");
|
||||||
textRenderer.draw(spells, (float) (5 - textRenderer.getStringWidth(spells) / 2 + 48), 6.0F, 4210752);
|
textRenderer.draw(matrixStack, spells, (float) (5 - textRenderer.getStringWidth(spells) / 2 + 48), 6.0F, 4210752);
|
||||||
renderXPCost();
|
renderXPCost(matrixStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetIndex() {
|
public void resetIndex() {
|
||||||
@ -46,37 +48,37 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
assert client != null;
|
assert client != null;
|
||||||
client.getTextureManager().bindTexture(TEXTURE);
|
client.getTextureManager().bindTexture(TEXTURE);
|
||||||
int i = (width - backgroundWidth) / 2;
|
int i = (width - backgroundWidth) / 2;
|
||||||
int j = (height - backgroundHeight) / 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
|
@Override
|
||||||
public void render(int mouseX, int mouseY, float delta) {
|
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) {
|
||||||
renderBackground();
|
renderBackground(matrixStack);
|
||||||
super.render(mouseX, mouseY, delta);
|
super.render(matrixStack, mouseX, mouseY, delta);
|
||||||
drawMouseoverTooltip(mouseX, mouseY);
|
drawMouseoverTooltip(matrixStack, mouseX, mouseY);
|
||||||
|
|
||||||
renderScrollbar();
|
renderScrollbar(matrixStack);
|
||||||
renderItems();
|
renderItems();
|
||||||
|
|
||||||
for (WidgetButtonPage button : buttons) {
|
for (WidgetButtonPage button : buttons) {
|
||||||
if (button.isHovered()) {
|
if (button.isHovered()) {
|
||||||
button.renderToolTip(mouseX, mouseY);
|
button.renderToolTip(matrixStack, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
button.visible = button.index < handler.getRecipes().length;
|
button.visible = button.index < handler.getRecipes().length;
|
||||||
if (button.visible) {
|
if (button.visible) {
|
||||||
Spell spell = handler.getRecipes()[button.getIndex() + indexStartOffset];
|
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();
|
Spell[] spells = handler.getRecipes();
|
||||||
assert client != null;
|
assert client != null;
|
||||||
client.getTextureManager().bindTexture(TEXTURE);
|
client.getTextureManager().bindTexture(TEXTURE);
|
||||||
@ -86,9 +88,9 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
|
|
||||||
if (k > 0) {
|
if (k > 0) {
|
||||||
int modifier = (int) (((float) indexStartOffset / k) * (1 + 139 - 27));
|
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 {
|
} 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) {
|
if (handler.getRecipes().length > 0) {
|
||||||
int cost = handler.getRecipes()[selectedIndex].getXPCost();
|
int cost = handler.getRecipes()[selectedIndex].getXPCost();
|
||||||
int color = 8453920;
|
int color = 8453920;
|
||||||
assert client != null;
|
assert client != null;
|
||||||
assert client.player != 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)) {
|
if (!handler.canTakeResult(playerInventory.player)) {
|
||||||
color = 16736352;
|
color = 16736352;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x2 = backgroundWidth - 8;
|
int x2 = backgroundWidth - 8;
|
||||||
int x1 = x2 - textRenderer.getStringWidth(string);
|
int x1 = x2 - textRenderer.getStringWidth(string);
|
||||||
fill(x1, 65, x2, 77, 1325400064);
|
fill(matrixStack, x1, 65, x2, 77, 1325400064);
|
||||||
textRenderer.drawWithShadow(string, (float) x1, 67.0F, color);
|
textRenderer.drawWithShadow(matrixStack, string, (float) x1, 67.0F, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,33 +205,33 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
final int index;
|
final int index;
|
||||||
|
|
||||||
public WidgetButtonPage(int i, int j, int k, PressAction pressAction) {
|
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;
|
index = k;
|
||||||
visible = false;
|
visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
active = (index + CastingTableScreen.this.indexStartOffset) != CastingTableScreen.this.selectedIndex;
|
||||||
super.render(mouseX, mouseY, delta);
|
super.render(matrixStack, mouseX, mouseY, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
return this.index;
|
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) {
|
if (hovered && handler.getRecipes().length > index + indexStartOffset && mouseX > this.x + 65) {
|
||||||
ItemStack itemStack = handler.getRecipes()[index + indexStartOffset].getItemCost();
|
ItemStack itemStack = handler.getRecipes()[index + indexStartOffset].getItemCost();
|
||||||
if (!itemStack.isEmpty()) {
|
if (!itemStack.isEmpty()) {
|
||||||
renderTooltip(itemStack, mouseX, mouseY);
|
renderTooltip(matrixStack, itemStack, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawCenteredString(TextRenderer textRenderer, String str, int centerX, int y, int color) {
|
public void drawCenteredString(MatrixStack matrixStack, TextRenderer textRenderer, String str, int centerX, int y, int color) {
|
||||||
drawString(textRenderer, str, x + 5, y, color);
|
drawString(matrixStack, textRenderer, str, x + 5, y, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package com.thebrokenrail.sorcerycraft.spell.api;
|
|||||||
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
@ -83,8 +83,8 @@ public abstract class Spell {
|
|||||||
* @param level Spell Level
|
* @param level Spell Level
|
||||||
* @return Translated Display Name
|
* @return Translated Display Name
|
||||||
*/
|
*/
|
||||||
public static Text getDefaultTranslation(Identifier id, int level) {
|
public static MutableText getDefaultTranslation(Identifier id, int level) {
|
||||||
Text text = new TranslatableText("spell." + id.getNamespace() + '.' + id.getPath());
|
MutableText text = new TranslatableText("spell." + id.getNamespace() + '.' + id.getPath());
|
||||||
if (level != 0 || SpellRegistry.getMaxLevel(id) != 1) {
|
if (level != 0 || SpellRegistry.getMaxLevel(id) != 1) {
|
||||||
text.append(" ").append(new TranslatableText("enchantment.level." + (level + 1)));
|
text.append(" ").append(new TranslatableText("enchantment.level." + (level + 1)));
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ public abstract class Spell {
|
|||||||
* Get Translated Display Name
|
* Get Translated Display Name
|
||||||
* @return Translated Display Name
|
* @return Translated Display Name
|
||||||
*/
|
*/
|
||||||
public Text getTranslation() {
|
public MutableText getTranslation() {
|
||||||
return getDefaultTranslation(getID(), getLevel());
|
return getDefaultTranslation(getID(), getLevel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import net.minecraft.nbt.ListTag;
|
|||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
@ -85,7 +86,7 @@ public class SpellHelper {
|
|||||||
|
|
||||||
public static Text getTranslatedSpell(Identifier id, int level) {
|
public static Text getTranslatedSpell(Identifier id, int level) {
|
||||||
Spell spell = SpellRegistry.getSpell(id, level);
|
Spell spell = SpellRegistry.getSpell(id, level);
|
||||||
Text text;
|
MutableText text;
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
text = spell.getTranslation();
|
text = spell.getTranslation();
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user