This commit is contained in:
Boblet 2025-06-16 16:17:31 +02:00
parent 1e26546c79
commit 5f08488268
21 changed files with 669 additions and 13 deletions

View File

@ -3,6 +3,9 @@
* Compressed biomass now has a nice cube shape
* The new chemical plant's indicator lights are now functional
* The new chemical plant can now use upgrades
* Reeds now drop sticks when broken
* Switching the recipe in the new chemplant now annihilates residual fluid that is not overwritten by the new recipe
* I don't know why people wanted this, but here you go
## Fixed
* Chemical plant ports. For real this time.
@ -10,4 +13,6 @@
* Fixed new chemical plant not saving power values to disk
* Fixed laser rifle scope texture being missing
* Potentially fixed shift clicking issue with the new chemical plant
* Fixed blowtorch having a minimum gas requirement of 1,000mB despite only using 250mB
* Fixed blowtorch having a minimum gas requirement of 1,000mB despite only using 250mB
* The gas turbine now uses audio with a 20 tick timeout, fixing a rare issue where the loop gets stuck and never ends
* Potentially fixed a dupe caused by using InventoryBogoSorter in combination with crates

View File

@ -1008,6 +1008,7 @@ public class ModBlocks {
@Deprecated public static Block machine_chemplant;
public static Block machine_chemical_plant;
public static Block machine_chemfac;
public static Block machine_chemical_factory;
public static Block machine_mixer;
public static Block machine_fluidtank;
@ -2227,6 +2228,7 @@ public class ModBlocks {
machine_chemplant = new MachineChemplant(Material.iron).setBlockName("machine_chemplant").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_chemical_plant = new MachineChemicalPlant(Material.iron).setBlockName("machine_chemical_plant").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_chemfac = new MachineChemfac(Material.iron).setBlockName("machine_chemfac").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_chemical_factory = new MachineChemicalFactory(Material.iron).setBlockName("machine_chemical_factory").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_mixer = new MachineMixer(Material.iron).setBlockName("machine_mixer").setHardness(5.0F).setResistance(30.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_fluidtank = new MachineFluidTank(Material.iron).setBlockName("machine_fluidtank").setHardness(5.0F).setResistance(20.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_fluidtank");
machine_bat9000 = new MachineBigAssTank9000(Material.iron).setBlockName("machine_bat9000").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
@ -3267,6 +3269,7 @@ public class ModBlocks {
GameRegistry.registerBlock(machine_chemplant, machine_chemplant.getUnlocalizedName());
register(machine_chemical_plant);
register(machine_chemfac);
register(machine_chemical_factory);
register(machine_arc_welder);
register(machine_soldering_station);
register(machine_arc_furnace);

View File

@ -11,6 +11,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
@ -66,7 +67,7 @@ public class BlockReeds extends Block {
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
return null;
return Items.stick;
}
@Override

View File

@ -0,0 +1,45 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityMachineChemicalFactory;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineChemicalFactory extends BlockDummyable {
public MachineChemicalFactory(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachineChemicalFactory();
if(meta >= 6) return new TileEntityProxyCombo().inventory().power().fluid();
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, 2, 2, 2, 2}; }
@Override public int getOffset() { return 2; }
@Override
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
x -= dir.offsetX;
z -= dir.offsetZ;
for(int i = -2; i <= 2; i++) for(int j = -2; j <= 2; j++) {
if(Math.abs(i) == 2 || Math.abs(j) == 2) this.makeExtra(world, x + i, y, z + j);
}
}
}

View File

@ -95,7 +95,10 @@ public class ContainerBase extends Container {
* @param from the slot index to start from
*/
public void addSlots(IInventory inv, int from, int x, int y, int rows, int cols) {
int slotSize = 18;
addSlots(inv, from, x, y, rows, cols, 18);
}
public void addSlots(IInventory inv, int from, int x, int y, int rows, int cols, int slotSize) {
for(int row = 0; row < rows; row++) {
for(int col = 0; col < cols; col++) {
this.addSlotToContainer(new SlotNonRetarded(inv, col + row * cols + from, x + col * slotSize, y + row * slotSize));
@ -104,14 +107,20 @@ public class ContainerBase extends Container {
}
public void addOutputSlots(EntityPlayer player, IInventory inv, int from, int x, int y, int rows, int cols) {
int slotSize = 18;
addOutputSlots(player, inv, from, x, y, rows, cols, 18);
}
public void addOutputSlots(EntityPlayer player, IInventory inv, int from, int x, int y, int rows, int cols, int slotSize) {
for(int row = 0; row < rows; row++) for(int col = 0; col < cols; col++) {
this.addSlotToContainer(new SlotCraftingOutput(player, inv, col + row * cols + from, x + col * slotSize, y + row * slotSize));
}
}
public void addTakeOnlySlots(IInventory inv, int from, int x, int y, int rows, int cols) {
int slotSize = 18;
addTakeOnlySlots(inv, from, x, y, rows, cols, 18);
}
public void addTakeOnlySlots(IInventory inv, int from, int x, int y, int rows, int cols, int slotSize) {
for(int row = 0; row < rows; row++) for(int col = 0; col < cols; col++) {
this.addSlotToContainer(new SlotTakeOnly(inv, col + row * cols + from, x + col * slotSize, y + row * slotSize));
}

View File

@ -24,7 +24,7 @@ public class ContainerCrateBase extends ContainerBase {
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new SlotNonRetarded(invPlayer, i, playerInvX + i * 18, playerHotbarY));
this.addSlotToContainer(new SlotPlayerCrate(invPlayer, i, playerInvX + i * 18, playerHotbarY));
}
}
@ -67,5 +67,11 @@ public class ContainerCrateBase extends ContainerBase {
return false;
return super.canTakeStack(player);
}
@Override
public boolean isItemValid(ItemStack item) {
if(ItemStack.areItemStacksEqual(getStack(), item)) return false;
return super.isItemValid(item);
}
}
}

View File

@ -0,0 +1,77 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotCraftingOutput;
import com.hbm.inventory.SlotNonRetarded;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemMachineUpgrade;
import com.hbm.util.InventoryUtil;
import api.hbm.energymk2.IBatteryItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerMachineChemicalFactory extends ContainerBase {
public ContainerMachineChemicalFactory(InventoryPlayer invPlayer, IInventory chemicalPlant) {
super(invPlayer, chemicalPlant);
// Battery
this.addSlotToContainer(new SlotNonRetarded(chemicalPlant, 0, 224, 88));
// Upgrades
this.addSlots(chemicalPlant, 1, 206, 125, 3, 1);
for(int i = 0; i < 4; i++) {
// Template
this.addSlots(chemicalPlant, 4 + i * 7, 93, 20 + i * 22, 1, 1, 16);
// Solid Input
this.addSlots(chemicalPlant, 5 + i * 7, 10, 20 + i * 22, 1, 3, 16);
// Solid Output
this.addOutputSlots(invPlayer.player, chemicalPlant, 8 + i * 7, 139, 20 + i * 22, 1, 3, 16);
}
this.playerInv(invPlayer, 26, 134);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
ItemStack slotOriginal = null;
Slot slot = (Slot) this.inventorySlots.get(index);
if(slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
slotOriginal = slotStack.copy();
if(index <= tile.getSizeInventory() - 1) {
SlotCraftingOutput.checkAchievements(player, slotStack);
if(!this.mergeItemStack(slotStack, tile.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
} else {
if(slotOriginal.getItem() instanceof IBatteryItem || slotOriginal.getItem() == ModItems.battery_creative) {
if(!this.mergeItemStack(slotStack, 0, 1, false)) return null;
} else if(slotOriginal.getItem() instanceof ItemMachineUpgrade) {
if(!this.mergeItemStack(slotStack, 1, 4, false)) return null;
} else {
if(!InventoryUtil.mergeItemStack(this.inventorySlots, slotStack, 5, 8, false) &&
!InventoryUtil.mergeItemStack(this.inventorySlots, slotStack, 12, 15, false) &&
!InventoryUtil.mergeItemStack(this.inventorySlots, slotStack, 19, 22, false) &&
!InventoryUtil.mergeItemStack(this.inventorySlots, slotStack, 26, 29, false)) return null;
}
}
if(slotStack.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
slot.onPickupFromSlot(player, slotStack);
}
return slotOriginal;
}
}

View File

@ -65,6 +65,12 @@ public class FluidTank implements Cloneable {
this.setFill(0);
}
public void resetTank() {
this.type = Fluids.NONE;
this.fluid = 0;
this.pressure = 0;
}
/** Changes type and pressure based on a fluid stack, useful for changing tank types based on recipes */
public FluidTank conform(FluidStack stack) {
this.setTankType(stack.type);

View File

@ -0,0 +1,132 @@
package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerMachineChemicalFactory;
import com.hbm.inventory.recipes.ChemicalPlantRecipes;
import com.hbm.inventory.recipes.loader.GenericRecipe;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityMachineChemicalFactory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
public class GUIMachineChemicalFactory extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_chemical_factory.png");
private TileEntityMachineChemicalFactory chemplant;
public GUIMachineChemicalFactory(InventoryPlayer invPlayer, TileEntityMachineChemicalFactory tedf) {
super(new ContainerMachineChemicalFactory(invPlayer, tedf));
chemplant = tedf;
this.xSize = 248;
this.ySize = 216;
}
@Override
public void drawScreen(int mouseX, int mouseY, float f) {
super.drawScreen(mouseX, mouseY, f);
for(int i = 0; i < 3; i++) for(int j = 0; j < 4; j++) {
chemplant.inputTanks[i].renderTankInfo(this, mouseX, mouseY, guiLeft + 60 + i * 5, guiTop + 20 + j * 22, 4, 16);
chemplant.outputTanks[i].renderTankInfo(this, mouseX, mouseY, guiLeft + 189 + i * 5, guiTop + 20 + j * 22, 4, 16);
}
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 224, guiTop + 18, 16, 68, chemplant.power, chemplant.maxPower);
for(int i = 0; i < 4; i++) if(guiLeft + 74 <= mouseX && guiLeft + 74 + 18 > mouseX && guiTop + 19 + i * 22 < mouseY && guiTop + 19 + i * 22 + 18 >= mouseY) {
if(this.chemplant.chemplantModule[i].recipe != null && ChemicalPlantRecipes.INSTANCE.recipeNameMap.containsKey(this.chemplant.chemplantModule[i].recipe)) {
GenericRecipe recipe = (GenericRecipe) ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(this.chemplant.chemplantModule[i].recipe);
this.func_146283_a(recipe.print(), mouseX, mouseY);
} else {
this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + "Click to set recipe", mouseX, mouseY);
}
}
}
@Override
protected void mouseClicked(int x, int y, int button) {
super.mouseClicked(x, y, button);
for(int i = 0; i < 4; i++) if(this.checkClick(x, y, 74, 19 + i * 22, 18, 18)) GUIScreenRecipeSelector.openSelector(ChemicalPlantRecipes.INSTANCE, chemplant, chemplant.chemplantModule[i].recipe, i, this);
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.chemplant.hasCustomInventoryName() ? this.chemplant.getInventoryName() : I18n.format(this.chemplant.getInventoryName());
this.fontRendererObj.drawString(name, 106 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 26, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 248, 116);
drawTexturedModalRect(guiLeft + 18, guiTop + 116, 18, 116, 230, 100);
int p = (int) (chemplant.power * 68 / chemplant.maxPower);
drawTexturedModalRect(guiLeft + 224, guiTop + 86 - p, 0, 184 - p, 16, p);
for(int i = 0; i < 4; i++) if(chemplant.chemplantModule[i].progress > 0) {
int j = (int) Math.ceil(22 * chemplant.chemplantModule[i].progress);
drawTexturedModalRect(guiLeft + 113, guiTop + 29 + i * 22, 0, 216, j, 6);
}
for(int g = 0; g < 4; g++) {
GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(chemplant.chemplantModule[g].recipe);
/// LEFT LED
if(chemplant.didProcess) {
drawTexturedModalRect(guiLeft + 113, guiTop + 21 + g * 22, 4, 222, 4, 4);
} else if(recipe != null) {
drawTexturedModalRect(guiLeft + 113, guiTop + 21 + g * 22, 0, 222, 4, 4);
}
/// RIGHT LED
if(chemplant.didProcess) {
drawTexturedModalRect(guiLeft + 121, guiTop + 21 + g * 22, 4, 222, 4, 4);
} else if(recipe != null && chemplant.power >= recipe.power) {
drawTexturedModalRect(guiLeft + 121, guiTop + 21 + g * 22, 0, 222, 4, 4);
}
}
for(int g = 0; g < 4; g++) { // not a great way of doing it but at least we eliminate state leak bullshit
GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(chemplant.chemplantModule[g].recipe);
this.renderItem(recipe != null ? recipe.getIcon() : TEMPLATE_FOLDER, 75, 20 + g * 22);
if(recipe != null && recipe.inputItem != null) {
for(int i = 0; i < recipe.inputItem.length; i++) {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(chemplant.chemplantModule[g].inputSlots[i]);
if(!slot.getHasStack()) this.renderItem(recipe.inputItem[i].extractForCyclingDisplay(20), slot.xDisplayPosition, slot.yDisplayPosition, 10F);
}
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glColor4f(1F, 1F, 1F, 0.5F);
GL11.glEnable(GL11.GL_BLEND);
this.zLevel = 300F;
for(int i = 0; i < recipe.inputItem.length; i++) {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(chemplant.chemplantModule[g].inputSlots[i]);
if(!slot.getHasStack()) drawTexturedModalRect(guiLeft + slot.xDisplayPosition, guiTop + slot.yDisplayPosition, slot.xDisplayPosition, slot.yDisplayPosition, 16, 16);
}
this.zLevel = 0F;
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glDisable(GL11.GL_BLEND);
}
}
for(int i = 0; i < 3; i++) for(int j = 0; j < 4; j++) {
chemplant.inputTanks[i + j * 3].renderTank(guiLeft + 60 + i * 5, guiTop + 36 + j * 22, this.zLevel, 4, 16);
chemplant.outputTanks[i + j * 3].renderTank(guiLeft + 189 + i * 5, guiTop + 36 + j * 22, this.zLevel, 4, 16);
}
}
}

View File

@ -91,6 +91,7 @@ import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.i18n.I18nClient;
import com.hbm.util.i18n.ITranslate;
import com.hbm.wiaj.cannery.Jars;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
@ -270,6 +271,7 @@ public class ClientProxy extends ServerProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineChemplant.class, new RenderChemplant());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineChemicalPlant.class, new RenderChemicalPlant());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineChemfac.class, new RenderChemfac());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineChemicalFactory.class, new RenderChemicalFactory());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineFluidTank.class, new RenderFluidTank());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineBAT9000.class, new RenderBAT9000());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineOrbus.class, new RenderOrbus());

View File

@ -150,6 +150,7 @@ public class ResourceManager {
public static final IModelCustom chemplant_fluidcap = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/chemplant_new_fluidcap.hmf"));
public static final IModelCustom chemical_plant = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/chemical_plant.obj"));
public static final IModelCustom chemfac = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/chemfac.obj"));
public static final IModelCustom chemical_factory = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/chemical_factory.obj"));
//Mixer
public static final IModelCustom mixer = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/mixer.obj"));
@ -583,6 +584,7 @@ public class ResourceManager {
public static final ResourceLocation chemical_plant_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/chemical_plant.png");
public static final ResourceLocation chemical_plant_fluid_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/chemical_plant_fluid.png");
public static final ResourceLocation chemfac_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/chemfac.png");
public static final ResourceLocation chemical_factory_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/chemical_factory.png");
//Mixer
public static final ResourceLocation mixer_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/mixer.png");

View File

@ -43,8 +43,8 @@ public class ModuleMachineChemplant {
/** Chances tank type and pressure based on recipe */
public void setupTanks(GenericRecipe recipe) {
if(recipe == null) return;
if(recipe.inputFluid != null) for(int i = 0; i < Math.min(inputTanks.length, recipe.inputFluid.length); i++) inputTanks[i].conform(recipe.inputFluid[i]);
if(recipe.outputFluid != null) for(int i = 0; i < Math.min(outputTanks.length, recipe.outputFluid.length); i++) outputTanks[i].conform(recipe.outputFluid[i]);
for(int i = 0; i < 3; i++) if(recipe.inputFluid != null && recipe.inputFluid.length > i) inputTanks[i].conform(recipe.inputFluid[i]); else inputTanks[i].resetTank();
for(int i = 0; i < 3; i++) if(recipe.outputFluid != null && recipe.outputFluid.length > i) outputTanks[i].conform(recipe.outputFluid[i]); else outputTanks[i].resetTank();
}
/** Expects the tanks to be set up correctly beforehand */

View File

@ -0,0 +1,71 @@
package com.hbm.render.tileentity;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.main.ResourceManager;
import com.hbm.render.item.ItemRenderBase;
import com.hbm.tileentity.machine.TileEntityMachineChemicalFactory;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.IItemRenderer;
public class RenderChemicalFactory extends TileEntitySpecialRenderer implements IItemRendererProvider {
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float interp) {
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y, z + 0.5);
GL11.glRotated(90, 0, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
switch(tileEntity.getBlockMetadata() - BlockDummyable.offset) {
case 2: GL11.glRotatef(0, 0F, 1F, 0F); break;
case 4: GL11.glRotatef(90, 0F, 1F, 0F); break;
case 3: GL11.glRotatef(180, 0F, 1F, 0F); break;
case 5: GL11.glRotatef(270, 0F, 1F, 0F); break;
}
TileEntityMachineChemicalFactory chemplant = (TileEntityMachineChemicalFactory) tileEntity;
float anim = chemplant.prevAnim + (chemplant.anim - chemplant.prevAnim) * interp;
bindTexture(ResourceManager.chemical_factory_tex);
ResourceManager.chemical_factory.renderPart("Base");
if(chemplant.frame) ResourceManager.chemical_factory.renderPart("Frame");
ResourceManager.chemical_factory.renderPart("Fan1");
ResourceManager.chemical_factory.renderPart("Fan2");
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glPopMatrix();
}
@Override
public Item getItemForRenderer() {
return Item.getItemFromBlock(ModBlocks.machine_chemical_factory);
}
@Override
public IItemRenderer getRenderer() {
return new ItemRenderBase() {
public void renderInventory() {
GL11.glTranslated(0, -1.5, 0);
GL11.glScaled(3, 3, 3);
}
public void renderCommonWithStack(ItemStack item) {
GL11.glScaled(0.75, 0.75, 0.75);
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.chemical_factory_tex);
ResourceManager.chemical_factory.renderPart("Base");
ResourceManager.chemical_factory.renderPart("Frame");
ResourceManager.chemical_factory.renderPart("Fan1");
ResourceManager.chemical_factory.renderPart("Fan2");
GL11.glShadeModel(GL11.GL_FLAT);
}};
}
}

View File

@ -342,6 +342,7 @@ public class TileMappings {
put(TileEntityMachineChemplant.class, "tileentity_chemical_plant");
put(TileEntityMachineChemicalPlant.class, "tileentity_chemicalplant");
put(TileEntityMachineChemfac.class, "tileentity_chemfac");
put(TileEntityMachineChemicalFactory.class, "tileentity_chemicalfactory");
put(TileEntityMachineOilWell.class, "tileentity_derrick");
put(TileEntityMachinePumpjack.class, "tileentity_machine_pumpjack");

View File

@ -0,0 +1,293 @@
package com.hbm.tileentity.machine;
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.ContainerMachineChemicalFactory;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.gui.GUIMachineChemicalFactory;
import com.hbm.items.machine.ItemMachineUpgrade;
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;
import com.hbm.util.BobMathUtil;
import com.hbm.util.fauxpointtwelve.DirPos;
import com.hbm.util.i18n.I18nUtil;
import api.hbm.energymk2.IEnergyReceiverMK2;
import api.hbm.fluidmk2.IFluidStandardTransceiverMK2;
import cpw.mods.fml.relauncher.Side;
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.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityMachineChemicalFactory extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IUpgradeInfoProvider, IControlReceiver, IGUIProvider {
public FluidTank[] allTanks;
public FluidTank[] inputTanks;
public FluidTank[] outputTanks;
public long power;
public long maxPower = 10_000_000;
public boolean didProcess = false;
public boolean frame = false;
public int anim;
public int prevAnim;
public ModuleMachineChemplant[] chemplantModule;
public UpgradeManagerNT upgradeManager = new UpgradeManagerNT(this);
public TileEntityMachineChemicalFactory() {
super(32);
this.inputTanks = new FluidTank[12];
this.outputTanks = new FluidTank[12];
for(int i = 0; i < 12; i++) {
this.inputTanks[i] = new FluidTank(Fluids.NONE, 24_000);
this.outputTanks[i] = new FluidTank(Fluids.NONE, 24_000);
}
this.allTanks = new FluidTank[this.inputTanks.length + this.outputTanks.length];
for(int i = 0; i < inputTanks.length; i++) this.allTanks[i] = this.inputTanks[i];
for(int i = 0; i < outputTanks.length; i++) this.allTanks[i + this.inputTanks.length] = this.outputTanks[i];
this.chemplantModule = new ModuleMachineChemplant[4];
for(int i = 0; i < 4; i++) this.chemplantModule[i] = new ModuleMachineChemplant(i, this, slots)
.itemInput(5 + i * 7, 6 + i * 7, 7 + i * 7)
.itemOutput(8 + i * 7, 9 + i * 7, 10 + i * 7)
.fluidInput(inputTanks[0 + i * 3], inputTanks[1 + i * 3], inputTanks[2 + i * 3])
.fluidOutput(outputTanks[0 + i * 3], outputTanks[1 + i * 3], outputTanks[2 + i * 3]);
}
@Override
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
if(i >= 8 && i <= 10) return true;
if(i >= 12 && i <= 14) return true;
if(i >= 19 && i <= 21) return true;
if(i >= 26 && i <= 28) return true;
return false;
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
if(slot == 0) return true; // battery
if(slot >= 1 && slot <= 3 && stack.getItem() instanceof ItemMachineUpgrade) return true; // upgrades
for(int i = 0; i < 4; i++) if(this.chemplantModule[i].isItemValid(slot, stack)) return true; // recipe input crap
return false;
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return new int[] {
5, 6, 7, 8, 9, 10,
12, 13, 14, 15, 16, 17,
19, 20, 21, 22, 23, 24,
26, 27, 28, 29, 30, 31
};
}
@Override
public String getName() {
return "container.machineChemicalFactory";
}
@Override
public void updateEntity() {
if(maxPower <= 0) this.maxPower = 10_000_000;
if(!worldObj.isRemote) {
this.power = Library.chargeTEFromItems(slots, 0, power, maxPower);
upgradeManager.checkSlots(slots, 1, 3);
inputTanks[0].loadTank(10, 13, slots);
inputTanks[1].loadTank(11, 14, slots);
inputTanks[2].loadTank(12, 15, slots);
outputTanks[0].unloadTank(16, 19, slots);
outputTanks[1].unloadTank(17, 20, slots);
outputTanks[2].unloadTank(18, 21, slots);
for(DirPos pos : getConPos()) {
this.trySubscribe(worldObj, pos);
for(FluidTank tank : inputTanks) if(tank.getTankType() != Fluids.NONE) this.trySubscribe(tank.getTankType(), worldObj, pos);
for(FluidTank tank : outputTanks) if(tank.getFill() > 0) this.tryProvide(tank, worldObj, pos);
}
double speed = 1D;
double pow = 1D;
speed += Math.min(upgradeManager.getLevel(UpgradeType.SPEED), 3) / 3D;
speed += Math.min(upgradeManager.getLevel(UpgradeType.OVERDRIVE), 3);
pow -= Math.min(upgradeManager.getLevel(UpgradeType.POWER), 3) * 0.25D;
pow += Math.min(upgradeManager.getLevel(UpgradeType.SPEED), 3) * 1D;
pow += Math.min(upgradeManager.getLevel(UpgradeType.OVERDRIVE), 3) * 10D / 3D;
this.didProcess = false;
boolean markDirty = false;
for(int i = 0; i < 4; i++) {
this.chemplantModule[i].update(speed * 2D, pow);
this.didProcess |= this.chemplantModule[i].didProcess;
markDirty |= this.chemplantModule[i].markDirty;
}
if(markDirty) this.markDirty();
this.networkPackNT(100);
} else {
this.prevAnim = this.anim;
if(this.didProcess) this.anim++;
if(worldObj.getTotalWorldTime() % 20 == 0) {
frame = !worldObj.getBlock(xCoord, yCoord + 3, zCoord).isAir(worldObj, xCoord, yCoord + 3, zCoord);
}
}
}
public DirPos[] getConPos() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
return new DirPos[] {
new DirPos(xCoord + 3, yCoord, zCoord - 2, Library.POS_X),
new DirPos(xCoord + 3, yCoord, zCoord + 0, Library.POS_X),
new DirPos(xCoord + 3, yCoord, zCoord + 2, Library.POS_X),
new DirPos(xCoord - 3, yCoord, zCoord - 2, Library.NEG_X),
new DirPos(xCoord - 3, yCoord, zCoord + 0, Library.NEG_X),
new DirPos(xCoord - 3, yCoord, zCoord + 2, Library.NEG_X),
new DirPos(xCoord - 2, yCoord, zCoord + 3, Library.POS_Z),
new DirPos(xCoord + 0, yCoord, zCoord + 3, Library.POS_Z),
new DirPos(xCoord + 2, yCoord, zCoord + 3, Library.POS_Z),
new DirPos(xCoord - 2, yCoord, zCoord - 3, Library.NEG_Z),
new DirPos(xCoord + 0, yCoord, zCoord - 3, Library.NEG_Z),
new DirPos(xCoord + 2, yCoord, zCoord - 3, Library.NEG_Z),
new DirPos(xCoord + dir.offsetX + rot.offsetX * 3, yCoord, zCoord + dir.offsetZ + rot.offsetZ * 3, rot),
new DirPos(xCoord - dir.offsetX + rot.offsetX * 3, yCoord, zCoord - dir.offsetZ + rot.offsetZ * 3, rot),
new DirPos(xCoord + dir.offsetX - rot.offsetX * 3, yCoord, zCoord + dir.offsetZ - rot.offsetZ * 3, rot.getOpposite()),
new DirPos(xCoord - dir.offsetX - rot.offsetX * 3, yCoord, zCoord - dir.offsetZ - rot.offsetZ * 3, rot.getOpposite()),
};
}
public DirPos[] getCoolPos() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
return new DirPos[] {
new DirPos(xCoord + rot.offsetX + dir.offsetX * 3, yCoord, zCoord + rot.offsetZ + dir.offsetZ * 3, dir),
new DirPos(xCoord - rot.offsetX + dir.offsetX * 3, yCoord, zCoord - rot.offsetZ + dir.offsetZ * 3, dir),
new DirPos(xCoord + rot.offsetX - dir.offsetX * 3, yCoord, zCoord + rot.offsetZ - dir.offsetZ * 3, dir.getOpposite()),
new DirPos(xCoord - rot.offsetX - dir.offsetX * 3, yCoord, zCoord - rot.offsetZ - dir.offsetZ * 3, dir.getOpposite()),
};
}
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
for(FluidTank tank : inputTanks) tank.serialize(buf);
for(FluidTank tank : outputTanks) tank.serialize(buf);
buf.writeLong(power);
buf.writeLong(maxPower);
buf.writeBoolean(didProcess);
for(int i = 0; i < 4; i++) this.chemplantModule[i].serialize(buf);
}
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
for(FluidTank tank : inputTanks) tank.deserialize(buf);
for(FluidTank tank : outputTanks) tank.deserialize(buf);
this.power = buf.readLong();
this.maxPower = buf.readLong();
this.didProcess = buf.readBoolean();
for(int i = 0; i < 4; i++) this.chemplantModule[i].deserialize(buf);
}
@Override public long getPower() { return power; }
@Override public void setPower(long power) { this.power = power; }
@Override public long getMaxPower() { return maxPower; }
@Override public FluidTank[] getReceivingTanks() { return inputTanks; }
@Override public FluidTank[] getSendingTanks() { return outputTanks; }
@Override public FluidTank[] getAllTanks() { return allTanks; }
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerMachineChemicalFactory(player.inventory, this); }
@Override @SideOnly(Side.CLIENT) public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIMachineChemicalFactory(player.inventory, this); }
@Override public boolean hasPermission(EntityPlayer player) { return this.isUseableByPlayer(player); }
@Override
public void receiveControl(NBTTagCompound data) {
if(data.hasKey("index") && data.hasKey("selection")) {
int index = data.getInteger("index");
String selection = data.getString("selection");
if(index >= 0 && index < 4) {
this.chemplantModule[index].recipe = selection;
this.markChanged();
}
}
}
AxisAlignedBB bb = null;
@Override
public AxisAlignedBB getRenderBoundingBox() {
if(bb == null) bb = AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord, zCoord - 2, xCoord + 3, yCoord + 3, zCoord + 3);
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;
}
@Override
public void provideInfo(UpgradeType type, int level, List<String> info, boolean extendedInfo) {
info.add(IUpgradeInfoProvider.getStandardLabel(ModBlocks.machine_chemical_plant));
if(type == UpgradeType.SPEED) {
info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(KEY_SPEED, "+" + (level * 100 / 3) + "%"));
info.add(EnumChatFormatting.RED + I18nUtil.resolveKey(KEY_CONSUMPTION, "+" + (level * 50) + "%"));
}
if(type == UpgradeType.POWER) {
info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(KEY_CONSUMPTION, "-" + (level * 25) + "%"));
}
if(type == UpgradeType.OVERDRIVE) {
info.add((BobMathUtil.getBlink() ? EnumChatFormatting.RED : EnumChatFormatting.DARK_GRAY) + "YES");
}
}
@Override
public HashMap<UpgradeType, Integer> getValidUpgrades() {
HashMap<UpgradeType, Integer> upgrades = new HashMap<>();
upgrades.put(UpgradeType.SPEED, 3);
upgrades.put(UpgradeType.POWER, 3);
upgrades.put(UpgradeType.OVERDRIVE, 3);
return upgrades;
}
}

View File

@ -228,8 +228,10 @@ public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implem
if(data.hasKey("index") && data.hasKey("selection")) {
int index = data.getInteger("index");
String selection = data.getString("selection");
if(index == 0) this.chemplantModule.recipe = selection;
this.markChanged();
if(index == 0) {
this.chemplantModule.recipe = selection;
this.markChanged();
}
}
}

View File

@ -74,7 +74,7 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
fuelMaxCons.put(Fluids.GAS, 50D); // natgas doesn't burn well so it burns faster to compensate
fuelMaxCons.put(Fluids.SYNGAS, 10D); // syngas just fucks
fuelMaxCons.put(Fluids.OXYHYDROGEN, 100D); // oxyhydrogen is terrible so it needs to burn a ton for the bare minimum
fuelMaxCons.put(Fluids.REFORMGAS, 5D); // fuck it we ball
fuelMaxCons.put(Fluids.REFORMGAS, 5D); // fuck it we ball
// default to 5 if not in list
}
@ -166,17 +166,18 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
if(audio == null) { //if there is no sound playing, start it
audio = MainRegistry.proxy.getLoopedSound("hbm:block.turbinegasRunning", xCoord, yCoord, zCoord, getVolume(1.0F), 20F, 2.0F);
audio = MainRegistry.proxy.getLoopedSound("hbm:block.turbinegasRunning", xCoord, yCoord, zCoord, getVolume(1.0F), 20F, 2.0F, 20);
audio.startSound();
} else if(!audio.isPlaying()) {
audio.stopSound();
audio = MainRegistry.proxy.getLoopedSound("hbm:block.turbinegasRunning", xCoord, yCoord, zCoord, getVolume(1.0F), 20F, 2.0F);
audio = MainRegistry.proxy.getLoopedSound("hbm:block.turbinegasRunning", xCoord, yCoord, zCoord, getVolume(1.0F), 20F, 2.0F, 20);
audio.startSound();
}
audio.updatePitch((float) (0.55 + 0.1 * rpm / 10)); //dynamic pitch update based on rpm
audio.updateVolume(getVolume(2F)); //yeah i need this
audio.keepAlive();
} else {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1006 B

After

Width:  |  Height:  |  Size: 947 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB