Rebrand as BCx-modern, a 1.7.10 port of BCx
Position this mod as a port of BCx from the Minecraft 1.2.5 era. - Rename the mod to BCx-modern (modid bcxmodern) and the package to net.kanawo.bcxmodern; the main class is now BCxModern and takes its version from Tags.VERSION. - Move assets to assets/bcxmodern and rename the lang key and EMC save data to match. - Fill in mcmod.info (description, author agomizi1cm, credits, dependencies) and the LICENSE copyright holder. - Add a README. - Remove template leftovers: CODEOWNERS, LICENSE-template, the greeting Config, template comments, empty event handlers and the commented-out NEI dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ecde802cdb
commit
28b1841c2a
27 files changed
+150
-194
No files matched your search
@@ -0,0 +1,252 @@
|
||||
package net.kanawo.bcxmodern.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.kanawo.bcxmodern.BCxModern;
|
||||
import net.kanawo.bcxmodern.tile.TileEMCBuilder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.builders.gui.SlotBuilderRequirement;
|
||||
import buildcraft.core.blueprints.RequirementItemStack;
|
||||
import buildcraft.core.lib.fluids.Tank;
|
||||
import buildcraft.core.lib.gui.AdvancedSlot;
|
||||
import buildcraft.core.lib.gui.GuiAdvancedInterface;
|
||||
import buildcraft.core.lib.network.command.CommandWriter;
|
||||
import buildcraft.core.lib.network.command.PacketCommand;
|
||||
import buildcraft.core.lib.utils.StringUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import moze_intel.projecte.utils.Constants;
|
||||
|
||||
/**
|
||||
* BuildCraft's GuiBuilder with the EMC consume slot and the stored EMC added. GuiBuilder cannot be extended because it
|
||||
* creates its own ContainerBuilder.
|
||||
*/
|
||||
public class GuiEMCBuilder extends GuiAdvancedInterface {
|
||||
|
||||
/** BuildCraft's builder.png with the EMC consume slot added. */
|
||||
private static final ResourceLocation REGULAR_TEXTURE = new ResourceLocation(
|
||||
BCxModern.MODID,
|
||||
"textures/gui/emcbuilder.png");
|
||||
private static final ResourceLocation BLUEPRINT_TEXTURE = new ResourceLocation(
|
||||
"buildcraftbuilders:textures/gui/builder_blueprint.png");
|
||||
|
||||
private final TileEMCBuilder builder;
|
||||
private GuiButton selectedButton;
|
||||
|
||||
public GuiEMCBuilder(IInventory playerInventory, TileEMCBuilder builder) {
|
||||
super(new ContainerEMCBuilder(playerInventory, builder), builder, BLUEPRINT_TEXTURE);
|
||||
this.builder = builder;
|
||||
xSize = 256;
|
||||
ySize = 225;
|
||||
|
||||
resetNullSlots(6 * 4);
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
slots.set(i * 4 + j, new SlotBuilderRequirement(this, 179 + j * 18, 18 + i * 18));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ContainerEMCBuilder getContainerBuilder() {
|
||||
return (ContainerEMCBuilder) getContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
super.drawGuiContainerForegroundLayer(par1, par2);
|
||||
|
||||
drawCenteredString(StringUtils.localize("tile.emcBuilder.name"), 178 / 2, 16, 0x404040);
|
||||
|
||||
drawCenteredString(
|
||||
StatCollector.translateToLocalFormatted(
|
||||
"gui.bcxmodern.stored",
|
||||
Constants.EMC_FORMATTER.format(builder.getStoredEmc())),
|
||||
178 / 2,
|
||||
51,
|
||||
0x404040);
|
||||
|
||||
if (builder.getStackInSlot(0) != null) {
|
||||
fontRendererObj.drawString(StringUtils.localize("gui.building.resources"), 8, 60, 0x404040);
|
||||
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
|
||||
fontRendererObj.drawString(StringUtils.localize("gui.needed"), 178, 7, 0x404040);
|
||||
fontRendererObj.drawString(StringUtils.localize("gui.building.fluids"), 178, 133, 0x404040);
|
||||
}
|
||||
|
||||
drawTooltips(par1, par2);
|
||||
}
|
||||
|
||||
private void drawTooltips(int par1, int par2) {
|
||||
int top = guiTop + 145;
|
||||
for (int i = 0; i < builder.fluidTanks.length; i++) {
|
||||
int left = guiLeft + 179 + 18 * i;
|
||||
if (par1 >= left && par2 >= top && par1 < (left + 16) && par2 < (left + 47)) {
|
||||
List<String> fluidTip = new ArrayList<>();
|
||||
Tank tank = builder.fluidTanks[i];
|
||||
if (tank.getFluid() != null && tank.getFluid().amount > 0) {
|
||||
fluidTip.add(
|
||||
tank.getFluid()
|
||||
.getLocalizedName());
|
||||
if (!BuildCraftCore.hideFluidNumbers) {
|
||||
fluidTip.add(
|
||||
EnumChatFormatting.GRAY + "" + EnumChatFormatting.ITALIC + tank.getFluid().amount + " mB");
|
||||
}
|
||||
} else {
|
||||
fluidTip.add(StatCollector.translateToLocal("gui.fluidtank.empty"));
|
||||
}
|
||||
drawHoveringText(fluidTip, par1 - guiLeft, par2 - guiTop, fontRendererObj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
drawTooltipForSlotAt(par1, par2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
// Like GuiBuilder, super is not called because the GUI is resized dynamically.
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
boolean isBlueprint = builder.getStackInSlot(0) != null;
|
||||
|
||||
mc.renderEngine.bindTexture(REGULAR_TEXTURE);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 176, ySize);
|
||||
mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE);
|
||||
if (isBlueprint) {
|
||||
drawTexturedModalRect(guiLeft + 169, guiTop, 169, 0, 256 - 169, ySize);
|
||||
}
|
||||
|
||||
List<RequirementItemStack> needs = builder.getNeededItems();
|
||||
|
||||
if (needs != null) {
|
||||
if (needs.size() > slots.size()) {
|
||||
getContainerBuilder().getScrollbar().hidden = false;
|
||||
getContainerBuilder().getScrollbar()
|
||||
.setLength((needs.size() - slots.size() + 3) / 4);
|
||||
} else {
|
||||
getContainerBuilder().getScrollbar().hidden = true;
|
||||
}
|
||||
|
||||
int offset = getContainerBuilder().getScrollbar()
|
||||
.getPosition() * 4;
|
||||
for (int s = 0; s < slots.size(); s++) {
|
||||
int ts = offset + s;
|
||||
if (ts >= needs.size()) {
|
||||
((SlotBuilderRequirement) slots.get(s)).stack = null;
|
||||
} else {
|
||||
((SlotBuilderRequirement) slots.get(s)).stack = needs.get(ts);
|
||||
}
|
||||
}
|
||||
|
||||
for (GuiButton b : (List<GuiButton>) buttonList) {
|
||||
b.visible = true;
|
||||
}
|
||||
} else {
|
||||
getContainerBuilder().getScrollbar().hidden = true;
|
||||
for (AdvancedSlot slot : slots) {
|
||||
((SlotBuilderRequirement) slot).stack = null;
|
||||
}
|
||||
for (GuiButton b : (List<GuiButton>) buttonList) {
|
||||
b.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
drawWidgets(x, y);
|
||||
|
||||
if (isBlueprint) {
|
||||
drawBackgroundSlots(x, y);
|
||||
|
||||
for (int i = 0; i < builder.fluidTanks.length; i++) {
|
||||
Tank tank = builder.fluidTanks[i];
|
||||
if (tank.getFluid() != null && tank.getFluid().amount > 0) {
|
||||
drawFluid(tank.getFluid(), guiLeft + 179 + 18 * i, guiTop + 145, 16, 47, tank.getCapacity());
|
||||
}
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE);
|
||||
|
||||
for (int i = 0; i < builder.fluidTanks.length; i++) {
|
||||
Tank tank = builder.fluidTanks[i];
|
||||
if (tank.getFluid() != null && tank.getFluid().amount > 0) {
|
||||
drawTexturedModalRect(guiLeft + 179 + 18 * i, guiTop + 145, 0, 54, 16, 47);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
buttonList.add(new EraseTankButton(i, guiLeft + 178 + 18 * i, guiTop + 197, 18, 18));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int mouseX, int mouseY, int eventType) {
|
||||
super.mouseMovedOrUp(mouseX, mouseY, eventType);
|
||||
if (this.selectedButton != null && eventType == 0) {
|
||||
this.selectedButton.mouseReleased(mouseX, mouseY);
|
||||
this.selectedButton = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Empties one of the builder's fluid tanks; same as GuiBuilder's erase button. */
|
||||
private class EraseTankButton extends GuiButton {
|
||||
|
||||
private boolean clicked;
|
||||
|
||||
public EraseTankButton(int id, int x, int y, int width, int height) {
|
||||
super(id, x, y, width, height, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int x, int y) {
|
||||
if (super.mousePressed(mc, x, y)) {
|
||||
selectedButton = this;
|
||||
clicked = true;
|
||||
BuildCraftCore.instance.sendToServer(new PacketCommand(builder, "eraseFluidTank", new CommandWriter() {
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf data) {
|
||||
data.writeInt(id);
|
||||
}
|
||||
}));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int x, int y) {
|
||||
super.mouseReleased(x, y);
|
||||
clicked = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft mc, int x, int y) {
|
||||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
// hovered
|
||||
this.field_146123_n = x >= this.xPosition && y >= this.yPosition
|
||||
&& x < this.xPosition + this.width
|
||||
&& y < this.yPosition + this.height;
|
||||
|
||||
mc.renderEngine.bindTexture(BLUEPRINT_TEXTURE);
|
||||
drawTexturedModalRect(xPosition, yPosition, 0, (clicked ? 1 : this.field_146123_n ? 2 : 0) * 18, 18, 18);
|
||||
mouseDragged(mc, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user