Merge branch 'master' into fix-glass

This commit is contained in:
Moses Miller authored and GitHub committed 2026-05-02 22:26:39 -07:00
commit a115d91fa4
9 files changed
+225 -72

No files matched your search

@@ -39,24 +39,17 @@ public class SmelteryGui extends ActiveContainerGui {
private final int columns;
private final int smelterySize;
public static final int maxRows = 8;
private int fuelDisplayTick = 0;
public SmelteryGui(InventoryPlayer inventoryplayer, SmelteryLogic smeltery, World world, int x, int y, int z) {
super((ActiveContainer) smeltery.getGuiContainer(inventoryplayer, world, x, y, z));
logic = smeltery;
smelterySize = smeltery.getBlockCapacity();
smeltery.updateFuelDisplay();
columns = ((SmelteryContainer) this.inventorySlots).columns;
xSize = 254 + (columns - 3) * 22; // Adjust for column count
}
@Override
public void initGui() {
super.initGui();
if (logic != null) logic.updateFuelDisplay();
}
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
// the smeltery changed. we close the screen because updating the changes in all containers would be way too
@@ -66,11 +59,13 @@ public class SmelteryGui extends ActiveContainerGui {
return;
}
if (fuelDisplayTick++ % 5 == 0) logic.updateFuelDisplay();
updateScrollbar(mouseX, mouseY);
super.drawScreen(mouseX, mouseY, par3);
updateScrollbar(mouseX, mouseY, par3);
}
protected void updateScrollbar(int mouseX, int mouseY, float par3) {
protected void updateScrollbar(int mouseX, int mouseY) {
if (smelterySize > columns * maxRows) {
boolean mouseDown = Mouse.isButtonDown(0);
int lefto = this.guiLeft;
@@ -144,13 +139,12 @@ public class SmelteryGui extends ActiveContainerGui {
}
// lava/fuel
if (logic.fuelGague > 0) {
int fuel = logic.getScaledFuelGague(52);
if (fuel > 0) {
int leftX = cornerX + 117;
int topY = (cornerY + 68) - logic.getScaledFuelGague(52);
int sizeX = 12;
int sizeY = logic.getScaledFuelGague(52);
if (mouseX >= leftX && mouseX <= leftX + sizeX && mouseY >= topY && mouseY < topY + sizeY) {
drawFluidStackTooltip(getFuelTooltip(logic.getFuel()), mouseX - cornerX + 36, mouseY - cornerY);
int topY = (cornerY + 68) - fuel;
if (mouseX >= leftX && mouseX <= leftX + 12 && mouseY >= topY && mouseY < topY + fuel) {
drawFluidStackTooltip(getFuelTooltip(), mouseX - cornerX + 36, mouseY - cornerY);
}
}
}
@@ -170,11 +164,11 @@ public class SmelteryGui extends ActiveContainerGui {
// Fuel - Lava
this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
if (logic.fuelGague > 0) {
int fuel = logic.getScaledFuelGague(52);
if (fuel > 0) {
FluidStack fuelStack = logic.getFuel();
IIcon lavaIcon = fuelStack.getFluid().getStillIcon();
if (lavaIcon == null) lavaIcon = Blocks.lava.getIcon(0, 0);
int fuel = logic.getScaledFuelGague(52);
int count = 0;
while (fuel > 0) {
int size = Math.min(fuel, 16);
@@ -281,7 +275,7 @@ public class SmelteryGui extends ActiveContainerGui {
int slotTemp = logic.getTempForSlot(iter + slotPos * columns) - 20;
int maxTemp = logic.getMeltingPointForSlot(iter + slotPos * columns) - 20;
if (slotTemp > 0 && maxTemp > 0) {
int size = 16 * slotTemp / maxTemp + 1;
int size = Math.max(1, Math.min(16, 16 * slotTemp / maxTemp));
drawTexturedModalRect(
cornerX - xleft + (iter % columns * 22),
cornerY + 8 + (iter / columns * 18) + 16 - size,
@@ -346,10 +340,10 @@ public class SmelteryGui extends ActiveContainerGui {
this.zLevel = 0;
}
private List<String> getFuelTooltip(FluidStack liquid) {
private List<String> getFuelTooltip() {
ArrayList<String> list = new ArrayList<>();
list.add("\u00A7f" + StatCollector.translateToLocal("gui.smeltery.fuel"));
list.add("mB: " + liquid.amount);
list.add(logic.fuelAmount + "/" + logic.fuelCapacity + " mB");
return list;
}
@@ -29,7 +29,7 @@ public class LavaTankLogic extends MultiServantLogic implements IFluidHandler {
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
int amount = tank.fill(resource, doFill);
if (amount > 0 && doFill) {
renderOffset += resource.amount;
renderOffset += amount;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, this.getBlockType());
}
@@ -41,7 +41,7 @@ public class LavaTankLogic extends MultiServantLogic implements IFluidHandler {
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
FluidStack amount = tank.drain(maxDrain, doDrain);
if (amount != null && doDrain) {
renderOffset = -maxDrain;
renderOffset = -amount.amount;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, this.getBlockType());
}
@@ -2,6 +2,7 @@ package tconstruct.smeltery.logic;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
@@ -75,9 +76,10 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
public int useTime;
public int fuelGague;
public int fuelAmount;
public int fuelCapacity;
protected boolean inUse;
protected ArrayList<CoordTuple> lavaTanks;
protected List<CoordTuple> lavaTanks;
protected ArrayList<CoordTuple> drains;
protected CoordTuple activeLavaTank;
@@ -96,7 +98,7 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
public SmelteryLogic() {
super(0);
lavaTanks = new ArrayList<>();
lavaTanks = Collections.synchronizedList(new ArrayList<>());
drains = new ArrayList<>();
activeTemps = new int[0];
meltingTemps = new int[0];
@@ -262,8 +264,9 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
}
public int getScaledFuelGague(int scale) {
int ret = (fuelGague * scale) / 52;
if (ret < 1) ret = 1;
if (fuelCapacity <= 0) return 0;
int ret = (int) ((float) fuelAmount * (float) scale / (float) fuelCapacity);
if (ret < 1 && fuelAmount > 0) ret = 1;
return ret;
}
@@ -502,22 +505,40 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
}
public void updateFuelDisplay() {
// ensure our active tank is valid
verifyFuelTank();
if (activeLavaTank == null) {
fuelAmount = 0;
fuelGague = 0;
return;
int totalAmount = 0;
int totalCapacity = 0;
FluidStack fuelType = null;
synchronized (lavaTanks) {
Iterator<CoordTuple> iter = lavaTanks.iterator();
while (iter.hasNext()) {
CoordTuple coord = iter.next();
if (!worldObj.blockExists(coord.x, coord.y, coord.z)) continue;
TileEntity te = worldObj.getTileEntity(coord.x, coord.y, coord.z);
if (!(te instanceof IFluidHandler)) {
iter.remove();
continue;
}
FluidTankInfo[] info = ((IFluidHandler) te).getTankInfo(ForgeDirection.DOWN);
if (info.length <= 0) continue;
totalCapacity += info[0].capacity;
if (info[0].fluid != null && info[0].fluid.amount > 0) {
if (fuelType == null) {
fuelType = info[0].fluid;
totalAmount += info[0].fluid.amount;
} else if (fuelType.isFluidEqual(info[0].fluid)) {
totalAmount += info[0].fluid.amount;
}
}
}
}
// checks are all done before in verifyFuelTank. Don't do this without checks!
IFluidHandler tankContainer = (IFluidHandler) worldObj
.getTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z);
FluidTankInfo[] info = tankContainer.getTankInfo(ForgeDirection.DOWN);
int capacity = info[0].capacity;
fuelAmount = info[0].fluid.amount;
fuelGague = (int) ((float) fuelAmount * 52f / (float) capacity);
fuelAmount = totalAmount;
fuelCapacity = totalCapacity;
}
// actually is updateFuel.
@@ -566,24 +587,26 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
// our tank got derped or is empty. time to look for a new one!
activeLavaTank = null;
for (CoordTuple tank : lavaTanks) {
// does the tank still exist?
if (!worldObj.blockExists(tank.x, tank.y, tank.z)) continue;
synchronized (lavaTanks) {
for (CoordTuple tank : lavaTanks) {
// does the tank still exist?
if (!worldObj.blockExists(tank.x, tank.y, tank.z)) continue;
// yes, it does, but is it a tank?
TileEntity tankContainer = worldObj.getTileEntity(tank.x, tank.y, tank.z);
if (!(tankContainer instanceof IFluidHandler)) continue;
// yes, it does, but is it a tank?
TileEntity tankContainer = worldObj.getTileEntity(tank.x, tank.y, tank.z);
if (!(tankContainer instanceof IFluidHandler)) continue;
// yes it is, but does it contain a liquid?
FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN);
if (info.length <= 0 || info[0].fluid == null || info[0].fluid.amount <= 0) continue;
// yes it is, but does it contain a liquid?
FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN);
if (info.length <= 0 || info[0].fluid == null || info[0].fluid.amount <= 0) continue;
// is it also a smeltery fuel?
if (!Smeltery.isSmelteryFuel(info[0].fluid.getFluid())) continue;
// is it also a smeltery fuel?
if (!Smeltery.isSmelteryFuel(info[0].fluid.getFluid())) continue;
// we found a tank! :)
activeLavaTank = tank;
return;
// we found a tank! :)
activeLavaTank = tank;
return;
}
}
// possibly assign default empty tank here (tanks.get(0)) so we don't have a null activeLavaTank if all are
@@ -592,15 +615,35 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
@SideOnly(Side.CLIENT)
public FluidStack getFuel() {
if (activeLavaTank == null)
// sane default
FluidStack combined = null;
synchronized (lavaTanks) {
Iterator<CoordTuple> iter = lavaTanks.iterator();
while (iter.hasNext()) {
CoordTuple coord = iter.next();
if (!worldObj.blockExists(coord.x, coord.y, coord.z)) continue;
TileEntity te = worldObj.getTileEntity(coord.x, coord.y, coord.z);
if (!(te instanceof IFluidHandler)) {
iter.remove();
continue;
}
FluidTankInfo[] info = ((IFluidHandler) te).getTankInfo(ForgeDirection.DOWN);
if (info.length <= 0 || info[0].fluid == null || info[0].fluid.amount <= 0) continue;
if (combined == null) {
combined = info[0].fluid.copy();
} else if (combined.isFluidEqual(info[0].fluid)) {
combined.amount += info[0].fluid.amount;
}
}
}
if (combined == null) {
return new FluidStack(FluidRegistry.LAVA, 0);
TileEntity tankContainer = worldObj.getTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z);
if (tankContainer instanceof IFluidHandler)
return ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN)[0].fluid;
return new FluidStack(FluidRegistry.LAVA, 0);
}
return combined;
}
public FluidStack getResultFor(ItemStack stack) {
@@ -736,17 +779,19 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
if (tempValidStructure) {
// try to derive temperature from fueltank
activeLavaTank = null;
for (CoordTuple tank : lavaTanks) {
TileEntity tankContainer = worldObj.getTileEntity(tank.x, tank.y, tank.z);
if (!(tankContainer instanceof IFluidHandler)) continue;
synchronized (lavaTanks) {
for (CoordTuple tank : lavaTanks) {
TileEntity tankContainer = worldObj.getTileEntity(tank.x, tank.y, tank.z);
if (!(tankContainer instanceof IFluidHandler)) continue;
FluidStack liquid = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN)[0].fluid;
if (liquid == null) continue;
if (!Smeltery.isSmelteryFuel(liquid.getFluid())) continue;
FluidStack liquid = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN)[0].fluid;
if (liquid == null) continue;
if (!Smeltery.isSmelteryFuel(liquid.getFluid())) continue;
internalTemp = Smeltery.getFuelPower(liquid.getFluid());
activeLavaTank = tank;
break;
internalTemp = Smeltery.getFuelPower(liquid.getFluid());
activeLavaTank = tank;
break;
}
}
// no tank with fuel. we reserve the first found one
@@ -4,6 +4,8 @@ import java.awt.Rectangle;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -21,12 +23,14 @@ import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import cpw.mods.fml.common.Optional;
import tconstruct.TConstruct;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.modifier.IModifyable;
import tconstruct.library.tools.ToolMaterial;
import tconstruct.library.util.HarvestLevels;
import tconstruct.tools.logic.CraftingStationLogic;
import tconstruct.util.network.CraftingStationDumpPacket;
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
@@ -121,6 +125,45 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
this.craftingTextLeft = this.craftingLeft - this.guiLeft;
this.descTextLeft = this.descLeft - this.guiLeft;
// Add dump button if chest is connected
this.buttonList.clear();
if (logic.chest != null) {
int bothOffset = 0;
if (logic.slotCount > 54) bothOffset += 12;
bothOffset += 122;
this.buttonList.add(new GuiButtonDump(0, this.guiLeft + bothOffset + 161, this.guiTop + 5));
}
}
@Override
protected void actionPerformed(GuiButton button) {
if (button.id == 0 && logic.chest != null) {
TConstruct.packetPipeline.sendToServer(new CraftingStationDumpPacket());
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
drawDumpButtonTooltip(mouseX, mouseY);
}
private void drawDumpButtonTooltip(int mouseX, int mouseY) {
for (Object obj : this.buttonList) {
if (obj instanceof GuiButtonDump) {
GuiButtonDump button = (GuiButtonDump) obj;
if (button.func_146115_a()) {
this.drawHoveringText(
Collections.singletonList(
StatCollector.translateToLocal("craftingstation.dump_button.tooltip")),
mouseX,
mouseY,
this.fontRendererObj);
return;
}
}
}
}
@Override
@@ -523,6 +566,27 @@ public class CraftingStationGui extends GuiContainer implements INEIGuiHandler {
}
}
private static class GuiButtonDump extends GuiButton {
private GuiButtonDump(int id, int x, int y) {
super(id, x, y, 10, 10, "");
}
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition
&& mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(CraftingStationGui.icons);
int v = this.field_146123_n ? 213 : 223;
drawTexturedModalRect(this.xPosition, this.yPosition, 0, v, this.width, this.height);
}
}
}
/*
* Hide the deprecated stuff at the bottom
*/
@@ -434,4 +434,21 @@ public class CraftingStationContainer extends Container {
return didSomething;
}
// Dump crafting grid to connected chests
public void dumpCraftingGrid() {
if (logic.slotCount == 0) return;
// 46 is the first slot index of the attached inventory
for (int i = 0; i < 9; i++) {
ItemStack stack = craftMatrix.getStackInSlot(i);
if (stack != null && stack.stackSize > 0) {
if (mergeItemStack(stack, 46, 46 + logic.slotCount, false)) {
craftMatrix.setInventorySlotContents(i, stack.stackSize > 0 ? stack : null);
}
}
}
this.onCraftMatrixChanged(this.craftMatrix);
}
}
@@ -0,0 +1,30 @@
package tconstruct.util.network;
import net.minecraft.entity.player.EntityPlayer;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import mantle.common.network.AbstractPacket;
import tconstruct.tools.inventory.CraftingStationContainer;
public class CraftingStationDumpPacket extends AbstractPacket {
public CraftingStationDumpPacket() {}
@Override
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {}
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {}
@Override
public void handleClientSide(EntityPlayer player) {}
@Override
public void handleServerSide(EntityPlayer player) {
if (player.openContainer instanceof CraftingStationContainer) {
CraftingStationContainer container = (CraftingStationContainer) player.openContainer;
container.dumpCraftingGrid();
}
}
}
@@ -135,6 +135,8 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
registerPacket(MovementUpdatePacket.class);
registerPacket(ArmourGuiSyncPacket.class);
registerPacket(CraftingStationDumpPacket.class);
}
// Method to call from FMLPostInitializationEvent
@@ -859,6 +859,7 @@ smeltery.brick.tooltip2=(Safe for decoration)
smeltery.castingtable.tooltip=Basic Smeltery equipment
smeltery.castingfaucet.tooltip=This Smeltery is leaking
smeltery.castingbasin.tooltip=For the ambitious Smeltery
craftingstation.dump_button.tooltip=Dump grid content to linked inventory
#Dear translators, only translate these lines if the jokes are applicable in your language.
grout.tooltip=I am Grout!
frypankill.tooltip=This poor animal met its demise with a loud *bang*
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB