Started some rework on the mixer

This commit is contained in:
Calclavia 2014-02-01 12:07:22 +08:00
parent 5dbc7e1cb5
commit 19b7c37a84
7 changed files with 37 additions and 38 deletions

View file

@ -108,7 +108,7 @@ public class TileFirebox extends TileElectricalInventory implements IPacketSende
{
String name = ((TileMaterial) dustTile).name;
// 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);
worldObj.setBlock(xCoord, yCoord + 1, zCoord, ResonantInduction.blockFluidMaterials.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)

View file

@ -81,12 +81,12 @@ public class ResonantInduction
public static ItemOreResource itemDust;
public static ItemOreResource itemRefinedDust;
public static Block blockDust;
public static Block blockFluidMixture;
public static List<Block> blockFluidMaterial = new ArrayList<Block>();
public static List<Block> blockFluidMixtures = new ArrayList<Block>();
public static List<Block> blockFluidMaterials = new ArrayList<Block>();
public static Block blockGas;
public static Fluid fluidMixture;
public static List<Fluid> fluidMaterial = new ArrayList<Fluid>();
public static List<Fluid> fluidMixtures = new ArrayList<Fluid>();
public static List<Fluid> fluidMaterials = new ArrayList<Fluid>();
public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, ID);
@ -105,10 +105,6 @@ public class ResonantInduction
MinecraftForge.EVENT_BUS.register(ResourceGenerator.INSTANCE);
MinecraftForge.EVENT_BUS.register(new FluidEventHandler());
fluidMixture = new Fluid("water");
FluidRegistry.registerFluid(fluidMixture);
blockFluidMixture = contentRegistry.createTile(BlockFluidMixture.class, TileFluidMixture.class);
/**
* Melting dusts
*/
@ -166,7 +162,7 @@ public class ResonantInduction
@SideOnly(Side.CLIENT)
public void postTextureHook(TextureStitchEvent.Post event)
{
for (Fluid fluid : fluidMaterial)
for (Fluid fluid : fluidMaterials)
fluid.setIcons(loadedIconMap.get(Reference.PREFIX + "molten_flow"));
}
}

View file

@ -5,6 +5,7 @@ import java.util.HashMap;
import net.minecraft.util.Icon;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.fluids.Fluid;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import cpw.mods.fml.relauncher.Side;
@ -29,7 +30,8 @@ public class FluidEventHandler
{
if (event.map.textureType == 0)
{
registerIcon(Reference.PREFIX + "mixture", event);
registerIcon(Reference.PREFIX + "mixture_flow", event);
registerIcon(Reference.PREFIX + "molten_flow", event);
}
}
@ -37,6 +39,9 @@ public class FluidEventHandler
@SideOnly(Side.CLIENT)
public void textureHook(TextureStitchEvent.Post event)
{
ResonantInduction.fluidMixture.setIcons(fluidIconMap.get(Reference.PREFIX + "mixture"));
for (Fluid f : ResonantInduction.fluidMixtures)
f.setIcons(fluidIconMap.get(Reference.PREFIX + "mixture_flow"));
for (Fluid f : ResonantInduction.fluidMaterials)
f.setIcons(fluidIconMap.get(Reference.PREFIX + "molten_flow"));
}
}

View file

@ -30,6 +30,7 @@ import resonantinduction.api.recipe.OreDetectionBlackList;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.resource.fluid.BlockFluidMaterial;
import resonantinduction.core.resource.fluid.BlockFluidMixture;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -90,7 +91,16 @@ public class ResourceGenerator
FluidRegistry.registerFluid(fluidMaterial);
Block blockFluidMaterial = new BlockFluidMaterial(fluidMaterial);
GameRegistry.registerBlock(blockFluidMaterial, "molten" + nameCaps);
ResonantInduction.blockFluidMaterial.add(blockFluidMaterial);
ResonantInduction.blockFluidMaterials.add(blockFluidMaterial);
/**
* Generate dust mixture fluids
*/
Fluid fluidMixture = new Fluid("mixture" + nameCaps);
FluidRegistry.registerFluid(fluidMixture);
Block blockFluidMixture = new BlockFluidMixture(fluidMixture);
GameRegistry.registerBlock(blockFluidMixture, "mixture" + nameCaps);
ResonantInduction.blockFluidMaterials.add(blockFluidMixture);
if (OreDictionary.getOres("ore" + nameCaps).size() > 0)
{

View file

@ -24,9 +24,9 @@ import cpw.mods.fml.relauncher.SideOnly;
*/
public class BlockFluidMixture extends BlockFluidFinite implements ITileEntityProvider
{
public BlockFluidMixture()
public BlockFluidMixture(Fluid fluid)
{
super(Settings.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, "fluidMixture", Settings.getNextBlockID()).getInt(), ResonantInduction.fluidMixture, Material.water);
super(Settings.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, "fluidMixture", Settings.getNextBlockID()).getInt(), fluid, Material.water);
setTextureName(Reference.PREFIX + "mixture_flow");
this.setUnlocalizedName(Reference.PREFIX + "fluidMixture");
}
@ -43,9 +43,9 @@ public class BlockFluidMixture extends BlockFluidFinite implements ITileEntityPr
@Override
public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
{
TileFluidMixture tileFluid = (TileFluidMixture) world.getBlockTileEntity(x, y, z);
FluidStack stack = new FluidStack(ResonantInduction.fluidMixture, (int) (FluidContainerRegistry.BUCKET_VOLUME * this.getFilledPercentage(world, x, y, z)));
tileFluid.writeFluidToNBT(stack.tag != null ? stack.tag : new NBTTagCompound());
FluidStack stack = new FluidStack(getFluid(), (int) (FluidContainerRegistry.BUCKET_VOLUME * this.getFilledPercentage(world, x, y, z)));
if (doDrain)
world.setBlockToAir(x, y, z);
return stack;
}

View file

@ -62,13 +62,13 @@ public class BlockFilter extends BlockRI implements ITileEntityProvider
/**
* Leak the fluid down.
*/
BlockFluidMixture fluidBlock = (BlockFluidMixture) ResonantInduction.blockFluidMixture;
BlockFluidMixture fluidBlock = (BlockFluidMixture) ResonantInduction.blockFluidMixtures;
int amount = fluidBlock.getQuantaValue(world, x, y, z);
/**
* All fluid is filtered out, spawn all the items.
*/
if (amount <= 1)
if (amount <= 1)
{
System.out.println("filter dropped");
for (ItemStack itemStack : ((TileFluidMixture) tileAbove).items)
@ -98,7 +98,7 @@ public class BlockFilter extends BlockRI implements ITileEntityProvider
/**
* Add liquid to bottom.
*/
if (checkBelow.getBlockID(world) == ResonantInduction.blockFluidMixture.blockID)
if (Block.blocksList[checkBelow.getBlockID(world)] instanceof BlockFluidMixture)
{
fluidBlock.setQuanta(world, checkBelow.intX(), checkBelow.intY(), checkBelow.intZ(), fluidBlock.getQuantaValue(world, checkBelow.intX(), checkBelow.intY(), checkBelow.intZ()) + 1);
}

View file

@ -54,22 +54,6 @@ public class TileMixer extends TileMechanical
{
boolean didWork = false;
/**
* Transform all water blocks into mixture blocks
*/
for (int x = -1; x < 1; x++)
{
for (int z = -1; z < 1; z++)
{
Vector3 checkVector = new Vector3(this).translate(x, 0, z);
if (checkVector.getBlockID(worldObj) == Block.waterStill.blockID || checkVector.getBlockID(worldObj) == Block.waterMoving.blockID)
{
checkVector.setBlock(worldObj, ResonantInduction.blockFluidMixture.blockID, 8, 3);
}
}
}
// Search for an item to "process"
AxisAlignedBB aabb = AxisAlignedBB.getAABBPool().getAABB(this.xCoord - 1, this.yCoord, this.zCoord - 1, this.xCoord + 2, this.yCoord + 1, this.zCoord + 2);
List<Entity> entities = this.worldObj.getEntitiesWithinAABB(Entity.class, aabb);
@ -159,13 +143,17 @@ public class TileMixer extends TileMechanical
if (tileEntity instanceof TileFluidMixture)
{
ItemStack itemStack = entity.getEntityItem().copy();
if (((TileFluidMixture) tileEntity).mix(itemStack))
{
System.out.println("MIXED");
worldObj.notifyBlocksOfNeighborChange(mixPosition.intX(), mixPosition.intY(), mixPosition.intZ(), mixPosition.getBlockID(worldObj));
return true;
}
}
else
{
mixPosition.setBlock(worldObj, ResonantInduction.blockFluidMixtures.get(entity.getEntityItem().getItemDamage()).blockID);
}
return false;
}