Added electric hot plate
This commit is contained in:
parent
c38290a920
commit
018e3253a6
7 changed files with 121 additions and 54 deletions
|
@ -20,6 +20,7 @@ import resonantinduction.core.ResonantInduction;
|
|||
import resonantinduction.core.Settings;
|
||||
import calclavia.lib.content.ContentRegistry;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.item.ItemBlockMetadata;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
|
@ -73,7 +74,7 @@ public class Archaic
|
|||
blockImprinter = contentRegistry.createTile(BlockImprinter.class, TileImprinter.class);
|
||||
blockTurntable = contentRegistry.createBlock(BlockTurntable.class);
|
||||
blockFirebox = contentRegistry.createTile(BlockFirebox.class, TileFirebox.class);
|
||||
blockHotPlate = contentRegistry.createTile(BlockHotPlate.class, TileHotPlate.class);
|
||||
blockHotPlate = contentRegistry.createBlock(BlockHotPlate.class, ItemBlockMetadata.class, TileHotPlate.class);
|
||||
|
||||
itemImprint = contentRegistry.createItem(ItemBlockImprint.class);
|
||||
proxy.preInit();
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
package resonantinduction.archaic.firebox;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.Icon;
|
||||
|
@ -16,17 +22,31 @@ import universalelectricity.api.vector.Vector3;
|
|||
|
||||
public class BlockHotPlate extends BlockRI
|
||||
{
|
||||
private Icon topOn;
|
||||
private Icon topOff;
|
||||
private Icon topElectric;
|
||||
|
||||
public BlockHotPlate()
|
||||
{
|
||||
super("hotPlate", Material.wood);
|
||||
setTextureName(Reference.PREFIX + "material_stone_chiseled");
|
||||
setTextureName(Reference.PREFIX + "material_wood_surface");
|
||||
setBlockBounds(0, 0, 0, 1, 0.2f, 1);
|
||||
this.setTickRandomly(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconReg)
|
||||
{
|
||||
super.registerIcons(iconReg);
|
||||
topElectric = iconReg.registerIcon(Reference.PREFIX + "material_steel");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon(int side, int meta)
|
||||
{
|
||||
return meta == 1 ? topElectric : blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
|
@ -98,15 +118,18 @@ public class BlockHotPlate extends BlockRI
|
|||
|
||||
if (tile.getStackInSlot(i) != null && tile.getSmeltTime(i) > 0)
|
||||
{
|
||||
int timeSmelt = TileHotPlate.MAX_SMELT_TIME * tile.getStackInSlot(i).stackSize - tile.getSmeltTime(i);
|
||||
int maxSmelt = TileHotPlate.MAX_SMELT_TIME * tile.getStackInSlot(i).stackSize;
|
||||
int maxParticles = (int) (((double) (maxSmelt - tile.getSmeltTime(i)) / (double) maxSmelt) * 30);
|
||||
|
||||
for (int spawn = 0; spawn < timeSmelt / 20; spawn++)
|
||||
for (int spawn = 0; spawn < maxParticles; spawn++)
|
||||
{
|
||||
Vector3 particlePosition = new Vector3(x, y, z).translate((double) (i / 2) / ((double) 2) + (0.5 / ((double) 2)), 0.2, (double) (i % 2) / ((double) 2) + (0.5 / ((double) 2)));
|
||||
particlePosition.translate(new Vector3((random.nextFloat() - 0.5) * 0.15, (random.nextFloat() - 0.5) * 0.15, (random.nextFloat() - 0.5) * 0.15));
|
||||
particlePosition.translate(new Vector3((random.nextFloat() - 0.5) * 0.2, (random.nextFloat() - 0.5) * 0.2, (random.nextFloat() - 0.5) * 0.2));
|
||||
world.spawnParticle("smoke", particlePosition.x, particlePosition.y, particlePosition.z, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", particlePosition.x, particlePosition.y, particlePosition.z, 0.0D, 0.01D, 0.0D);
|
||||
}
|
||||
|
||||
Vector3 particlePosition = new Vector3(x, y, z).translate((double) (i / 2) / ((double) 2) + (0.5 / ((double) 2)), 0.2, (double) (i % 2) / ((double) 2) + (0.5 / ((double) 2)));
|
||||
world.spawnParticle("flame", particlePosition.x, particlePosition.y, particlePosition.z, 0.0D, 0.01D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +152,13 @@ public class BlockHotPlate extends BlockRI
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
|
|
|
@ -9,11 +9,13 @@ import net.minecraft.item.crafting.FurnaceRecipes;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import universalelectricity.api.energy.EnergyStorageHandler;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.IPacketSender;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.TileExternalInventory;
|
||||
import calclavia.lib.prefab.tile.TileElectricalInventory;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
|
@ -23,12 +25,8 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileHotPlate extends TileExternalInventory implements IPacketSender, IPacketReceiver
|
||||
public class TileHotPlate extends TileElectricalInventory implements IPacketSender, IPacketReceiver
|
||||
{
|
||||
/**
|
||||
* The power of the firebox in terms of thermal energy. The thermal energy can be transfered
|
||||
* into fluids to increase their internal energy.
|
||||
*/
|
||||
private final int POWER = 50000;
|
||||
public final int[] smeltTime = new int[] { 0, 0, 0, 0 };
|
||||
public final int[] stackSizeCache = new int[] { 0, 0, 0, 0 };
|
||||
|
@ -36,56 +34,59 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
|||
|
||||
public TileHotPlate()
|
||||
{
|
||||
invSlots = 4;
|
||||
maxSlots = 4;
|
||||
energy = new EnergyStorageHandler(POWER * 2, POWER);
|
||||
setIO(ForgeDirection.UP, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
// if (!worldObj.isRemote)
|
||||
if (canRun())
|
||||
{
|
||||
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
boolean didSmelt = false;
|
||||
|
||||
if (tileEntity instanceof TileFirebox)
|
||||
for (int i = 0; i < maxSlots; i++)
|
||||
{
|
||||
if (((TileFirebox) tileEntity).isBurning())
|
||||
if (canSmelt(this.getStackInSlot(i)))
|
||||
{
|
||||
for (int i = 0; i < invSlots; i++)
|
||||
if (smeltTime[i] <= 0)
|
||||
{
|
||||
if (canSmelt(this.getStackInSlot(i)))
|
||||
/**
|
||||
* Heat up all slots
|
||||
*/
|
||||
stackSizeCache[i] = this.getStackInSlot(i).stackSize;
|
||||
smeltTime[i] = MAX_SMELT_TIME * stackSizeCache[i];
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
else if (smeltTime[i] > 0)
|
||||
{
|
||||
/**
|
||||
* Do the smelt action.
|
||||
*/
|
||||
if (--smeltTime[i] == 0)
|
||||
{
|
||||
if (smeltTime[i] <= 0)
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
/**
|
||||
* Heat up all slots
|
||||
*/
|
||||
stackSizeCache[i] = this.getStackInSlot(i).stackSize;
|
||||
smeltTime[i] = MAX_SMELT_TIME * stackSizeCache[i];
|
||||
ItemStack outputStack = FurnaceRecipes.smelting().getSmeltingResult(getStackInSlot(i)).copy();
|
||||
outputStack.stackSize = stackSizeCache[i];
|
||||
setInventorySlotContents(i, outputStack);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
else if (smeltTime[i] > 0)
|
||||
{
|
||||
/**
|
||||
* Do the smelt action.
|
||||
*/
|
||||
if (--smeltTime[i] == 0)
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
ItemStack outputStack = FurnaceRecipes.smelting().getSmeltingResult(getStackInSlot(i)).copy();
|
||||
outputStack.stackSize = stackSizeCache[i];
|
||||
setInventorySlotContents(i, outputStack);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
smeltTime[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
didSmelt = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
smeltTime[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (didSmelt)
|
||||
{
|
||||
energy.extractEnergy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +99,7 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
|||
/**
|
||||
* Update cache calculation.
|
||||
*/
|
||||
for (int i = 0; i < invSlots; i++)
|
||||
for (int i = 0; i < maxSlots; i++)
|
||||
{
|
||||
if (getStackInSlot(i) != null)
|
||||
{
|
||||
|
@ -124,6 +125,39 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isElectrical()
|
||||
{
|
||||
return this.getBlockMetadata() == 1;
|
||||
}
|
||||
|
||||
public boolean canRun()
|
||||
{
|
||||
if (isElectrical())
|
||||
{
|
||||
return energy.checkExtract();
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
|
||||
if (tileEntity instanceof TileFirebox)
|
||||
{
|
||||
if (((TileFirebox) tileEntity).isBurning())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return isElectrical() && super.canConnect(direction);
|
||||
}
|
||||
|
||||
public boolean canSmelt(ItemStack stack)
|
||||
{
|
||||
return FurnaceRecipes.smelting().getSmeltingResult(stack) != null;
|
||||
|
@ -131,7 +165,7 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
|||
|
||||
public boolean isSmelting()
|
||||
{
|
||||
for (int i = 0; i < invSlots; i++)
|
||||
for (int i = 0; i < maxSlots; i++)
|
||||
{
|
||||
if (getSmeltTime(i) > 0)
|
||||
{
|
||||
|
@ -150,7 +184,7 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
|||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack)
|
||||
{
|
||||
return i < invSlots && canSmelt(itemStack);
|
||||
return i < maxSlots && canSmelt(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -192,7 +226,7 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
|||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
for (int i = 0; i < invSlots; i++)
|
||||
for (int i = 0; i < maxSlots; i++)
|
||||
smeltTime[i] = nbt.getInteger("smeltTime" + i);
|
||||
}
|
||||
|
||||
|
@ -200,7 +234,7 @@ public class TileHotPlate extends TileExternalInventory implements IPacketSender
|
|||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
for (int i = 0; i < invSlots; i++)
|
||||
for (int i = 0; i < maxSlots; i++)
|
||||
nbt.setInteger("smeltTime" + i, smeltTime[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public abstract class TileEntityFilterable extends TileAssembly implements IRota
|
|||
public TileEntityFilterable()
|
||||
{
|
||||
super(0);
|
||||
this.invSlots = 2;
|
||||
this.maxSlots = 2;
|
||||
}
|
||||
|
||||
public TileEntityFilterable(long wattsPerTick, long maxEnergy)
|
||||
|
|
|
@ -23,6 +23,7 @@ public class BlockGenerator extends BlockRIRotatable
|
|||
if (tileEntity instanceof TileGenerator)
|
||||
{
|
||||
((TileGenerator) tileEntity).isInversed = !((TileGenerator) tileEntity).isInversed;
|
||||
entityPlayer.addChatMessage("Generator now producing " + (((TileGenerator) tileEntity).isInversed ? "electrical" : "mechanical") + " energy.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -19,7 +19,8 @@ item.resonantinduction\:imprint.name=Imprint
|
|||
tile.resonantinduction\:imprinter.name=Imprinter
|
||||
tile.resonantinduction\:engineeringTable.name=Engineering Table
|
||||
tile.resonantinduction\:firebox.name=Firebox
|
||||
tile.resonantinduction\:hotPlate.name=Hot Plate
|
||||
tile.resonantinduction\:hotPlate.0.name=Hot Plate
|
||||
tile.resonantinduction\:hotPlate.1.name=Electric Hot Plate
|
||||
|
||||
## Transport
|
||||
tile.resonantinduction\:turntable.name=Turntable
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.9 KiB |
Loading…
Reference in a new issue