Added ability to use normal dust as a dust block for smelting

This commit is contained in:
Calclavia 2014-03-25 21:03:45 +08:00
parent e58c5209d4
commit bdf8b146ec
9 changed files with 138 additions and 132 deletions

View file

@ -1,5 +1,11 @@
package resonantinduction.archaic.firebox;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.Synced;
import calclavia.lib.prefab.tile.TileElectricalInventory;
import calclavia.lib.thermal.BoilEvent;
import calclavia.lib.thermal.ThermalPhysics;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -9,13 +15,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.*;
import resonantinduction.archaic.Archaic;
import resonantinduction.archaic.fluid.gutter.TileGutter;
import resonantinduction.core.ResonantInduction;
@ -23,19 +23,11 @@ import resonantinduction.core.resource.ResourceGenerator;
import resonantinduction.core.resource.TileMaterial;
import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.Synced;
import calclavia.lib.prefab.tile.TileElectricalInventory;
import calclavia.lib.thermal.BoilEvent;
import calclavia.lib.thermal.ThermalPhysics;
import com.google.common.io.ByteArrayDataInput;
/**
* Meant to replace the furnace class.
*
*
* @author Calclavia
*
*/
public class TileFirebox extends TileElectricalInventory implements IPacketReceiver, IFluidHandler
{
@ -47,12 +39,10 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei
* into fluids to increase their internal energy.
*/
private final long POWER = 100000;
protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
@Synced
private int burnTime;
private long heatEnergy = 0;
private int boiledVolume;
public TileFirebox()
@ -116,7 +106,7 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei
heatEnergy += POWER / 20;
boolean usedHeat = false;
if (blockID == ResonantInduction.blockDust.blockID)
if (blockID == ResonantInduction.blockDust.blockID || blockID == ResonantInduction.blockRefinedDust.blockID)
{
usedHeat = true;
@ -127,10 +117,11 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei
String name = ((TileMaterial) dustTile).name;
int meta = worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord);
if (heatEnergy >= getMeltIronEnergy(((meta + 1) / 5f) * 1000))
if (heatEnergy >= getMeltIronEnergy(((meta + 1) / 7f) * 1000))
{
// TODO: Make refined dust yield more molten fluid than normal dust.
worldObj.setBlock(xCoord, yCoord + 1, zCoord, ResourceGenerator.getMolten(name).blockID, meta, 3);
int volumeMeta = blockID == ResonantInduction.blockRefinedDust.blockID ? meta : meta / 2;
worldObj.setBlock(xCoord, yCoord + 1, zCoord, ResourceGenerator.getMolten(name).blockID, volumeMeta, 3);
TileEntity tile = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
@ -206,9 +197,8 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei
/**
* Approximately 327600 + 2257000 = 2584600.
*
*
* @param volume
*
* @return
*/
public long getRequiredBoilWaterEnergy(int volume)
@ -278,8 +268,6 @@ public class TileFirebox extends TileElectricalInventory implements IPacketRecei
tank.writeToNBT(nbt);
}
protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
/* IFluidHandler */
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)

View file

@ -44,7 +44,7 @@ public class TileSorter extends TileInventory
maxSlots = 12;
normalRender = false;
isOpaqueCube = false;
bounds = Cuboid.full().expand(-0.1);
bounds = Cuboid.full().expand(-0.01);
}
@Override

View file

@ -1,25 +1,5 @@
package resonantinduction.core;
import java.util.HashMap;
import java.util.logging.Logger;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.BlockFluidFinite;
import org.modstats.ModstatInfo;
import org.modstats.Modstats;
import resonantinduction.core.handler.TextureHookHandler;
import resonantinduction.core.prefab.part.PacketMultiPart;
import resonantinduction.core.resource.BlockDust;
import resonantinduction.core.resource.BlockMachineMaterial;
import resonantinduction.core.resource.ItemOreResource;
import resonantinduction.core.resource.ResourceGenerator;
import resonantinduction.core.resource.TileMaterial;
import resonantinduction.core.resource.fluid.ItemOreResourceBucket;
import resonantinduction.core.resource.fluid.TileFluidMixture;
import calclavia.lib.config.ConfigHandler;
import calclavia.lib.content.ContentRegistry;
import calclavia.lib.network.PacketAnnotation;
@ -39,10 +19,24 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.BlockFluidFinite;
import org.modstats.ModstatInfo;
import org.modstats.Modstats;
import resonantinduction.core.handler.TextureHookHandler;
import resonantinduction.core.prefab.part.PacketMultiPart;
import resonantinduction.core.resource.*;
import resonantinduction.core.resource.fluid.ItemOreResourceBucket;
import resonantinduction.core.resource.fluid.TileFluidMixture;
import java.util.HashMap;
import java.util.logging.Logger;
/**
* The core module of Resonant Induction
*
*
* @author Calclavia
*/
@Mod(modid = ResonantInduction.ID, name = ResonantInduction.NAME, version = Reference.VERSION, dependencies = "required-after:ForgeMultipart@[1.0.0.244,);required-after:CalclaviaCore;before:ThermalExpansion;before:Mekanism")
@ -50,45 +44,36 @@ import cpw.mods.fml.common.registry.GameRegistry;
@ModstatInfo(prefix = "resonantin")
public class ResonantInduction
{
/** Mod Information */
/**
* Mod Information
*/
public static final String ID = "ResonantInduction|Core";
public static final String NAME = Reference.NAME;
@Instance(ID)
public static ResonantInduction INSTANCE;
@SidedProxy(clientSide = "resonantinduction.core.ClientProxy", serverSide = "resonantinduction.core.CommonProxy")
public static CommonProxy proxy;
@Mod.Metadata(ID)
public static ModMetadata metadata;
public static final Logger LOGGER = Logger.getLogger(Reference.NAME);
/** Packets */
/**
* Packets
*/
public static final PacketTile PACKET_TILE = new PacketTile(Reference.CHANNEL);
public static final PacketMultiPart PACKET_MULTIPART = new PacketMultiPart(Reference.CHANNEL);
public static final PacketAnnotation PACKET_ANNOTATION = new PacketAnnotation(Reference.CHANNEL);
/** Blocks and Items */
public static final HashMap<Integer, BlockFluidFinite> blockMixtureFluids = new HashMap<Integer, BlockFluidFinite>();
public static final HashMap<Integer, BlockFluidFinite> blockMoltenFluid = new HashMap<Integer, BlockFluidFinite>();
public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, Settings.idManager, ID).setPrefix(Reference.PREFIX).setTab(TabRI.CORE);
@Instance(ID)
public static ResonantInduction INSTANCE;
@SidedProxy(clientSide = "resonantinduction.core.ClientProxy", serverSide = "resonantinduction.core.CommonProxy")
public static CommonProxy proxy;
@Mod.Metadata(ID)
public static ModMetadata metadata;
/**
* Blocks and Items
*/
public static Block blockOre;
public static ItemOreResource itemRubble, itemDust, itemRefinedDust;
public static ItemOreResourceBucket itemBucketMixture, itemBucketMolten;
public static Block blockDust;
public static final HashMap<Integer, BlockFluidFinite> blockMixtureFluids = new HashMap<Integer, BlockFluidFinite>();
public static final HashMap<Integer, BlockFluidFinite> blockMoltenFluid = new HashMap<Integer, BlockFluidFinite>();
public static Block blockDust, blockRefinedDust;
public static Block blockMachinePart;
public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, Settings.idManager, ID).setPrefix(Reference.PREFIX).setTab(TabRI.CORE);
/**
* Recipe Types
*/
public static enum RecipeType
{
CRUSHER, GRINDER, MIXER, SMELTER, SAWMILL;
}
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
@ -105,7 +90,8 @@ public class ResonantInduction
/**
* Melting dusts
*/
blockDust = contentRegistry.createTile(BlockDust.class, TileMaterial.class).setCreativeTab(null);
blockDust = contentRegistry.createBlock("dust", BlockDust.class, null, TileDust.class).setCreativeTab(null);
blockRefinedDust = contentRegistry.createBlock("refinedDust", BlockDust.class, null, TileDust.class).setCreativeTab(null);
// Items
itemRubble = new ItemOreResource(Settings.getNextItemID("oreRubble"), "oreRubble");
@ -155,4 +141,12 @@ public class ResonantInduction
ResourceGenerator.generateOreResources();
proxy.postInit();
}
/**
* Recipe Types
*/
public static enum RecipeType
{
CRUSHER, GRINDER, MIXER, SMELTER, SAWMILL;
}
}

View file

@ -33,6 +33,7 @@ public class NEIResonantInductionConfig implements IConfigureNEI
API.hideItem(block.blockID);
API.hideItem(ResonantInduction.blockDust.blockID);
API.hideItem(ResonantInduction.blockRefinedDust.blockID);
}
@Override

View file

@ -1,7 +1,8 @@
package resonantinduction.core.resource;
import java.util.Random;
import calclavia.lib.prefab.block.BlockTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
@ -12,18 +13,18 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import calclavia.lib.prefab.block.BlockTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
/**
* The block form of the item dust.
*
*
* @author Calclavia
*
*/
public class BlockDust extends BlockTile
{
int nextDropMaterialID = 0;
public BlockDust(int id)
{
super(id, Material.sand);
@ -34,6 +35,25 @@ public class BlockDust extends BlockTile
setStepSound(soundGravelFootstep);
}
public static boolean canFallBelow(World par0World, int par1, int par2, int par3)
{
int l = par0World.getBlockId(par1, par2, par3);
if (par0World.isAirBlock(par1, par2, par3))
{
return true;
}
else if (l == Block.fire.blockID)
{
return true;
}
else
{
Material material = Block.blocksList[l].blockMaterial;
return material == Material.water ? true : material == Material.lava;
}
}
@SideOnly(Side.CLIENT)
@Override
public int colorMultiplier(IBlockAccess access, int x, int y, int z)
@ -91,8 +111,6 @@ public class BlockDust extends BlockTile
if (canFallBelow(world, x, y - 1, z) && y >= 0)
{
byte b0 = 32;
world.setBlockToAir(x, y, z);
while (canFallBelow(world, x, y - 1, z) && y > 0)
@ -117,29 +135,10 @@ public class BlockDust extends BlockTile
}
public static boolean canFallBelow(World par0World, int par1, int par2, int par3)
{
int l = par0World.getBlockId(par1, par2, par3);
if (par0World.isAirBlock(par1, par2, par3))
{
return true;
}
else if (l == Block.fire.blockID)
{
return true;
}
else
{
Material material = Block.blocksList[l].blockMaterial;
return material == Material.water ? true : material == Material.lava;
}
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileMaterial();
return new TileDust();
}
/**
@ -212,17 +211,15 @@ public class BlockDust extends BlockTile
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return ResonantInduction.itemRefinedDust.itemID;
return this == ResonantInduction.blockRefinedDust ? ResonantInduction.itemRefinedDust.itemID : ResonantInduction.itemDust.itemID;
}
@Override
public int idPicked(World par1World, int par2, int par3, int par4)
{
return ResonantInduction.itemRefinedDust.itemID;
return this == ResonantInduction.blockRefinedDust ? ResonantInduction.itemRefinedDust.itemID : ResonantInduction.itemDust.itemID;
}
int nextDropMaterialID = 0;
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{

View file

@ -1,7 +1,8 @@
package resonantinduction.core.resource;
import java.util.List;
import calclavia.lib.utility.LanguageUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@ -13,19 +14,18 @@ import net.minecraftforge.oredict.OreDictionary;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.TabRI;
import calclavia.lib.utility.LanguageUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
/**
* An item used for auto-generated dusts based on registered ingots in the OreDict.
*
*
* @author Calclavia
*
*/
public class ItemOreResource extends Item
{
private int blockID = ResonantInduction.blockDust.blockID;;
private int blockID = ResonantInduction.blockRefinedDust.blockID;
;
public ItemOreResource(int id, String name)
{
@ -37,6 +37,11 @@ public class ItemOreResource extends Item
setMaxDamage(0);
}
public static String getMaterialFromStack(ItemStack itemStack)
{
return ResourceGenerator.getName(itemStack.getItemDamage());
}
@Override
public String getItemDisplayName(ItemStack is)
{
@ -64,8 +69,10 @@ public class ItemOreResource extends Item
/**
* Allow refined dust to be placed down.
*/
if (itemStack.getItem() == ResonantInduction.itemRefinedDust)
if (itemStack.getItem() == ResonantInduction.itemDust || itemStack.getItem() == ResonantInduction.itemRefinedDust)
{
blockID = itemStack.getItem() == ResonantInduction.itemRefinedDust ? ResonantInduction.blockRefinedDust.blockID : ResonantInduction.blockDust.blockID;
if (itemStack.stackSize == 0)
{
return false;
@ -147,6 +154,8 @@ public class ItemOreResource extends Item
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
blockID = stack.getItem() == ResonantInduction.itemRefinedDust ? ResonantInduction.blockRefinedDust.blockID : ResonantInduction.blockDust.blockID;
if (!world.setBlock(x, y, z, this.blockID, metadata, 3))
{
return false;
@ -168,11 +177,6 @@ public class ItemOreResource extends Item
return itemStack;
}
public static String getMaterialFromStack(ItemStack itemStack)
{
return ResourceGenerator.getName(itemStack.getItemDamage());
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{

View file

@ -0,0 +1,10 @@
package resonantinduction.core.resource
import net.minecraft.block.material.Material
/**
* Created by Henry on 3/25/2014.
*/
class TileDust extends TileMaterial(Material.sand)
{
}

View file

@ -1,24 +1,33 @@
package resonantinduction.core.resource;
import calclavia.lib.content.module.TileBase;
import calclavia.lib.network.IPacketReceiver;
import com.google.common.io.ByteArrayDataInput;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import resonantinduction.core.ResonantInduction;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.prefab.tile.TileAdvanced;
import com.google.common.io.ByteArrayDataInput;
/**
* A tile that stores the material name.
*
*
* @author Calclavia
*
*/
public class TileMaterial extends TileAdvanced implements IPacketReceiver
public abstract class TileMaterial extends TileBase implements IPacketReceiver
{
public String name;
public TileMaterial()
{
super(null);
}
public TileMaterial(Material material)
{
super(material);
}
public int getColor()
{
return ResourceGenerator.getColor(name);
@ -60,6 +69,8 @@ public class TileMaterial extends TileAdvanced implements IPacketReceiver
{
super.writeToNBT(nbt);
if (name != null)
{
nbt.setString("name", name);
}
}
}

View file

@ -18,6 +18,7 @@ import calclavia.api.recipe.MachineRecipes;
* @author Calclavia
*
*/
@Deprecated
public class TileFluidMixture extends TileMaterial
{
public final Set<ItemStack> items = new HashSet<ItemStack>();