Added metal caster
This commit is contained in:
parent
a1b0747ba6
commit
c1e6a6eb6e
11 changed files with 291 additions and 44 deletions
|
@ -4,9 +4,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import resonantinduction.archaic.blocks.BlockMillstone;
|
||||
import resonantinduction.archaic.blocks.BlockTurntable;
|
||||
import resonantinduction.archaic.blocks.TileMillstone;
|
||||
import resonantinduction.archaic.crate.BlockCrate;
|
||||
import resonantinduction.archaic.crate.ItemBlockCrate;
|
||||
import resonantinduction.archaic.crate.TileCrate;
|
||||
|
@ -20,6 +18,10 @@ import resonantinduction.archaic.firebox.TileHotPlate;
|
|||
import resonantinduction.archaic.imprint.BlockImprinter;
|
||||
import resonantinduction.archaic.imprint.ItemImprint;
|
||||
import resonantinduction.archaic.imprint.TileImprinter;
|
||||
import resonantinduction.archaic.process.BlockCast;
|
||||
import resonantinduction.archaic.process.BlockMillstone;
|
||||
import resonantinduction.archaic.process.TileCast;
|
||||
import resonantinduction.archaic.process.TileMillstone;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.Settings;
|
||||
|
@ -71,6 +73,7 @@ public class Archaic
|
|||
public static Block blockFirebox;
|
||||
public static Block blockHotPlate;
|
||||
public static Block blockMillstone;
|
||||
public static Block blockCast;
|
||||
public static Block blockMachinePart;
|
||||
|
||||
public static Item itemImprint;
|
||||
|
@ -90,6 +93,7 @@ public class Archaic
|
|||
blockFirebox = contentRegistry.createTile(BlockFirebox.class, TileFirebox.class);
|
||||
blockHotPlate = contentRegistry.createBlock(BlockHotPlate.class, ItemBlockMetadata.class, TileHotPlate.class);
|
||||
blockMillstone = contentRegistry.createTile(BlockMillstone.class, TileMillstone.class);
|
||||
blockCast = contentRegistry.createTile(BlockCast.class, TileCast.class);
|
||||
blockMachinePart = contentRegistry.createBlock(BlockMachineMaterial.class, ItemBlockMetadata.class);
|
||||
|
||||
itemImprint = contentRegistry.createItem(ItemImprint.class);
|
||||
|
@ -119,8 +123,8 @@ public class Archaic
|
|||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockImprinter, "SSS", "W W", "PPP", 'S', Block.stone, 'P', Block.pistonBase, 'W', "logWood"));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockTurntable, "SSS", "PGP", "WWW", 'S', Block.stone, 'G', "gear", 'P', Block.pistonBase, 'W', "logWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockTurntable, "SSS", "PGP", "WWW", 'S', Block.stone, 'G', Item.redstone, 'P', Block.pistonBase, 'W', "logWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockTurntable, "SSS", "PGP", "WWW", 'S', Block.stone, 'G', UniversalRecipe.MOTOR.get(), 'P', Block.pistonBase, 'W', "logWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockCast, "I I", "IBI", "III", 'S', Item.ingotIron, 'B', Block.fenceIron));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockHotPlate, "SSS", "III", 'I', Item.ingotIron, 'S', Block.stone));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockHotPlate, 1, 1), "HHH", "WWW", 'H', new ItemStack(blockHotPlate, 1, 0), 'W', UniversalRecipe.WIRE.get()));
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package resonantinduction.archaic.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import calclavia.lib.render.ColorCode;
|
||||
|
||||
public class ItemBlockColored extends ItemBlock
|
||||
{
|
||||
public ItemBlockColored(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack par1ItemStack)
|
||||
{
|
||||
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + ColorCode.get(par1ItemStack.getItemDamage()).name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return Block.blocksList[this.getBlockID()].getUnlocalizedName();
|
||||
}
|
||||
}
|
|
@ -76,14 +76,15 @@ public class TileFirebox extends TileExternalInventory implements IPacketSender,
|
|||
{
|
||||
usedHeat = true;
|
||||
|
||||
//if (heatEnergy >= requiredMeltIronEnergy)
|
||||
if (heatEnergy >= requiredMeltIronEnergy)
|
||||
{
|
||||
TileEntity dustTile = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
if (dustTile instanceof TileMaterial)
|
||||
{
|
||||
String name = ((TileMaterial) dustTile).name;
|
||||
worldObj.setBlock(xCoord, yCoord + 1, zCoord, ResonantInduction.blockFluidMaterial.get(ResourceGenerator.materialNames.indexOf(name)).blockID, 8, 3);
|
||||
// TODO: Make refined dust yield more molten fluid than normal dust.
|
||||
worldObj.setBlock(xCoord, yCoord + 1, zCoord, ResonantInduction.blockFluidMaterial.get(ResourceGenerator.materialNames.indexOf(name)).blockID, worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord), 3);
|
||||
TileEntity tile = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
if (tile instanceof TileMaterial)
|
||||
|
|
120
src/main/java/resonantinduction/archaic/process/BlockCast.java
Normal file
120
src/main/java/resonantinduction/archaic/process/BlockCast.java
Normal file
|
@ -0,0 +1,120 @@
|
|||
package resonantinduction.archaic.process;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.prefab.block.BlockRI;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCast extends BlockRI
|
||||
{
|
||||
Icon top;
|
||||
|
||||
public BlockCast()
|
||||
{
|
||||
super("cast", Material.wood);
|
||||
setTextureName(Reference.PREFIX + "material_metal_side");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IconRegister iconReg)
|
||||
{
|
||||
this.top = iconReg.registerIcon(Reference.PREFIX + "material_wood_top");
|
||||
super.registerIcons(iconReg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
return getIcon(side, 0);
|
||||
}
|
||||
|
||||
/** Returns the block texture based on the side being looked at. Args: side */
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon(int side, int meta)
|
||||
{
|
||||
if (side == 1)
|
||||
{
|
||||
return top;
|
||||
}
|
||||
|
||||
return blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile != null)
|
||||
tile.updateEntity();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (te instanceof TileCast)
|
||||
{
|
||||
TileCast tile = (TileCast) te;
|
||||
|
||||
ItemStack output = tile.getStackInSlot(0);
|
||||
|
||||
if (output != null)
|
||||
{
|
||||
InventoryUtility.dropItemStack(world, new Vector3(player), output, 0);
|
||||
tile.setInventorySlotContents(0, null);
|
||||
}
|
||||
|
||||
tile.onInventoryChanged();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (te instanceof TileCast)
|
||||
{
|
||||
TileCast tile = (TileCast) te;
|
||||
tile.updateEntity();
|
||||
|
||||
ItemStack current = player.inventory.getCurrentItem();
|
||||
|
||||
ItemStack output = tile.getStackInSlot(0);
|
||||
|
||||
if (output != null)
|
||||
{
|
||||
InventoryUtility.dropItemStack(world, new Vector3(player), output, 0);
|
||||
tile.setInventorySlotContents(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
{
|
||||
return new TileCast();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.archaic.blocks;
|
||||
package resonantinduction.archaic.process;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
|
@ -0,0 +1,23 @@
|
|||
package resonantinduction.archaic.process;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import resonantinduction.core.render.RenderItemOverlayTile;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderCast extends RenderItemOverlayTile
|
||||
{
|
||||
private final RenderBlocks renderBlocks = new RenderBlocks();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
{
|
||||
if (tileEntity instanceof TileCast)
|
||||
{
|
||||
TileCast tile = (TileCast) tileEntity;
|
||||
renderItemOnSides(tileEntity, tile.getStackInSlot(0), x, y, z, "Empty");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.archaic.blocks;
|
||||
package resonantinduction.archaic.process;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
132
src/main/java/resonantinduction/archaic/process/TileCast.java
Normal file
132
src/main/java/resonantinduction/archaic/process/TileCast.java
Normal file
|
@ -0,0 +1,132 @@
|
|||
package resonantinduction.archaic.process;
|
||||
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.resource.fluid.BlockFluidMaterial;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.prefab.tile.TileExternalInventory;
|
||||
|
||||
/**
|
||||
* Turns molten fuilds into ingots.
|
||||
*
|
||||
* 1 m^3 of molten fluid = 1 block
|
||||
* Approximately 110 L of fluid = 1 ingot.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileCast extends TileExternalInventory implements IFluidHandler
|
||||
{
|
||||
protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
private final int amountPerIngot = 110;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
/**
|
||||
* Check blocks above for fluid.
|
||||
*/
|
||||
Vector3 checkPos = new Vector3(this).translate(0, 1, 0);
|
||||
int blockID = checkPos.getBlockID(worldObj);
|
||||
Block block = Block.blocksList[blockID];
|
||||
|
||||
if (block instanceof BlockFluidMaterial)
|
||||
{
|
||||
// TODO: Fix overfill.
|
||||
tank.fill(((BlockFluidMaterial) block).drain(worldObj, checkPos.intX(), checkPos.intY(), checkPos.intZ(), true), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to cast the fluid
|
||||
*/
|
||||
if (tank.getFluidAmount() > amountPerIngot)
|
||||
{
|
||||
String fluidName = tank.getFluid().getFluid().getName();
|
||||
String materialName = fluidName.replace("molten", "");
|
||||
String nameCaps = materialName.substring(0, 1).toUpperCase() + materialName.substring(1);
|
||||
String ingotName = "ingot" + nameCaps;
|
||||
|
||||
if (OreDictionary.getOres(ingotName).size() > 0)
|
||||
{
|
||||
ItemStack stack = OreDictionary.getOres(ingotName).get(0);
|
||||
incrStackSize(0, stack);
|
||||
tank.drain(amountPerIngot, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
tank.writeToNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeToNBT(tag);
|
||||
tank.readFromNBT(tag);
|
||||
}
|
||||
|
||||
/* IFluidHandler */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
int fill = tank.fill(resource, doFill);
|
||||
updateEntity();
|
||||
return fill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return fluid != null && fluid.getName().contains("molten");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] { tank.getInfo() };
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package resonantinduction.archaic.blocks;
|
||||
package resonantinduction.archaic.process;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
|
@ -32,7 +32,6 @@ public class BlockFluidMaterial extends BlockFluidFinite
|
|||
super(Settings.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, fluid.getName(), Settings.getNextBlockID()).getInt(), fluid, Material.lava);
|
||||
setTextureName(Reference.PREFIX + "molten_flow");
|
||||
setUnlocalizedName(Reference.PREFIX + "fluidMaterial");
|
||||
setQuantaPerBlock(16);
|
||||
}
|
||||
|
||||
public void setQuanta(World world, int x, int y, int z, int quanta)
|
||||
|
|
|
@ -37,6 +37,8 @@ item.resonantinduction\:imprint.name=Imprint
|
|||
item.resonantinduction\:hammer.name=Hammer
|
||||
|
||||
## Machines
|
||||
tile.resonantinduction\:cast.name=Metal Caster
|
||||
tile.resonantinduction\:cast.tooltip=Pour molten metal into the cast to form an ingot.
|
||||
tile.resonantinduction\:millstone.name=Millstone
|
||||
tile.resonantinduction\:millstone.tooltip=Put some rubble in the millstone and start wrenching to grind rubble into dust.
|
||||
tile.resonantinduction\:imprinter.name=Imprinter
|
||||
|
|
Loading…
Add table
Reference in a new issue