exploding 256k tanks

This commit is contained in:
Bob 2022-12-13 21:57:05 +01:00
parent 2ff7052ca3
commit 8aaa0d0c5d
7 changed files with 5156 additions and 30 deletions

View File

@ -100,6 +100,7 @@ public class ResourceManager {
//Tank
public static final IModelCustom fluidtank = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/fluidtank.obj"));
public static final IModelCustom fluidtank_exploded = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/fluidtank_exploded.obj"));
public static final IModelCustom bat9000 = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/bat9000.obj"));
public static final IModelCustom orbus = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/orbus.obj"));
@ -428,6 +429,7 @@ public class ResourceManager {
//Tank
public static final ResourceLocation tank_tex = new ResourceLocation(RefStrings.MODID, "textures/models/tank.png");
public static final ResourceLocation tank_inner_tex = new ResourceLocation(RefStrings.MODID, "textures/models/tank/tank_inner.png");
public static final ResourceLocation tank_label_tex = new ResourceLocation(RefStrings.MODID, "textures/models/tank/tank_NONE.png");
public static final ResourceLocation bat9000_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/bat9000.png");
public static final ResourceLocation orbus_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/orbus.png");

View File

@ -37,19 +37,26 @@ public class RenderFluidTank extends TileEntitySpecialRenderer implements IItemR
case 3: GL11.glRotatef(90, 0F, 1F, 0F); break;
case 5: GL11.glRotatef(180, 0F, 1F, 0F); break;
}
TileEntityMachineFluidTank tank = (TileEntityMachineFluidTank) tileEntity;
FluidType type = tank.tank.getTankType();
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.tank_tex);
ResourceManager.fluidtank.renderPart("Frame");
TileEntityMachineFluidTank tank = (TileEntityMachineFluidTank) tileEntity;
bindTexture(new ResourceLocation(RefStrings.MODID, getTextureFromType(tank.tank.getTankType())));
ResourceManager.fluidtank.renderPart("Tank");
if(!tank.hasExploded) {
ResourceManager.fluidtank.renderPart("Frame");
bindTexture(new ResourceLocation(RefStrings.MODID, getTextureFromType(tank.tank.getTankType())));
ResourceManager.fluidtank.renderPart("Tank");
} else {
ResourceManager.fluidtank_exploded.renderPart("Frame");
bindTexture(ResourceManager.tank_inner_tex);
ResourceManager.fluidtank_exploded.renderPart("TankInner");
bindTexture(new ResourceLocation(RefStrings.MODID, getTextureFromType(tank.tank.getTankType())));
ResourceManager.fluidtank_exploded.renderPart("Tank");
}
GL11.glShadeModel(GL11.GL_FLAT);
FluidType type = ((TileEntityMachineFluidTank) tileEntity).tank.getTankType();
if(type != null && type != Fluids.NONE) {
@ -99,15 +106,26 @@ public class RenderFluidTank extends TileEntitySpecialRenderer implements IItemR
GL11.glRotated(90, 0, 1, 0);
GL11.glScaled(0.75, 0.75, 0.75);
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.tank_tex); ResourceManager.fluidtank.renderPart("Frame");
GL11.glDisable(GL11.GL_CULL_FACE);
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
boolean exploded = false;
if(item.hasTagCompound() && item.getTagCompound().hasKey(IPersistentNBT.NBT_PERSISTENT_KEY)) {
tank.readFromNBT(item.getTagCompound().getCompoundTag(IPersistentNBT.NBT_PERSISTENT_KEY), "tank");
exploded = item.getTagCompound().getCompoundTag(IPersistentNBT.NBT_PERSISTENT_KEY).getBoolean("hasExploded");
}
bindTexture(new ResourceLocation(RefStrings.MODID, getTextureFromType(tank.getTankType())));
ResourceManager.fluidtank.renderPart("Tank");
if(!exploded) {
bindTexture(ResourceManager.tank_tex); ResourceManager.fluidtank.renderPart("Frame");
bindTexture(new ResourceLocation(RefStrings.MODID, getTextureFromType(tank.getTankType())));
ResourceManager.fluidtank.renderPart("Tank");
} else {
bindTexture(ResourceManager.tank_tex); ResourceManager.fluidtank_exploded.renderPart("Frame");
bindTexture(ResourceManager.tank_inner_tex); ResourceManager.fluidtank_exploded.renderPart("TankInner");
bindTexture(new ResourceLocation(RefStrings.MODID, getTextureFromType(tank.getTankType())));
ResourceManager.fluidtank_exploded.renderPart("Tank");
}
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_FLAT);
}};
}

View File

@ -0,0 +1,8 @@
package com.hbm.tileentity;
import net.minecraft.world.World;
public interface IOverpressurable {
public void explode(World world, int x, int y, int z);
}

View File

@ -19,6 +19,7 @@ import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.NBTPacket;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.INBTPacketReceiver;
import com.hbm.tileentity.IOverpressurable;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
import com.hbm.util.I18nUtil;
@ -491,9 +492,12 @@ public abstract class TileEntityRBMKBase extends TileEntityLoadedBase implements
IFluidConnector con = itReceivers.next();
if(con instanceof TileEntity) {
TileEntity tile = (TileEntity) con;
worldObj.setBlock(tile.xCoord, tile.yCoord, tile.zCoord, Blocks.air);
//TODO: create an interface so overpressure can be handled by machines themselves
worldObj.newExplosion(null, tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, 5F, false, false);
if(con instanceof IOverpressurable) {
((IOverpressurable) con).explode(worldObj, tile.xCoord, tile.yCoord, tile.zCoord);
} else {
worldObj.setBlock(tile.xCoord, tile.yCoord, tile.zCoord, Blocks.air);
worldObj.newExplosion(null, tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, 5F, false, false);
}
}
}
}

View File

@ -2,31 +2,42 @@ package com.hbm.tileentity.machine.storage;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.hbm.interfaces.IFluidAcceptor;
import com.hbm.interfaces.IFluidContainer;
import com.hbm.interfaces.IFluidSource;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.trait.FT_Corrosive;
import com.hbm.inventory.fluid.trait.FT_Flammable;
import com.hbm.inventory.fluid.trait.FluidTraitSimple.FT_Gaseous;
import com.hbm.inventory.fluid.trait.FluidTraitSimple.FT_Gaseous_ART;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.lib.Library;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.IOverpressurable;
import com.hbm.tileentity.IPersistentNBT;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.ParticleUtil;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.fluid.IFluidStandardTransceiver;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
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.world.World;
public class TileEntityMachineFluidTank extends TileEntityMachineBase implements IFluidContainer, IFluidSource, IFluidAcceptor, IFluidStandardTransceiver, IPersistentNBT {
public class TileEntityMachineFluidTank extends TileEntityMachineBase implements IFluidContainer, IFluidSource, IFluidAcceptor, IFluidStandardTransceiver, IPersistentNBT, IOverpressurable {
public FluidTank tank;
public short mode = 0;
public static final short modes = 4;
public boolean hasExploded = false;
public int age = 0;
public List<IFluidAcceptor> list = new ArrayList();
@ -51,16 +62,6 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
if(age >= 20)
age = 0;
/*if(this.mode == 2 || this.mode == 3) {
for(DirPos pos : getConPos()) this.tryUnsubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ());
}
if(this.mode == 0 || this.mode == 1) {
for(DirPos pos : getConPos()) this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
if(this.mode == 1 || this.mode == 2) {
for(DirPos pos : getConPos()) this.sendFluid(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}*/
tank.setFill(TileEntityBarrel.transmitFluidFairly(worldObj, tank.getTankType(), this, tank.getFill(), this.mode == 0 || this.mode == 1, this.mode == 1 || this.mode == 2, getConPos()));
if((mode == 1 || mode == 2) && (age == 9 || age == 19))
@ -71,12 +72,30 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
if(tank.getFill() > 0) {
if(tank.getTankType().isAntimatter()) {
worldObj.func_147480_a(xCoord, yCoord, zCoord, false);
worldObj.newExplosion(null, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 5, true, true);
//worldObj.func_147480_a(xCoord, yCoord, zCoord, false);
worldObj.newExplosion(null, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 5, true, false);
this.hasExploded = true;
this.tank.setFill(0);
}
if(tank.getTankType().hasTrait(FT_Corrosive.class) && tank.getTankType().getTrait(FT_Corrosive.class).isHighlyCorrosive()) {
worldObj.func_147480_a(xCoord, yCoord, zCoord, false);
//worldObj.func_147480_a(xCoord, yCoord, zCoord, false);
this.hasExploded = true;
this.tank.setFill(0);
}
this.hasExploded = true;
if(this.hasExploded) {
int leaking = 0;
if(tank.getTankType().isAntimatter()) {
leaking = tank.getFill();
} else if(tank.getTankType().hasTrait(FT_Gaseous.class) || tank.getTankType().hasTrait(FT_Gaseous_ART.class)) {
leaking = Math.min(tank.getFill(), tank.getMaxFill() / 100);
} else {
leaking = Math.min(tank.getFill(), tank.getMaxFill() / 10000);
}
updateLeak(leaking);
}
}
@ -85,10 +104,45 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
NBTTagCompound data = new NBTTagCompound();
data.setShort("mode", mode);
data.setBoolean("hasExploded", hasExploded);
this.networkPack(data, 50);
}
}
public void updateLeak(int amount) {
if(!hasExploded) return;
if(amount <= 0) return;
this.tank.getTankType().onFluidRelease(this, tank, amount);
this.tank.setFill(Math.max(0, this.tank.getFill() - amount));
if(tank.getTankType().hasTrait(FT_Flammable.class)) {
Random rand = worldObj.rand;
ParticleUtil.spawnGasFlame(worldObj, xCoord + rand.nextDouble(), yCoord + 0.5 + rand.nextDouble(), zCoord + rand.nextDouble(), rand.nextGaussian() * 0.2, 0.1, rand.nextGaussian() * 0.2);
} else if(tank.getTankType().hasTrait(FT_Gaseous.class) || tank.getTankType().hasTrait(FT_Gaseous_ART.class)) {
if(worldObj.getTotalWorldTime() % 5 == 0) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "tower");
data.setFloat("lift", 1F);
data.setFloat("base", 1F);
data.setFloat("max", 5F);
data.setInteger("life", 100 + worldObj.rand.nextInt(20));
data.setInteger("color", tank.getTankType().getColor());
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.5, yCoord + 1, zCoord + 0.5), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 150));
}
}
}
@Override
public void explode(World world, int x, int y, int z) {
if(this.hasExploded) return;
this.hasExploded = true;
this.markChanged();
}
protected DirPos[] getConPos() {
return new DirPos[] {
new DirPos(xCoord + 2, yCoord, zCoord - 1, Library.POS_X),
@ -103,8 +157,8 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
}
public void networkUnpack(NBTTagCompound data) {
mode = data.getShort("mode");
this.mode = data.getShort("mode");
this.hasExploded = data.getBoolean("hasExploded");
}
public void handleButtonPacket(int value, int meta) {
@ -230,10 +284,11 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
@Override
public void writeNBT(NBTTagCompound nbt) {
if(tank.getFill() == 0) return;
if(tank.getFill() == 0 && !this.hasExploded) return;
NBTTagCompound data = new NBTTagCompound();
this.tank.writeToNBT(data, "tank");
data.setShort("mode", mode);
data.setBoolean("hasExploded", hasExploded);
nbt.setTag(NBT_PERSISTENT_KEY, data);
}
@ -242,6 +297,7 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
NBTTagCompound data = nbt.getCompoundTag(NBT_PERSISTENT_KEY);
this.tank.readFromNBT(data, "tank");
this.mode = data.getShort("mode");
this.hasExploded = data.getBoolean("hasExploded");
}
@Override

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B