powered condenser

This commit is contained in:
Bob 2023-09-28 22:49:12 +02:00
parent 6918974095
commit d7ff947bbf
9 changed files with 361 additions and 16 deletions

View File

@ -1018,6 +1018,7 @@ public class ModBlocks {
public static Block machine_condenser;
public static Block machine_tower_small;
public static Block machine_tower_large;
public static Block machine_condenser_powered;
public static Block machine_electrolyser;
@ -2301,6 +2302,7 @@ public class ModBlocks {
machine_condenser = new MachineCondenser(Material.iron).setBlockName("machine_condenser").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":condenser");
machine_tower_small = new MachineTowerSmall(Material.iron).setBlockName("machine_tower_small").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":brick_concrete");
machine_tower_large = new MachineTowerLarge(Material.iron).setBlockName("machine_tower_large").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":concrete");
machine_condenser_powered = new MachineCondenserPowered(Material.iron).setBlockName("machine_condenser_powered").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel_machine");
machine_deuterium_extractor = new MachineDeuteriumExtractor(Material.iron).setBlockName("machine_deuterium_extractor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_deuterium_extractor_side");
machine_deuterium_tower = new DeuteriumTower(Material.iron).setBlockName("machine_deuterium_tower").setHardness(10.0F).setResistance(20.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":concrete");
@ -3332,6 +3334,7 @@ public class ModBlocks {
GameRegistry.registerBlock(machine_condenser, machine_condenser.getUnlocalizedName());
GameRegistry.registerBlock(machine_tower_small, machine_tower_small.getUnlocalizedName());
GameRegistry.registerBlock(machine_tower_large, machine_tower_large.getUnlocalizedName());
register(machine_condenser_powered);
GameRegistry.registerBlock(machine_deuterium_extractor, machine_deuterium_extractor.getUnlocalizedName());
GameRegistry.registerBlock(machine_deuterium_tower, machine_deuterium_tower.getUnlocalizedName());
GameRegistry.registerBlock(machine_liquefactor, ItemBlockBase.class, machine_liquefactor.getUnlocalizedName());

View File

@ -0,0 +1,82 @@
package com.hbm.blocks.machine;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ILookOverlay;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityCondenserPowered;
import com.hbm.util.BobMathUtil;
import com.hbm.util.I18nUtil;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineCondenserPowered extends BlockDummyable implements ILookOverlay {
public MachineCondenserPowered(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int meta) {
if(meta >= 12) return new TileEntityCondenserPowered();
if(meta >= 6) return new TileEntityProxyCombo().power().fluid();
return null;
}
@Override
public int[] getDimensions() {
return new int[] {2, 0, 1, 1, 3, 3};
}
@Override
public int getOffset() {
return 1;
}
@Override
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
x = x + dir.offsetX * o;
z = z + dir.offsetZ * o;
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
this.makeExtra(world, x + rot.offsetX * 3, y + 1, z + rot.offsetZ * 3);
this.makeExtra(world, x - rot.offsetX * 3, y + 1, z - rot.offsetZ * 3);
this.makeExtra(world, x + dir.offsetX + rot.offsetX, y + 1, z + dir.offsetZ + rot.offsetZ);
this.makeExtra(world, x + dir.offsetX - rot.offsetX, y + 1, z + dir.offsetZ - rot.offsetZ);
this.makeExtra(world, x - dir.offsetX + rot.offsetX, y + 1, z - dir.offsetZ + rot.offsetZ);
this.makeExtra(world, x - dir.offsetX - rot.offsetX, y + 1, z - dir.offsetZ - rot.offsetZ);
}
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return;
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
if(!(te instanceof TileEntityCondenserPowered)) return;
TileEntityCondenserPowered tower = (TileEntityCondenserPowered) te;
List<String> text = new ArrayList();
text.add(BobMathUtil.getShortNumber(tower.power) + "HE / " + BobMathUtil.getShortNumber(tower.maxPower) + "HE");
for(int i = 0; i < tower.tanks.length; i++)
text.add((i < 1 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + I18nUtil.resolveKey("hbmfluid." + tower.tanks[i].getTankType().getName().toLowerCase(Locale.US)) + ": " + tower.tanks[i].getFill() + "/" + tower.tanks[i].getMaxFill() + "mB");
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
}

View File

@ -255,6 +255,7 @@ public class ClientProxy extends ServerProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChungus.class, new RenderChungus());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTowerLarge.class, new RenderLargeTower());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTowerSmall.class, new RenderSmallTower());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCondenserPowered.class, new RenderCondenser());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDeuteriumTower.class, new RenderDeuteriumTower());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineCatalyticCracker.class, new RenderCatalyticCracker());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineLiquefactor.class, new RenderLiquefactor());

View File

@ -108,6 +108,7 @@ public class ResourceManager {
//Cooling Tower
public static final IModelCustom tower_small = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/tower_small.obj"));
public static final IModelCustom tower_large = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/tower_large.obj"));
public static final IModelCustom condenser = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/condenser.obj"));
//IGen
public static final IModelCustom igen = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/igen.obj"));
@ -467,6 +468,7 @@ public class ResourceManager {
//Cooling Tower
public static final ResourceLocation tower_small_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/tower_small.png");
public static final ResourceLocation tower_large_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/tower_large.png");
public static final ResourceLocation condenser_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/condenser.png");
//Deuterium Tower
public static final ResourceLocation deuterium_tower_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/machine_deuterium_tower.png");

View File

@ -0,0 +1,81 @@
package com.hbm.render.tileentity;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.ModBlocks;
import com.hbm.main.ResourceManager;
import com.hbm.render.item.ItemRenderBase;
import com.hbm.tileentity.machine.TileEntityCondenserPowered;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.IItemRenderer;
public class RenderCondenser extends TileEntitySpecialRenderer implements IItemRendererProvider {
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
switch(tileEntity.getBlockMetadata() - 10) {
case 2: GL11.glRotatef(90, 0F, 1F, 0F); break;
case 4: GL11.glRotatef(180, 0F, 1F, 0F); break;
case 3: GL11.glRotatef(270, 0F, 1F, 0F); break;
case 5: GL11.glRotatef(0, 0F, 1F, 0F); break;
}
TileEntityCondenserPowered condenser = (TileEntityCondenserPowered) tileEntity;
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.condenser_tex);
ResourceManager.condenser.renderPart("Condenser");
float rot = condenser.lastSpin + (condenser.spin - condenser.lastSpin) * f;
GL11.glPushMatrix();
GL11.glTranslated(0,1.5, 0);
GL11.glRotatef(rot, 1, 0, 0);
GL11.glTranslated(0, -1.5, 0);
ResourceManager.condenser.renderPart("Fan1");
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(0,1.5, 0);
GL11.glRotatef(rot, -1, 0, 0);
GL11.glTranslated(0, -1.5, 0);
ResourceManager.condenser.renderPart("Fan2");
GL11.glPopMatrix();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
}
@Override
public Item getItemForRenderer() {
return Item.getItemFromBlock(ModBlocks.machine_condenser_powered);
}
@Override
public IItemRenderer getRenderer() {
return new ItemRenderBase( ) {
public void renderInventory() {
GL11.glTranslated(-1, -1, 0);
GL11.glScaled(2.75, 2.75, 2.75);
}
public void renderCommon() {
GL11.glScaled(0.75, 0.75, 0.75);
GL11.glTranslated(0.5, 0, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.condenser_tex); ResourceManager.condenser.renderAll();
GL11.glShadeModel(GL11.GL_FLAT);
}
};
}
}

View File

@ -299,6 +299,7 @@ public class TileMappings {
put(TileEntityCondenser.class, "tileentity_condenser");
put(TileEntityTowerSmall.class, "tileentity_cooling_tower_small");
put(TileEntityTowerLarge.class, "tileentity_cooling_tower_large");
put(TileEntityCondenserPowered.class, "tileentity_condenser_powered");
put(TileEntityDeuteriumExtractor.class, "tileentity_deuterium_extractor");
put(TileEntityDeuteriumTower.class, "tileentity_deuterium_tower");
put(TileEntityMachineLiquefactor.class, "tileentity_liquefactor");

View File

@ -42,36 +42,46 @@ public class TileEntityCondenser extends TileEntityLoadedBase implements IFluidA
age = 0;
}
NBTTagCompound data = new NBTTagCompound();
this.tanks[0].writeToNBT(data, "0");
if(this.waterTimer > 0)
this.waterTimer--;
int convert = Math.min(tanks[0].getFill(), tanks[1].getMaxFill() - tanks[1].getFill());
tanks[0].setFill(tanks[0].getFill() - convert);
if(extraCondition(convert)) {
tanks[0].setFill(tanks[0].getFill() - convert);
if(convert > 0)
this.waterTimer = 20;
if(convert > 0)
this.waterTimer = 20;
int light = this.worldObj.getSavedLightValue(EnumSkyBlock.Sky, this.xCoord, this.yCoord, this.zCoord);
int light = this.worldObj.getSavedLightValue(EnumSkyBlock.Sky, this.xCoord, this.yCoord, this.zCoord);
if(TomSaveData.forWorld(worldObj).fire > 1e-5 && light > 7) { // Make both steam and water evaporate during firestorms...
tanks[1].setFill(tanks[1].getFill() - convert);
} else {
tanks[1].setFill(tanks[1].getFill() + convert);
if(TomSaveData.forWorld(worldObj).fire > 1e-5 && light > 7) { // Make both steam and water evaporate during firestorms...
tanks[1].setFill(tanks[1].getFill() - convert);
} else {
tanks[1].setFill(tanks[1].getFill() + convert);
}
postConvert(convert);
}
this.tanks[1].writeToNBT(data, "1");
this.subscribeToAllAround(tanks[0].getTankType(), this);
this.sendFluidToAll(tanks[1], this);
fillFluidInit(tanks[1].getTankType());
NBTTagCompound data = new NBTTagCompound();
this.tanks[0].writeToNBT(data, "0");
this.tanks[1].writeToNBT(data, "1");
data.setByte("timer", (byte) this.waterTimer);
packExtra(data);
INBTPacketReceiver.networkPack(this, data, 150);
}
}
public void packExtra(NBTTagCompound data) { }
public boolean extraCondition(int convert) { return true; }
public void postConvert(int convert) { }
@Override
public void networkUnpack(NBTTagCompound nbt) {
this.tanks[0].readFromNBT(nbt, "0");

View File

@ -0,0 +1,165 @@
package com.hbm.tileentity.machine;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energy.IEnergyUser;
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.minecraftforge.common.util.ForgeDirection;
public class TileEntityCondenserPowered extends TileEntityCondenser implements IEnergyUser {
public long power;
public static final long maxPower = 10_000_000;
public float spin;
public float lastSpin;
public TileEntityCondenserPowered() {
tanks = new FluidTank[2];
tanks[0] = new FluidTank(Fluids.SPENTSTEAM, 100_000);
tanks[1] = new FluidTank(Fluids.WATER, 100_000);
}
@Override
public void updateEntity() {
super.updateEntity();
if(worldObj.isRemote) {
this.lastSpin = this.spin;
if(this.waterTimer > 0) {
this.spin += 30F;
if(this.spin >= 360F) {
this.spin -= 360F;
this.lastSpin -= 360F;
}
if(worldObj.getTotalWorldTime() % 4 == 0) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
worldObj.spawnParticle("cloud", xCoord + 0.5 + dir.offsetX * 1.5, yCoord + 1.5, zCoord + 0.5 + dir.offsetZ * 1.5, dir.offsetX * 0.1, 0, dir.offsetZ * 0.1);
worldObj.spawnParticle("cloud", xCoord + 0.5 - dir.offsetX * 1.5, yCoord + 1.5, zCoord + 0.5 - dir.offsetZ * 1.5, dir.offsetX * -0.1, 0, dir.offsetZ * -0.1);
}
}
}
}
@Override
public void packExtra(NBTTagCompound data) {
data.setLong("power", power);
}
@Override
public boolean extraCondition(int convert) {
return power >= convert * 10;
}
@Override
public void postConvert(int convert) {
this.power -= convert * 10;
if(this.power < 0) this.power = 0;
}
@Override
public void networkUnpack(NBTTagCompound nbt) {
this.power = nbt.getLong("power");
this.tanks[0].readFromNBT(nbt, "0");
this.tanks[1].readFromNBT(nbt, "1");
this.waterTimer = nbt.getByte("timer");
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.power = nbt.getLong("power");
tanks[0].readFromNBT(nbt, "water");
tanks[1].readFromNBT(nbt, "steam");
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setLong("power", power);
tanks[0].writeToNBT(nbt, "water");
tanks[1].writeToNBT(nbt, "steam");
}
@Deprecated @Override public void fillFluidInit(FluidType type) { }
@Override
public void subscribeToAllAround(FluidType type, TileEntity te) {
for(DirPos pos : getConPos()) {
this.trySubscribe(this.tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}
@Override
public void sendFluidToAll(FluidTank tank, TileEntity te) {
for(DirPos pos : getConPos()) {
this.sendFluid(this.tanks[1], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
}
public DirPos[] getConPos() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
return new DirPos[] {
new DirPos(xCoord + rot.offsetX * 4, yCoord + 1, zCoord + rot.offsetZ * 4, rot),
new DirPos(xCoord - rot.offsetX * 4, yCoord + 1, zCoord - rot.offsetZ * 4, rot.getOpposite()),
new DirPos(xCoord + dir.offsetX * 2 - rot.offsetX, yCoord + 1, zCoord + dir.offsetZ * 2 - rot.offsetZ, dir),
new DirPos(xCoord + dir.offsetX * 2 + rot.offsetX, yCoord + 1, zCoord + dir.offsetZ * 2 + rot.offsetZ, dir),
new DirPos(xCoord - dir.offsetX * 2 - rot.offsetX, yCoord + 1, zCoord - dir.offsetZ * 2 - rot.offsetZ, dir.getOpposite()),
new DirPos(xCoord - dir.offsetX * 2 + rot.offsetX, yCoord + 1, zCoord - dir.offsetZ * 2 + rot.offsetZ, dir.getOpposite())
};
}
AxisAlignedBB bb = null;
@Override
public AxisAlignedBB getRenderBoundingBox() {
if(bb == null) {
bb = AxisAlignedBB.getBoundingBox(
xCoord - 3,
yCoord,
zCoord - 3,
xCoord + 4,
yCoord + 3,
zCoord + 4
);
}
return bb;
}
@Override
@SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() {
return 65536.0D;
}
@Override
public long getPower() {
return this.power;
}
@Override
public void setPower(long power) {
this.power = power;
}
@Override
public long getMaxPower() {
return this.maxPower;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB