mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Fix patchouli integration components
This commit is contained in:
1 parent
26103c00ae
commit
f430df39f2
4 files changed
+41
-35
No files matched your search
@@ -8,9 +8,13 @@
|
||||
*/
|
||||
package vazkii.botania.client.patchouli.component;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.patchouli.api.IComponentRenderContext;
|
||||
@@ -42,11 +46,10 @@ public class ManaComponent implements ICustomComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(IComponentRenderContext context, float pticks, int mouseX, int mouseY) {
|
||||
FontRenderer font = context.getFont();
|
||||
|
||||
String manaUsage = I18n.format("botaniamisc.manaUsage");
|
||||
font.drawString(manaUsage, x + 102 / 2 - font.getStringWidth(manaUsage) / 2, y, 0x66000000);
|
||||
public void render(MatrixStack ms, IComponentRenderContext context, float pticks, int mouseX, int mouseY) {
|
||||
FontRenderer font = Minecraft.getInstance().fontRenderer;
|
||||
ITextComponent manaUsage = new TranslationTextComponent("botaniamisc.manaUsage").func_230530_a_(context.getFont());
|
||||
font.func_238422_b_(ms, manaUsage, x + 102 / 2 - font.func_238414_a_(manaUsage) / 2, y, 0x66000000);
|
||||
|
||||
int ratio = 10;
|
||||
if (context.isAreaHovered(mouseX, mouseY, x, y - 2, 102, 5 + 20)) {
|
||||
@@ -55,8 +58,8 @@ public class ManaComponent implements ICustomComponent {
|
||||
HUDHandler.renderManaBar(ms, x, y + 10, 0x0000FF, 0.75F,
|
||||
manaValues[(context.getTicksInBook() / 20) % manaValues.length], TilePool.MAX_MANA / ratio);
|
||||
|
||||
String ratioString = I18n.format("botaniamisc.ratio", ratio);
|
||||
font.drawString(ratioString, x + 102 / 2 - font.getStringWidth(ratioString) / 2, y + 15, 0x99000000);
|
||||
ITextComponent ratioString = new TranslationTextComponent("botaniamisc.ratio", ratio).func_230530_a_(context.getFont());
|
||||
font.func_238422_b_(ms, ratioString, x + 102 / 2 - font.func_238414_a_(ratioString) / 2, y + 15, 0x99000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-7
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package vazkii.botania.client.patchouli.component;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
@@ -39,7 +40,7 @@ abstract class RotatingItemListComponentBase implements ICustomComponent {
|
||||
protected abstract List<Ingredient> makeIngredients();
|
||||
|
||||
@Override
|
||||
public void render(IComponentRenderContext context, float pticks, int mouseX, int mouseY) {
|
||||
public void render(MatrixStack ms, IComponentRenderContext context, float pticks, int mouseX, int mouseY) {
|
||||
int degreePerInput = (int) (360F / ingredients.size());
|
||||
int ticksElapsed = context.getTicksInBook();
|
||||
|
||||
@@ -50,13 +51,13 @@ abstract class RotatingItemListComponentBase implements ICustomComponent {
|
||||
: 0;
|
||||
|
||||
for (Ingredient input : ingredients) {
|
||||
renderIngredientAtAngle(context, currentDegree, input, mouseX, mouseY);
|
||||
renderIngredientAtAngle(ms, context, currentDegree, input, mouseX, mouseY);
|
||||
|
||||
currentDegree += degreePerInput;
|
||||
}
|
||||
}
|
||||
|
||||
private void renderIngredientAtAngle(IComponentRenderContext context, float angle, Ingredient ingredient, int mouseX, int mouseY) {
|
||||
private void renderIngredientAtAngle(MatrixStack ms, IComponentRenderContext context, float angle, Ingredient ingredient, int mouseX, int mouseY) {
|
||||
if (ingredient.hasNoMatchingItems()) {
|
||||
return;
|
||||
}
|
||||
@@ -66,10 +67,10 @@ abstract class RotatingItemListComponentBase implements ICustomComponent {
|
||||
double xPos = x + Math.cos(angle * Math.PI / 180D) * radius + 32;
|
||||
double yPos = y + Math.sin(angle * Math.PI / 180D) * radius + 32;
|
||||
|
||||
RenderSystem.pushMatrix(); // This translation makes it not stuttery. It does not affect the tooltip as that is drawn separately later.
|
||||
RenderSystem.translated(xPos - (int) xPos, yPos - (int) yPos, 0);
|
||||
context.renderIngredient((int) xPos, (int) yPos, mouseX, mouseY, ingredient);
|
||||
RenderSystem.popMatrix();
|
||||
ms.push(); // This translation makes it not stuttery. It does not affect the tooltip as that is drawn separately later.
|
||||
ms.translate(xPos - (int) xPos, yPos - (int) yPos, 0);
|
||||
context.renderIngredient(ms, (int) xPos, (int) yPos, mouseX, mouseY, ingredient);
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package vazkii.botania.client.patchouli.component;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -43,32 +44,32 @@ public class TerraPlateComponent implements ICustomComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(IComponentRenderContext context, float pticks, int mouseX, int mouseY) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef(0F, 0F, -10.0f);
|
||||
context.renderItemStack(x + 13, y + 1, mouseX, mouseY, cornerBlock);
|
||||
public void render(MatrixStack ms, IComponentRenderContext context, float pticks, int mouseX, int mouseY) {
|
||||
ms.push();
|
||||
ms.translate(0, 0, -10);
|
||||
context.renderItemStack(ms, x + 13, y + 1, mouseX, mouseY, cornerBlock);
|
||||
|
||||
RenderSystem.translatef(0F, 0F, 5F);
|
||||
context.renderItemStack(x + 20, y + 4, mouseX, mouseY, middleBlock);
|
||||
context.renderItemStack(x + 7, y + 4, mouseX, mouseY, middleBlock);
|
||||
ms.translate(0F, 0F, 5F);
|
||||
context.renderItemStack(ms, x + 20, y + 4, mouseX, mouseY, middleBlock);
|
||||
context.renderItemStack(ms, x + 7, y + 4, mouseX, mouseY, middleBlock);
|
||||
|
||||
RenderSystem.translatef(0F, 0F, 5F);
|
||||
context.renderItemStack(x + 13, y + 8, mouseX, mouseY, cornerBlock);
|
||||
context.renderItemStack(x + 27, y + 8, mouseX, mouseY, centerBlock);
|
||||
context.renderItemStack(x, y + 8, mouseX, mouseY, cornerBlock);
|
||||
ms.translate(0F, 0F, 5F);
|
||||
context.renderItemStack(ms, x + 13, y + 8, mouseX, mouseY, cornerBlock);
|
||||
context.renderItemStack(ms, x + 27, y + 8, mouseX, mouseY, centerBlock);
|
||||
context.renderItemStack(ms, x, y + 8, mouseX, mouseY, cornerBlock);
|
||||
|
||||
RenderSystem.translatef(0F, 0F, 5F);
|
||||
context.renderItemStack(x + 7, y + 12, mouseX, mouseY, middleBlock);
|
||||
context.renderItemStack(x + 20, y + 12, mouseX, mouseY, middleBlock);
|
||||
ms.translate(0F, 0F, 5F);
|
||||
context.renderItemStack(ms, x + 7, y + 12, mouseX, mouseY, middleBlock);
|
||||
context.renderItemStack(ms, x + 20, y + 12, mouseX, mouseY, middleBlock);
|
||||
|
||||
RenderSystem.translatef(0F, 0F, 5F);
|
||||
context.renderItemStack(x + 14, y + 15, mouseX, mouseY, cornerBlock);
|
||||
ms.translate(0F, 0F, 5F);
|
||||
context.renderItemStack(ms, x + 14, y + 15, mouseX, mouseY, cornerBlock);
|
||||
|
||||
RenderSystem.translatef(0F, 0F, 5F);
|
||||
context.renderItemStack(x + 13, y, mouseX, mouseY, plateBlock);
|
||||
RenderSystem.translatef(0F, 0F, -10.0f);
|
||||
ms.translate(0F, 0F, 5F);
|
||||
context.renderItemStack(ms, x + 13, y, mouseX, mouseY, plateBlock);
|
||||
ms.translate(0F, 0F, -10.0f);
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.KeybindTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
@@ -92,7 +93,7 @@ public class ManaInfusionProcessor implements IComponentProcessor {
|
||||
return I18n.format("botaniamisc.drop") + TextFormatting.BOLD + " (?)";
|
||||
case "dropTip0":
|
||||
case "dropTip1": {
|
||||
String drop = new KeybindTextComponent("key.drop").func_240699_a_(TextFormatting.GREEN).getFormattedText();
|
||||
ITextComponent drop = new KeybindTextComponent("key.drop").func_240699_a_(TextFormatting.GREEN);
|
||||
return I18n.format("botaniamisc.dropTip" + key.substring(7), drop);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user