multi artillery fix, functional steam engine

This commit is contained in:
Bob 2022-11-13 00:10:39 +01:00
parent 3d2ccd537b
commit b04054dd9f
9 changed files with 681 additions and 816 deletions

View File

@ -170,6 +170,8 @@ public class EntityArtilleryShell extends EntityThrowableNT implements IChunkLoa
protected void onImpact(MovingObjectPosition mop) {
if(!worldObj.isRemote) {
if(mop.typeOfHit == mop.typeOfHit.ENTITY && mop.entityHit instanceof EntityArtilleryShell) return;
this.getType().onImpact(this, mop);
}
}

View File

@ -218,10 +218,10 @@ public class ItemAmmoArty extends Item {
for(int i = 0; i < amount; i++) {
EntityArtilleryShell cluster = new EntityArtilleryShell(shell.worldObj);
cluster.setType(clusterType);
cluster.setPositionAndRotation(shell.posX, shell.posY, shell.posZ, shell.rotationYaw, shell.rotationPitch);
cluster.motionX = i == 0 ? shell.motionX : (shell.motionX + rand.nextGaussian() * deviation);
cluster.motionY = shell.motionY;
cluster.motionZ = i == 0 ? shell.motionZ : (shell.motionZ + rand.nextGaussian() * deviation);
cluster.setPositionAndRotation(shell.posX, shell.posY, shell.posZ, shell.rotationYaw, shell.rotationPitch);
double[] target = shell.getTarget();
cluster.setTarget(target[0], target[1], target[2]);
cluster.setWhistle(shell.getWhistle() && !shell.didWhistle());

View File

@ -6,6 +6,7 @@ import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.main.ResourceManager;
import com.hbm.render.item.ItemRenderBase;
import com.hbm.tileentity.machine.TileEntitySteamEngine;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
@ -29,7 +30,8 @@ public class RenderSteamEngine extends TileEntitySpecialRenderer implements IIte
case 4: GL11.glRotatef(0, 0F, 1F, 0F); break;
}
double angle = System.currentTimeMillis() % 3600D;
TileEntitySteamEngine engine = (TileEntitySteamEngine) tile;
float angle = engine.lastRotor + (engine.rotor - engine.lastRotor) * interp;
GL11.glTranslated(2, 0, 0);
renderCommon(angle);

View File

@ -12,6 +12,7 @@ import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.fluid.trait.FT_Coolable;
import com.hbm.inventory.fluid.trait.FT_Coolable.CoolingType;
import com.hbm.lib.Library;
import com.hbm.tileentity.INBTPacketReceiver;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.fauxpointtwelve.DirPos;
@ -19,11 +20,13 @@ import api.hbm.energy.IEnergyGenerator;
import api.hbm.fluid.IFluidStandardTransceiver;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntitySteamEngine extends TileEntityLoadedBase implements IFluidAcceptor, IFluidSource, IEnergyGenerator, IFluidStandardTransceiver {
public class TileEntitySteamEngine extends TileEntityLoadedBase implements IFluidAcceptor, IFluidSource, IEnergyGenerator, IFluidStandardTransceiver, INBTPacketReceiver {
public long powerBuffer;
@ -31,12 +34,14 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IFlui
public float lastRotor;
public List<IFluidAcceptor> list2 = new ArrayList();
public FluidTank[] tanks;
private float acceleration = 0F;
public TileEntitySteamEngine() {
tanks = new FluidTank[2];
tanks[0] = new FluidTank(Fluids.STEAM, 8_000, 0);
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, 80, 1);
tanks[0] = new FluidTank(Fluids.STEAM, 2_000, 0);
tanks[1] = new FluidTank(Fluids.SPENTSTEAM, 20, 1);
}
@Override
@ -59,8 +64,37 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IFlui
tanks[1].setFill(tanks[1].getFill() + ops * trait.amountProduced);
this.powerBuffer += (ops * trait.heatEnergy * eff);
for(DirPos pos : getConPos()) if(this.powerBuffer > 0) this.sendPower(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
if(ops > 0) {
this.acceleration += 0.1F;
} else {
this.acceleration -= 0.1F;
}
this.acceleration = MathHelper.clamp_float(this.acceleration, 0F, 40F);
this.lastRotor = this.rotor;
this.rotor += this.acceleration;
if(this.rotor >= 360D) {
this.lastRotor -= 360D;
this.rotor -= 360D;
this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:block.steamEngineOperate", 1.0F, 0.5F + (acceleration / 80F));
}
NBTTagCompound data = new NBTTagCompound();
data.setLong("power", this.powerBuffer);
data.setFloat("rotor", this.rotor);
data.setFloat("lastRotor", this.lastRotor);
for(DirPos pos : getConPos()) {
if(this.powerBuffer > 0)
this.sendPower(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].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
if(tanks[1].getFill() > 0) fillFluidInit(tanks[1].getTankType());
INBTPacketReceiver.networkPack(this, data, 150);
}
}
@ -69,9 +103,9 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IFlui
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
return new DirPos[] {
new DirPos(xCoord + rot.offsetX * 2, yCoord + 2, zCoord + rot.offsetZ * 2, rot),
new DirPos(xCoord + rot.offsetX * 2 + dir.offsetX, yCoord + 2, zCoord + rot.offsetZ * 2 + dir.offsetZ, rot),
new DirPos(xCoord + rot.offsetX * 2 - dir.offsetX, yCoord + 2, zCoord + rot.offsetZ * 2 - dir.offsetZ, 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)
};
}
@ -183,4 +217,11 @@ public class TileEntitySteamEngine extends TileEntityLoadedBase implements IFlui
public FluidTank[] getAllTanks() {
return tanks;
}
@Override
public void networkUnpack(NBTTagCompound nbt) {
this.powerBuffer = nbt.getLong("power");
this.rotor = nbt.getFloat("rotor");
this.lastRotor = nbt.getFloat("lastRotor");
}
}

View File

@ -192,7 +192,6 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
protected void transmitPowerFairly() {
if(power == 0) return;
short mode = (short) this.getRelevantMode();
//HasSets to we don'T have any duplicates
@ -220,7 +219,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
}
//send power to buffered consumers, independent of nets
if(mode == mode_buffer || mode == mode_output) {
if(this.power > 0 && (mode == mode_buffer || mode == mode_output)) {
List<IEnergyConnector> con = new ArrayList();
con.addAll(consumers);
this.power = PowerNet.fairTransfer(con, this.power);

File diff suppressed because it is too large Load Diff

View File

@ -46,6 +46,7 @@
"block.closeC": {"category": "block", "sounds": ["block/closeC1", "block/closeC2", "block/closeC3"]},
"block.warnOverspeed": {"category": "block", "sounds": [{"name": "block/warnOverspeed", "stream": false}]},
"block.boilerGroan": {"category": "block", "sounds": ["block/boilerGroan0", "block/boilerGroan1", "block/boilerGroan2"]},
"block.steamEngineOperate": {"category": "block", "sounds": [{"name": "block/steamEngineOperate", "stream": false}]},
"door.TransitionSealOpen": {"category": "block", "sounds": [{"name": "block/door/transition_seal_open", "stream": true}]},
"door.wghStart": {"category": "block", "sounds": [{"name": "block/door/wgh_start", "stream": true}]},

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB