mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
finished electric heater
This commit is contained in:
parent
23fc31e2b0
commit
211da211b4
@ -1,21 +1,26 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.TileEntityHeaterElectric;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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 HeaterElectric extends BlockDummyable implements ITooltipProvider, IToolable {
|
||||
public class HeaterElectric extends BlockDummyable implements ILookOverlay, ITooltipProvider, IToolable {
|
||||
|
||||
public HeaterElectric() {
|
||||
super(Material.iron);
|
||||
@ -54,12 +59,37 @@ public class HeaterElectric extends BlockDummyable implements ITooltipProvider,
|
||||
this.addStandardInfo(stack, player, list, ext);
|
||||
}
|
||||
|
||||
@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 TileEntityHeaterElectric))
|
||||
return;
|
||||
|
||||
TileEntityHeaterElectric heater = (TileEntityHeaterElectric) te;
|
||||
|
||||
List<String> text = new ArrayList();
|
||||
text.add(String.format("%,d", heater.heatEnergy) + " TU");
|
||||
text.add(EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + heater.getConsumption() + " HE/t");
|
||||
text.add(EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + heater.getHeatGen() + " TU/t");
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
|
||||
if(tool != ToolType.SCREWDRIVER)
|
||||
return false;
|
||||
|
||||
if(world.isRemote) return true;
|
||||
|
||||
int[] pos = this.findCore(world, x, y, z);
|
||||
|
||||
if(pos == null) return false;
|
||||
|
||||
@ -242,6 +242,15 @@ public class AnvilRecipes {
|
||||
new OreDictStack(CU.ingot(), 8)
|
||||
}, new AnvilOutput(new ItemStack(ModBlocks.heater_oilburner))).setTier(3));
|
||||
|
||||
constructionRecipes.add(new AnvilConstructionRecipe(
|
||||
new AStack[] {
|
||||
new OreDictStack(ANY_PLASTIC.ingot(), 4),
|
||||
new OreDictStack(CU.ingot(), 8),
|
||||
new OreDictStack(STEEL.plate(), 8),
|
||||
new ComparableStack(ModItems.coil_tungsten, 8),
|
||||
new ComparableStack(ModItems.circuit_copper, 1)
|
||||
}, new AnvilOutput(new ItemStack(ModBlocks.heater_electric))).setTier(3));
|
||||
|
||||
constructionRecipes.add(new AnvilConstructionRecipe(
|
||||
new AStack[] {
|
||||
new ComparableStack(Blocks.stonebrick, 16),
|
||||
|
||||
@ -33,6 +33,13 @@ public class RenderBoiler extends TileEntitySpecialRenderer implements IItemRend
|
||||
bindTexture(ResourceManager.boiler_tex);
|
||||
TileEntityHeatBoiler boiler = (TileEntityHeatBoiler) tile;
|
||||
if(!boiler.hasExploded) {
|
||||
|
||||
if(boiler.tanks[1].getFill() > boiler.tanks[1].getMaxFill() * 0.9) {
|
||||
double sine = Math.sin(System.currentTimeMillis() / 50D % (Math.PI * 2));
|
||||
sine *= 0.01D;
|
||||
GL11.glScaled(1 - sine, 1 + sine, 1 - sine);
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
ResourceManager.boiler.renderAll();
|
||||
} else {
|
||||
|
||||
@ -10,6 +10,7 @@ import org.lwjgl.opengl.GL12;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.util.BeamPronter;
|
||||
import com.hbm.render.util.HorsePronter;
|
||||
import com.hbm.render.util.RenderMiscEffects;
|
||||
import com.hbm.render.util.BeamPronter.EnumBeamType;
|
||||
import com.hbm.render.util.BeamPronter.EnumWaveType;
|
||||
@ -39,7 +40,30 @@ public class RendererObjTester extends TileEntitySpecialRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y, z + 0.5);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
this.bindTexture(HorsePronter.tex_demohorse);
|
||||
HorsePronter.reset();
|
||||
//HorsePronter.pose(HorsePronter.id_lfl, 0, System.currentTimeMillis() % 360 / 10D, 0);
|
||||
double r = 60;
|
||||
HorsePronter.pose(HorsePronter.id_body, 0, -r, 0);
|
||||
HorsePronter.pose(HorsePronter.id_tail, 0, 45, 90);
|
||||
HorsePronter.pose(HorsePronter.id_lbl, 0, -90 + r, 35);
|
||||
HorsePronter.pose(HorsePronter.id_rbl, 0, -90 + r, -35);
|
||||
HorsePronter.pose(HorsePronter.id_lfl, 0, r - 10, 5);
|
||||
HorsePronter.pose(HorsePronter.id_rfl, 0, r - 10, -5);
|
||||
HorsePronter.pose(HorsePronter.id_head, 0, r, 0);
|
||||
HorsePronter.enableHorn();
|
||||
HorsePronter.pront();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
public void renderTileEntityAt2(TileEntity tileEntity, double x, double y, double z, float f)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y, z + 0.5);
|
||||
|
||||
@ -13,26 +13,26 @@ public class HorsePronter {
|
||||
|
||||
public static final IModelCustom horse = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/mobs/horse.obj"), false).asDisplayList();
|
||||
|
||||
public static final ResourceLocation tex_demohorse = new ResourceLocation(RefStrings.MODID, "textures/models/horse/horse_template.png");
|
||||
public static final ResourceLocation tex_demohorse = new ResourceLocation(RefStrings.MODID, "textures/models/horse/horse_demo.png");
|
||||
|
||||
private Vec3[] pose = new Vec3[] {
|
||||
private static Vec3[] pose = new Vec3[] {
|
||||
Vec3.createVectorHelper(0, 0, 0), //head
|
||||
Vec3.createVectorHelper(0, 0, 0), //left front leg
|
||||
Vec3.createVectorHelper(0, 0, 0), //right front leg
|
||||
Vec3.createVectorHelper(0, 0, 0), //left back leg
|
||||
Vec3.createVectorHelper(0, 0, 0), //left back leg
|
||||
Vec3.createVectorHelper(0, 0, 0), //right back leg
|
||||
Vec3.createVectorHelper(0, 0, 0), //tail
|
||||
Vec3.createVectorHelper(0, 0, 0), //body
|
||||
Vec3.createVectorHelper(0, 0, 0) //body offset
|
||||
};
|
||||
|
||||
private Vec3[] offsets = new Vec3[] {
|
||||
Vec3.createVectorHelper(0, 0, 0), //head
|
||||
Vec3.createVectorHelper(0, 0, 0), //left front leg
|
||||
Vec3.createVectorHelper(0, 0, 0), //right front leg
|
||||
Vec3.createVectorHelper(0, 0, 0), //left back leg
|
||||
Vec3.createVectorHelper(0, 0, 0), //left back leg
|
||||
Vec3.createVectorHelper(0, 0, 0), //tail
|
||||
private static Vec3[] offsets = new Vec3[] {
|
||||
Vec3.createVectorHelper(0, 1.125, 0.375), //head
|
||||
Vec3.createVectorHelper(0.125, 0.75, 0.3125), //left front leg
|
||||
Vec3.createVectorHelper(-0.125, 0.75, 0.3125), //right front leg
|
||||
Vec3.createVectorHelper(0.125, 0.75, -0.25), //left back leg
|
||||
Vec3.createVectorHelper(-0.125, 0.75, -0.25), //right back leg
|
||||
Vec3.createVectorHelper(0, 1.125, -0.4375), //tail
|
||||
Vec3.createVectorHelper(0, 0, 0), //body
|
||||
Vec3.createVectorHelper(0, 0, 0) //body offset
|
||||
};
|
||||
@ -46,11 +46,11 @@ public class HorsePronter {
|
||||
public static final int id_body = 6;
|
||||
public static final int id_position = 7;
|
||||
|
||||
private boolean wings = false;
|
||||
private boolean horn = false;
|
||||
private boolean maleSnoot = false;
|
||||
private static boolean wings = false;
|
||||
private static boolean horn = false;
|
||||
private static boolean maleSnoot = false;
|
||||
|
||||
public void reset() {
|
||||
public static void reset() {
|
||||
|
||||
wings = false;
|
||||
horn = false;
|
||||
@ -62,22 +62,22 @@ public class HorsePronter {
|
||||
}
|
||||
}
|
||||
|
||||
public void enableHorn() { horn = true; }
|
||||
public void enableWings() { wings = true; }
|
||||
public void setMaleSnoot() { maleSnoot = true; }
|
||||
public static void enableHorn() { horn = true; }
|
||||
public static void enableWings() { wings = true; }
|
||||
public static void setMaleSnoot() { maleSnoot = true; }
|
||||
|
||||
public void setAlicorn() {
|
||||
public static void setAlicorn() {
|
||||
enableHorn();
|
||||
enableWings();
|
||||
}
|
||||
|
||||
public void pose(int id, double yaw, double pitch, double roll) {
|
||||
public static void pose(int id, double yaw, double pitch, double roll) {
|
||||
pose[id].xCoord = yaw;
|
||||
pose[id].yCoord = pitch;
|
||||
pose[id].zCoord = roll;
|
||||
}
|
||||
|
||||
public void pront() {
|
||||
public static void pront() {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
doTransforms(id_body);
|
||||
@ -85,9 +85,9 @@ public class HorsePronter {
|
||||
horse.renderPart("Body");
|
||||
|
||||
if(horn) {
|
||||
renderWithTransform(id_head, "Head", maleSnoot ? "NoseMale" : "NoseFemale", "HornPointy");
|
||||
renderWithTransform(id_head, "Head", "Mane", maleSnoot ? "NoseMale" : "NoseFemale", "HornPointy");
|
||||
} else {
|
||||
renderWithTransform(id_head, "Head", maleSnoot ? "NoseMale" : "NoseFemale");
|
||||
renderWithTransform(id_head, "Head", "Mane", maleSnoot ? "NoseMale" : "NoseFemale");
|
||||
}
|
||||
|
||||
renderWithTransform(id_lfl, "LeftFrontLeg");
|
||||
@ -104,7 +104,7 @@ public class HorsePronter {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void doTransforms(int id) {
|
||||
private static void doTransforms(int id) {
|
||||
Vec3 rotation = pose[id];
|
||||
Vec3 offset = offsets[id];
|
||||
GL11.glTranslated(offset.xCoord, offset.yCoord, offset.zCoord);
|
||||
@ -114,7 +114,7 @@ public class HorsePronter {
|
||||
GL11.glTranslated(-offset.xCoord, -offset.yCoord, -offset.zCoord);
|
||||
}
|
||||
|
||||
private void renderWithTransform(int id, String... parts) {
|
||||
private static void renderWithTransform(int id, String... parts) {
|
||||
GL11.glPushMatrix();
|
||||
doTransforms(id);
|
||||
for(String part : parts) horse.renderPart(part);
|
||||
|
||||
@ -6,8 +6,11 @@ import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
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 TileEntityHeaterElectric extends TileEntityLoadedBase implements IHeatSource, IEnergyUser, INBTPacketReceiver {
|
||||
@ -26,18 +29,19 @@ public class TileEntityHeaterElectric extends TileEntityLoadedBase implements IH
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX * 3, yCoord, zCoord + dir.offsetZ * 3, dir);
|
||||
}
|
||||
|
||||
this.heatEnergy = 0;
|
||||
this.heatEnergy *= 0.999;
|
||||
|
||||
this.tryPullHeat();
|
||||
|
||||
if(setting > 0 && this.power >= this.getConsumption()) {
|
||||
this.power -= this.getConsumption();
|
||||
this.heatEnergy += setting * 100;
|
||||
this.heatEnergy += getHeatGen();
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("s", (byte) this.setting);
|
||||
data.setInteger("h", heatEnergy);
|
||||
data.setInteger("h", this.heatEnergy);
|
||||
INBTPacketReceiver.networkPack(this, data, 25);
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,12 +51,30 @@ public class TileEntityHeaterElectric extends TileEntityLoadedBase implements IH
|
||||
this.heatEnergy = nbt.getInteger("h");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
this.power = nbt.getLong("power");
|
||||
this.setting = nbt.getInteger("setting");
|
||||
this.heatEnergy = nbt.getInteger("heatEnergy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
nbt.setLong("power", power);
|
||||
nbt.setInteger("setting", setting);
|
||||
nbt.setInteger("heatEnergy", heatEnergy);
|
||||
}
|
||||
|
||||
protected void tryPullHeat() {
|
||||
TileEntity con = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
|
||||
if(con instanceof IHeatSource) {
|
||||
IHeatSource source = (IHeatSource) con;
|
||||
this.heatEnergy += source.getHeatStored() * 0.75;
|
||||
this.heatEnergy += source.getHeatStored() * 0.85;
|
||||
source.useUpHeat(source.getHeatStored());
|
||||
}
|
||||
}
|
||||
@ -70,13 +92,17 @@ public class TileEntityHeaterElectric extends TileEntityLoadedBase implements IH
|
||||
}
|
||||
|
||||
public long getConsumption() {
|
||||
return (long) Math.pow(setting * 200, 1.4D);
|
||||
return (long) (Math.pow(setting, 1.4D) * 200D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return getConsumption() * 20;
|
||||
}
|
||||
|
||||
public int getHeatGen() {
|
||||
return this.setting * 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long power) {
|
||||
@ -92,4 +118,29 @@ public class TileEntityHeaterElectric extends TileEntityLoadedBase implements IH
|
||||
public void useUpHeat(int heat) {
|
||||
this.heatEnergy = Math.max(0, this.heatEnergy - heat);
|
||||
}
|
||||
|
||||
AxisAlignedBB bb = null;
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
|
||||
if(bb == null) {
|
||||
bb = AxisAlignedBB.getBoundingBox(
|
||||
xCoord - 2,
|
||||
yCoord,
|
||||
zCoord - 2,
|
||||
xCoord + 3,
|
||||
yCoord + 1,
|
||||
zCoord + 3
|
||||
);
|
||||
}
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3431,6 +3431,8 @@ tile.hadron_power_100m.name=Teilchenbeschleuniger-Stromanschluss (100MHE)
|
||||
tile.hadron_power_1g.name=Teilchenbeschleuniger-Stromanschluss (1GHE)
|
||||
tile.hadron_power_10g.name=Teilchenbeschleuniger-Stromanschluss (10GHE)
|
||||
tile.hazmat.name=Strahlenschutzstoff-Block
|
||||
tile.heater_electric.name=Elektrische Heizung
|
||||
tile.heater_electric.desc=Erzeugt Wärme aus Strom.$Nimmt von unten Wärme mit 85%% Effizienz auf.$Kann mit einem Schraubenzeiher konfiguriert werden.
|
||||
tile.heater_firebox.name=Feuerbüchse
|
||||
tile.heater_firebox.desc=Erzeugt Wärme aus Festbrennstoff.
|
||||
tile.heater_oilburner.name=Brenner
|
||||
|
||||
@ -3869,6 +3869,8 @@ tile.hadron_power_100m.name=Particle Accelerator Power Plug (100MHE)
|
||||
tile.hadron_power_1g.name=Particle Accelerator Power Plug (1GHE)
|
||||
tile.hadron_power_10g.name=Particle Accelerator Power Plug (10GHE)
|
||||
tile.hazmat.name=Hazmat Cloth Block
|
||||
tile.heater_electric.name=Electric Heater
|
||||
tile.heater_electric.desc=Uses energy to produce heat.$Accepts heat from the bottom with 85%% efficiency.$Can be configured with a screwdriver.
|
||||
tile.heater_firebox.name=Firebox
|
||||
tile.heater_firebox.desc=Burns solid fuel to produce heat.
|
||||
tile.heater_oilburner.name=Fluid Burner
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user