mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
electric heater functionality
This commit is contained in:
parent
3d765347dc
commit
23fc31e2b0
@ -2,6 +2,7 @@ package com.hbm.blocks.machine;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import api.hbm.block.IToolable;
|
||||||
import com.hbm.blocks.BlockDummyable;
|
import com.hbm.blocks.BlockDummyable;
|
||||||
import com.hbm.blocks.ITooltipProvider;
|
import com.hbm.blocks.ITooltipProvider;
|
||||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||||
@ -14,7 +15,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class HeaterElectric extends BlockDummyable implements ITooltipProvider {
|
public class HeaterElectric extends BlockDummyable implements ITooltipProvider, IToolable {
|
||||||
|
|
||||||
public HeaterElectric() {
|
public HeaterElectric() {
|
||||||
super(Material.iron);
|
super(Material.iron);
|
||||||
@ -52,4 +53,25 @@ public class HeaterElectric extends BlockDummyable implements ITooltipProvider {
|
|||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||||
this.addStandardInfo(stack, player, list, ext);
|
this.addStandardInfo(stack, player, list, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
|
||||||
|
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 TileEntityHeaterElectric)) return false;
|
||||||
|
|
||||||
|
TileEntityHeaterElectric tile = (TileEntityHeaterElectric) te;
|
||||||
|
tile.toggleSetting();
|
||||||
|
tile.markDirty();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,7 +85,7 @@ public class Mats {
|
|||||||
public static final NTMMaterial MAT_SOLINIUM = makeSmeltable(12627, SA327, 0).setShapes(NUGGET, BILLET, INGOT, BLOCK);
|
public static final NTMMaterial MAT_SOLINIUM = makeSmeltable(12627, SA327, 0).setShapes(NUGGET, BILLET, INGOT, BLOCK);
|
||||||
public static final NTMMaterial MAT_SCHRABIDATE = makeSmeltable(12600, SBD, 0).setShapes(INGOT, DUST, BLOCK);
|
public static final NTMMaterial MAT_SCHRABIDATE = makeSmeltable(12600, SBD, 0).setShapes(INGOT, DUST, BLOCK);
|
||||||
public static final NTMMaterial MAT_SCHRARANIUM = makeSmeltable(12601, SRN, 0).setShapes(INGOT, BLOCK);
|
public static final NTMMaterial MAT_SCHRARANIUM = makeSmeltable(12601, SRN, 0).setShapes(INGOT, BLOCK);
|
||||||
public static final NTMMaterial MAT_GHIORSIUM = makeSmeltable(11936, GH336, 0).setShapes(NUGGET, BILLET, INGOT, BLOCK);
|
public static final NTMMaterial MAT_GHIORSIUM = makeSmeltable(12836, GH336, 0).setShapes(NUGGET, BILLET, INGOT, BLOCK);
|
||||||
|
|
||||||
//Base metals
|
//Base metals
|
||||||
public static final NTMMaterial MAT_TITANIUM = makeSmeltable(2200, TI, 0xA99E79).setShapes(INGOT, DUST, PLATE, BLOCK);
|
public static final NTMMaterial MAT_TITANIUM = makeSmeltable(2200, TI, 0xA99E79).setShapes(INGOT, DUST, PLATE, BLOCK);
|
||||||
|
|||||||
@ -668,6 +668,7 @@ public class CraftingManager {
|
|||||||
|
|
||||||
addShapelessAuto(new ItemStack(Items.paper, 1), new Object[] { new ItemStack(ModItems.assembly_template, 1, OreDictionary.WILDCARD_VALUE) });
|
addShapelessAuto(new ItemStack(Items.paper, 1), new Object[] { new ItemStack(ModItems.assembly_template, 1, OreDictionary.WILDCARD_VALUE) });
|
||||||
addShapelessAuto(new ItemStack(Items.paper, 1), new Object[] { new ItemStack(ModItems.chemistry_template, 1, OreDictionary.WILDCARD_VALUE) });
|
addShapelessAuto(new ItemStack(Items.paper, 1), new Object[] { new ItemStack(ModItems.chemistry_template, 1, OreDictionary.WILDCARD_VALUE) });
|
||||||
|
addShapelessAuto(new ItemStack(Items.paper, 1), new Object[] { new ItemStack(ModItems.crucible_template, 1, OreDictionary.WILDCARD_VALUE) });
|
||||||
addShapelessAuto(new ItemStack(Items.slime_ball, 16), new Object[] { new ItemStack(Items.dye, 1, 15), new ItemStack(Items.dye, 1, 15), new ItemStack(Items.dye, 1, 15), new ItemStack(Items.dye, 1, 15), Fluids.SULFURIC_ACID.getDict(1000) });
|
addShapelessAuto(new ItemStack(Items.slime_ball, 16), new Object[] { new ItemStack(Items.dye, 1, 15), new ItemStack(Items.dye, 1, 15), new ItemStack(Items.dye, 1, 15), new ItemStack(Items.dye, 1, 15), Fluids.SULFURIC_ACID.getDict(1000) });
|
||||||
|
|
||||||
for(int i = 1; i < Fluids.getAll().length; ++i) {
|
for(int i = 1; i < Fluids.getAll().length; ++i) {
|
||||||
|
|||||||
123
src/main/java/com/hbm/render/util/HorsePronter.java
Normal file
123
src/main/java/com/hbm/render/util/HorsePronter.java
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
package com.hbm.render.util;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import com.hbm.lib.RefStrings;
|
||||||
|
import com.hbm.render.loader.HFRWavefrontObject;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraftforge.client.model.IModelCustom;
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
private 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), //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
|
||||||
|
Vec3.createVectorHelper(0, 0, 0), //body
|
||||||
|
Vec3.createVectorHelper(0, 0, 0) //body offset
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final int id_head = 0;
|
||||||
|
public static final int id_lfl = 1;
|
||||||
|
public static final int id_rfl = 2;
|
||||||
|
public static final int id_lbl = 3;
|
||||||
|
public static final int id_rbl = 4;
|
||||||
|
public static final int id_tail = 5;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
|
||||||
|
wings = false;
|
||||||
|
horn = false;
|
||||||
|
|
||||||
|
for(Vec3 angles : pose) {
|
||||||
|
angles.xCoord = 0;
|
||||||
|
angles.yCoord = 0;
|
||||||
|
angles.zCoord = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableHorn() { horn = true; }
|
||||||
|
public void enableWings() { wings = true; }
|
||||||
|
public void setMaleSnoot() { maleSnoot = true; }
|
||||||
|
|
||||||
|
public void setAlicorn() {
|
||||||
|
enableHorn();
|
||||||
|
enableWings();
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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() {
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
doTransforms(id_body);
|
||||||
|
|
||||||
|
horse.renderPart("Body");
|
||||||
|
|
||||||
|
if(horn) {
|
||||||
|
renderWithTransform(id_head, "Head", maleSnoot ? "NoseMale" : "NoseFemale", "HornPointy");
|
||||||
|
} else {
|
||||||
|
renderWithTransform(id_head, "Head", maleSnoot ? "NoseMale" : "NoseFemale");
|
||||||
|
}
|
||||||
|
|
||||||
|
renderWithTransform(id_lfl, "LeftFrontLeg");
|
||||||
|
renderWithTransform(id_rfl, "RightFrontLeg");
|
||||||
|
renderWithTransform(id_lbl, "LeftBackLeg");
|
||||||
|
renderWithTransform(id_rbl, "RightBackLeg");
|
||||||
|
renderWithTransform(id_tail, "Tail");
|
||||||
|
|
||||||
|
if(wings) {
|
||||||
|
horse.renderPart("LeftWing");
|
||||||
|
horse.renderPart("RightWing");
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doTransforms(int id) {
|
||||||
|
Vec3 rotation = pose[id];
|
||||||
|
Vec3 offset = offsets[id];
|
||||||
|
GL11.glTranslated(offset.xCoord, offset.yCoord, offset.zCoord);
|
||||||
|
GL11.glRotated(rotation.xCoord, 0, 1, 0);
|
||||||
|
GL11.glRotated(rotation.yCoord, 1, 0, 0);
|
||||||
|
GL11.glRotated(rotation.zCoord, 0, 0, 1); //TODO: check pitch and roll axis
|
||||||
|
GL11.glTranslated(-offset.xCoord, -offset.yCoord, -offset.zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderWithTransform(int id, String... parts) {
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
doTransforms(id);
|
||||||
|
for(String part : parts) horse.renderPart(part);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,34 +1,95 @@
|
|||||||
package com.hbm.tileentity.machine;
|
package com.hbm.tileentity.machine;
|
||||||
|
|
||||||
|
import com.hbm.blocks.BlockDummyable;
|
||||||
|
import com.hbm.tileentity.INBTPacketReceiver;
|
||||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||||
|
|
||||||
import api.hbm.energy.IEnergyUser;
|
import api.hbm.energy.IEnergyUser;
|
||||||
import api.hbm.tile.IHeatSource;
|
import api.hbm.tile.IHeatSource;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityHeaterElectric extends TileEntityLoadedBase implements IHeatSource, IEnergyUser {
|
public class TileEntityHeaterElectric extends TileEntityLoadedBase implements IHeatSource, IEnergyUser, INBTPacketReceiver {
|
||||||
|
|
||||||
|
public long power;
|
||||||
|
public int heatEnergy;
|
||||||
|
protected int setting = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
|
||||||
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
|
if(worldObj.getTotalWorldTime() % 20 == 0) { //doesn't have to happen constantly
|
||||||
|
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||||
|
this.trySubscribe(worldObj, xCoord + dir.offsetX * 3, yCoord, zCoord + dir.offsetZ * 3, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.heatEnergy = 0;
|
||||||
|
|
||||||
|
this.tryPullHeat();
|
||||||
|
|
||||||
|
if(setting > 0 && this.power >= this.getConsumption()) {
|
||||||
|
this.power -= this.getConsumption();
|
||||||
|
this.heatEnergy += setting * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
|
data.setByte("s", (byte) this.setting);
|
||||||
|
data.setInteger("h", heatEnergy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void networkUnpack(NBTTagCompound nbt) {
|
||||||
|
this.setting = nbt.getByte("s");
|
||||||
|
this.heatEnergy = nbt.getInteger("h");
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
source.useUpHeat(source.getHeatStored());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleSetting() {
|
||||||
|
setting++;
|
||||||
|
|
||||||
|
if(setting > 10)
|
||||||
|
setting = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getPower() {
|
public long getPower() {
|
||||||
return 0;
|
return power;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getConsumption() {
|
||||||
|
return (long) Math.pow(setting * 200, 1.4D);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMaxPower() {
|
public long getMaxPower() {
|
||||||
return 0;
|
return getConsumption() * 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPower(long power) {
|
public void setPower(long power) {
|
||||||
|
this.power = power;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeatStored() {
|
public int getHeatStored() {
|
||||||
return 0;
|
return heatEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void useUpHeat(int heat) {
|
public void useUpHeat(int heat) {
|
||||||
|
this.heatEnergy = Math.max(0, this.heatEnergy - heat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 528 B |
Loading…
x
Reference in New Issue
Block a user