mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
bug fixes part 2
(both me and radium did testing)
This commit is contained in:
parent
e3cf157501
commit
94c97bc87a
@ -9,6 +9,8 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
|
import java.nio.BufferOverflowException;
|
||||||
|
|
||||||
public class BufPacket implements IMessage {
|
public class BufPacket implements IMessage {
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
@ -16,7 +18,7 @@ public class BufPacket implements IMessage {
|
|||||||
int z;
|
int z;
|
||||||
IBufPacketReceiver rec;
|
IBufPacketReceiver rec;
|
||||||
ByteBuf buf;
|
ByteBuf buf;
|
||||||
|
|
||||||
public BufPacket() { }
|
public BufPacket() { }
|
||||||
|
|
||||||
public BufPacket(int x, int y, int z, IBufPacketReceiver rec) {
|
public BufPacket(int x, int y, int z, IBufPacketReceiver rec) {
|
||||||
@ -43,19 +45,19 @@ public class BufPacket implements IMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Handler implements IMessageHandler<BufPacket, IMessage> {
|
public static class Handler implements IMessageHandler<BufPacket, IMessage> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(BufPacket m, MessageContext ctx) {
|
public IMessage onMessage(BufPacket m, MessageContext ctx) {
|
||||||
|
|
||||||
if(Minecraft.getMinecraft().theWorld == null)
|
if(Minecraft.getMinecraft().theWorld == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
|
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
|
||||||
|
|
||||||
if(te instanceof IBufPacketReceiver) {
|
if (te instanceof IBufPacketReceiver) {
|
||||||
((IBufPacketReceiver) te).deserialize(m.buf);
|
((IBufPacketReceiver) te).deserialize(m.buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,18 +32,18 @@ import net.minecraft.util.MovingObjectPosition;
|
|||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
|
|
||||||
public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IBufPacketReceiver, IFluidStandardReceiver, IFluidCopiable {
|
public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IBufPacketReceiver, IFluidStandardReceiver, IFluidCopiable {
|
||||||
|
|
||||||
public static final HashSet<FluidType> acceptedFuels = new HashSet();
|
public static final HashSet<FluidType> acceptedFuels = new HashSet();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
acceptedFuels.add(Fluids.WOODOIL);
|
acceptedFuels.add(Fluids.WOODOIL);
|
||||||
acceptedFuels.add(Fluids.ETHANOL);
|
acceptedFuels.add(Fluids.ETHANOL);
|
||||||
acceptedFuels.add(Fluids.FISHOIL);
|
acceptedFuels.add(Fluids.FISHOIL);
|
||||||
acceptedFuels.add(Fluids.HEAVYOIL);
|
acceptedFuels.add(Fluids.HEAVYOIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FluidTank tank;
|
public FluidTank tank;
|
||||||
|
|
||||||
public boolean isOn;
|
public boolean isOn;
|
||||||
public float syncYaw;
|
public float syncYaw;
|
||||||
public float rotationYaw;
|
public float rotationYaw;
|
||||||
@ -51,24 +51,24 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
public float syncPitch;
|
public float syncPitch;
|
||||||
public float rotationPitch;
|
public float rotationPitch;
|
||||||
public float prevRotationPitch;
|
public float prevRotationPitch;
|
||||||
|
|
||||||
// 0: searching, 1: extending, 2: retracting
|
// 0: searching, 1: extending, 2: retracting
|
||||||
private int state = 0;
|
private int state = 0;
|
||||||
|
|
||||||
private int turnProgress;
|
private int turnProgress;
|
||||||
|
|
||||||
public float spin;
|
public float spin;
|
||||||
public float lastSpin;
|
public float lastSpin;
|
||||||
|
|
||||||
public TileEntityMachineAutosaw() {
|
public TileEntityMachineAutosaw() {
|
||||||
this.tank = new FluidTank(Fluids.WOODOIL, 100);
|
this.tank = new FluidTank(Fluids.WOODOIL, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||||
if(tank.getFill() > 0) {
|
if(tank.getFill() > 0) {
|
||||||
tank.setFill(tank.getFill() - 1);
|
tank.setFill(tank.getFill() - 1);
|
||||||
@ -76,7 +76,7 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
} else {
|
} else {
|
||||||
this.isOn = false;
|
this.isOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.subscribeToAllAround(tank.getTankType(), this);
|
this.subscribeToAllAround(tank.getTankType(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,13 +90,13 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
lowerArm.rotateAroundY(-(float) Math.toRadians(rotationYaw));
|
lowerArm.rotateAroundY(-(float) Math.toRadians(rotationYaw));
|
||||||
Vec3 armTip = Vec3.createVectorHelper(0, 0, -2);
|
Vec3 armTip = Vec3.createVectorHelper(0, 0, -2);
|
||||||
armTip.rotateAroundY(-(float) Math.toRadians(rotationYaw));
|
armTip.rotateAroundY(-(float) Math.toRadians(rotationYaw));
|
||||||
|
|
||||||
double cX = pivot.xCoord + upperArm.xCoord + lowerArm.xCoord + armTip.xCoord;
|
double cX = pivot.xCoord + upperArm.xCoord + lowerArm.xCoord + armTip.xCoord;
|
||||||
double cY = pivot.yCoord;
|
double cY = pivot.yCoord;
|
||||||
double cZ = pivot.zCoord + upperArm.zCoord + lowerArm.zCoord + armTip.zCoord;
|
double cZ = pivot.zCoord + upperArm.zCoord + lowerArm.zCoord + armTip.zCoord;
|
||||||
|
|
||||||
List<EntityLivingBase> affected = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(cX - 1, cY - 0.25, cZ - 1, cX + 1, cY + 0.25, cZ + 1));
|
List<EntityLivingBase> affected = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(cX - 1, cY - 0.25, cZ - 1, cX + 1, cY + 0.25, cZ + 1));
|
||||||
|
|
||||||
for(EntityLivingBase e : affected) {
|
for(EntityLivingBase e : affected) {
|
||||||
if(e.isEntityAlive() && e.attackEntityFrom(ModDamageSource.turbofan, 100)) {
|
if(e.isEntityAlive() && e.attackEntityFrom(ModDamageSource.turbofan, 100)) {
|
||||||
worldObj.playSoundEffect(e.posX, e.posY, e.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F);
|
worldObj.playSoundEffect(e.posX, e.posY, e.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F);
|
||||||
@ -110,34 +110,34 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, e.posX, e.posY + e.height * 0.5, e.posZ), new TargetPoint(e.dimension, e.posX, e.posY, e.posZ, 50));
|
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, e.posX, e.posY + e.height * 0.5, e.posZ), new TargetPoint(e.dimension, e.posX, e.posY, e.posZ, 50));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state == 0) {
|
if(state == 0) {
|
||||||
|
|
||||||
this.rotationYaw += 1;
|
this.rotationYaw += 1;
|
||||||
|
|
||||||
if(this.rotationYaw >= 360) {
|
if(this.rotationYaw >= 360) {
|
||||||
this.rotationYaw -= 360;
|
this.rotationYaw -= 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 grace = Vec3.createVectorHelper(0, 0, -3.5);
|
Vec3 grace = Vec3.createVectorHelper(0, 0, -3.5);
|
||||||
grace.rotateAroundY(-(float) Math.toRadians(rotationYaw));
|
grace.rotateAroundY(-(float) Math.toRadians(rotationYaw));
|
||||||
grace.xCoord += pivot.xCoord;
|
grace.xCoord += pivot.xCoord;
|
||||||
grace.yCoord += pivot.yCoord;
|
grace.yCoord += pivot.yCoord;
|
||||||
grace.zCoord += pivot.zCoord;
|
grace.zCoord += pivot.zCoord;
|
||||||
|
|
||||||
Vec3 detector = Vec3.createVectorHelper(0, 0, -9);
|
Vec3 detector = Vec3.createVectorHelper(0, 0, -9);
|
||||||
detector.rotateAroundY(-(float) Math.toRadians(rotationYaw));
|
detector.rotateAroundY(-(float) Math.toRadians(rotationYaw));
|
||||||
detector.xCoord += pivot.xCoord;
|
detector.xCoord += pivot.xCoord;
|
||||||
detector.yCoord += pivot.yCoord;
|
detector.yCoord += pivot.yCoord;
|
||||||
detector.zCoord += pivot.zCoord;
|
detector.zCoord += pivot.zCoord;
|
||||||
MovingObjectPosition pos = worldObj.func_147447_a(grace, detector, false, false, false);
|
MovingObjectPosition pos = worldObj.func_147447_a(grace, detector, false, false, false);
|
||||||
|
|
||||||
if(pos != null && pos.typeOfHit == pos.typeOfHit.BLOCK) {
|
if(pos != null && pos.typeOfHit == pos.typeOfHit.BLOCK) {
|
||||||
|
|
||||||
Block b = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
Block b = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||||
|
|
||||||
if(b.getMaterial() == Material.wood || b.getMaterial() == Material.leaves || b.getMaterial() == Material.plants) {
|
if(b.getMaterial() == Material.wood || b.getMaterial() == Material.leaves || b.getMaterial() == Material.plants) {
|
||||||
|
|
||||||
int meta = worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
|
int meta = worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
|
||||||
if(!shouldIgnore(b, meta)) {
|
if(!shouldIgnore(b, meta)) {
|
||||||
state = 1;
|
state = 1;
|
||||||
@ -156,7 +156,7 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
this.tryInteract(hitX1, hitY, hitZ0);
|
this.tryInteract(hitX1, hitY, hitZ0);
|
||||||
this.tryInteract(hitX0, hitY, hitZ1);
|
this.tryInteract(hitX0, hitY, hitZ1);
|
||||||
this.tryInteract(hitX1, hitY, hitZ1);
|
this.tryInteract(hitX1, hitY, hitZ1);
|
||||||
|
|
||||||
if(state == 1) {
|
if(state == 1) {
|
||||||
this.rotationPitch += 2;
|
this.rotationPitch += 2;
|
||||||
|
|
||||||
@ -165,31 +165,31 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
state = 2;
|
state = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state == 2) {
|
if(state == 2) {
|
||||||
this.rotationPitch -= 2;
|
this.rotationPitch -= 2;
|
||||||
|
|
||||||
if(this.rotationPitch <= 0) {
|
if(this.rotationPitch <= 0) {
|
||||||
this.rotationPitch = 0;
|
this.rotationPitch = 0;
|
||||||
state = 0;
|
state = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendStandard(100);
|
sendStandard(100);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
this.lastSpin = this.spin;
|
this.lastSpin = this.spin;
|
||||||
|
|
||||||
if(isOn) {
|
if(isOn) {
|
||||||
this.spin += 15F;
|
this.spin += 15F;
|
||||||
|
|
||||||
Vec3 vec = Vec3.createVectorHelper(0.625, 0, 1.625);
|
Vec3 vec = Vec3.createVectorHelper(0.625, 0, 1.625);
|
||||||
vec.rotateAroundY(-(float) Math.toRadians(rotationYaw));
|
vec.rotateAroundY(-(float) Math.toRadians(rotationYaw));
|
||||||
|
|
||||||
worldObj.spawnParticle("smoke", xCoord + 0.5 + vec.xCoord, yCoord + 2.0625, zCoord + 0.5 + vec.zCoord, 0, 0, 0);
|
worldObj.spawnParticle("smoke", xCoord + 0.5 + vec.xCoord, yCoord + 2.0625, zCoord + 0.5 + vec.zCoord, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.spin >= 360F) {
|
if(this.spin >= 360F) {
|
||||||
this.spin -= 360F;
|
this.spin -= 360F;
|
||||||
this.lastSpin -= 360F;
|
this.lastSpin -= 360F;
|
||||||
@ -197,7 +197,7 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
|
|
||||||
this.prevRotationYaw = this.rotationYaw;
|
this.prevRotationYaw = this.rotationYaw;
|
||||||
this.prevRotationPitch = this.rotationPitch;
|
this.prevRotationPitch = this.rotationPitch;
|
||||||
|
|
||||||
if(this.turnProgress > 0) {
|
if(this.turnProgress > 0) {
|
||||||
double d0 = MathHelper.wrapAngleTo180_double(this.syncYaw - (double) this.rotationYaw);
|
double d0 = MathHelper.wrapAngleTo180_double(this.syncYaw - (double) this.rotationYaw);
|
||||||
double d1 = MathHelper.wrapAngleTo180_double(this.syncPitch - (double) this.rotationPitch);
|
double d1 = MathHelper.wrapAngleTo180_double(this.syncPitch - (double) this.rotationPitch);
|
||||||
@ -210,30 +210,30 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Anything additionally that the detector nor the blades should pick up on, like non-mature willows */
|
/** Anything additionally that the detector nor the blades should pick up on, like non-mature willows */
|
||||||
public static boolean shouldIgnore(Block b, int meta) {
|
public static boolean shouldIgnore(Block b, int meta) {
|
||||||
if(b == ModBlocks.plant_tall) {
|
if(b == ModBlocks.plant_tall) {
|
||||||
return meta == EnumTallFlower.CD2.ordinal() + 8 || meta == EnumTallFlower.CD3.ordinal() + 8;
|
return meta == EnumTallFlower.CD2.ordinal() + 8 || meta == EnumTallFlower.CD3.ordinal() + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tryInteract(int x, int y, int z) {
|
protected void tryInteract(int x, int y, int z) {
|
||||||
|
|
||||||
Block b = worldObj.getBlock(x, y, z);
|
Block b = worldObj.getBlock(x, y, z);
|
||||||
int meta = worldObj.getBlockMetadata(x, y, z);
|
int meta = worldObj.getBlockMetadata(x, y, z);
|
||||||
|
|
||||||
if(shouldIgnore(b, meta)) {
|
if(shouldIgnore(b, meta)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b.getMaterial() == Material.leaves || b.getMaterial() == Material.plants) {
|
if(b.getMaterial() == Material.leaves || b.getMaterial() == Material.plants) {
|
||||||
worldObj.func_147480_a(x, y, z, true);
|
worldObj.func_147480_a(x, y, z, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b.getMaterial() == Material.wood) {
|
if(b.getMaterial() == Material.wood) {
|
||||||
fellTree(x, y, z);
|
fellTree(x, y, z);
|
||||||
if(state == 1) {
|
if(state == 1) {
|
||||||
@ -241,22 +241,22 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fellTree(int x, int y, int z) {
|
protected void fellTree(int x, int y, int z) {
|
||||||
|
|
||||||
if(worldObj.getBlock(x, y - 1, z).getMaterial() == Material.wood) {
|
if(worldObj.getBlock(x, y - 1, z).getMaterial() == Material.wood) {
|
||||||
y--;
|
y--;
|
||||||
if(worldObj.getBlock(x, y - 2, z).getMaterial() == Material.wood) {
|
if(worldObj.getBlock(x, y - 2, z).getMaterial() == Material.wood) {
|
||||||
y--;
|
y--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int meta = -1;
|
int meta = -1;
|
||||||
|
|
||||||
for(int i = y; i < y + 10; i++) {
|
for(int i = y; i < y + 10; i++) {
|
||||||
|
|
||||||
int[][] dir = new int[][] {{0, 0}, {1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
int[][] dir = new int[][] {{0, 0}, {1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||||
|
|
||||||
for(int[] d : dir) {
|
for(int[] d : dir) {
|
||||||
Block b = worldObj.getBlock(x + d[0], i, z + d[1]);
|
Block b = worldObj.getBlock(x + d[0], i, z + d[1]);
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(meta >= 0) {
|
if(meta >= 0) {
|
||||||
if(Blocks.sapling.canPlaceBlockAt(worldObj, x, y, z)) {
|
if(Blocks.sapling.canPlaceBlockAt(worldObj, x, y, z)) {
|
||||||
worldObj.setBlock(x, y, z, Blocks.sapling, meta, 3);
|
worldObj.setBlock(x, y, z, Blocks.sapling, meta, 3);
|
||||||
@ -279,8 +279,8 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf buf) {
|
public void serialize(ByteBuf buf) {
|
||||||
buf.writeBoolean(this.isOn);
|
buf.writeBoolean(this.isOn);
|
||||||
buf.writeFloat(this.syncYaw);
|
buf.writeFloat(this.rotationYaw);
|
||||||
buf.writeFloat(this.syncPitch);
|
buf.writeFloat(this.rotationPitch);
|
||||||
this.tank.serialize(buf);
|
this.tank.serialize(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
this.turnProgress = 3; //use 3-ply for extra smoothness
|
this.turnProgress = 3; //use 3-ply for extra smoothness
|
||||||
this.tank.deserialize(buf);
|
this.tank.deserialize(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
@ -302,7 +302,7 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
this.state = nbt.getInteger("state");
|
this.state = nbt.getInteger("state");
|
||||||
this.tank.readFromNBT(nbt, "t");
|
this.tank.readFromNBT(nbt, "t");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
@ -322,12 +322,12 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
public FluidTank[] getReceivingTanks() {
|
public FluidTank[] getReceivingTanks() {
|
||||||
return new FluidTank[] {tank};
|
return new FluidTank[] {tank};
|
||||||
}
|
}
|
||||||
|
|
||||||
AxisAlignedBB bb = null;
|
AxisAlignedBB bb = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getRenderBoundingBox() {
|
public AxisAlignedBB getRenderBoundingBox() {
|
||||||
|
|
||||||
if(bb == null) {
|
if(bb == null) {
|
||||||
bb = AxisAlignedBB.getBoundingBox(
|
bb = AxisAlignedBB.getBoundingBox(
|
||||||
xCoord - 12,
|
xCoord - 12,
|
||||||
@ -338,10 +338,10 @@ public class TileEntityMachineAutosaw extends TileEntityLoadedBase implements IB
|
|||||||
zCoord + 13
|
zCoord + 13
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public double getMaxRenderDistanceSquared() {
|
public double getMaxRenderDistanceSquared() {
|
||||||
|
|||||||
@ -34,19 +34,19 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityMachineCombustionEngine extends TileEntityMachinePolluting implements IEnergyProviderMK2, IFluidStandardTransceiver, IControlReceiver, IGUIProvider, IFluidCopiable {
|
public class TileEntityMachineCombustionEngine extends TileEntityMachinePolluting implements IEnergyProviderMK2, IFluidStandardTransceiver, IControlReceiver, IGUIProvider, IFluidCopiable {
|
||||||
|
|
||||||
public boolean isOn = false;
|
public boolean isOn = false;
|
||||||
public static long maxPower = 2_500_000;
|
public static long maxPower = 2_500_000;
|
||||||
public long power;
|
public long power;
|
||||||
private int playersUsing = 0;
|
private int playersUsing = 0;
|
||||||
public int setting = 0;
|
public int setting = 0;
|
||||||
public boolean wasOn = false;
|
public boolean wasOn = false;
|
||||||
|
|
||||||
public float doorAngle = 0;
|
public float doorAngle = 0;
|
||||||
public float prevDoorAngle = 0;
|
public float prevDoorAngle = 0;
|
||||||
|
|
||||||
private AudioWrapper audio;
|
private AudioWrapper audio;
|
||||||
|
|
||||||
public FluidTank tank;
|
public FluidTank tank;
|
||||||
public int tenth = 0;
|
public int tenth = 0;
|
||||||
|
|
||||||
@ -62,26 +62,26 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
this.tank.loadTank(0, 1, slots);
|
this.tank.loadTank(0, 1, slots);
|
||||||
if(this.tank.setType(4, slots)) {
|
if(this.tank.setType(4, slots)) {
|
||||||
this.tenth = 0;
|
this.tenth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wasOn = false;
|
wasOn = false;
|
||||||
|
|
||||||
int fill = tank.getFill() * 10 + tenth;
|
int fill = tank.getFill() * 10 + tenth;
|
||||||
if(isOn && setting > 0 && slots[2] != null && slots[2].getItem() == ModItems.piston_set && fill > 0 && tank.getTankType().hasTrait(FT_Combustible.class)) {
|
if(isOn && setting > 0 && slots[2] != null && slots[2].getItem() == ModItems.piston_set && fill > 0 && tank.getTankType().hasTrait(FT_Combustible.class)) {
|
||||||
EnumPistonType piston = EnumUtil.grabEnumSafely(EnumPistonType.class, slots[2].getItemDamage());
|
EnumPistonType piston = EnumUtil.grabEnumSafely(EnumPistonType.class, slots[2].getItemDamage());
|
||||||
FT_Combustible trait = tank.getTankType().getTrait(FT_Combustible.class);
|
FT_Combustible trait = tank.getTankType().getTrait(FT_Combustible.class);
|
||||||
|
|
||||||
double eff = piston.eff[trait.getGrade().ordinal()];
|
double eff = piston.eff[trait.getGrade().ordinal()];
|
||||||
|
|
||||||
if(eff > 0) {
|
if(eff > 0) {
|
||||||
int speed = setting * 2;
|
int speed = setting * 2;
|
||||||
|
|
||||||
int toBurn = Math.min(fill, speed);
|
int toBurn = Math.min(fill, speed);
|
||||||
this.power += toBurn * (trait.getCombustionEnergy() / 10_000D) * eff;
|
this.power += toBurn * (trait.getCombustionEnergy() / 10_000D) * eff;
|
||||||
fill -= toBurn;
|
fill -= toBurn;
|
||||||
@ -89,46 +89,46 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
if(worldObj.getTotalWorldTime() % 5 == 0 && toBurn > 0) {
|
if(worldObj.getTotalWorldTime() % 5 == 0 && toBurn > 0) {
|
||||||
super.pollute(tank.getTankType(), FluidReleaseType.BURN, toBurn * 0.5F);
|
super.pollute(tank.getTankType(), FluidReleaseType.BURN, toBurn * 0.5F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(toBurn > 0) {
|
if(toBurn > 0) {
|
||||||
wasOn = true;
|
wasOn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tank.setFill(fill / 10);
|
tank.setFill(fill / 10);
|
||||||
tenth = fill % 10;
|
tenth = fill % 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagCompound data = new NBTTagCompound();
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
data.setLong("power", Math.min(power, maxPower));
|
data.setLong("power", Math.min(power, maxPower));
|
||||||
|
|
||||||
this.power = Library.chargeItemsFromTE(slots, 3, power, power);
|
this.power = Library.chargeItemsFromTE(slots, 3, power, power);
|
||||||
|
|
||||||
for(DirPos pos : getConPos()) {
|
for(DirPos pos : getConPos()) {
|
||||||
this.tryProvide(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
this.tryProvide(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||||
this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||||
this.sendSmoke(pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
this.sendSmoke(pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(power > maxPower)
|
if(power > maxPower)
|
||||||
power = maxPower;
|
power = maxPower;
|
||||||
|
|
||||||
this.networkPackNT(50);
|
this.networkPackNT(50);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.prevDoorAngle = this.doorAngle;
|
this.prevDoorAngle = this.doorAngle;
|
||||||
float swingSpeed = (doorAngle / 10F) + 3;
|
float swingSpeed = (doorAngle / 10F) + 3;
|
||||||
|
|
||||||
if(this.playersUsing > 0) {
|
if(this.playersUsing > 0) {
|
||||||
this.doorAngle += swingSpeed;
|
this.doorAngle += swingSpeed;
|
||||||
} else {
|
} else {
|
||||||
this.doorAngle -= swingSpeed;
|
this.doorAngle -= swingSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.doorAngle = MathHelper.clamp_float(this.doorAngle, 0F, 135F);
|
this.doorAngle = MathHelper.clamp_float(this.doorAngle, 0F, 135F);
|
||||||
|
|
||||||
if(wasOn) {
|
if(wasOn) {
|
||||||
|
|
||||||
if(audio == null) {
|
if(audio == null) {
|
||||||
audio = createAudioLoop();
|
audio = createAudioLoop();
|
||||||
audio.startSound();
|
audio.startSound();
|
||||||
@ -138,9 +138,9 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
|
|
||||||
audio.keepAlive();
|
audio.keepAlive();
|
||||||
audio.updateVolume(this.getVolume(1F));
|
audio.updateVolume(this.getVolume(1F));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(audio != null) {
|
if(audio != null) {
|
||||||
audio.stopSound();
|
audio.stopSound();
|
||||||
audio = null;
|
audio = null;
|
||||||
@ -148,11 +148,11 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DirPos[] getConPos() {
|
private DirPos[] getConPos() {
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||||
|
|
||||||
return new DirPos[] {
|
return new DirPos[] {
|
||||||
new DirPos(xCoord + dir.offsetX * 1 + rot.offsetX, yCoord, zCoord + dir.offsetZ * 1 + rot.offsetZ, dir),
|
new DirPos(xCoord + dir.offsetX * 1 + rot.offsetX, yCoord, zCoord + dir.offsetZ * 1 + rot.offsetZ, dir),
|
||||||
new DirPos(xCoord + dir.offsetX * 1 - rot.offsetX, yCoord, zCoord + dir.offsetZ * 1 - rot.offsetZ, dir),
|
new DirPos(xCoord + dir.offsetX * 1 - rot.offsetX, yCoord, zCoord + dir.offsetZ * 1 - rot.offsetZ, dir),
|
||||||
@ -160,7 +160,7 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
new DirPos(xCoord - dir.offsetX * 2 - rot.offsetX, yCoord, zCoord - dir.offsetZ * 2 - rot.offsetZ, dir.getOpposite())
|
new DirPos(xCoord - dir.offsetX * 2 - rot.offsetX, yCoord, zCoord - dir.offsetZ * 2 - rot.offsetZ, dir.getOpposite())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AudioWrapper createAudioLoop() {
|
public AudioWrapper createAudioLoop() {
|
||||||
return MainRegistry.proxy.getLoopedSound("hbm:block.igeneratorOperate", xCoord, yCoord, zCoord, 1.0F, 10F, 1.0F, 20);
|
return MainRegistry.proxy.getLoopedSound("hbm:block.igeneratorOperate", xCoord, yCoord, zCoord, 1.0F, 10F, 1.0F, 20);
|
||||||
@ -200,6 +200,7 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
super.serialize(buf);
|
super.serialize(buf);
|
||||||
buf.writeInt(this.playersUsing);
|
buf.writeInt(this.playersUsing);
|
||||||
buf.writeInt(this.setting);
|
buf.writeInt(this.setting);
|
||||||
|
buf.writeLong(this.power);
|
||||||
buf.writeBoolean(this.isOn);
|
buf.writeBoolean(this.isOn);
|
||||||
buf.writeBoolean(this.wasOn);
|
buf.writeBoolean(this.wasOn);
|
||||||
tank.serialize(buf);
|
tank.serialize(buf);
|
||||||
@ -210,6 +211,7 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
super.deserialize(buf);
|
super.deserialize(buf);
|
||||||
this.playersUsing = buf.readInt();
|
this.playersUsing = buf.readInt();
|
||||||
this.setting = buf.readInt();
|
this.setting = buf.readInt();
|
||||||
|
this.power = buf.readLong();
|
||||||
this.isOn = buf.readBoolean();
|
this.isOn = buf.readBoolean();
|
||||||
this.wasOn = buf.readBoolean();
|
this.wasOn = buf.readBoolean();
|
||||||
tank.deserialize(buf);
|
tank.deserialize(buf);
|
||||||
@ -234,12 +236,12 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
tank.writeToNBT(nbt, "tank");
|
tank.writeToNBT(nbt, "tank");
|
||||||
nbt.setInteger("tenth", tenth);
|
nbt.setInteger("tenth", tenth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openInventory() {
|
public void openInventory() {
|
||||||
if(!worldObj.isRemote) this.playersUsing++;
|
if(!worldObj.isRemote) this.playersUsing++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeInventory() {
|
public void closeInventory() {
|
||||||
if(!worldObj.isRemote) this.playersUsing--;
|
if(!worldObj.isRemote) this.playersUsing--;
|
||||||
@ -285,12 +287,12 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
public FluidTank[] getSendingTanks() {
|
public FluidTank[] getSendingTanks() {
|
||||||
return this.getSmokeTanks();
|
return this.getSmokeTanks();
|
||||||
}
|
}
|
||||||
|
|
||||||
AxisAlignedBB bb = null;
|
AxisAlignedBB bb = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getRenderBoundingBox() {
|
public AxisAlignedBB getRenderBoundingBox() {
|
||||||
|
|
||||||
if(bb == null) {
|
if(bb == null) {
|
||||||
bb = AxisAlignedBB.getBoundingBox(
|
bb = AxisAlignedBB.getBoundingBox(
|
||||||
xCoord - 3,
|
xCoord - 3,
|
||||||
@ -301,10 +303,10 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
zCoord + 4
|
zCoord + 4
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public double getMaxRenderDistanceSquared() {
|
public double getMaxRenderDistanceSquared() {
|
||||||
@ -320,7 +322,7 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin
|
|||||||
public void receiveControl(NBTTagCompound data) {
|
public void receiveControl(NBTTagCompound data) {
|
||||||
if(data.hasKey("turnOn")) this.isOn = !this.isOn;
|
if(data.hasKey("turnOn")) this.isOn = !this.isOn;
|
||||||
if(data.hasKey("setting")) this.setting = data.getInteger("setting");
|
if(data.hasKey("setting")) this.setting = data.getInteger("setting");
|
||||||
|
|
||||||
this.markChanged();
|
this.markChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityMachineMiningLaser extends TileEntityMachineBase implements IEnergyReceiverMK2, IMiningDrill, IFluidStandardSender, IGUIProvider, IUpgradeInfoProvider {
|
public class TileEntityMachineMiningLaser extends TileEntityMachineBase implements IEnergyReceiverMK2, IMiningDrill, IFluidStandardSender, IGUIProvider, IUpgradeInfoProvider {
|
||||||
|
|
||||||
public long power;
|
public long power;
|
||||||
public int age = 0;
|
public int age = 0;
|
||||||
public static final long maxPower = 100000000;
|
public static final long maxPower = 100000000;
|
||||||
@ -70,7 +70,7 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
double breakProgress;
|
double breakProgress;
|
||||||
|
|
||||||
public TileEntityMachineMiningLaser() {
|
public TileEntityMachineMiningLaser() {
|
||||||
|
|
||||||
//slot 0: battery
|
//slot 0: battery
|
||||||
//slots 1 - 8: upgrades
|
//slots 1 - 8: upgrades
|
||||||
//slots 9 - 29: output
|
//slots 9 - 29: output
|
||||||
@ -87,31 +87,31 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
this.updateConnections();
|
this.updateConnections();
|
||||||
|
|
||||||
this.sendFluid(tank, worldObj, xCoord + 2, yCoord, zCoord, Library.POS_X);
|
this.sendFluid(tank, worldObj, xCoord + 2, yCoord, zCoord, Library.POS_X);
|
||||||
this.sendFluid(tank, worldObj, xCoord - 2, yCoord, zCoord, Library.NEG_X);
|
this.sendFluid(tank, worldObj, xCoord - 2, yCoord, zCoord, Library.NEG_X);
|
||||||
this.sendFluid(tank, worldObj, xCoord, yCoord + 2, zCoord, Library.POS_Z);
|
this.sendFluid(tank, worldObj, xCoord, yCoord + 2, zCoord, Library.POS_Z);
|
||||||
this.sendFluid(tank, worldObj, xCoord, yCoord - 2, zCoord, Library.NEG_Z);
|
this.sendFluid(tank, worldObj, xCoord, yCoord - 2, zCoord, Library.NEG_Z);
|
||||||
|
|
||||||
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
|
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
|
||||||
|
|
||||||
//reset progress if the position changes
|
//reset progress if the position changes
|
||||||
if(lastTargetX != targetX ||
|
if(lastTargetX != targetX ||
|
||||||
lastTargetY != targetY ||
|
lastTargetY != targetY ||
|
||||||
lastTargetZ != targetZ)
|
lastTargetZ != targetZ)
|
||||||
breakProgress = 0;
|
breakProgress = 0;
|
||||||
|
|
||||||
//set last positions for interpolation and the like
|
//set last positions for interpolation and the like
|
||||||
lastTargetX = targetX;
|
lastTargetX = targetX;
|
||||||
lastTargetY = targetY;
|
lastTargetY = targetY;
|
||||||
lastTargetZ = targetZ;
|
lastTargetZ = targetZ;
|
||||||
|
|
||||||
if(isOn) {
|
if(isOn) {
|
||||||
|
|
||||||
UpgradeManager.eval(slots, 1, 8);
|
UpgradeManager.eval(slots, 1, 8);
|
||||||
int cycles = 1 + UpgradeManager.getLevel(UpgradeType.OVERDRIVE);
|
int cycles = 1 + UpgradeManager.getLevel(UpgradeType.OVERDRIVE);
|
||||||
int speed = 1 + Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 12);
|
int speed = 1 + Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 12);
|
||||||
@ -120,35 +120,35 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
int consumption = this.consumption
|
int consumption = this.consumption
|
||||||
- (this.consumption * Math.min(UpgradeManager.getLevel(UpgradeType.POWER), 12) / 16)
|
- (this.consumption * Math.min(UpgradeManager.getLevel(UpgradeType.POWER), 12) / 16)
|
||||||
+ (this.consumption * Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 12) / 16);
|
+ (this.consumption * Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 12) / 16);
|
||||||
|
|
||||||
for(int i = 0; i < cycles; i++) {
|
for(int i = 0; i < cycles; i++) {
|
||||||
|
|
||||||
if(power < consumption) {
|
if(power < consumption) {
|
||||||
beam = false;
|
beam = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
power -= consumption;
|
power -= consumption;
|
||||||
|
|
||||||
if(targetY <= 0)
|
if(targetY <= 0)
|
||||||
targetY = yCoord - 2;
|
targetY = yCoord - 2;
|
||||||
|
|
||||||
scan(range);
|
scan(range);
|
||||||
|
|
||||||
|
|
||||||
Block block = worldObj.getBlock(targetX, targetY, targetZ);
|
Block block = worldObj.getBlock(targetX, targetY, targetZ);
|
||||||
|
|
||||||
if(block.getMaterial().isLiquid()) {
|
if(block.getMaterial().isLiquid()) {
|
||||||
worldObj.setBlockToAir(targetX, targetY, targetZ);
|
worldObj.setBlockToAir(targetX, targetY, targetZ);
|
||||||
buildDam();
|
buildDam();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(beam && canBreak(block, targetX, targetY, targetZ)) {
|
if(beam && canBreak(block, targetX, targetY, targetZ)) {
|
||||||
|
|
||||||
breakProgress += getBreakSpeed(speed);
|
breakProgress += getBreakSpeed(speed);
|
||||||
clientBreakProgress = Math.min(breakProgress, 1);
|
clientBreakProgress = Math.min(breakProgress, 1);
|
||||||
|
|
||||||
if(breakProgress < 1) {
|
if(breakProgress < 1) {
|
||||||
worldObj.destroyBlockInWorldPartially(-1, targetX, targetY, targetZ, (int) Math.floor(breakProgress * 10));
|
worldObj.destroyBlockInWorldPartially(-1, targetX, targetY, targetZ, (int) Math.floor(breakProgress * 10));
|
||||||
} else {
|
} else {
|
||||||
@ -166,17 +166,18 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
this.tryFillContainer(xCoord - 2, yCoord, zCoord);
|
this.tryFillContainer(xCoord - 2, yCoord, zCoord);
|
||||||
this.tryFillContainer(xCoord, yCoord, zCoord + 2);
|
this.tryFillContainer(xCoord, yCoord, zCoord + 2);
|
||||||
this.tryFillContainer(xCoord, yCoord, zCoord - 2);
|
this.tryFillContainer(xCoord, yCoord, zCoord - 2);
|
||||||
|
|
||||||
this.networkPackNT(250);
|
this.networkPackNT(250);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateConnections() {
|
private void updateConnections() {
|
||||||
this.trySubscribe(worldObj, xCoord, yCoord + 2, zCoord, ForgeDirection.UP);
|
this.trySubscribe(worldObj, xCoord, yCoord + 2, zCoord, ForgeDirection.UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf buf) {
|
public void serialize(ByteBuf buf) {
|
||||||
|
super.serialize(buf);
|
||||||
buf.writeLong(this.power);
|
buf.writeLong(this.power);
|
||||||
buf.writeInt(this.lastTargetX);
|
buf.writeInt(this.lastTargetX);
|
||||||
buf.writeInt(this.lastTargetY);
|
buf.writeInt(this.lastTargetY);
|
||||||
@ -213,76 +214,76 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
if(worldObj.getBlock(targetX, targetY, targetZ + 1).getMaterial().isLiquid()) worldObj.setBlock(targetX, targetY, targetZ + 1, ModBlocks.barricade);
|
if(worldObj.getBlock(targetX, targetY, targetZ + 1).getMaterial().isLiquid()) worldObj.setBlock(targetX, targetY, targetZ + 1, ModBlocks.barricade);
|
||||||
if(worldObj.getBlock(targetX, targetY, targetZ - 1).getMaterial().isLiquid()) worldObj.setBlock(targetX, targetY, targetZ - 1, ModBlocks.barricade);
|
if(worldObj.getBlock(targetX, targetY, targetZ - 1).getMaterial().isLiquid()) worldObj.setBlock(targetX, targetY, targetZ - 1, ModBlocks.barricade);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryFillContainer(int x, int y, int z) {
|
private void tryFillContainer(int x, int y, int z) {
|
||||||
|
|
||||||
Block b = worldObj.getBlock(x, y, z);
|
Block b = worldObj.getBlock(x, y, z);
|
||||||
if(b != Blocks.chest && b != Blocks.trapped_chest && b != ModBlocks.crate_iron && b != ModBlocks.crate_desh &&
|
if(b != Blocks.chest && b != Blocks.trapped_chest && b != ModBlocks.crate_iron && b != ModBlocks.crate_desh &&
|
||||||
b != ModBlocks.crate_steel && b != ModBlocks.safe && b != Blocks.hopper)
|
b != ModBlocks.crate_steel && b != ModBlocks.safe && b != Blocks.hopper)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IInventory inventory = (IInventory)worldObj.getTileEntity(x, y, z);
|
IInventory inventory = (IInventory)worldObj.getTileEntity(x, y, z);
|
||||||
if(inventory == null)
|
if(inventory == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(int i = 9; i <= 29; i++) {
|
for(int i = 9; i <= 29; i++) {
|
||||||
|
|
||||||
if(slots[i] != null) {
|
if(slots[i] != null) {
|
||||||
int prev = slots[i].stackSize;
|
int prev = slots[i].stackSize;
|
||||||
slots[i] = InventoryUtil.tryAddItemToInventory(inventory, 0, inventory.getSizeInventory() - 1, slots[i]);
|
slots[i] = InventoryUtil.tryAddItemToInventory(inventory, 0, inventory.getSizeInventory() - 1, slots[i]);
|
||||||
|
|
||||||
if(slots[i] == null || slots[i].stackSize < prev)
|
if(slots[i] == null || slots[i].stackSize < prev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void breakBlock(int fortune) {
|
private void breakBlock(int fortune) {
|
||||||
|
|
||||||
Block b = worldObj.getBlock(targetX, targetY, targetZ);
|
Block b = worldObj.getBlock(targetX, targetY, targetZ);
|
||||||
int meta = worldObj.getBlockMetadata(targetX, targetY, targetZ);
|
int meta = worldObj.getBlockMetadata(targetX, targetY, targetZ);
|
||||||
boolean normal = true;
|
boolean normal = true;
|
||||||
boolean doesBreak = true;
|
boolean doesBreak = true;
|
||||||
|
|
||||||
if(b == Blocks.lit_redstone_ore)
|
if(b == Blocks.lit_redstone_ore)
|
||||||
b = Blocks.redstone_ore;
|
b = Blocks.redstone_ore;
|
||||||
|
|
||||||
ItemStack stack = new ItemStack(b, 1, meta);
|
ItemStack stack = new ItemStack(b, 1, meta);
|
||||||
|
|
||||||
if(stack != null && stack.getItem() != null) {
|
if(stack != null && stack.getItem() != null) {
|
||||||
if(hasCrystallizer()) {
|
if(hasCrystallizer()) {
|
||||||
|
|
||||||
CrystallizerRecipe result = CrystallizerRecipes.getOutput(stack, Fluids.PEROXIDE);
|
CrystallizerRecipe result = CrystallizerRecipes.getOutput(stack, Fluids.PEROXIDE);
|
||||||
if(result == null) result = CrystallizerRecipes.getOutput(stack, Fluids.SULFURIC_ACID);
|
if(result == null) result = CrystallizerRecipes.getOutput(stack, Fluids.SULFURIC_ACID);
|
||||||
|
|
||||||
if(result != null) {
|
if(result != null) {
|
||||||
worldObj.spawnEntityInWorld(new EntityItem(worldObj, targetX + 0.5, targetY + 0.5, targetZ + 0.5, result.output.copy()));
|
worldObj.spawnEntityInWorld(new EntityItem(worldObj, targetX + 0.5, targetY + 0.5, targetZ + 0.5, result.output.copy()));
|
||||||
normal = false;
|
normal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(hasCentrifuge()) {
|
} else if(hasCentrifuge()) {
|
||||||
|
|
||||||
ItemStack[] result = CentrifugeRecipes.getOutput(stack);
|
ItemStack[] result = CentrifugeRecipes.getOutput(stack);
|
||||||
if(result != null) {
|
if(result != null) {
|
||||||
for(ItemStack sta : result) {
|
for(ItemStack sta : result) {
|
||||||
|
|
||||||
if(sta != null) {
|
if(sta != null) {
|
||||||
worldObj.spawnEntityInWorld(new EntityItem(worldObj, targetX + 0.5, targetY + 0.5, targetZ + 0.5, sta.copy()));
|
worldObj.spawnEntityInWorld(new EntityItem(worldObj, targetX + 0.5, targetY + 0.5, targetZ + 0.5, sta.copy()));
|
||||||
normal = false;
|
normal = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(hasShredder()) {
|
} else if(hasShredder()) {
|
||||||
|
|
||||||
ItemStack result = ShredderRecipes.getShredderResult(stack);
|
ItemStack result = ShredderRecipes.getShredderResult(stack);
|
||||||
if(result != null && result.getItem() != ModItems.scrap) {
|
if(result != null && result.getItem() != ModItems.scrap) {
|
||||||
worldObj.spawnEntityInWorld(new EntityItem(worldObj, targetX + 0.5, targetY + 0.5, targetZ + 0.5, result.copy()));
|
worldObj.spawnEntityInWorld(new EntityItem(worldObj, targetX + 0.5, targetY + 0.5, targetZ + 0.5, result.copy()));
|
||||||
normal = false;
|
normal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(hasSmelter()) {
|
} else if(hasSmelter()) {
|
||||||
|
|
||||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
|
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
|
||||||
if(result != null) {
|
if(result != null) {
|
||||||
worldObj.spawnEntityInWorld(new EntityItem(worldObj, targetX + 0.5, targetY + 0.5, targetZ + 0.5, result.copy()));
|
worldObj.spawnEntityInWorld(new EntityItem(worldObj, targetX + 0.5, targetY + 0.5, targetZ + 0.5, result.copy()));
|
||||||
@ -290,32 +291,32 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(normal && b instanceof IDrillInteraction) {
|
if(normal && b instanceof IDrillInteraction) {
|
||||||
IDrillInteraction in = (IDrillInteraction) b;
|
IDrillInteraction in = (IDrillInteraction) b;
|
||||||
ItemStack drop = in.extractResource(worldObj, targetX, targetY, targetZ, meta, this);
|
ItemStack drop = in.extractResource(worldObj, targetX, targetY, targetZ, meta, this);
|
||||||
|
|
||||||
if(drop != null) {
|
if(drop != null) {
|
||||||
worldObj.spawnEntityInWorld(new EntityItem(worldObj, targetX + 0.5, targetY + 0.5, targetZ + 0.5, drop.copy()));
|
worldObj.spawnEntityInWorld(new EntityItem(worldObj, targetX + 0.5, targetY + 0.5, targetZ + 0.5, drop.copy()));
|
||||||
}
|
}
|
||||||
|
|
||||||
doesBreak = in.canBreak(worldObj, targetX, targetY, targetZ, meta, this);
|
doesBreak = in.canBreak(worldObj, targetX, targetY, targetZ, meta, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doesBreak) {
|
if(doesBreak) {
|
||||||
if(normal) b.dropBlockAsItem(worldObj, targetX, targetY, targetZ, meta, fortune);
|
if(normal) b.dropBlockAsItem(worldObj, targetX, targetY, targetZ, meta, fortune);
|
||||||
worldObj.func_147480_a(targetX, targetY, targetZ, false);
|
worldObj.func_147480_a(targetX, targetY, targetZ, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
suckDrops();
|
suckDrops();
|
||||||
|
|
||||||
if(doesScream()) {
|
if(doesScream()) {
|
||||||
worldObj.playSoundEffect(targetX + 0.5, targetY + 0.5, targetZ + 0.5, "hbm:block.screm", 2000.0F, 1.0F);
|
worldObj.playSoundEffect(targetX + 0.5, targetY + 0.5, targetZ + 0.5, "hbm:block.screm", 2000.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
breakProgress = 0;
|
breakProgress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<Item> bad = Sets.newHashSet(new Item[] {
|
private static final Set<Item> bad = Sets.newHashSet(new Item[] {
|
||||||
Item.getItemFromBlock(Blocks.dirt),
|
Item.getItemFromBlock(Blocks.dirt),
|
||||||
Item.getItemFromBlock(Blocks.stone),
|
Item.getItemFromBlock(Blocks.stone),
|
||||||
@ -329,14 +330,14 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
Items.snowball,
|
Items.snowball,
|
||||||
Items.wheat_seeds
|
Items.wheat_seeds
|
||||||
});
|
});
|
||||||
|
|
||||||
//hahahahahahahaha he said "suck"
|
//hahahahahahahaha he said "suck"
|
||||||
private void suckDrops() {
|
private void suckDrops() {
|
||||||
|
|
||||||
int rangeHor = 3;
|
int rangeHor = 3;
|
||||||
int rangeVer = 1;
|
int rangeVer = 1;
|
||||||
boolean nullifier = hasNullifier();
|
boolean nullifier = hasNullifier();
|
||||||
|
|
||||||
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(
|
List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(
|
||||||
targetX + 0.5 - rangeHor,
|
targetX + 0.5 - rangeHor,
|
||||||
targetY + 0.5 - rangeVer,
|
targetY + 0.5 - rangeVer,
|
||||||
@ -345,36 +346,36 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
targetY + 0.5 + rangeVer,
|
targetY + 0.5 + rangeVer,
|
||||||
targetZ + 0.5 + rangeHor
|
targetZ + 0.5 + rangeHor
|
||||||
));
|
));
|
||||||
|
|
||||||
for(EntityItem item : items) {
|
for(EntityItem item : items) {
|
||||||
|
|
||||||
if(item.isDead) continue;
|
if(item.isDead) continue;
|
||||||
|
|
||||||
if(nullifier && bad.contains(item.getEntityItem().getItem())) {
|
if(nullifier && bad.contains(item.getEntityItem().getItem())) {
|
||||||
item.setDead();
|
item.setDead();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(item.getEntityItem().getItem() == Item.getItemFromBlock(ModBlocks.ore_oil)) {
|
if(item.getEntityItem().getItem() == Item.getItemFromBlock(ModBlocks.ore_oil)) {
|
||||||
|
|
||||||
tank.setTankType(Fluids.OIL); //just to be sure
|
tank.setTankType(Fluids.OIL); //just to be sure
|
||||||
|
|
||||||
tank.setFill(tank.getFill() + 500);
|
tank.setFill(tank.getFill() + 500);
|
||||||
if(tank.getFill() > tank.getMaxFill())
|
if(tank.getFill() > tank.getMaxFill())
|
||||||
tank.setFill(tank.getMaxFill());
|
tank.setFill(tank.getMaxFill());
|
||||||
|
|
||||||
item.setDead();
|
item.setDead();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = InventoryUtil.tryAddItemToInventory(slots, 9, 29, item.getEntityItem().copy());
|
ItemStack stack = InventoryUtil.tryAddItemToInventory(slots, 9, 29, item.getEntityItem().copy());
|
||||||
|
|
||||||
if(stack == null)
|
if(stack == null)
|
||||||
item.setDead();
|
item.setDead();
|
||||||
else
|
else
|
||||||
item.setEntityItemStack(stack.copy()); //copy is not necessary but i'm paranoid due to the kerfuffle of the old drill
|
item.setEntityItemStack(stack.copy()); //copy is not necessary but i'm paranoid due to the kerfuffle of the old drill
|
||||||
}
|
}
|
||||||
|
|
||||||
List<EntityLivingBase> mobs = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(
|
List<EntityLivingBase> mobs = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(
|
||||||
targetX + 0.5 - 1,
|
targetX + 0.5 - 1,
|
||||||
targetY + 0.5 - 1,
|
targetY + 0.5 - 1,
|
||||||
@ -383,31 +384,31 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
targetY + 0.5 + 1,
|
targetY + 0.5 + 1,
|
||||||
targetZ + 0.5 + 1
|
targetZ + 0.5 + 1
|
||||||
));
|
));
|
||||||
|
|
||||||
for(EntityLivingBase mob : mobs) {
|
for(EntityLivingBase mob : mobs) {
|
||||||
mob.setFire(5);
|
mob.setFire(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getBreakSpeed(int speed) {
|
public double getBreakSpeed(int speed) {
|
||||||
|
|
||||||
float hardness = worldObj.getBlock(targetX, targetY, targetZ).getBlockHardness(worldObj, targetX, targetY, targetZ) * 15 / speed;
|
float hardness = worldObj.getBlock(targetX, targetY, targetZ).getBlockHardness(worldObj, targetX, targetY, targetZ) * 15 / speed;
|
||||||
|
|
||||||
if(hardness == 0)
|
if(hardness == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 1 / hardness;
|
return 1 / hardness;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scan(int range) {
|
public void scan(int range) {
|
||||||
|
|
||||||
for(int x = -range; x <= range; x++) {
|
for(int x = -range; x <= range; x++) {
|
||||||
for(int z = -range; z <= range; z++) {
|
for(int z = -range; z <= range; z++) {
|
||||||
|
|
||||||
if(worldObj.getBlock(x + xCoord, targetY, z + zCoord).getMaterial().isLiquid()) {
|
if(worldObj.getBlock(x + xCoord, targetY, z + zCoord).getMaterial().isLiquid()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canBreak(worldObj.getBlock(x + xCoord, targetY, z + zCoord), x + xCoord, targetY, z + zCoord)) {
|
if(canBreak(worldObj.getBlock(x + xCoord, targetY, z + zCoord), x + xCoord, targetY, z + zCoord)) {
|
||||||
targetX = x + xCoord;
|
targetX = x + xCoord;
|
||||||
targetZ = z + zCoord;
|
targetZ = z + zCoord;
|
||||||
@ -416,23 +417,23 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
beam = false;
|
beam = false;
|
||||||
targetY--;
|
targetY--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canBreak(Block block, int x, int y, int z) {
|
private boolean canBreak(Block block, int x, int y, int z) {
|
||||||
return !block.isAir(worldObj, x, y, z) && block.getBlockHardness(worldObj, x, y, z) >= 0 && !block.getMaterial().isLiquid() && block != Blocks.bedrock;
|
return !block.isAir(worldObj, x, y, z) && block.getBlockHardness(worldObj, x, y, z) >= 0 && !block.getMaterial().isLiquid() && block != Blocks.bedrock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRange() {
|
public int getRange() {
|
||||||
|
|
||||||
int range = 1;
|
int range = 1;
|
||||||
|
|
||||||
for(int i = 1; i < 9; i++) {
|
for(int i = 1; i < 9; i++) {
|
||||||
|
|
||||||
if(slots[i] != null) {
|
if(slots[i] != null) {
|
||||||
|
|
||||||
if(slots[i].getItem() == ModItems.upgrade_effect_1)
|
if(slots[i].getItem() == ModItems.upgrade_effect_1)
|
||||||
range += 2;
|
range += 2;
|
||||||
else if(slots[i].getItem() == ModItems.upgrade_effect_2)
|
else if(slots[i].getItem() == ModItems.upgrade_effect_2)
|
||||||
@ -441,100 +442,100 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
range += 6;
|
range += 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.min(range, 25);
|
return Math.min(range, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNullifier() {
|
public boolean hasNullifier() {
|
||||||
|
|
||||||
for(int i = 1; i < 9; i++) {
|
for(int i = 1; i < 9; i++) {
|
||||||
|
|
||||||
if(slots[i] != null) {
|
if(slots[i] != null) {
|
||||||
|
|
||||||
if(slots[i].getItem() == ModItems.upgrade_nullifier)
|
if(slots[i].getItem() == ModItems.upgrade_nullifier)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSmelter() {
|
public boolean hasSmelter() {
|
||||||
|
|
||||||
for(int i = 1; i < 9; i++) {
|
for(int i = 1; i < 9; i++) {
|
||||||
|
|
||||||
if(slots[i] != null) {
|
if(slots[i] != null) {
|
||||||
|
|
||||||
if(slots[i].getItem() == ModItems.upgrade_smelter)
|
if(slots[i].getItem() == ModItems.upgrade_smelter)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasShredder() {
|
public boolean hasShredder() {
|
||||||
|
|
||||||
for(int i = 1; i < 9; i++) {
|
for(int i = 1; i < 9; i++) {
|
||||||
|
|
||||||
if(slots[i] != null) {
|
if(slots[i] != null) {
|
||||||
|
|
||||||
if(slots[i].getItem() == ModItems.upgrade_shredder)
|
if(slots[i].getItem() == ModItems.upgrade_shredder)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCentrifuge() {
|
public boolean hasCentrifuge() {
|
||||||
|
|
||||||
for(int i = 1; i < 9; i++) {
|
for(int i = 1; i < 9; i++) {
|
||||||
|
|
||||||
if(slots[i] != null) {
|
if(slots[i] != null) {
|
||||||
|
|
||||||
if(slots[i].getItem() == ModItems.upgrade_centrifuge)
|
if(slots[i].getItem() == ModItems.upgrade_centrifuge)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCrystallizer() {
|
public boolean hasCrystallizer() {
|
||||||
|
|
||||||
for(int i = 1; i < 9; i++) {
|
for(int i = 1; i < 9; i++) {
|
||||||
|
|
||||||
if(slots[i] != null) {
|
if(slots[i] != null) {
|
||||||
|
|
||||||
if(slots[i].getItem() == ModItems.upgrade_crystallizer)
|
if(slots[i].getItem() == ModItems.upgrade_crystallizer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean doesScream() {
|
public boolean doesScream() {
|
||||||
|
|
||||||
for(int i = 1; i < 9; i++) {
|
for(int i = 1; i < 9; i++) {
|
||||||
|
|
||||||
if(slots[i] != null) {
|
if(slots[i] != null) {
|
||||||
|
|
||||||
if(slots[i].getItem() == ModItems.upgrade_screm)
|
if(slots[i].getItem() == ModItems.upgrade_screm)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConsumption() {
|
public int getConsumption() {
|
||||||
return this.consumption;
|
return this.consumption;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
|
|
||||||
return 1 + getRange() * 2;
|
return 1 + getRange() * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,12 +546,12 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
public int getProgressScaled(int i) {
|
public int getProgressScaled(int i) {
|
||||||
return (int) (breakProgress * i);
|
return (int) (breakProgress * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getRenderBoundingBox() {
|
public AxisAlignedBB getRenderBoundingBox() {
|
||||||
return TileEntity.INFINITE_EXTENT_AABB;
|
return TileEntity.INFINITE_EXTENT_AABB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public double getMaxRenderDistanceSquared()
|
public double getMaxRenderDistanceSquared()
|
||||||
@ -570,20 +571,20 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getAccessibleSlotsFromSide(int slot) {
|
public int[] getAccessibleSlotsFromSide(int slot) {
|
||||||
|
|
||||||
int[] slots = new int[21];
|
int[] slots = new int[21];
|
||||||
|
|
||||||
for(int i = 0; i < 21; i++) {
|
for(int i = 0; i < 21; i++) {
|
||||||
slots[i] = i + 9;
|
slots[i] = i + 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
return slots;
|
return slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInventorySlotContents(int i, ItemStack stack) {
|
public void setInventorySlotContents(int i, ItemStack stack) {
|
||||||
super.setInventorySlotContents(i, stack);
|
super.setInventorySlotContents(i, stack);
|
||||||
|
|
||||||
if(stack != null && i >= 1 && i <= 8 && stack.getItem() instanceof ItemMachineUpgrade)
|
if(stack != null && i >= 1 && i <= 8 && stack.getItem() instanceof ItemMachineUpgrade)
|
||||||
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, "hbm:item.upgradePlug", 1.0F, 1.0F);
|
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, "hbm:item.upgradePlug", 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
@ -606,7 +607,7 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
tank.readFromNBT(nbt, "oil");
|
tank.readFromNBT(nbt, "oil");
|
||||||
isOn = nbt.getBoolean("isOn");
|
isOn = nbt.getBoolean("isOn");
|
||||||
}
|
}
|
||||||
@ -614,7 +615,7 @@ public class TileEntityMachineMiningLaser extends TileEntityMachineBase implemen
|
|||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
tank.writeToNBT(nbt, "oil");
|
tank.writeToNBT(nbt, "oil");
|
||||||
nbt.setBoolean("isOn", isOn);
|
nbt.setBoolean("isOn", isOn);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,30 +44,30 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
|
|
||||||
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
||||||
public class TileEntityMachineTurbineGas extends TileEntityMachineBase implements IFluidStandardTransceiver, IEnergyProviderMK2, IControlReceiver, IGUIProvider, SimpleComponent, IInfoProviderEC, CompatHandler.OCComponent, IFluidCopiable {
|
public class TileEntityMachineTurbineGas extends TileEntityMachineBase implements IFluidStandardTransceiver, IEnergyProviderMK2, IControlReceiver, IGUIProvider, SimpleComponent, IInfoProviderEC, CompatHandler.OCComponent, IFluidCopiable {
|
||||||
|
|
||||||
public long power;
|
public long power;
|
||||||
public static final long maxPower = 1000000L;
|
public static final long maxPower = 1000000L;
|
||||||
|
|
||||||
public int rpm; //0-100, crescent moon gauge, used for calculating the amount of power generated, starts past 10%
|
public int rpm; //0-100, crescent moon gauge, used for calculating the amount of power generated, starts past 10%
|
||||||
public int temp; //0-800, used for figuring out how much water to boil, starts boiling at 300°C
|
public int temp; //0-800, used for figuring out how much water to boil, starts boiling at 300°C
|
||||||
public int rpmIdle = 10;
|
public int rpmIdle = 10;
|
||||||
public int tempIdle = 300;
|
public int tempIdle = 300;
|
||||||
|
|
||||||
public int powerSliderPos; //goes from 0 to 60, 0 is idle, 60 is max power
|
public int powerSliderPos; //goes from 0 to 60, 0 is idle, 60 is max power
|
||||||
public int throttle; //the same thing, but goes from 0 to 100
|
public int throttle; //the same thing, but goes from 0 to 100
|
||||||
|
|
||||||
public boolean autoMode;
|
public boolean autoMode;
|
||||||
public int state = 0; //0 is offline, -1 is startup, 1 is online
|
public int state = 0; //0 is offline, -1 is startup, 1 is online
|
||||||
|
|
||||||
public int counter = 0; //used to startup and shutdown
|
public int counter = 0; //used to startup and shutdown
|
||||||
public int instantPowerOutput;
|
public int instantPowerOutput;
|
||||||
|
|
||||||
public FluidTank[] tanks;
|
public FluidTank[] tanks;
|
||||||
|
|
||||||
private AudioWrapper audio;
|
private AudioWrapper audio;
|
||||||
|
|
||||||
public static HashMap<FluidType, Double> fuelMaxCons = new HashMap(); //fuel consumption per tick at max power
|
public static HashMap<FluidType, Double> fuelMaxCons = new HashMap(); //fuel consumption per tick at max power
|
||||||
|
|
||||||
static {
|
static {
|
||||||
fuelMaxCons.put(Fluids.GAS, 50D); // natgas doesn't burn well so it burns faster to compensate
|
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.SYNGAS, 10D); // syngas just fucks
|
||||||
@ -75,9 +75,9 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
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
|
// default to 5 if not in list
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO particles from heat exchanger maybe? maybe in a future
|
//TODO particles from heat exchanger maybe? maybe in a future
|
||||||
|
|
||||||
public TileEntityMachineTurbineGas() {
|
public TileEntityMachineTurbineGas() {
|
||||||
super(2);
|
super(2);
|
||||||
this.tanks = new FluidTank[4];
|
this.tanks = new FluidTank[4];
|
||||||
@ -91,23 +91,23 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
throttle = powerSliderPos * 100 / 60;
|
throttle = powerSliderPos * 100 / 60;
|
||||||
|
|
||||||
if(slots[1] != null && slots[1].getItem() instanceof IItemFluidIdentifier) {
|
if(slots[1] != null && slots[1].getItem() instanceof IItemFluidIdentifier) {
|
||||||
FluidType fluid = ((IItemFluidIdentifier) slots[1].getItem()).getType(worldObj, xCoord, yCoord, zCoord, slots[1]);
|
FluidType fluid = ((IItemFluidIdentifier) slots[1].getItem()).getType(worldObj, xCoord, yCoord, zCoord, slots[1]);
|
||||||
if(fluid.hasTrait(FT_Combustible.class) && fluid.getTrait(FT_Combustible.class).getGrade() == FuelGrade.GAS) {
|
if(fluid.hasTrait(FT_Combustible.class) && fluid.getTrait(FT_Combustible.class).getGrade() == FuelGrade.GAS) {
|
||||||
tanks[0].setTankType(fluid);
|
tanks[0].setTankType(fluid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(autoMode) { //power production depending on power requirement
|
if(autoMode) { //power production depending on power requirement
|
||||||
|
|
||||||
//scales the slider proportionally to the power gauge
|
//scales the slider proportionally to the power gauge
|
||||||
int powerSliderTarget = 60 - (int) (60 * power / maxPower);
|
int powerSliderTarget = 60 - (int) (60 * power / maxPower);
|
||||||
|
|
||||||
if(powerSliderTarget > powerSliderPos) { //makes the auto slider slide instead of snapping into position
|
if(powerSliderTarget > powerSliderPos) { //makes the auto slider slide instead of snapping into position
|
||||||
powerSliderPos++;
|
powerSliderPos++;
|
||||||
}
|
}
|
||||||
@ -115,23 +115,23 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
powerSliderPos--;
|
powerSliderPos--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(state) { //what to do when turbine offline, starting up and online
|
switch(state) { //what to do when turbine offline, starting up and online
|
||||||
case 0:
|
case 0:
|
||||||
shutdown();
|
shutdown();
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
stopIfNotReady();
|
stopIfNotReady();
|
||||||
startup();
|
startup();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
stopIfNotReady();
|
stopIfNotReady();
|
||||||
run();
|
run();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||||
|
|
||||||
@ -140,11 +140,11 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
//do net/battery deductions first...
|
//do net/battery deductions first...
|
||||||
power = Library.chargeItemsFromTE(slots, 0, power, maxPower);
|
power = Library.chargeItemsFromTE(slots, 0, power, maxPower);
|
||||||
this.tryProvide(worldObj, xCoord - dir.offsetZ * 5, yCoord + 1, zCoord + dir.offsetX * 5, rot); //sends out power
|
this.tryProvide(worldObj, xCoord - dir.offsetZ * 5, yCoord + 1, zCoord + dir.offsetX * 5, rot); //sends out power
|
||||||
|
|
||||||
//...and then cap it. Prevents potential future cases where power would be limited due to the fuel being too strong and the buffer too small.
|
//...and then cap it. Prevents potential future cases where power would be limited due to the fuel being too strong and the buffer too small.
|
||||||
if(this.power > this.maxPower)
|
if(this.power > this.maxPower)
|
||||||
this.power = this.maxPower;
|
this.power = this.maxPower;
|
||||||
|
|
||||||
for(int i = 0; i < 2; i++) { //fuel and lube
|
for(int i = 0; i < 2; i++) { //fuel and lube
|
||||||
this.trySubscribe(tanks[i].getTankType(), worldObj, xCoord - dir.offsetX * 2 + rot.offsetX, yCoord, zCoord - dir.offsetZ * 2 + rot.offsetZ, dir.getOpposite());
|
this.trySubscribe(tanks[i].getTankType(), worldObj, xCoord - dir.offsetX * 2 + rot.offsetX, yCoord, zCoord - dir.offsetZ * 2 + rot.offsetZ, dir.getOpposite());
|
||||||
this.trySubscribe(tanks[i].getTankType(), worldObj, xCoord + dir.offsetX * 2 + rot.offsetX, yCoord, zCoord + dir.offsetZ * 2 + rot.offsetZ, dir);
|
this.trySubscribe(tanks[i].getTankType(), worldObj, xCoord + dir.offsetX * 2 + rot.offsetX, yCoord, zCoord + dir.offsetZ * 2 + rot.offsetZ, dir);
|
||||||
@ -154,29 +154,29 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
this.trySubscribe(tanks[2].getTankType(), worldObj, xCoord + dir.offsetX * 2 + rot.offsetX * -4, yCoord, zCoord + dir.offsetZ * 2 + rot.offsetZ * -4, dir);
|
this.trySubscribe(tanks[2].getTankType(), worldObj, xCoord + dir.offsetX * 2 + rot.offsetX * -4, yCoord, zCoord + dir.offsetZ * 2 + rot.offsetZ * -4, dir);
|
||||||
//steam
|
//steam
|
||||||
this.sendFluid(tanks[3], worldObj, xCoord + dir.offsetZ * 6, yCoord + 1, zCoord - dir.offsetX * 6, rot.getOpposite());
|
this.sendFluid(tanks[3], worldObj, xCoord + dir.offsetZ * 6, yCoord + 1, zCoord - dir.offsetX * 6, rot.getOpposite());
|
||||||
|
|
||||||
this.networkPackNT(150);
|
this.networkPackNT(150);
|
||||||
|
|
||||||
} else { //client side, for sounds n shit
|
} else { //client side, for sounds n shit
|
||||||
|
|
||||||
if(rpm >= 10 && state != -1) { //if conditions are right, play the sound
|
if(rpm >= 10 && state != -1) { //if conditions are right, play the sound
|
||||||
|
|
||||||
if(audio == null) { //if there is no sound playing, start it
|
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);
|
||||||
audio.startSound();
|
audio.startSound();
|
||||||
|
|
||||||
} else if(!audio.isPlaying()) {
|
} else if(!audio.isPlaying()) {
|
||||||
audio.stopSound();
|
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);
|
||||||
audio.startSound();
|
audio.startSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
audio.updatePitch((float) (0.55 + 0.1 * rpm / 10)); //dynamic pitch update based on rpm
|
audio.updatePitch((float) (0.55 + 0.1 * rpm / 10)); //dynamic pitch update based on rpm
|
||||||
audio.updateVolume(getVolume(2F)); //yeah i need this
|
audio.updateVolume(getVolume(2F)); //yeah i need this
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(audio != null) {
|
if(audio != null) {
|
||||||
audio.stopSound();
|
audio.stopSound();
|
||||||
audio = null;
|
audio = null;
|
||||||
@ -216,8 +216,8 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
this.temp = buf.readInt();
|
this.temp = buf.readInt();
|
||||||
this.state = buf.readInt();
|
this.state = buf.readInt();
|
||||||
this.autoMode = buf.readBoolean();
|
this.autoMode = buf.readBoolean();
|
||||||
this.powerSliderPos = buf.readInt();
|
|
||||||
this.throttle = buf.readInt();
|
this.throttle = buf.readInt();
|
||||||
|
this.powerSliderPos = buf.readInt();
|
||||||
|
|
||||||
if(state != 1)
|
if(state != 1)
|
||||||
this.counter = buf.readInt();
|
this.counter = buf.readInt();
|
||||||
@ -229,9 +229,9 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
this.tanks[2].deserialize(buf);
|
this.tanks[2].deserialize(buf);
|
||||||
this.tanks[3].deserialize(buf);
|
this.tanks[3].deserialize(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopIfNotReady() {
|
private void stopIfNotReady() {
|
||||||
|
|
||||||
if(tanks[0].getFill() == 0 || tanks[1].getFill() == 0) {
|
if(tanks[0].getFill() == 0 || tanks[1].getFill() == 0) {
|
||||||
state = 0;
|
state = 0;
|
||||||
}
|
}
|
||||||
@ -239,20 +239,20 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
state = 0;
|
state = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAcceptableFuel() {
|
public boolean hasAcceptableFuel() {
|
||||||
|
|
||||||
if(tanks[0].getTankType().hasTrait(FT_Combustible.class)) {
|
if(tanks[0].getTankType().hasTrait(FT_Combustible.class)) {
|
||||||
return tanks[0].getTankType().getTrait(FT_Combustible.class).getGrade() == FuelGrade.GAS;
|
return tanks[0].getTankType().getTrait(FT_Combustible.class).getGrade() == FuelGrade.GAS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startup() {
|
private void startup() {
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
if(counter <= 20) //rpm gauge 0-100-0
|
if(counter <= 20) //rpm gauge 0-100-0
|
||||||
rpm = 5 * counter;
|
rpm = 5 * counter;
|
||||||
else if (counter > 20 && counter <= 40)
|
else if (counter > 20 && counter <= 40)
|
||||||
@ -261,43 +261,43 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
rpm = (int) (rpmIdle * (counter - 50) / 530); //slowly ramps up temp and RPM
|
rpm = (int) (rpmIdle * (counter - 50) / 530); //slowly ramps up temp and RPM
|
||||||
temp = (int) (tempIdle * (counter - 50) / 530);
|
temp = (int) (tempIdle * (counter - 50) / 530);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(counter == 50) {
|
if(counter == 50) {
|
||||||
worldObj.playSoundEffect(xCoord, yCoord + 2, zCoord, "hbm:block.turbinegasStartup", getVolume(1.0F), 1.0F);
|
worldObj.playSoundEffect(xCoord, yCoord + 2, zCoord, "hbm:block.turbinegasStartup", getVolume(1.0F), 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(counter == 580) {
|
if(counter == 580) {
|
||||||
state = 1;
|
state = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int rpmLast; //used to progressively slow down and cool the turbine without immediatly setting rpm and temp to 0
|
int rpmLast; //used to progressively slow down and cool the turbine without immediatly setting rpm and temp to 0
|
||||||
int tempLast;
|
int tempLast;
|
||||||
|
|
||||||
private void shutdown() {
|
private void shutdown() {
|
||||||
|
|
||||||
autoMode = false;
|
autoMode = false;
|
||||||
instantPowerOutput = 0;
|
instantPowerOutput = 0;
|
||||||
|
|
||||||
if(powerSliderPos > 0)
|
if(powerSliderPos > 0)
|
||||||
powerSliderPos--;
|
powerSliderPos--;
|
||||||
|
|
||||||
if(rpm <= 10 && counter > 0) {
|
if(rpm <= 10 && counter > 0) {
|
||||||
|
|
||||||
if(counter == 225) {
|
if(counter == 225) {
|
||||||
|
|
||||||
worldObj.playSoundEffect(xCoord, yCoord + 2, zCoord, "hbm:block.turbinegasShutdown", getVolume(1.0F), 1.0F);
|
worldObj.playSoundEffect(xCoord, yCoord + 2, zCoord, "hbm:block.turbinegasShutdown", getVolume(1.0F), 1.0F);
|
||||||
|
|
||||||
rpmLast = rpm;
|
rpmLast = rpm;
|
||||||
tempLast = temp;
|
tempLast = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
counter--;
|
counter--;
|
||||||
|
|
||||||
rpm = (int) (rpmLast * (counter) / 225);
|
rpm = (int) (rpmLast * (counter) / 225);
|
||||||
temp = (int) (tempLast * (counter) / 225);
|
temp = (int) (tempLast * (counter) / 225);
|
||||||
|
|
||||||
} else if(rpm > 11) { //quickly slows down the turbine to idle before shutdown
|
} else if(rpm > 11) { //quickly slows down the turbine to idle before shutdown
|
||||||
counter = 42069; //absolutely necessary to avoid fuckeries on shutdown
|
counter = 42069; //absolutely necessary to avoid fuckeries on shutdown
|
||||||
rpm--;
|
rpm--;
|
||||||
@ -306,15 +306,15 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
rpm--;
|
rpm--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dynamically calculates a (hopefully) sensible burn heat from the combustion energy, scales from 300°C - 800°C */
|
/** Dynamically calculates a (hopefully) sensible burn heat from the combustion energy, scales from 300°C - 800°C */
|
||||||
protected int getFluidBurnTemp(FluidType type) {
|
protected int getFluidBurnTemp(FluidType type) {
|
||||||
double dFuel = type.hasTrait(FT_Combustible.class) ? type.getTrait(FT_Combustible.class).getCombustionEnergy() : 0;
|
double dFuel = type.hasTrait(FT_Combustible.class) ? type.getTrait(FT_Combustible.class).getCombustionEnergy() : 0;
|
||||||
return (int) Math.floor(800D - (Math.pow(Math.E, -dFuel / 100_000D)) * 300D);
|
return (int) Math.floor(800D - (Math.pow(Math.E, -dFuel / 100_000D)) * 300D);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run() {
|
private void run() {
|
||||||
|
|
||||||
if((int) (throttle * 0.9) > rpm - rpmIdle) { //simulates the rotor's moment of inertia
|
if((int) (throttle * 0.9) > rpm - rpmIdle) { //simulates the rotor's moment of inertia
|
||||||
if(worldObj.getTotalWorldTime() % 5 == 0) {
|
if(worldObj.getTotalWorldTime() % 5 == 0) {
|
||||||
rpm++;
|
rpm++;
|
||||||
@ -324,9 +324,9 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
rpm--;
|
rpm--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxTemp = getFluidBurnTemp(tanks[0].getTankType()); // fuelMaxTemp.get(tanks[0].getTankType())
|
int maxTemp = getFluidBurnTemp(tanks[0].getTankType()); // fuelMaxTemp.get(tanks[0].getTankType())
|
||||||
|
|
||||||
if(throttle * 5 * (maxTemp - tempIdle) / 500 > temp - tempIdle) { //simulates the heat exchanger's resistance to temperature variation
|
if(throttle * 5 * (maxTemp - tempIdle) / 500 > temp - tempIdle) { //simulates the heat exchanger's resistance to temperature variation
|
||||||
if(worldObj.getTotalWorldTime() % 2 == 0) {
|
if(worldObj.getTotalWorldTime() % 2 == 0) {
|
||||||
temp++;
|
temp++;
|
||||||
@ -336,30 +336,30 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
temp--;
|
temp--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double consumption = fuelMaxCons.containsKey(tanks[0].getTankType()) ? fuelMaxCons.get(tanks[0].getTankType()) : 5D;
|
double consumption = fuelMaxCons.containsKey(tanks[0].getTankType()) ? fuelMaxCons.get(tanks[0].getTankType()) : 5D;
|
||||||
if(worldObj.getTotalWorldTime() % 20 == 0 && tanks[0].getTankType() != Fluids.OXYHYDROGEN) PollutionHandler.incrementPollution(worldObj, xCoord, yCoord, zCoord, PollutionType.SOOT, PollutionHandler.SOOT_PER_SECOND * 3);
|
if(worldObj.getTotalWorldTime() % 20 == 0 && tanks[0].getTankType() != Fluids.OXYHYDROGEN) PollutionHandler.incrementPollution(worldObj, xCoord, yCoord, zCoord, PollutionType.SOOT, PollutionHandler.SOOT_PER_SECOND * 3);
|
||||||
makePower(consumption, throttle);
|
makePower(consumption, throttle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double fuelToConsume; //used to consume 1 mb of fuel at a time when consumption is <1 mb/tick
|
double fuelToConsume; //used to consume 1 mb of fuel at a time when consumption is <1 mb/tick
|
||||||
double waterToBoil;
|
double waterToBoil;
|
||||||
double waterPerTick = 0;
|
double waterPerTick = 0;
|
||||||
|
|
||||||
private void makePower(double consMax, int throttle) {
|
private void makePower(double consMax, int throttle) {
|
||||||
|
|
||||||
double idleConsumption = consMax * 0.05D;
|
double idleConsumption = consMax * 0.05D;
|
||||||
double consumption = idleConsumption + consMax * throttle / 100;
|
double consumption = idleConsumption + consMax * throttle / 100;
|
||||||
|
|
||||||
fuelToConsume += consumption;
|
fuelToConsume += consumption;
|
||||||
|
|
||||||
tanks[0].setFill(tanks[0].getFill() - (int) Math.floor(fuelToConsume));
|
tanks[0].setFill(tanks[0].getFill() - (int) Math.floor(fuelToConsume));
|
||||||
fuelToConsume -= (int) Math.floor(fuelToConsume);
|
fuelToConsume -= (int) Math.floor(fuelToConsume);
|
||||||
|
|
||||||
if(worldObj.getTotalWorldTime() % 10 == 0) //lube consumption
|
if(worldObj.getTotalWorldTime() % 10 == 0) //lube consumption
|
||||||
tanks[1].setFill(tanks[1].getFill() - 1);
|
tanks[1].setFill(tanks[1].getFill() - 1);
|
||||||
|
|
||||||
if(tanks[0].getFill() < 0) { //avoids negative amounts of fluid
|
if(tanks[0].getFill() < 0) { //avoids negative amounts of fluid
|
||||||
tanks[0].setFill(0);
|
tanks[0].setFill(0);
|
||||||
state = 0;
|
state = 0;
|
||||||
@ -368,16 +368,16 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
tanks[1].setFill(0);
|
tanks[1].setFill(0);
|
||||||
state = 0;
|
state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long energy = 0; //energy per mb of fuel
|
long energy = 0; //energy per mb of fuel
|
||||||
|
|
||||||
if(tanks[0].getTankType().hasTrait(FT_Combustible.class)) {
|
if(tanks[0].getTankType().hasTrait(FT_Combustible.class)) {
|
||||||
energy = tanks[0].getTankType().getTrait(FT_Combustible.class).getCombustionEnergy() / 1000L;
|
energy = tanks[0].getTankType().getTrait(FT_Combustible.class).getCombustionEnergy() / 1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rpmEff = rpm - rpmIdle; // RPM above idle level, 0-90
|
int rpmEff = rpm - rpmIdle; // RPM above idle level, 0-90
|
||||||
|
|
||||||
//consMax*energy is equivalent to power production at 100%
|
//consMax*energy is equivalent to power production at 100%
|
||||||
if(instantPowerOutput < (consMax * energy * rpmEff / 90)) { //this shit avoids power rising in steps of 2000 or so HE at a time, instead it does it smoothly
|
if(instantPowerOutput < (consMax * energy * rpmEff / 90)) { //this shit avoids power rising in steps of 2000 or so HE at a time, instead it does it smoothly
|
||||||
instantPowerOutput += Math.random() * 0.005 * consMax * energy;
|
instantPowerOutput += Math.random() * 0.005 * consMax * energy;
|
||||||
@ -390,22 +390,22 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
instantPowerOutput = (int) (consMax * energy * rpmEff / 90);
|
instantPowerOutput = (int) (consMax * energy * rpmEff / 90);
|
||||||
}
|
}
|
||||||
this.power += instantPowerOutput;
|
this.power += instantPowerOutput;
|
||||||
|
|
||||||
waterPerTick = (consMax * energy * (temp - tempIdle) / 220000); //it just works fuck you
|
waterPerTick = (consMax * energy * (temp - tempIdle) / 220000); //it just works fuck you
|
||||||
|
|
||||||
if(tanks[2].getFill() >= Math.ceil(waterPerTick)) { //checks if there's enough water to boil
|
if(tanks[2].getFill() >= Math.ceil(waterPerTick)) { //checks if there's enough water to boil
|
||||||
|
|
||||||
waterToBoil += waterPerTick;
|
waterToBoil += waterPerTick;
|
||||||
|
|
||||||
if(tanks[3].getFill() <= 160000 - waterToBoil * 10) { //checks if there's room for steam in the tank
|
if(tanks[3].getFill() <= 160000 - waterToBoil * 10) { //checks if there's room for steam in the tank
|
||||||
|
|
||||||
tanks[2].setFill(tanks[2].getFill() - (int) Math.floor(waterToBoil));
|
tanks[2].setFill(tanks[2].getFill() - (int) Math.floor(waterToBoil));
|
||||||
tanks[3].setFill(tanks[3].getFill() + 10 * (int) Math.floor(waterToBoil));
|
tanks[3].setFill(tanks[3].getFill() + 10 * (int) Math.floor(waterToBoil));
|
||||||
waterToBoil -= (int) Math.floor(waterToBoil);
|
waterToBoil -= (int) Math.floor(waterToBoil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -424,11 +424,11 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
this.instantPowerOutput = nbt.getInteger("instPwr");
|
this.instantPowerOutput = nbt.getInteger("instPwr");
|
||||||
this.counter = nbt.getInteger("counter");
|
this.counter = nbt.getInteger("counter");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
tanks[0].writeToNBT(nbt, "gas");
|
tanks[0].writeToNBT(nbt, "gas");
|
||||||
tanks[1].writeToNBT(nbt, "lube");
|
tanks[1].writeToNBT(nbt, "lube");
|
||||||
tanks[2].writeToNBT(nbt, "water");
|
tanks[2].writeToNBT(nbt, "water");
|
||||||
@ -454,24 +454,24 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveControl(NBTTagCompound data) {
|
public void receiveControl(NBTTagCompound data) {
|
||||||
|
|
||||||
if(data.hasKey("slidPos"))
|
if(data.hasKey("slidPos"))
|
||||||
powerSliderPos = data.getInteger("slidPos");
|
powerSliderPos = data.getInteger("slidPos");
|
||||||
|
|
||||||
if(data.hasKey("autoMode"))
|
if(data.hasKey("autoMode"))
|
||||||
autoMode = data.getBoolean("autoMode");
|
autoMode = data.getBoolean("autoMode");
|
||||||
|
|
||||||
if(data.hasKey("state"))
|
if(data.hasKey("state"))
|
||||||
state = data.getInteger("state");
|
state = data.getInteger("state");
|
||||||
|
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(EntityPlayer player) {
|
public boolean hasPermission(EntityPlayer player) {
|
||||||
return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 25;
|
return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChunkUnload() {
|
public void onChunkUnload() {
|
||||||
|
|
||||||
@ -501,17 +501,17 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
public long getPower() {
|
public long getPower() {
|
||||||
return this.power;
|
return this.power;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMaxPower() {
|
public long getMaxPower() {
|
||||||
return this.maxPower;
|
return this.maxPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
AxisAlignedBB bb = null;
|
AxisAlignedBB bb = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getRenderBoundingBox() {
|
public AxisAlignedBB getRenderBoundingBox() {
|
||||||
|
|
||||||
if(bb == null) {
|
if(bb == null) {
|
||||||
bb = AxisAlignedBB.getBoundingBox(
|
bb = AxisAlignedBB.getBoundingBox(
|
||||||
xCoord - 5,
|
xCoord - 5,
|
||||||
@ -522,10 +522,10 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
zCoord + 6
|
zCoord + 6
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public double getMaxRenderDistanceSquared() {
|
public double getMaxRenderDistanceSquared() {
|
||||||
@ -551,7 +551,7 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
public FluidTank[] getSendingTanks() {
|
public FluidTank[] getSendingTanks() {
|
||||||
return new FluidTank[] { tanks[3] };
|
return new FluidTank[] { tanks[3] };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection dir) {
|
public boolean canConnect(ForgeDirection dir) {
|
||||||
return dir != ForgeDirection.DOWN;
|
return dir != ForgeDirection.DOWN;
|
||||||
@ -716,4 +716,4 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
data.setDouble(CompatEnergyControl.D_CONSUMPTION_MB, this.waterToBoil);
|
data.setDouble(CompatEnergyControl.D_CONSUMPTION_MB, this.waterToBoil);
|
||||||
data.setDouble(CompatEnergyControl.D_OUTPUT_MB, this.waterToBoil * 10);
|
data.setDouble(CompatEnergyControl.D_OUTPUT_MB, this.waterToBoil * 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -402,7 +402,7 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
this.typeLoaded = buf.readInt();
|
this.typeLoaded = buf.readInt();
|
||||||
this.amountLoaded = buf.readInt();
|
this.amountLoaded = buf.readInt();
|
||||||
this.rodLevel = buf.readDouble();
|
this.rodLevel = buf.readDouble();
|
||||||
this.rodTarget = buf.readInt();
|
this.rodTarget = buf.readDouble();
|
||||||
this.coreHeatCapacity = buf.readLong();
|
this.coreHeatCapacity = buf.readLong();
|
||||||
tanks[0].deserialize(buf);
|
tanks[0].deserialize(buf);
|
||||||
tanks[1].deserialize(buf);
|
tanks[1].deserialize(buf);
|
||||||
|
|||||||
@ -39,14 +39,14 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IEner
|
|||||||
|
|
||||||
private int turnProgress;
|
private int turnProgress;
|
||||||
private float acceleration = 0F;
|
private float acceleration = 0F;
|
||||||
|
|
||||||
/* CONFIGURABLE */
|
/* CONFIGURABLE */
|
||||||
private static int steamCap = 2_000;
|
private static int steamCap = 2_000;
|
||||||
private static int ldsCap = 20;
|
private static int ldsCap = 20;
|
||||||
private static double efficiency = 0.85D;
|
private static double efficiency = 0.85D;
|
||||||
|
|
||||||
public TileEntitySteamEngine() {
|
public TileEntitySteamEngine() {
|
||||||
|
|
||||||
tanks = new FluidTank[2];
|
tanks = new FluidTank[2];
|
||||||
tanks[0] = new FluidTank(Fluids.STEAM, steamCap);
|
tanks[0] = new FluidTank(Fluids.STEAM, steamCap);
|
||||||
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, ldsCap);
|
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, ldsCap);
|
||||||
@ -75,9 +75,9 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IEner
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
this.powerBuffer = 0;
|
this.powerBuffer = 0;
|
||||||
|
|
||||||
tanks[0].setTankType(Fluids.STEAM);
|
tanks[0].setTankType(Fluids.STEAM);
|
||||||
@ -87,29 +87,29 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IEner
|
|||||||
|
|
||||||
FT_Coolable trait = tanks[0].getTankType().getTrait(FT_Coolable.class);
|
FT_Coolable trait = tanks[0].getTankType().getTrait(FT_Coolable.class);
|
||||||
double eff = trait.getEfficiency(CoolingType.TURBINE) * efficiency;
|
double eff = trait.getEfficiency(CoolingType.TURBINE) * efficiency;
|
||||||
|
|
||||||
int inputOps = tanks[0].getFill() / trait.amountReq;
|
int inputOps = tanks[0].getFill() / trait.amountReq;
|
||||||
int outputOps = (tanks[1].getMaxFill() - tanks[1].getFill()) / trait.amountProduced;
|
int outputOps = (tanks[1].getMaxFill() - tanks[1].getFill()) / trait.amountProduced;
|
||||||
int ops = Math.min(inputOps, outputOps);
|
int ops = Math.min(inputOps, outputOps);
|
||||||
tanks[0].setFill(tanks[0].getFill() - ops * trait.amountReq);
|
tanks[0].setFill(tanks[0].getFill() - ops * trait.amountReq);
|
||||||
tanks[1].setFill(tanks[1].getFill() + ops * trait.amountProduced);
|
tanks[1].setFill(tanks[1].getFill() + ops * trait.amountProduced);
|
||||||
this.powerBuffer += (ops * trait.heatEnergy * eff);
|
this.powerBuffer += (ops * trait.heatEnergy * eff);
|
||||||
|
|
||||||
if(ops > 0) {
|
if(ops > 0) {
|
||||||
this.acceleration += 0.1F;
|
this.acceleration += 0.1F;
|
||||||
} else {
|
} else {
|
||||||
this.acceleration -= 0.1F;
|
this.acceleration -= 0.1F;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.acceleration = MathHelper.clamp_float(this.acceleration, 0F, 40F);
|
this.acceleration = MathHelper.clamp_float(this.acceleration, 0F, 40F);
|
||||||
this.rotor += this.acceleration;
|
this.rotor += this.acceleration;
|
||||||
|
|
||||||
if(this.rotor >= 360D) {
|
if(this.rotor >= 360D) {
|
||||||
this.rotor -= 360D;
|
this.rotor -= 360D;
|
||||||
|
|
||||||
this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:block.steamEngineOperate", getVolume(1.0F), 0.5F + (acceleration / 80F));
|
this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:block.steamEngineOperate", getVolume(1.0F), 0.5F + (acceleration / 80F));
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.writeLong(this.powerBuffer);
|
buf.writeLong(this.powerBuffer);
|
||||||
buf.writeFloat(this.rotor);
|
buf.writeFloat(this.rotor);
|
||||||
tanks[1].serialize(buf);
|
tanks[1].serialize(buf);
|
||||||
@ -119,11 +119,11 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IEner
|
|||||||
this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||||
this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
this.sendFluid(tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
sendStandard(150);
|
sendStandard(150);
|
||||||
} else {
|
} else {
|
||||||
this.lastRotor = this.rotor;
|
this.lastRotor = this.rotor;
|
||||||
|
|
||||||
if(this.turnProgress > 0) {
|
if(this.turnProgress > 0) {
|
||||||
double d = MathHelper.wrapAngleTo180_double(this.syncRotor - (double) this.rotor);
|
double d = MathHelper.wrapAngleTo180_double(this.syncRotor - (double) this.rotor);
|
||||||
this.rotor = (float) ((double) this.rotor + d / (double) this.turnProgress);
|
this.rotor = (float) ((double) this.rotor + d / (double) this.turnProgress);
|
||||||
@ -133,11 +133,11 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IEner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DirPos[] getConPos() {
|
protected DirPos[] getConPos() {
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||||
|
|
||||||
return new DirPos[] {
|
return new DirPos[] {
|
||||||
new DirPos(xCoord + rot.offsetX * 2, yCoord + 1, zCoord + rot.offsetZ * 2, rot),
|
new DirPos(xCoord + rot.offsetX * 2, yCoord + 1, zCoord + rot.offsetZ * 2, rot),
|
||||||
new DirPos(xCoord + rot.offsetX * 2 + dir.offsetX, yCoord + 1, zCoord + rot.offsetZ * 2 + dir.offsetZ, rot),
|
new DirPos(xCoord + rot.offsetX * 2 + dir.offsetX, yCoord + 1, zCoord + rot.offsetZ * 2 + dir.offsetZ, rot),
|
||||||
@ -154,7 +154,7 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IEner
|
|||||||
this.tanks[0].readFromNBT(nbt, "s");
|
this.tanks[0].readFromNBT(nbt, "s");
|
||||||
this.tanks[1].readFromNBT(nbt, "w");
|
this.tanks[1].readFromNBT(nbt, "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
@ -164,12 +164,12 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IEner
|
|||||||
tanks[0].writeToNBT(nbt, "s");
|
tanks[0].writeToNBT(nbt, "s");
|
||||||
tanks[1].writeToNBT(nbt, "w");
|
tanks[1].writeToNBT(nbt, "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getRenderBoundingBox() {
|
public AxisAlignedBB getRenderBoundingBox() {
|
||||||
return TileEntity.INFINITE_EXTENT_AABB;
|
return TileEntity.INFINITE_EXTENT_AABB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public double getMaxRenderDistanceSquared() {
|
public double getMaxRenderDistanceSquared() {
|
||||||
@ -219,11 +219,11 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IEner
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserialize(ByteBuf buf) {
|
public void deserialize(ByteBuf buf) {
|
||||||
|
this.tanks[0].deserialize(buf);
|
||||||
this.powerBuffer = buf.readLong();
|
this.powerBuffer = buf.readLong();
|
||||||
this.syncRotor = buf.readFloat();
|
this.syncRotor = buf.readFloat();
|
||||||
this.turnProgress = 3; //use 3-ply for extra smoothness
|
|
||||||
this.tanks[0].deserialize(buf);
|
|
||||||
this.tanks[1].deserialize(buf);
|
this.tanks[1].deserialize(buf);
|
||||||
|
this.turnProgress = 3; //use 3-ply for extra smoothness
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -20,9 +20,9 @@ import net.minecraft.util.AxisAlignedBB;
|
|||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase implements IBufPacketReceiver, IFluidStandardTransceiver, IFluidCopiable {
|
public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase implements IBufPacketReceiver, IFluidStandardTransceiver, IFluidCopiable {
|
||||||
|
|
||||||
public FluidTank[] tanks;
|
public FluidTank[] tanks;
|
||||||
|
|
||||||
public TileEntityMachineCatalyticCracker() {
|
public TileEntityMachineCatalyticCracker() {
|
||||||
tanks = new FluidTank[5];
|
tanks = new FluidTank[5];
|
||||||
tanks[0] = new FluidTank(Fluids.BITUMEN, 4000);
|
tanks[0] = new FluidTank(Fluids.BITUMEN, 4000);
|
||||||
@ -31,10 +31,10 @@ public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase impl
|
|||||||
tanks[3] = new FluidTank(Fluids.PETROLEUM, 4000);
|
tanks[3] = new FluidTank(Fluids.PETROLEUM, 4000);
|
||||||
tanks[4] = new FluidTank(Fluids.SPENTSTEAM, 800);
|
tanks[4] = new FluidTank(Fluids.SPENTSTEAM, 800);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
this.worldObj.theProfiler.startSection("catalyticCracker_setup_tanks");
|
this.worldObj.theProfiler.startSection("catalyticCracker_setup_tanks");
|
||||||
@ -48,48 +48,48 @@ public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase impl
|
|||||||
|
|
||||||
this.worldObj.theProfiler.endStartSection("catalyticCracker_send_fluid");
|
this.worldObj.theProfiler.endStartSection("catalyticCracker_send_fluid");
|
||||||
if(worldObj.getTotalWorldTime() % 10 == 0) {
|
if(worldObj.getTotalWorldTime() % 10 == 0) {
|
||||||
|
|
||||||
for(DirPos pos : getConPos()) {
|
for(DirPos pos : getConPos()) {
|
||||||
for(int i = 2; i <= 4; i++) {
|
for(int i = 2; i <= 4; i++) {
|
||||||
if(tanks[i].getFill() > 0) this.sendFluid(tanks[i], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
if(tanks[i].getFill() > 0) this.sendFluid(tanks[i], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendStandard(25);
|
|
||||||
}
|
}
|
||||||
this.worldObj.theProfiler.endSection();
|
this.worldObj.theProfiler.endSection();
|
||||||
|
sendStandard(25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ByteBuf buf) {
|
public void serialize(ByteBuf buf) {
|
||||||
for(int i = 0; i < 5; i++)
|
for(FluidTank tank : tanks)
|
||||||
tanks[i].serialize(buf);
|
tank.serialize(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserialize(ByteBuf buf) {
|
public void deserialize(ByteBuf buf) {
|
||||||
for(int i = 0; i < 5; i++)
|
for(FluidTank tank : tanks)
|
||||||
tanks[i].deserialize(buf);
|
tank.deserialize(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateConnections() {
|
private void updateConnections() {
|
||||||
|
|
||||||
for(DirPos pos : getConPos()) {
|
for(DirPos pos : getConPos()) {
|
||||||
this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||||
this.trySubscribe(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
this.trySubscribe(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void crack() {
|
private void crack() {
|
||||||
|
|
||||||
Pair<FluidStack, FluidStack> quart = CrackingRecipes.getCracking(tanks[0].getTankType());
|
Pair<FluidStack, FluidStack> quart = CrackingRecipes.getCracking(tanks[0].getTankType());
|
||||||
|
|
||||||
if(quart != null) {
|
if(quart != null) {
|
||||||
|
|
||||||
int left = quart.getKey().fill;
|
int left = quart.getKey().fill;
|
||||||
int right = quart.getValue().fill;
|
int right = quart.getValue().fill;
|
||||||
|
|
||||||
for(int i = 0; i < 2; i++) {
|
for(int i = 0; i < 2; i++) {
|
||||||
if(tanks[0].getFill() >= 100 && tanks[1].getFill() >= 200 && hasSpace(left, right)) {
|
if(tanks[0].getFill() >= 100 && tanks[1].getFill() >= 200 && hasSpace(left, right)) {
|
||||||
tanks[0].setFill(tanks[0].getFill() - 100);
|
tanks[0].setFill(tanks[0].getFill() - 100);
|
||||||
@ -101,15 +101,15 @@ public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasSpace(int left, int right) {
|
private boolean hasSpace(int left, int right) {
|
||||||
return tanks[2].getFill() + left <= tanks[2].getMaxFill() && tanks[3].getFill() + right <= tanks[3].getMaxFill() && tanks[4].getFill() + 2 <= tanks[4].getMaxFill();
|
return tanks[2].getFill() + left <= tanks[2].getMaxFill() && tanks[3].getFill() + right <= tanks[3].getMaxFill() && tanks[4].getFill() + 2 <= tanks[4].getMaxFill();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTanks() {
|
private void setupTanks() {
|
||||||
|
|
||||||
Pair<FluidStack, FluidStack> quart = CrackingRecipes.getCracking(tanks[0].getTankType());
|
Pair<FluidStack, FluidStack> quart = CrackingRecipes.getCracking(tanks[0].getTankType());
|
||||||
|
|
||||||
if(quart != null) {
|
if(quart != null) {
|
||||||
tanks[1].setTankType(Fluids.STEAM);
|
tanks[1].setTankType(Fluids.STEAM);
|
||||||
tanks[2].setTankType(quart.getKey().type);
|
tanks[2].setTankType(quart.getKey().type);
|
||||||
@ -123,7 +123,7 @@ public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase impl
|
|||||||
tanks[4].setTankType(Fluids.NONE);
|
tanks[4].setTankType(Fluids.NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
@ -131,7 +131,7 @@ public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase impl
|
|||||||
for(int i = 0; i < 5; i++)
|
for(int i = 0; i < 5; i++)
|
||||||
tanks[i].readFromNBT(nbt, "tank" + i);
|
tanks[i].readFromNBT(nbt, "tank" + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
@ -139,12 +139,12 @@ public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase impl
|
|||||||
for(int i = 0; i < 5; i++)
|
for(int i = 0; i < 5; i++)
|
||||||
tanks[i].writeToNBT(nbt, "tank" + i);
|
tanks[i].writeToNBT(nbt, "tank" + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DirPos[] getConPos() {
|
protected DirPos[] getConPos() {
|
||||||
|
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||||
|
|
||||||
return new DirPos[] {
|
return new DirPos[] {
|
||||||
new DirPos(xCoord + dir.offsetX * 4 + rot.offsetX * 1, yCoord, zCoord + dir.offsetZ * 4 + rot.offsetZ * 1, dir),
|
new DirPos(xCoord + dir.offsetX * 4 + rot.offsetX * 1, yCoord, zCoord + dir.offsetZ * 4 + rot.offsetZ * 1, dir),
|
||||||
new DirPos(xCoord + dir.offsetX * 4 - rot.offsetX * 2, yCoord, zCoord + dir.offsetZ * 4 - rot.offsetZ * 2, dir),
|
new DirPos(xCoord + dir.offsetX * 4 - rot.offsetX * 2, yCoord, zCoord + dir.offsetZ * 4 - rot.offsetZ * 2, dir),
|
||||||
@ -156,12 +156,12 @@ public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase impl
|
|||||||
new DirPos(xCoord - dir.offsetX * 2 - rot.offsetX * 4, yCoord, zCoord - dir.offsetZ * 2 - rot.offsetZ * 4, rot.getOpposite())
|
new DirPos(xCoord - dir.offsetX * 2 - rot.offsetX * 4, yCoord, zCoord - dir.offsetZ * 2 - rot.offsetZ * 4, rot.getOpposite())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
AxisAlignedBB bb = null;
|
AxisAlignedBB bb = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getRenderBoundingBox() {
|
public AxisAlignedBB getRenderBoundingBox() {
|
||||||
|
|
||||||
if(bb == null) {
|
if(bb == null) {
|
||||||
bb = AxisAlignedBB.getBoundingBox(
|
bb = AxisAlignedBB.getBoundingBox(
|
||||||
xCoord - 3,
|
xCoord - 3,
|
||||||
@ -172,10 +172,10 @@ public class TileEntityMachineCatalyticCracker extends TileEntityLoadedBase impl
|
|||||||
zCoord + 4
|
zCoord + 4
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public double getMaxRenderDistanceSquared() {
|
public double getMaxRenderDistanceSquared() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user