more compressor stuff

This commit is contained in:
Bob 2023-06-22 21:02:19 +02:00
parent d6cdc69c89
commit ff4b231be2
6 changed files with 98 additions and 12 deletions

View File

@ -21,6 +21,9 @@ public class ContainerCompressor extends Container {
this.addSlotToContainer(new Slot(tile, 0, 17, 72));
//Battery
this.addSlotToContainer(new Slot(tile, 1, 152, 72));
//Upgrades
this.addSlotToContainer(new Slot(tile, 2, 52, 72));
this.addSlotToContainer(new Slot(tile, 3, 70, 72));
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
@ -47,8 +50,8 @@ public class ContainerCompressor extends Container {
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if(index < 2) {
if(!this.mergeItemStack(var5, 2, this.inventorySlots.size(), true)) {
if(index < 4) {
if(!this.mergeItemStack(var5, 4, this.inventorySlots.size(), true)) {
return null;
}
} else {
@ -62,7 +65,9 @@ public class ContainerCompressor extends Container {
return null;
}
} else {
return null;
if(!this.mergeItemStack(var5, 2, 4, false)) {
return null;
}
}
}

View File

@ -68,7 +68,7 @@ public class GUICompressor extends GuiInfoContainer {
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(compressor.power >= 1_000) {
if(compressor.power >= compressor.powerRequirement) {
drawTexturedModalRect(guiLeft + 156, guiTop + 4, 176, 52, 9, 12);
}
@ -77,6 +77,9 @@ public class GUICompressor extends GuiInfoContainer {
int i = compressor.progress * 55 / compressor.processTime;
drawTexturedModalRect(guiLeft + 42, guiTop + 26, 192, 0, i, 17);
int j = (int) (compressor.power * 52 / compressor.maxPower);
drawTexturedModalRect(guiLeft + 152, guiTop + 70 - j, 176, 52 - j, 16, j);
compressor.tanks[0].renderTank(guiLeft + 17, guiTop + 70, this.zLevel, 16, 52);
compressor.tanks[1].renderTank(guiLeft + 107, guiTop + 70, this.zLevel, 16, 52);
}

View File

@ -3,13 +3,17 @@ 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.TileEntityMachineCompressor;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.IItemRenderer;
public class RenderCompressor extends TileEntitySpecialRenderer {
public class RenderCompressor extends TileEntitySpecialRenderer implements IItemRendererProvider {
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) {
@ -50,4 +54,46 @@ public class RenderCompressor extends TileEntitySpecialRenderer {
GL11.glPopMatrix();
}
@Override
public Item getItemForRenderer() {
return Item.getItemFromBlock(ModBlocks.machine_compressor);
}
@Override
public IItemRenderer getRenderer() {
return new ItemRenderBase() {
public void renderInventory() {
GL11.glTranslated(0, -4, 0);
GL11.glScaled(3, 3, 3);
}
public void renderCommon() {
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glScaled(0.5, 0.5, 0.5);
bindTexture(ResourceManager.compressor_tex);
ResourceManager.compressor.renderPart("Compressor");
double lift = (System.currentTimeMillis() * 0.005) % 9;
if(lift > 3) lift = 3 - (lift - 3) / 2D;
GL11.glPushMatrix();
GL11.glTranslated(0, -lift, 0);
ResourceManager.compressor.renderPart("Pump");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(0, 1.5, 0);
GL11.glRotated((System.currentTimeMillis() * 0.25) % 360D, 1, 0, 0);
GL11.glTranslated(0, -1.5, 0);
ResourceManager.compressor.renderPart("Fan");
GL11.glPopMatrix();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glEnable(GL11.GL_CULL_FACE);
}};
}
}

View File

@ -2,12 +2,14 @@ package com.hbm.tileentity.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.UpgradeManager;
import com.hbm.inventory.container.ContainerCompressor;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.gui.GUICompressor;
import com.hbm.inventory.recipes.CompressorRecipes;
import com.hbm.inventory.recipes.CompressorRecipes.CompressorRecipe;
import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
import com.hbm.lib.Library;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
@ -18,12 +20,15 @@ import api.hbm.energy.IEnergyUser;
import api.hbm.fluid.IFluidStandardTransceiver;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiScreen;
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.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -35,6 +40,9 @@ public class TileEntityMachineCompressor extends TileEntityMachineBase implement
public boolean isOn;
public int progress;
public int processTime = 100;
public static final int processTimeBase = 100;
public int powerRequirement;
public static final int powerRequirementBase = 10_000;
public float fanSpin;
public float prevFanSpin;
@ -43,7 +51,7 @@ public class TileEntityMachineCompressor extends TileEntityMachineBase implement
public boolean pistonDir;
public TileEntityMachineCompressor() {
super(2);
super(4);
this.tanks = new FluidTank[2];
this.tanks[0] = new FluidTank(Fluids.NONE, 16_000);
this.tanks[1] = new FluidTank(Fluids.NONE, 16_000).withPressure(1);
@ -67,10 +75,22 @@ public class TileEntityMachineCompressor extends TileEntityMachineBase implement
this.tanks[0].setType(0, slots);
this.setupTanks();
UpgradeManager.eval(slots, 1, 3);
int speedLevel = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 3);
int powerLevel = Math.min(UpgradeManager.getLevel(UpgradeType.POWER), 3);
int overLevel = UpgradeManager.getLevel(UpgradeType.OVERDRIVE);
//there is a reason to do this but i'm not telling you
this.processTime = speedLevel == 3 ? 10 : speedLevel == 2 ? 20 : speedLevel == 1 ? 60 : this.processTimeBase;
this.powerRequirement = this.powerRequirementBase / (powerLevel + 1);
this.processTime = this.processTime / (overLevel + 1);
this.powerRequirement = this.powerRequirement * ((overLevel * 2) + 1);
if(canProcess()) {
this.progress++;
this.isOn = true;
this.power -= 1_000;
this.power -= powerRequirement;
if(progress >= this.processTime) {
progress = 0;
@ -89,6 +109,8 @@ public class TileEntityMachineCompressor extends TileEntityMachineBase implement
NBTTagCompound data = new NBTTagCompound();
data.setInteger("progress", progress);
data.setInteger("processTime", processTime);
data.setInteger("powerRequirement", powerRequirement);
data.setLong("power", power);
tanks[0].writeToNBT(data, "0");
tanks[1].writeToNBT(data, "1");
@ -109,11 +131,17 @@ public class TileEntityMachineCompressor extends TileEntityMachineBase implement
}
if(this.pistonDir) {
this.piston -= 0.1F;
if(this.piston <= 0) this.pistonDir = !this.pistonDir;
this.piston -= randSpeed;
if(this.piston <= 0) {
Minecraft.getMinecraft().getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation("hbm:item.boltgun"), 0.5F, 0.75F, xCoord, yCoord, zCoord));
this.pistonDir = !this.pistonDir;
}
} else {
this.piston += 0.05F;
if(this.piston >= 1) this.pistonDir = !this.pistonDir;
if(this.piston >= 1) {
this.randSpeed = 0.085F + worldObj.rand.nextFloat() * 0.03F;
this.pistonDir = !this.pistonDir;
}
}
this.piston = MathHelper.clamp_float(this.piston, 0F, 1F);
@ -121,8 +149,12 @@ public class TileEntityMachineCompressor extends TileEntityMachineBase implement
}
}
private float randSpeed = 0.1F;
public void networkUnpack(NBTTagCompound nbt) {
this.progress = nbt.getInteger("progress");
this.processTime = nbt.getInteger("processTime");
this.powerRequirement = nbt.getInteger("powerRequirement");
this.power = nbt.getLong("power");
tanks[0].readFromNBT(nbt, "0");
tanks[1].readFromNBT(nbt, "1");
@ -149,7 +181,7 @@ public class TileEntityMachineCompressor extends TileEntityMachineBase implement
public boolean canProcess() {
if(this.power <= 1_000) return false;
if(this.power <= powerRequirement) return false;
CompressorRecipe recipe = CompressorRecipes.recipes.get(new Pair(tanks[0].getTankType(), tanks[0].getPressure()));

View File

@ -41,7 +41,7 @@ public class TileEntityMachineVacuumDistill extends TileEntityMachineBase implem
super(11);
this.tanks = new FluidTank[5];
this.tanks[0] = new FluidTank(Fluids.OIL, 64_000);
this.tanks[0] = new FluidTank(Fluids.OIL, 64_000).withPressure(2);
this.tanks[1] = new FluidTank(Fluids.HEAVYOIL_VACUUM, 24_000);
this.tanks[2] = new FluidTank(Fluids.REFORMATE, 24_000);
this.tanks[3] = new FluidTank(Fluids.LIGHTOIL_VACUUM, 24_000);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB