boil yourself
@ -652,6 +652,7 @@ public class ModBlocks {
|
||||
public static Block machine_stirling_steel;
|
||||
public static Block machine_sawmill;
|
||||
public static Block machine_crucible;
|
||||
public static Block machine_boiler;
|
||||
|
||||
public static Block foundry_mold;
|
||||
public static Block foundry_basin;
|
||||
@ -1846,6 +1847,7 @@ public class ModBlocks {
|
||||
machine_stirling_steel = new MachineStirling().setBlockName("machine_stirling_steel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
machine_sawmill = new MachineSawmill().setBlockName("machine_sawmill").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
machine_crucible = new MachineCrucible().setBlockName("machine_crucible").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":brick_fire");
|
||||
machine_boiler = new MachineHeatBoiler().setBlockName("machine_boiler").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_copper");
|
||||
|
||||
foundry_mold = new FoundryMold().setBlockName("foundry_mold").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":brick_fire");
|
||||
foundry_basin = new FoundryBasin().setBlockName("foundry_basin").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":brick_fire");
|
||||
@ -3040,6 +3042,7 @@ public class ModBlocks {
|
||||
register(machine_stirling_steel);
|
||||
register(machine_sawmill);
|
||||
register(machine_crucible);
|
||||
register(machine_boiler);
|
||||
register(foundry_mold);
|
||||
register(foundry_basin);
|
||||
register(foundry_channel);
|
||||
|
||||
@ -30,7 +30,6 @@ import net.minecraft.world.World;
|
||||
public class MachineBoiler extends BlockContainer {
|
||||
|
||||
private final Random field_149933_a = new Random();
|
||||
private Random rand;
|
||||
private final boolean isActive;
|
||||
private static boolean keepInventory;
|
||||
|
||||
@ -41,7 +40,6 @@ public class MachineBoiler extends BlockContainer {
|
||||
|
||||
public MachineBoiler(boolean blockState) {
|
||||
super(Material.iron);
|
||||
rand = new Random();
|
||||
isActive = blockState;
|
||||
}
|
||||
|
||||
|
||||
177
src/main/java/com/hbm/blocks/machine/MachineHeatBoiler.java
Normal file
@ -0,0 +1,177 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingType;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.TileEntityHeatBoiler;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class MachineHeatBoiler extends BlockDummyable implements ILookOverlay {
|
||||
|
||||
public MachineHeatBoiler() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
|
||||
if(meta >= 12) return new TileEntityHeatBoiler();
|
||||
if(meta >= extra) return new TileEntityProxyCombo().fluid();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
|
||||
if(!world.isRemote && !player.isSneaking()) {
|
||||
|
||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IItemFluidIdentifier) {
|
||||
int[] pos = this.findCore(world, x, y, z);
|
||||
|
||||
if(pos == null)
|
||||
return false;
|
||||
|
||||
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
|
||||
if(!(te instanceof TileEntityHeatBoiler))
|
||||
return false;
|
||||
|
||||
TileEntityHeatBoiler boiler = (TileEntityHeatBoiler) te;
|
||||
|
||||
FluidType type = ((IItemFluidIdentifier) player.getHeldItem().getItem()).getType(world, pos[0], pos[1], pos[2], player.getHeldItem());
|
||||
|
||||
if(type.hasTrait(FT_Heatable.class) && type.getTrait(FT_Heatable.class).getEfficiency(HeatingType.BOILER) > 0) {
|
||||
boiler.tanks[0].setTankType(type);
|
||||
boiler.markDirty();
|
||||
player.addChatComponentMessage(new ChatComponentText("Changed type to ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)).appendSibling(new ChatComponentTranslation("hbmfluid." + type.getName().toLowerCase())).appendSibling(new ChatComponentText("!")));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, player, itemStack);
|
||||
|
||||
if(itemStack.getItemDamage() == 1) {
|
||||
|
||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
int o = -getOffset();
|
||||
|
||||
ForgeDirection dir = ForgeDirection.NORTH;
|
||||
if(i == 0) dir = ForgeDirection.getOrientation(2);
|
||||
if(i == 1) dir = ForgeDirection.getOrientation(5);
|
||||
if(i == 2) dir = ForgeDirection.getOrientation(3);
|
||||
if(i == 3) dir = ForgeDirection.getOrientation(4);
|
||||
|
||||
dir = getDirModified(dir);
|
||||
|
||||
TileEntity te = world.getTileEntity(x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o);
|
||||
|
||||
if(te instanceof TileEntityHeatBoiler) {
|
||||
((TileEntityHeatBoiler) te).hasExploded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
int count = quantityDropped(metadata, fortune, world.rand);
|
||||
int dmg = 0;
|
||||
|
||||
int[] pos = this.findCore(world, x, y, z);
|
||||
|
||||
if(pos != null) {
|
||||
TileEntityHeatBoiler stirling = (TileEntityHeatBoiler)world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
if(stirling.hasExploded) {
|
||||
dmg = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
Item item = getItemDropped(metadata, world.rand, fortune);
|
||||
if(item != null) {
|
||||
ret.add(new ItemStack(item, 1, dmg));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getDimensions() {
|
||||
return new int[] {3, 0, 1, 1, 1, 1};
|
||||
}
|
||||
|
||||
@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, y, z + rot.offsetZ);
|
||||
this.makeExtra(world, x - rot.offsetX, y, z - rot.offsetZ);
|
||||
this.makeExtra(world, x, y + 3, z);
|
||||
}
|
||||
|
||||
@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 TileEntityHeatBoiler))
|
||||
return;
|
||||
|
||||
TileEntityHeatBoiler boiler = (TileEntityHeatBoiler) te;
|
||||
|
||||
if(boiler.hasExploded) return;
|
||||
|
||||
List<String> text = new ArrayList();
|
||||
text.add(boiler.heat + "TU");
|
||||
text.add(EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + I18nUtil.resolveKey(boiler.tanks[0].getTankType().getUnlocalizedName()) + ": " + boiler.tanks[0].getFill() + " / " + boiler.tanks[0].getMaxFill() + "mB");
|
||||
text.add(EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + I18nUtil.resolveKey(boiler.tanks[1].getTankType().getUnlocalizedName()) + ": " + boiler.tanks[1].getFill() + " / " + boiler.tanks[1].getMaxFill() + "mB");
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
}
|
||||
@ -296,14 +296,6 @@ public class ShredderRecipes extends SerializableRecipe {
|
||||
ShredderRecipes.setRecipe(ModBlocks.deco_pipe_framed_red, new ItemStack(ModItems.powder_steel, 1));
|
||||
ShredderRecipes.setRecipe(ModBlocks.deco_pipe_framed_marked, new ItemStack(ModItems.powder_steel, 1));
|
||||
|
||||
/* Turret and ammo recycling */
|
||||
ShredderRecipes.setRecipe(ModItems.turret_light_ammo, new ItemStack(Items.gunpowder, 4));
|
||||
ShredderRecipes.setRecipe(ModItems.turret_heavy_ammo, new ItemStack(Items.gunpowder, 4));
|
||||
ShredderRecipes.setRecipe(ModItems.turret_flamer_ammo, new ItemStack(Items.gunpowder, 4));
|
||||
ShredderRecipes.setRecipe(ModItems.turret_rocket_ammo, new ItemStack(Items.gunpowder, 4));
|
||||
ShredderRecipes.setRecipe(ModItems.turret_cwis_ammo, new ItemStack(Items.gunpowder, 4));
|
||||
ShredderRecipes.setRecipe(ModItems.turret_tau_ammo, new ItemStack(ModItems.powder_uranium, 4));
|
||||
|
||||
/* Wool and clay scrapping */
|
||||
for(int i = 0; i < 16; i++) {
|
||||
ShredderRecipes.setRecipe(new ItemStack(Blocks.stained_hardened_clay, 1, i), new ItemStack(Items.clay_ball, 4));
|
||||
|
||||
@ -2430,13 +2430,7 @@ public class ModItems {
|
||||
|
||||
public static Item mech_key;
|
||||
|
||||
public static Item turret_light_ammo;
|
||||
public static Item turret_heavy_ammo;
|
||||
public static Item turret_rocket_ammo;
|
||||
public static Item turret_flamer_ammo;
|
||||
public static Item turret_tau_ammo;
|
||||
public static Item turret_spitfire_ammo;
|
||||
public static Item turret_cwis_ammo;
|
||||
public static Item turret_cheapo_ammo;
|
||||
|
||||
public static Item bucket_mud;
|
||||
@ -7464,13 +7458,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(ammo_folly_du, ammo_folly_du.getUnlocalizedName());
|
||||
|
||||
//Turret Ammo
|
||||
GameRegistry.registerItem(turret_light_ammo, turret_light_ammo.getUnlocalizedName());
|
||||
GameRegistry.registerItem(turret_heavy_ammo, turret_heavy_ammo.getUnlocalizedName());
|
||||
GameRegistry.registerItem(turret_rocket_ammo, turret_rocket_ammo.getUnlocalizedName());
|
||||
GameRegistry.registerItem(turret_flamer_ammo, turret_flamer_ammo.getUnlocalizedName());
|
||||
GameRegistry.registerItem(turret_tau_ammo, turret_tau_ammo.getUnlocalizedName());
|
||||
GameRegistry.registerItem(turret_spitfire_ammo, turret_spitfire_ammo.getUnlocalizedName());
|
||||
GameRegistry.registerItem(turret_cwis_ammo, turret_cwis_ammo.getUnlocalizedName());
|
||||
GameRegistry.registerItem(turret_cheapo_ammo, turret_cheapo_ammo.getUnlocalizedName());
|
||||
|
||||
//-C-l-i-p-s- Magazines
|
||||
|
||||
@ -265,6 +265,7 @@ public class ClientProxy extends ServerProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityStirling.class, new RenderStirling());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySawmill.class, new RenderSawmill());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrucible.class, new RenderCrucible());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHeatBoiler.class, new RenderBoiler());
|
||||
//Foundry
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFoundryBasin.class, new RenderFoundry());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFoundryMold.class, new RenderFoundry());
|
||||
|
||||
@ -949,6 +949,12 @@ public class MainRegistry {
|
||||
ignoreMappings.add("hbm:tile.turret_flamer");
|
||||
ignoreMappings.add("hbm:tile.turret_tau");
|
||||
ignoreMappings.add("hbm:tile.turret_cwis");
|
||||
ignoreMappings.add("hbm:item.turret_light_ammo");
|
||||
ignoreMappings.add("hbm:item.turret_heavy_ammo");
|
||||
ignoreMappings.add("hbm:item.turret_rocket_ammo");
|
||||
ignoreMappings.add("hbm:item.turret_flamer_ammo");
|
||||
ignoreMappings.add("hbm:item.turret_tau_ammo");
|
||||
ignoreMappings.add("hbm:item.turret_cwis_ammo");
|
||||
|
||||
/// REMAP ///
|
||||
remapItems.put("hbm:item.gadget_explosive8", ModItems.early_explosive_lenses);
|
||||
|
||||
@ -65,6 +65,8 @@ public class ResourceManager {
|
||||
public static final IModelCustom stirling = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/machines/stirling.obj"));
|
||||
public static final IModelCustom sawmill = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/machines/sawmill.obj"));
|
||||
public static final IModelCustom crucible_heat = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/machines/crucible.obj"));
|
||||
public static final IModelCustom boiler = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/boiler.obj"));
|
||||
public static final IModelCustom boiler_burst = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/boiler_burst.obj"));
|
||||
|
||||
//Furnaces
|
||||
public static final IModelCustom furnace_iron = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/machines/furnace_iron.obj"));
|
||||
@ -387,6 +389,7 @@ public class ResourceManager {
|
||||
public static final ResourceLocation stirling_steel_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/stirling_steel.png");
|
||||
public static final ResourceLocation sawmill_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/sawmill.png");
|
||||
public static final ResourceLocation crucible_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/crucible_heat.png");
|
||||
public static final ResourceLocation boiler_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/boiler.png");
|
||||
|
||||
//Furnaces
|
||||
public static final ResourceLocation furnace_iron_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/furnace_iron.png");
|
||||
|
||||
@ -23,6 +23,8 @@ public class RenderFoundryBasin implements ISimpleBlockRenderingHandler {
|
||||
double z = 0;
|
||||
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
|
||||
basin.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0F, 1F, 0F);
|
||||
|
||||
@ -23,6 +23,8 @@ public class RenderFoundryMold implements ISimpleBlockRenderingHandler {
|
||||
double z = 0;
|
||||
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
|
||||
basin.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0F, 1F, 0F);
|
||||
|
||||
70
src/main/java/com/hbm/render/tileentity/RenderBoiler.java
Normal file
@ -0,0 +1,70 @@
|
||||
package com.hbm.render.tileentity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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.TileEntityHeatBoiler;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
public class RenderBoiler extends TileEntitySpecialRenderer implements IItemRendererProvider {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
switch(tile.getBlockMetadata() - BlockDummyable.offset) {
|
||||
case 3: GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||
case 5: GL11.glRotatef(90, 0F, 1F, 0F); break;
|
||||
case 2: GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||
case 4: GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||
}
|
||||
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.boiler_tex);
|
||||
TileEntityHeatBoiler boiler = (TileEntityHeatBoiler) tile;
|
||||
if(!boiler.hasExploded) {
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
ResourceManager.boiler.renderAll();
|
||||
} else {
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
ResourceManager.boiler_burst.renderAll();
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
}
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemForRenderer() {
|
||||
return Item.getItemFromBlock(ModBlocks.machine_boiler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemRenderer getRenderer() {
|
||||
return new ItemRenderBase( ) {
|
||||
public void renderInventory() {
|
||||
GL11.glTranslated(0, -3, 0);
|
||||
GL11.glScaled(3, 3, 3);
|
||||
}
|
||||
public void renderCommonWithStack(ItemStack item) {
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.boiler_tex);
|
||||
if(item.getItemDamage() == 1)
|
||||
ResourceManager.boiler_burst.renderAll();
|
||||
else
|
||||
ResourceManager.boiler.renderAll();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
}};
|
||||
}
|
||||
}
|
||||
@ -251,6 +251,7 @@ public class TileMappings {
|
||||
put(TileEntityStirling.class, "tileentity_stirling");
|
||||
put(TileEntitySawmill.class, "tileentity_sawmill");
|
||||
put(TileEntityCrucible.class, "tileentity_crucible");
|
||||
put(TileEntityHeatBoiler.class, "tileentity_heat_boiler");
|
||||
|
||||
put(TileEntityFoundryMold.class, "tileentity_foundry_mold");
|
||||
put(TileEntityFoundryBasin.class, "tileentity_foundry_basin");
|
||||
|
||||
@ -0,0 +1,281 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.interfaces.IFluidAcceptor;
|
||||
import com.hbm.interfaces.IFluidSource;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingStep;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingType;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import api.hbm.tile.IHeatSource;
|
||||
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 TileEntityHeatBoiler extends TileEntityLoadedBase implements IFluidSource, IFluidAcceptor, INBTPacketReceiver, IFluidStandardTransceiver {
|
||||
|
||||
public int heat;
|
||||
public static final int maxHeat = 12_800_000; //the heat required to turn 64k of water into steam
|
||||
public static final double diffusion = 0.1D;
|
||||
public FluidTank[] tanks;
|
||||
public List<IFluidAcceptor> list = new ArrayList();
|
||||
public boolean hasExploded = false;
|
||||
|
||||
public TileEntityHeatBoiler() {
|
||||
this.tanks = new FluidTank[2];
|
||||
|
||||
this.tanks[0] = new FluidTank(Fluids.WATER, 64_000, 0);
|
||||
this.tanks[1] = new FluidTank(Fluids.STEAM, 64_000 * 100, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
if(!this.hasExploded) {
|
||||
this.setupTanks();
|
||||
this.updateConnections();
|
||||
this.tryPullHeat();
|
||||
int lastHeat = this.heat;
|
||||
|
||||
data.setInteger("heat", lastHeat);
|
||||
|
||||
tanks[0].writeToNBT(data, "0");
|
||||
this.tryConvert();
|
||||
tanks[1].writeToNBT(data, "1");
|
||||
|
||||
if(this.tanks[1].getFill() > 0) {
|
||||
this.sendFluid();
|
||||
|
||||
fillFluidInit(tanks[1].getTankType());
|
||||
}
|
||||
}
|
||||
|
||||
data.setBoolean("exploded", this.hasExploded);
|
||||
INBTPacketReceiver.networkPack(this, data, 25);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
this.hasExploded = nbt.getBoolean("exploded");
|
||||
this.heat = nbt.getInteger("heat");
|
||||
this.tanks[0].readFromNBT(nbt, "0");
|
||||
this.tanks[1].readFromNBT(nbt, "1");
|
||||
}
|
||||
|
||||
protected void tryPullHeat() {
|
||||
TileEntity con = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
|
||||
if(con instanceof IHeatSource) {
|
||||
IHeatSource source = (IHeatSource) con;
|
||||
int diff = source.getHeatStored() - this.heat;
|
||||
|
||||
if(diff == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(diff > 0) {
|
||||
diff = (int) Math.ceil(diff * diffusion);
|
||||
source.useUpHeat(diff);
|
||||
this.heat += diff;
|
||||
if(this.heat > this.maxHeat)
|
||||
this.heat = this.maxHeat;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.heat = Math.max(this.heat - Math.max(this.heat / 1000, 1), 0);
|
||||
}
|
||||
|
||||
protected void setupTanks() {
|
||||
|
||||
if(tanks[0].getTankType().hasTrait(FT_Heatable.class)) {
|
||||
FT_Heatable trait = tanks[0].getTankType().getTrait(FT_Heatable.class);
|
||||
if(trait.getEfficiency(HeatingType.BOILER) > 0) {
|
||||
HeatingStep entry = trait.getFirstStep();
|
||||
tanks[1].setTankType(entry.typeProduced);
|
||||
tanks[1].changeTankSize(tanks[0].getMaxFill() * entry.amountProduced / entry.amountReq);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tanks[0].setTankType(Fluids.NONE);
|
||||
tanks[1].setTankType(Fluids.NONE);
|
||||
}
|
||||
|
||||
protected void tryConvert() {
|
||||
|
||||
if(tanks[0].getTankType().hasTrait(FT_Heatable.class)) {
|
||||
FT_Heatable trait = tanks[0].getTankType().getTrait(FT_Heatable.class);
|
||||
if(trait.getEfficiency(HeatingType.BOILER) > 0) {
|
||||
|
||||
HeatingStep entry = trait.getFirstStep();
|
||||
int inputOps = this.tanks[0].getFill() / entry.amountReq;
|
||||
int outputOps = (this.tanks[1].getMaxFill() - this.tanks[1].getFill()) / entry.amountProduced;
|
||||
int heatOps = this.heat / entry.heatReq;
|
||||
|
||||
int ops = Math.min(inputOps, Math.min(outputOps, heatOps));
|
||||
|
||||
this.tanks[0].setFill(this.tanks[0].getFill() - entry.amountReq * ops);
|
||||
this.tanks[1].setFill(this.tanks[1].getFill() + entry.amountProduced * ops);
|
||||
this.heat -= entry.heatReq * ops;
|
||||
|
||||
if(ops > 0 && worldObj.rand.nextInt(400) == 0) {
|
||||
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 2, zCoord + 0.5, "hbm:block.boilerGroan", 0.5F, 1.0F);
|
||||
}
|
||||
|
||||
if(outputOps == 0) {
|
||||
this.hasExploded = true;
|
||||
worldObj.newExplosion(null, xCoord + 0.5, yCoord + 2, zCoord + 0.5, 5F, false, false);
|
||||
BlockDummyable.safeRem = true;
|
||||
for(int x = xCoord - 1; x <= xCoord + 1; x++) {
|
||||
for(int y = yCoord + 2; y <= yCoord + 3; y++) {
|
||||
for(int z = zCoord - 1; z <= zCoord + 1; z++) {
|
||||
worldObj.setBlockToAir(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord);
|
||||
BlockDummyable.safeRem = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConnections() {
|
||||
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
|
||||
private void sendFluid() {
|
||||
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir().getOpposite());
|
||||
}
|
||||
}
|
||||
|
||||
private DirPos[] getConPos() {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getRotation(ForgeDirection.UP);
|
||||
return new DirPos[] {
|
||||
new DirPos(xCoord + dir.offsetX * 2, yCoord, zCoord + dir.offsetZ * 2, dir),
|
||||
new DirPos(xCoord - dir.offsetX * 2, yCoord, zCoord - dir.offsetZ * 2, dir.getOpposite()),
|
||||
new DirPos(xCoord, yCoord + 4, zCoord, Library.POS_Y),
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFluidFill(int fill, FluidType type) {
|
||||
for(FluidTank tank : tanks) {
|
||||
if(tank.getTankType() == type) {
|
||||
tank.setFill(fill);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void setFillForSync(int fill, int index) { }
|
||||
@Override public void setTypeForSync(FluidType type, int index) { }
|
||||
|
||||
@Override
|
||||
public int getFluidFill(FluidType type) {
|
||||
for(FluidTank tank : tanks) {
|
||||
if(tank.getTankType() == type) {
|
||||
return tank.getFill();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFluidFill(FluidType type) {
|
||||
return type == tanks[0].getTankType() ? tanks[0].getMaxFill() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillFluidInit(FluidType type) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getRotation(ForgeDirection.UP);
|
||||
this.fillFluid(xCoord + dir.offsetX * 2, yCoord, zCoord + dir.offsetZ * 2, this.getTact(), type);
|
||||
this.fillFluid(xCoord - dir.offsetX * 2, yCoord, zCoord - dir.offsetZ * 2, this.getTact(), type);
|
||||
this.fillFluid(xCoord, yCoord + 4, zCoord, this.getTact(), type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillFluid(int x, int y, int z, boolean newTact, FluidType type) {
|
||||
Library.transmitFluid(x, y, z, newTact, this, worldObj, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getTact() {
|
||||
return worldObj.getTotalWorldTime() % 2 == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IFluidAcceptor> getFluidList(FluidType type) {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFluidList(FluidType type) {
|
||||
this.list.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getAllTanks() {
|
||||
return tanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getSendingTanks() {
|
||||
return new FluidTank[] {tanks[1]};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return new FluidTank[] {tanks[0]};
|
||||
}
|
||||
|
||||
AxisAlignedBB bb = null;
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
|
||||
if(bb == null) {
|
||||
bb = AxisAlignedBB.getBoundingBox(
|
||||
xCoord - 1,
|
||||
yCoord,
|
||||
zCoord - 1,
|
||||
xCoord + 2,
|
||||
yCoord + 4,
|
||||
zCoord + 2
|
||||
);
|
||||
}
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
}
|
||||
2080
src/main/resources/assets/hbm/models/machines/boiler.obj
Normal file
1299
src/main/resources/assets/hbm/models/machines/boiler_burst.obj
Normal file
@ -45,6 +45,7 @@
|
||||
"block.openC": {"category": "block", "sounds": ["block/openC1", "block/openC2", "block/openCSqueaky"]},
|
||||
"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"]},
|
||||
|
||||
"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}]},
|
||||
|
||||
BIN
src/main/resources/assets/hbm/sounds/block/boilerGroan0.ogg
Normal file
BIN
src/main/resources/assets/hbm/sounds/block/boilerGroan1.ogg
Normal file
BIN
src/main/resources/assets/hbm/sounds/block/boilerGroan2.ogg
Normal file
|
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 427 B |
|
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 454 B |
|
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 811 B |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 255 B |
@ -1,3 +0,0 @@
|
||||
{
|
||||
"animation": {}
|
||||
}
|
||||
|
After Width: | Height: | Size: 7.0 KiB |