even morer igen work

This commit is contained in:
Bob 2020-10-30 23:03:43 +01:00
parent 6f5cfc3723
commit 56698989ed
6 changed files with 240 additions and 35 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

View File

@ -2,14 +2,18 @@ package com.hbm.blocks.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityMachineIGenerator;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineIGenerator extends BlockDummyable {
@ -18,8 +22,15 @@ public class MachineIGenerator extends BlockDummyable {
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityMachineIGenerator();
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12)
return new TileEntityMachineIGenerator();
if(meta >= extra)
return new TileEntityProxyCombo(false, true, true);
return null;
}
@Override
@ -44,7 +55,16 @@ public class MachineIGenerator extends BlockDummyable {
return true;
} else if(!player.isSneaking()) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_machine_industrial_generator, world, x, y, z);
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return false;
TileEntityMachineIGenerator gen = (TileEntityMachineIGenerator)world.getTileEntity(pos[0], pos[1], pos[2]);
if(gen != null)
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_machine_industrial_generator, world, pos[0], pos[1], pos[2]);
return true;
} else {
return false;
@ -53,11 +73,49 @@ public class MachineIGenerator extends BlockDummyable {
@Override
public int[] getDimensions() {
return new int [] {0,0,0,0,0,0};
return new int [] {1,0,2,2,2,4};
}
@Override
public int getOffset() {
return 1;
return 2;
}
protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) {
if(!MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(), x, y, z, dir))
return false;
if(!MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int [] {5,0,2,2,8,-2}, x, y, z, dir))
return false;
if(!MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int [] {4,0,2,2,-4,8}, x, y, z, dir))
return false;
if(!MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int [] {3,-2,1,1,-1,3}, x, y, z, dir))
return false;
if(!MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int [] {4,-2,1,1,1,0}, x, y, z, dir))
return false;
return true;
}
protected void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(), this, dir);
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int [] {5,0,2,2,8,-2}, this, dir);
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int [] {4,0,2,2,-4,8}, this, dir);
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int [] {3,-2,1,1,-1,3}, this, dir);
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int [] {4,-2,1,1,1,0}, this, dir);
int[] rot = MultiblockHandlerXR.rotate(new int [] {1,0,2,2,8,8}, dir);
for(int iy = 0; iy <= 1; iy++) {
for(int ix = -rot[4]; ix <= rot[5]; ix++) {
for(int iz = -rot[2]; iz <= rot[3]; iz++) {
if(ix == -rot[4] || ix == rot[5] || iz == -rot[2] || iz == rot[3]) {
this.makeExtra(world, x + dir.offsetX * o + ix, y + iy, z + dir.offsetZ * o + iz);
}
}
}
}
}
}

View File

@ -4,6 +4,7 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerIGenerator;
import com.hbm.lib.Library;
import com.hbm.lib.RefStrings;
import com.hbm.packet.AuxButtonPacket;
import com.hbm.packet.PacketDispatcher;
@ -47,6 +48,13 @@ public class GUIIGenerator extends GuiInfoContainer {
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(igen.xCoord, igen.yCoord, igen.zCoord, dial, 2));
caughtMouse = false;
}
this.drawCustomInfoStat(x, y, guiLeft + 76, guiTop + 20, 36, 12, x, y, new String[] { (igen.temperature + 300) + "K" });
this.drawCustomInfoStat(x, y, guiLeft + 76, guiTop + 56, 36, 12, x, y, new String[] { (Math.round((igen.torque * igen.animSpeed / (360D * 20D)) * 10D) / 10D) + "RPM" });
this.drawCustomInfoStat(x, y, guiLeft + 76, guiTop + 92, 36, 12, x, y, new String[] { Library.getShortNumber(igen.power) + "HE" });
this.drawCustomInfoStat(x, y, guiLeft + 40, guiTop + 26, 18, 18, x, y, new String[] { (igen.burnTime / 20) + "s" });
this.drawCustomInfoStat(x, y, guiLeft + 24, guiTop + 64, 14, 14, x, y, new String[] { "Add pellet to stack" });
this.drawCustomInfoStat(x, y, guiLeft + 24, guiTop + 100, 14, 14, x, y, new String[] { "Take pellet from stack" });
igen.tanks[0].renderTankInfo(this, x, y, guiLeft + 148, guiTop + 26, 18, 18);
igen.tanks[1].renderTankInfo(this, x, y, guiLeft + 148, guiTop + 62, 18, 18);
@ -77,8 +85,6 @@ public class GUIIGenerator extends GuiInfoContainer {
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 14, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(igen.getConversion() + "", 100, this.ySize - 96 + 2, 0xffffff);
this.fontRendererObj.drawString(igen.getBrake() + "", 100, this.ySize - 96 + 12, 0xffffff);
}
@Override
@ -93,6 +99,23 @@ public class GUIIGenerator extends GuiInfoContainer {
drawTexturedModalRect(guiLeft + 6, guiTop + 106 - 4 * i, 188, igen.pellets[i].offset, 14, 9);
}
for(int i = 0; i < 3; i++) {
if(igen.tanks[i].getFill() > 0) {
int hex = igen.tanks[i].getTankType().getColor();
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = (hex & 0xFF);
GL11.glColor3f(r / 256F, g / 256F, b / 256F);
drawTexturedModalRect(guiLeft + 149, guiTop + 39 + 36 * i, 218, 0, 16, 4);
}
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
drawDial(x, y);
GaugeUtil.renderGauge(Gauge.BOW_SMALL, guiLeft + 40, guiTop + 26, this.zLevel, igen.getSolidGauge());

View File

@ -2,10 +2,12 @@ package com.hbm.render.tileentity;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.BlockDummyable;
import com.hbm.main.ResourceManager;
import com.hbm.render.util.BeamPronter;
import com.hbm.render.util.BeamPronter.EnumBeamType;
import com.hbm.render.util.BeamPronter.EnumWaveType;
import com.hbm.tileentity.machine.TileEntityMachineIGenerator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
@ -18,6 +20,16 @@ public class RenderIGenerator extends TileEntitySpecialRenderer {
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
switch(te.getBlockMetadata() - BlockDummyable.offset)
{
case 2: GL11.glRotatef(90, 0F, 1F, 0F); break;
case 4: GL11.glRotatef(180, 0F, 1F, 0F); break;
case 3: GL11.glRotatef(270, 0F, 1F, 0F); break;
case 5: GL11.glRotatef(0, 0F, 1F, 0F); break;
}
TileEntityMachineIGenerator igen = (TileEntityMachineIGenerator)te;
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_SMOOTH);
@ -25,7 +37,7 @@ public class RenderIGenerator extends TileEntitySpecialRenderer {
bindTexture(ResourceManager.igen_tex);
ResourceManager.igen.renderPart("Base");
float angle = System.currentTimeMillis() * 1 % 360;
float angle = igen.prevRotation + (igen.rotation - igen.prevRotation) * f;
float px = 0.0625F;
float sine = (float) Math.sin(Math.toRadians(angle));
float cosine = (float) Math.cos(Math.toRadians(angle));
@ -96,16 +108,16 @@ public class RenderIGenerator extends TileEntitySpecialRenderer {
GL11.glPopMatrix();
GL11.glTranslated(-0.75, 5.5625, -7);
for(int i = 0; i < 2; i++) {
BeamPronter.prontBeam(Vec3.createVectorHelper(1.5, 0, 0), EnumWaveType.RANDOM, EnumBeamType.LINE, 0x8080ff, 0x0000ff, (int)te.getWorldObj().getTotalWorldTime() % 1000 + i, 5, px * 4, 0, 0);
BeamPronter.prontBeam(Vec3.createVectorHelper(1.5, 0, 0), EnumWaveType.RANDOM, EnumBeamType.LINE, 0xffffff, 0x0000ff, (int)te.getWorldObj().getTotalWorldTime() % 1000 + 2 + i, 5, px * 4, 0, 0);
if(igen.torque > 0) {
for(int i = 0; i < 2; i++) {
BeamPronter.prontBeam(Vec3.createVectorHelper(1.5, 0, 0), EnumWaveType.RANDOM, EnumBeamType.LINE, 0x8080ff, 0x0000ff, (int)te.getWorldObj().getTotalWorldTime() % 1000 + i, 5, px * 4, 0, 0);
BeamPronter.prontBeam(Vec3.createVectorHelper(1.5, 0, 0), EnumWaveType.RANDOM, EnumBeamType.LINE, 0xffffff, 0x0000ff, (int)te.getWorldObj().getTotalWorldTime() % 1000 + 2 + i, 5, px * 4, 0, 0);
}
}
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glEnable(GL11.GL_CULL_FACE);
te.getWorldObj().spawnParticle("splash", te.xCoord + 2.1, te.yCoord + 5.875, te.zCoord + 0.5, 0, 0, -0.25);
te.getWorldObj().spawnParticle("smoke", te.xCoord + 2.8, te.yCoord + 5.05, te.zCoord + 2, 0, 0, -0.1);
GL11.glPopMatrix();
}

View File

@ -1,8 +1,11 @@
package com.hbm.tileentity.machine;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.HashBiMap;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.blocks.BlockDummyable;
import com.hbm.handler.FluidTypeHandler.FluidType;
import com.hbm.interfaces.IConsumer;
import com.hbm.interfaces.IFluidAcceptor;
@ -12,10 +15,15 @@ import com.hbm.items.ModItems;
import com.hbm.lib.Library;
import com.hbm.tileentity.TileEntityMachineBase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import scala.actors.threadpool.Arrays;
public class TileEntityMachineIGenerator extends TileEntityMachineBase implements ISource, IFluidAcceptor {
@ -30,8 +38,18 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
public static final int maxTorque = 10000;
public float limiter = 0.0F; /// 0 - 1 ///
public static final int animSpeed = 50;
@SideOnly(Side.CLIENT)
public float rotation;
@SideOnly(Side.CLIENT)
public float prevRotation;
public IGenRTG[] pellets = new IGenRTG[12];
public FluidTank[] tanks;
public int age = 0;
public List<IConsumer> list = new ArrayList();
public TileEntityMachineIGenerator() {
super(15);
@ -50,6 +68,14 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
public void updateEntity() {
if(!worldObj.isRemote) {
age++;
if (age >= 20) {
age = 0;
}
if (age == 9 || age == 19)
ffgeuaInit();
tanks[0].loadTank(7, 8, slots);
tanks[1].loadTank(9, 10, slots);
@ -64,7 +90,15 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
temperature += 100;
}
fuelAction();
if(temperature > maxTemperature)
temperature = maxTemperature;
int displayHeat = temperature;
rtgAction();
rotorAction();
generatorAction();
@ -81,7 +115,7 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
}
data.setIntArray("rtgs", rtgs);
data.setInteger("temp", temperature);
data.setInteger("temp", displayHeat);
data.setInteger("torque", torque);
data.setInteger("power", (int)power);
data.setShort("burn", (short) burnTime);
@ -91,6 +125,16 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
for(int i = 0; i < 3; i++)
tanks[i].updateTank(xCoord, yCoord, zCoord, this.worldObj.provider.dimensionId);
} else {
this.prevRotation = this.rotation;
this.rotation += this.torque * animSpeed / maxTorque;
if(this.rotation >= 360) {
this.rotation -= 360;
this.prevRotation -= 360;
}
}
}
@ -169,9 +213,39 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
if(pellets[i] != null)
this.temperature += pellets[i].heat;
}
}
/**
* Burns liquid fuel
*/
private void fuelAction() {
if(temperature > maxTemperature)
temperature = maxTemperature;
int heat = getHeatFromFuel(tanks[1].getTankType());
int maxBurn = 2;
if(tanks[1].getFill() > 0) {
int burn = Math.min(maxBurn, tanks[1].getFill());
tanks[1].setFill(tanks[1].getFill() - burn);
temperature += heat * burn;
}
}
public int getHeatFromFuel(FluidType type) {
switch(type) {
case SMEAR: return 75;
case HEATINGOIL: return 150;
case DIESEL: return 225;
case KEROSENE: return 300;
case RECLAIMED: return 100;
case PETROIL: return 125;
case BIOFUEL: return 200;
case NITAN: return 2500;
default: return 0;
}
}
/**
@ -203,7 +277,13 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
int conversion = getConversion();
this.torque += conversion;
if(temperature > 10 && tanks[0].getFill() > 0)
tanks[0].setFill(tanks[0].getFill() - 1);
if(torque > 10 && tanks[2].getFill() > 0 && worldObj.rand.nextInt(2) == 0)
tanks[2].setFill(tanks[2].getFill() - 1);
this.torque += conversion * (tanks[0].getFill() > 0 ? 1.5 : 1);
this.temperature -= conversion;
if(torque > maxTorque)
@ -215,7 +295,9 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
*/
private void generatorAction() {
this.power += this.torque;
double balanceFactor = 0.025D;
this.power += this.torque * balanceFactor;
torque -= getBrake();
if(power > maxPower)
@ -227,7 +309,7 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
}
public int getConversion() {
return (int) (temperature * limiter * (tanks[0].getFill() > 0 ? 1 : 0.35));
return (int) (temperature * limiter);
}
/**
@ -309,44 +391,58 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
@Override
public void ffgeuaInit() {
// TODO Auto-generated method stub
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
int[] rot = MultiblockHandlerXR.rotate(new int [] {1,0,2,2,8,8}, dir);
boolean tact = this.getTact();
for(int iy = 0; iy <= 1; iy++) {
for(int ix = -rot[4]; ix <= rot[5]; ix++) {
for(int iz = -rot[2]; iz <= rot[3]; iz++) {
if(ix == -rot[4] || ix == rot[5] || iz == -rot[2] || iz == rot[3]) {
ffgeua(xCoord + dir.offsetX * 2 + ix, yCoord + iy, zCoord + dir.offsetZ * 2 + iz, tact);
}
}
}
}
}
@Override
public void ffgeua(int x, int y, int z, boolean newTact) {
// TODO Auto-generated method stub
Library.ffgeua(x, y, z, newTact, this, worldObj);
}
@Override
public boolean getTact() {
// TODO Auto-generated method stub
if (age >= 0 && age < 10) {
return true;
}
return false;
}
@Override
public long getSPower() {
// TODO Auto-generated method stub
return 0;
return this.power;
}
@Override
public void setSPower(long i) {
// TODO Auto-generated method stub
this.power = i;
}
@Override
public List<IConsumer> getList() {
// TODO Auto-generated method stub
return null;
return this.list;
}
@Override
public void clearList() {
// TODO Auto-generated method stub
this.list.clear();
}
@Override
@ -356,14 +452,18 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
@Override
public void setFluidFill(int fill, FluidType type) {
// TODO Auto-generated method stub
if(type == FluidType.WATER)
tanks[0].setFill(fill);
else if(type == FluidType.LUBRICANT)
tanks[2].setFill(fill);
else if(tanks[1].getTankType() == type)
tanks[1].setFill(fill);
}
@Override
public void setType(FluidType type, int index) {
// TODO Auto-generated method stub
tanks[index].setTankType(type);
}
@Override
@ -449,4 +549,16 @@ public class TileEntityMachineIGenerator extends TileEntityMachineBase implement
return rtgPellets.get(item);
}
}
@Override
public AxisAlignedBB getRenderBoundingBox() {
return TileEntity.INFINITE_EXTENT_AABB;
}
@Override
@SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared()
{
return 65536.0D;
}
}