Merge branch 'master' into master

This commit is contained in:
Martin Robertz authored and GitHub committed 2026-03-03 07:41:57 +01:00
commit 9cdaf0f5ae
7 files changed
+114 -25

No files matched your search

@@ -45,6 +45,9 @@ public abstract class AbstractTab extends GuiButton {
mc.renderEngine.bindTexture(this.texture);
this.drawTexturedModalRect(this.xPosition, yPos, xOffset * 28, yTexPos, 28, ySize);
if (this.enabled) {
this.drawUnselectedTabDecorations(mc, xOffset, yTexPos, yPos, ySize);
}
RenderHelper.enableGUIStandardItemLighting();
this.zLevel = 100.0F;
@@ -69,6 +72,9 @@ public abstract class AbstractTab extends GuiButton {
}
}
protected void drawUnselectedTabDecorations(Minecraft mc, int textureXOffset, int textureYStart, int tabTopY,
int tabHeight) {}
@Override
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
boolean inWindow = this.enabled && this.visible
@@ -1,5 +1,6 @@
package tconstruct.client.tabs;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -18,4 +19,18 @@ public class InventoryTabVanilla extends AbstractTab {
public boolean shouldAddToList() {
return true;
}
@Override
protected void drawUnselectedTabDecorations(Minecraft mc, int textureXOffset, int textureYStart, int tabTopY,
int tabHeight) {
int textureX = textureXOffset * 28;
int sourceY = 29;
int targetY = tabTopY + tabHeight;
// Extend the bottom-left corner on the unselected vanilla tab.
// 0,29 -> two extra pixels down; 1,29 -> one extra pixel down.
this.drawTexturedModalRect(this.xPosition, targetY, textureX, sourceY, 1, 1);
this.drawTexturedModalRect(this.xPosition, targetY + 1, textureX, sourceY, 1, 1);
this.drawTexturedModalRect(this.xPosition + 1, targetY, textureX + 1, sourceY, 1, 1);
}
}
@@ -28,6 +28,23 @@ import tconstruct.util.config.PHConstruct;
public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
private static final int DefaultTextColor = 0x404040;
private static final String ColorKey = "tconstruct.nei.color.";
private static int getLocalizedColor(String colorName, int fallbackColor) {
String colorKey = ColorKey + colorName;
String colorValue = StatCollector.translateToLocal(colorKey);
if (colorKey.equals(colorValue)) {
return fallbackColor;
}
try {
return Integer.decode(colorValue.trim());
} catch (NumberFormatException ignored) {
return fallbackColor;
}
}
public class CachedToolMaterialsRecipe extends CachedBaseRecipe {
public List<PositionedStack> toolParts;
@@ -99,38 +116,43 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
public void drawExtras(int recipe) {
CachedToolMaterialsRecipe crecipe = (CachedToolMaterialsRecipe) this.arecipes.get(recipe);
if (crecipe.material != null) {
GuiDraw.drawString(EnumChatFormatting.BOLD + crecipe.material.localizedName(), 35, 10, 0x404040, false);
GuiDraw.drawString(
EnumChatFormatting.BOLD + crecipe.material.localizedName(),
35,
10,
getLocalizedColor("materialName", DefaultTextColor),
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter4") + crecipe.material.durability,
35,
20,
0x404040,
getLocalizedColor("materialDurability", DefaultTextColor),
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter5") + crecipe.material.handleModifier + "x",
35,
30,
0x404040,
getLocalizedColor("materialHandleModifier1", DefaultTextColor),
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter11")
+ Math.round(crecipe.material.durability * crecipe.material.handleModifier),
35,
40,
0x404040,
getLocalizedColor("materialHandleModifier2", DefaultTextColor),
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter6") + crecipe.material.miningspeed / 100F,
35,
50,
0x404040,
getLocalizedColor("materialMiningSpeed", DefaultTextColor),
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter7")
+ HarvestLevels.getHarvestLevelName(crecipe.material.harvestLevel),
35,
60,
0x404040,
getLocalizedColor("materialHarvestLevel", DefaultTextColor),
false);
String heart = crecipe.material.attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8")
: StatCollector.translateToLocal("gui.partcrafter9");
@@ -139,19 +161,24 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
StatCollector.translateToLocal("gui.partcrafter10") + crecipe.material.attack / 2 + heart,
35,
70,
0x404040,
getLocalizedColor("materialAttack1", DefaultTextColor),
false);
} else {
GuiDraw.drawString(
StatCollector.translateToLocal("gui.partcrafter10") + crecipe.material.attack / 2F + heart,
35,
70,
0x404040,
getLocalizedColor("materialAttack2", DefaultTextColor),
false);
}
int abilityY = 85;
if (crecipe.material.reinforced > 0) {
GuiDraw.drawString(getReinforcedString(crecipe.material.reinforced), 35, 85, 0x404040, false);
GuiDraw.drawString(
getReinforcedString(crecipe.material.reinforced),
35,
85,
getLocalizedColor("materialReinforced", DefaultTextColor),
false);
abilityY += 10;
}
String ability = crecipe.material.ability();
@@ -161,10 +188,15 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
ability + " (" + Math.abs(crecipe.material.stonebound) + ")",
35,
abilityY,
0x404040,
getLocalizedColor("materialStonebound", DefaultTextColor),
false);
} else {
GuiDraw.drawString(ability, 35, abilityY, 0x404040, false);
GuiDraw.drawString(
ability,
35,
abilityY,
getLocalizedColor("materialAbility", DefaultTextColor),
false);
}
}
}
@@ -175,20 +207,20 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
EnumChatFormatting.BOLD + StatCollector.translateToLocal("tconstruct.nei.projectilematerials"),
35,
10,
0x404040,
getLocalizedColor("materialBow", DefaultTextColor),
false);
GuiDraw.drawString(
StatCollector.translateToLocal("gui.toolstation6") + crecipe.bowMaterial.drawspeed,
x,
y,
0x404040,
getLocalizedColor("materialBowDrawSpeed", DefaultTextColor),
false);
y += 10;
GuiDraw.drawString(
StatCollector.translateToLocal("gui.toolstation7") + crecipe.bowMaterial.flightSpeedMax,
x,
y,
0x404040,
getLocalizedColor("materialBowFlightSpeedMax", DefaultTextColor),
false);
}
if (crecipe.arrowMaterial != null) {
@@ -198,14 +230,14 @@ public class RecipeHandlerToolMaterials extends RecipeHandlerBase {
StatCollector.translateToLocal("gui.toolstation8") + crecipe.arrowMaterial.mass,
x,
y,
0x404040,
getLocalizedColor("materialArrowMass", DefaultTextColor),
false);
y += 10;
GuiDraw.drawString(
StatCollector.translateToLocal("gui.toolstation22") + crecipe.arrowMaterial.breakChance,
x,
y,
0x404040,
getLocalizedColor("materialArrowBreakChance", DefaultTextColor),
false);
}
}
@@ -164,6 +164,8 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
}
void drawToolStats(ItemStack stack) {
if (stack == null) return;
if (stack.getItem() instanceof IModifyable) ToolStationGuiHelper.drawToolStats(stack, descTextLeft + 10, 0);
int matID = PatternBuilder.instance.getPartID(stack);
@@ -112,7 +112,7 @@ public class ToolStationGui extends GuiContainer implements INEIGuiHandler {
iconX = element.iconsX;
iconY = element.iconsY;
title = "§n" + StatCollector.translateToLocal(element.title);
body = StatCollector.translateToLocal(element.body).replaceAll("\\\\n", "\n");
body = StatCollector.translateToLocal(element.body).replace("\\n", "\n");
}
protected void setSlotType(int type) {
@@ -15,6 +15,8 @@ public class PatternShaperContainer extends Container {
public StencilTableLogic logic;
public static ItemStack BLANK_PATTERN = new ItemStack(TinkerTools.blankPattern, 1, 0);
public PatternShaperContainer(InventoryPlayer inventoryplayer, StencilTableLogic shaper) {
logic = shaper;
this.addSlotToContainer(new Slot(shaper, 0, 48, 35));
@@ -58,13 +60,36 @@ public class PatternShaperContainer extends Container {
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
return null;
/*
* ItemStack stack = null; Slot slot = (Slot)this.inventorySlots.get(slotID); if (slot != null &&
* slot.getHasStack()) { ItemStack slotStack = slot.getStack(); stack = slotStack.copy(); if (slotID <
* logic.getSizeInventory()) { if (!this.mergeItemStack(slotStack, logic.getSizeInventory(),
* this.inventorySlots.size(), true)) { return null; } } else if (!this.mergeItemStack(slotStack, 0,
* logic.getSizeInventory()-1, false)) { return null; } if (slotStack.stackSize == 0) {
* slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } } return stack;
*/
}
@Override
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
if (mode == 1 && clickedButton == 0) {
// is it shift left click?
Slot slot = (Slot) this.inventorySlots.get(slotId);
if (slot != null && slot.getHasStack()) {
ItemStack stack = slot.getStack();
if (slotId >= logic.getSizeInventory() && stack.isItemEqual(BLANK_PATTERN)) {
// clicked in player inventory
if (!this.mergeItemStack(stack, 0, 1, false)) {
return null;
}
} else if (slotId < logic.getSizeInventory()) {
// pattern slot
if (!this.mergeItemStack(stack, 2, this.inventorySlots.size(), false)) {
return null;
} else if (slotId == 1) {
// special for shift click the output pattern
this.inventorySlots.get(0).decrStackSize(1);
}
}
if (stack.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
}
}
return super.slotClick(slotId, clickedButton, mode, player);
}
}
@@ -198,4 +198,13 @@ public class ToolStationContainer extends ActiveContainer {
return failedToMerge;
}
@Override
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
ItemStack output = super.slotClick(slotId, clickedButton, mode, player);
if (slotId > 0) {
this.logic.buildTool(this.logic.toolName);
}
return output;
}
}