From 0a1822ff1087457502927728159a6ea84d471afb Mon Sep 17 00:00:00 2001 From: Bob Date: Sun, 1 Jun 2025 16:45:19 +0200 Subject: [PATCH] my balls are heavy --- .../blocks/machine/MachineChemicalPlant.java | 6 ++ .../gui/GUIMachineChemicalPlant.java | 8 +++ .../gui/GUIScreenRecipeSelector.java | 67 ++++++++++++++++++ .../recipes/ChemicalPlantRecipes.java | 2 + .../recipes/loader/SerializableRecipe.java | 2 +- .../hbm/module/ModuleMachineChemplant.java | 55 ++++++++++++++ .../item/weapon/sedna/ItemRenderAmat.java | 2 +- .../java/com/hbm/tileentity/TileMappings.java | 1 + .../TileEntityMachineChemicalPlant.java | 53 +++++++++++++- .../gui/processing/gui_recipe_selector.png | Bin 1778 -> 1802 bytes 10 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/hbm/inventory/gui/GUIScreenRecipeSelector.java create mode 100644 src/main/java/com/hbm/module/ModuleMachineChemplant.java diff --git a/src/main/java/com/hbm/blocks/machine/MachineChemicalPlant.java b/src/main/java/com/hbm/blocks/machine/MachineChemicalPlant.java index 6e9669efe..f26e1e3d6 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineChemicalPlant.java +++ b/src/main/java/com/hbm/blocks/machine/MachineChemicalPlant.java @@ -4,6 +4,7 @@ import com.hbm.blocks.BlockDummyable; import com.hbm.tileentity.machine.TileEntityMachineChemicalPlant; import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -18,6 +19,11 @@ public class MachineChemicalPlant extends BlockDummyable { if(meta >= 12) return new TileEntityMachineChemicalPlant(); return null; } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + return this.standardOpenBehavior(world, x, y, z, player, 0); + } @Override public int[] getDimensions() { return new int[] {2, 0, 1, 1, 1, 1}; } @Override public int getOffset() { return 1; } diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java index df47af6aa..5bc4c5a93 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java @@ -3,6 +3,7 @@ package com.hbm.inventory.gui; import org.lwjgl.opengl.GL11; import com.hbm.inventory.container.ContainerMachineChemicalPlant; +import com.hbm.inventory.recipes.ChemicalPlantRecipes; import com.hbm.lib.RefStrings; import com.hbm.tileentity.machine.TileEntityMachineChemicalPlant; @@ -35,6 +36,13 @@ public class GUIMachineChemicalPlant extends GuiInfoContainer { this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 18, 16, 61, chemplant.power, chemplant.maxPower); } + + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); + + if(this.checkClick(x, y, 7, 125, 18, 18)) GUIScreenRecipeSelector.openSelector(ChemicalPlantRecipes.INSTANCE, chemplant, "", 0, this); + } @Override protected void drawGuiContainerForegroundLayer(int i, int j) { diff --git a/src/main/java/com/hbm/inventory/gui/GUIScreenRecipeSelector.java b/src/main/java/com/hbm/inventory/gui/GUIScreenRecipeSelector.java new file mode 100644 index 000000000..ecb69ba16 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIScreenRecipeSelector.java @@ -0,0 +1,67 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.opengl.GL11; + +import com.hbm.interfaces.IControlReceiver; +import com.hbm.inventory.recipes.loader.GenericRecipes; +import com.hbm.lib.RefStrings; + +import cpw.mods.fml.common.FMLCommonHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.ResourceLocation; + +public class GUIScreenRecipeSelector extends GuiScreen { + + protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_recipe_selector.png"); + + protected int xSize = 176; + protected int ySize = 132; + protected int guiLeft; + protected int guiTop; + + protected GuiScreen previousScreen; + + public static void openSelector(GenericRecipes recipeSet, IControlReceiver tile, String selection, int index, GuiScreen previousScreen) { + FMLCommonHandler.instance().showGuiScreen(new GUIScreenRecipeSelector(recipeSet, tile, selection, index, previousScreen)); + } + + public GUIScreenRecipeSelector(GenericRecipes recipeSet, IControlReceiver tile, String selection, int index, GuiScreen previousScreen) { + this.previousScreen = previousScreen; + } + + @Override + public void initGui() { + super.initGui(); + this.guiLeft = (this.width - this.xSize) / 2; + this.guiTop = (this.height - this.ySize) / 2; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + this.drawDefaultBackground(); + this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + GL11.glDisable(GL11.GL_LIGHTING); + this.drawGuiContainerForegroundLayer(mouseX, mouseY); + GL11.glEnable(GL11.GL_LIGHTING); + } + + private void drawGuiContainerForegroundLayer(int x, int y) { + + } + + private void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + } + + @Override + protected void keyTyped(char typedChar, int keyCode) { + if(keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()) { + FMLCommonHandler.instance().showGuiScreen(previousScreen); + } + } + + @Override public boolean doesGuiPauseGame() { return false; } +} diff --git a/src/main/java/com/hbm/inventory/recipes/ChemicalPlantRecipes.java b/src/main/java/com/hbm/inventory/recipes/ChemicalPlantRecipes.java index f67f6579a..6aaf0e3cd 100644 --- a/src/main/java/com/hbm/inventory/recipes/ChemicalPlantRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/ChemicalPlantRecipes.java @@ -10,6 +10,8 @@ import com.hbm.items.ModItems; import net.minecraft.item.ItemStack; public class ChemicalPlantRecipes extends GenericRecipes { + + public static final ChemicalPlantRecipes INSTANCE = new ChemicalPlantRecipes(); @Override public int inputItemLimit() { return 3; } @Override public int inputFluidLimit() { return 3; } diff --git a/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java b/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java index 1ea45adca..46f9aa47c 100644 --- a/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java +++ b/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java @@ -83,7 +83,7 @@ public abstract class SerializableRecipe { recipeHandlers.add(new PedestalRecipes()); //GENERIC - recipeHandlers.add(new ChemicalPlantRecipes()); + recipeHandlers.add(ChemicalPlantRecipes.INSTANCE); recipeHandlers.add(new MatDistribution()); recipeHandlers.add(new CustomMachineRecipes()); diff --git a/src/main/java/com/hbm/module/ModuleMachineChemplant.java b/src/main/java/com/hbm/module/ModuleMachineChemplant.java new file mode 100644 index 000000000..9775ab26a --- /dev/null +++ b/src/main/java/com/hbm/module/ModuleMachineChemplant.java @@ -0,0 +1,55 @@ +package com.hbm.module; + +import com.hbm.inventory.fluid.tank.FluidTank; +import com.hbm.inventory.recipes.ChemicalPlantRecipes; +import com.hbm.inventory.recipes.loader.GenericRecipe; + +import api.hbm.energymk2.IEnergyHandlerMK2; +import net.minecraft.item.ItemStack; + +/** + * Option 1: Make a base class with weird arbitrary overrides to define shit like slots for multi machines like the chemfac + * Option 2: Make an easy to define module which can be used by whatever needs it, hypothetically allowing a mixed recipe machine. + * In the hudson bay, you know how we do it. + * @author hbm + */ +public class ModuleMachineChemplant { + + public int index; + public IEnergyHandlerMK2 battery; + public ItemStack[] slots; + public int[] inputSlots = new int[3]; + public int[] outputSlots = new int[3]; + public FluidTank[] inputTanks = new FluidTank[3]; + public FluidTank[] outputTanks = new FluidTank[3]; + + public String recipe; + public float progress; + + public ModuleMachineChemplant(int index, IEnergyHandlerMK2 battery, ItemStack[] slots) { + this.index = index; + this.battery = battery; + this.slots = slots; + } + + public boolean canProcess() { + GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(this.recipe); + if(recipe == null) return false; + if(battery.getPower() < recipe.power) return false; + + //TBI + + return true; + } + + public void resetProgress() { this.progress = 0F; } + + public void update() { + + } + + public ModuleMachineChemplant iInput(int a, int b, int c) { inputSlots[0] = a; inputSlots[1] = b; inputSlots[2] = c; return this; } + public ModuleMachineChemplant iOutput(int a, int b, int c) { outputSlots[0] = a; outputSlots[1] = b; outputSlots[2] = c; return this; } + public ModuleMachineChemplant fInput(FluidTank a, FluidTank b, FluidTank c) { inputTanks[0] = a; inputTanks[1] = b; inputTanks[2] = c; return this; } + public ModuleMachineChemplant fOutput(FluidTank a, FluidTank b, FluidTank c) { outputTanks[0] = a; outputTanks[1] = b; outputTanks[2] = c; return this; } +} diff --git a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderAmat.java b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderAmat.java index b66f0e893..9bb17c62b 100644 --- a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderAmat.java +++ b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderAmat.java @@ -149,7 +149,7 @@ public class ItemRenderAmat extends ItemRenderWeaponBase { @Override public void setupThirdPerson(ItemStack stack) { super.setupThirdPerson(stack); - double scale = 1.5D; + double scale = 1.25D; GL11.glScaled(scale, scale, scale); GL11.glTranslated(0, 0.5, 6.75); } diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index 375a89662..9a125268a 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -341,6 +341,7 @@ public class TileMappings { put(TileEntityMachineAssembler.class, "tileentity_assembly_machine"); put(TileEntityMachineAssemfac.class, "tileentity_assemfac"); put(TileEntityMachineChemplant.class, "tileentity_chemical_plant"); + put(TileEntityMachineChemicalPlant.class, "tileentity_chemicalplant"); put(TileEntityMachineChemfac.class, "tileentity_chemfac"); put(TileEntityMachineOilWell.class, "tileentity_derrick"); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java index c9bac3663..d0579ad9a 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.List; import com.hbm.blocks.ModBlocks; +import com.hbm.interfaces.IControlReceiver; import com.hbm.inventory.UpgradeManagerNT; import com.hbm.inventory.container.ContainerMachineChemicalPlant; import com.hbm.inventory.fluid.Fluids; @@ -11,6 +12,7 @@ import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.gui.GUIMachineChemicalPlant; import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType; import com.hbm.lib.Library; +import com.hbm.module.ModuleMachineChemplant; import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IUpgradeInfoProvider; import com.hbm.tileentity.TileEntityMachineBase; @@ -24,10 +26,12 @@ import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IUpgradeInfoProvider, IGUIProvider { +public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IUpgradeInfoProvider, IControlReceiver, IGUIProvider { public FluidTank[] inputTanks; public FluidTank[] outputTanks; @@ -37,6 +41,7 @@ public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implem public int progress; public int maxProgress; + public ModuleMachineChemplant chemplantModule; public UpgradeManagerNT upgradeManager = new UpgradeManagerNT(this); public TileEntityMachineChemicalPlant() { @@ -48,6 +53,9 @@ public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implem this.inputTanks[i] = new FluidTank(Fluids.NONE, 24_000); this.outputTanks[i] = new FluidTank(Fluids.NONE, 24_000); } + + this.chemplantModule = new ModuleMachineChemplant(0, this, slots) + .iInput(4, 5, 6).iOutput(7, 8, 9); } @Override @@ -91,6 +99,28 @@ public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implem this.progress = buf.readInt(); this.maxProgress = buf.readInt(); } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + for(int i = 0; i < 3; i++) { + this.inputTanks[i].readFromNBT(nbt, "i" + i); + this.outputTanks[i].readFromNBT(nbt, "o" + i); + } + + this.chemplantModule.fInput(inputTanks[0], inputTanks[1], inputTanks[2]).fOutput(outputTanks[0], outputTanks[1], outputTanks[2]); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + for(int i = 0; i < 3; i++) { + this.inputTanks[i].writeToNBT(nbt, "i" + i); + this.outputTanks[i].writeToNBT(nbt, "o" + i); + } + } @Override public long getPower() { return power; } @Override public void setPower(long power) { this.power = power; } @@ -103,6 +133,27 @@ public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implem @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerMachineChemicalPlant(player.inventory, this); } @Override @SideOnly(Side.CLIENT) public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIMachineChemicalPlant(player.inventory, this); } + @Override public boolean hasPermission(EntityPlayer player) { return this.isUseableByPlayer(player); } + + @Override + public void receiveControl(NBTTagCompound data) { + + } + + AxisAlignedBB bb = null; + + @Override + public AxisAlignedBB getRenderBoundingBox() { + if(bb == null) bb = AxisAlignedBB.getBoundingBox(xCoord - 1, yCoord, zCoord - 1, xCoord + 2, yCoord + 3, zCoord + 2); + return bb; + } + + @Override + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() { + return 65536.0D; + } + @Override public boolean canProvideInfo(UpgradeType type, int level, boolean extendedInfo) { return type == UpgradeType.SPEED || type == UpgradeType.POWER || type == UpgradeType.OVERDRIVE; diff --git a/src/main/resources/assets/hbm/textures/gui/processing/gui_recipe_selector.png b/src/main/resources/assets/hbm/textures/gui/processing/gui_recipe_selector.png index 73529c346c4794a0fab294fc3300041e9c2549e6..0da6d7d30bae3c87cee891582b9f9df354e71d4d 100644 GIT binary patch delta 1552 zcma)*`8yPN9LK+NSVJolLbGiK8Hz$F8kT7uvW}I_k)zv|n^}yBFf+`gM9VXka~L{Y zxy4RmTwz5u5y?6xLXJ_!ZD#CP`v>gzm(Tb8e4qFCd4HbI>$4!2urt|+++<^U()oJU z+z`iK$yZhSD@p5@j5vQInoug7ttZ_{tw%hu`Ev1+SMht7?6Z42bIH`9$2RCk&voCm zV*IhXuh3UCKe*BB@m`p^D$Yc^si`2w96j-%-dp-F0W+O+Eqjh`*8=9=)~)ioxiih2 z+Ku?QukBTn?*kmm`ZGo3($7^3qIq8C!~UcoMAu9oQ@SNthT1epqEBaKWw}1HDIp&6 ziSd~DENEAEj%xj=ThJNk)7&|=!>UK=$_Z?YT6lPPGoR1zMP6T>@=e_q$K$MIH2-e7m-V$VGK8Vg>I1v?|9=*PCI6xGl zQAJ1+wVa$&e@FLTe?^eR&2`S^8uN#;XX@_^56=`e8J99zA)4e8?kifO#+^uIpf3aR z(({{Uc0#(z_W?S=3RPE%d@J1QhtWTkVUYt^j7qt(HSJJsH1qK{?@&0935Da721AE? zI64B*xeHW#3`BrUG0FLx^0PaDXb5JEycuv+?J4nSu_pz3Cw;!edLYP*Wd z``AFb@ky(xGF4m@b@3n^a6i*=+zDfO)?Nrsvr^sh+MCVUH!3#dx?p!GrLFgv)~z*n zIE{7!%5r_pP0hTGo9=bhrd?O0>O4`wt2Ug7{1LB84ysEC4yaGlF?i?@Nu16=goO#s zX-ElhL5Pu<_yZl5Xrf=SQy3EQ%}w%`3}8@T`iIjIj~oJtZZQ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