Mixer now works
This commit is contained in:
parent
fb1d6d54b0
commit
961d6630cd
5 changed files with 87 additions and 81 deletions
|
@ -11,8 +11,10 @@ import java.util.Set;
|
|||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.Language;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
|
@ -79,7 +81,7 @@ public class ResourceGenerator
|
|||
for (String materialName : materialNames)
|
||||
{
|
||||
// Caps version of the name
|
||||
String nameCaps = materialName.substring(0, 1).toUpperCase() + materialName.substring(1);
|
||||
String nameCaps = LanguageUtility.capitalizeFirst(materialName);
|
||||
|
||||
/**
|
||||
* Generate molten fluids
|
||||
|
@ -102,21 +104,24 @@ public class ResourceGenerator
|
|||
GameRegistry.registerBlock(blockFluidMixture, "mixture" + nameCaps);
|
||||
ResonantInduction.blockFluidMixtures.add(blockFluidMixture);
|
||||
|
||||
OreDictionary.registerOre("dust" + nameCaps, ResonantInduction.itemDust.getStackFromMaterial(materialName));
|
||||
OreDictionary.registerOre("rubble" + nameCaps, ResonantInduction.itemRubble.getStackFromMaterial(materialName));
|
||||
OreDictionary.registerOre("dustRefined" + nameCaps, ResonantInduction.itemRefinedDust.getStackFromMaterial(materialName));
|
||||
if (OreDictionary.getOres("ore" + nameCaps).size() > 0)
|
||||
{
|
||||
OreDictionary.registerOre("dust" + nameCaps, ResonantInduction.itemDust.getStackFromMaterial(materialName));
|
||||
OreDictionary.registerOre("rubble" + nameCaps, ResonantInduction.itemRubble.getStackFromMaterial(materialName));
|
||||
OreDictionary.registerOre("dustRefined" + nameCaps, ResonantInduction.itemRefinedDust.getStackFromMaterial(materialName));
|
||||
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.CRUSHER, "ore" + nameCaps, "rubble" + nameCaps);
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER, "rubble" + nameCaps, "dust" + nameCaps, "dust" + nameCaps);
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.MIXER, "dust" + nameCaps, "dustRefined" + nameCaps);
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.SMELTER, "dustRefined" + nameCaps, "ingot" + nameCaps);
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.CRUSHER, "ore" + nameCaps, "rubble" + nameCaps);
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER, "rubble" + nameCaps, "dust" + nameCaps, "dust" + nameCaps);
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.MIXER, "dust" + nameCaps, "dustRefined" + nameCaps);
|
||||
MachineRecipes.INSTANCE.addRecipe(RecipeType.SMELTER, "dustRefined" + nameCaps, "ingot" + nameCaps);
|
||||
|
||||
ItemStack dust = ResonantInduction.itemDust.getStackFromMaterial(materialName);
|
||||
FurnaceRecipes.smelting().addSmelting(dust.itemID, dust.getItemDamage(), OreDictionary.getOres("ingot" + nameCaps).get(0).copy(), 0.7f);
|
||||
ItemStack refinedDust = ResonantInduction.itemRefinedDust.getStackFromMaterial(materialName);
|
||||
ItemStack smeltResult = OreDictionary.getOres("ingot" + nameCaps).get(0).copy();
|
||||
smeltResult.stackSize = 2;
|
||||
FurnaceRecipes.smelting().addSmelting(refinedDust.itemID, refinedDust.getItemDamage(), smeltResult, 0.7f);
|
||||
ItemStack dust = ResonantInduction.itemDust.getStackFromMaterial(materialName);
|
||||
FurnaceRecipes.smelting().addSmelting(dust.itemID, dust.getItemDamage(), OreDictionary.getOres("ingot" + nameCaps).get(0).copy(), 0.7f);
|
||||
ItemStack refinedDust = ResonantInduction.itemRefinedDust.getStackFromMaterial(materialName);
|
||||
ItemStack smeltResult = OreDictionary.getOres("ingot" + nameCaps).get(0).copy();
|
||||
smeltResult.stackSize = 2;
|
||||
FurnaceRecipes.smelting().addSmelting(refinedDust.itemID, refinedDust.getItemDamage(), smeltResult, 0.7f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package resonantinduction.core.resource.fluid;
|
|||
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -10,8 +11,11 @@ import net.minecraftforge.fluids.BlockFluidFinite;
|
|||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import resonantinduction.api.recipe.MachineRecipes;
|
||||
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.Settings;
|
||||
import resonantinduction.core.resource.ResourceGenerator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -19,7 +23,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockFluidMixture extends BlockFluidFinite implements ITileEntityProvider
|
||||
public class BlockFluidMixture extends BlockFluidFinite
|
||||
{
|
||||
public BlockFluidMixture(Fluid fluid)
|
||||
{
|
||||
|
@ -50,8 +54,23 @@ public class BlockFluidMixture extends BlockFluidFinite implements ITileEntityPr
|
|||
@Override
|
||||
public int colorMultiplier(IBlockAccess access, int x, int y, int z)
|
||||
{
|
||||
TileFluidMixture tileFluid = (TileFluidMixture) access.getBlockTileEntity(x, y, z);
|
||||
return tileFluid.getColor();
|
||||
return ResourceGenerator.getColor(getFluid().getName().replace("mixture", ""));
|
||||
/*
|
||||
* TileFluidMixture tileFluid = (TileFluidMixture) access.getBlockTileEntity(x, y, z);
|
||||
* return tileFluid.getColor();
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean mix(World world, int x, int y, int z, ItemStack stack)
|
||||
{
|
||||
if (MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, stack).length > 0 && getQuantaValue(world, x, y, z) < quantaPerBlock)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, getQuantaValue(world, x, y, z) + 1, 3);
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,10 +78,4 @@ public class BlockFluidMixture extends BlockFluidFinite implements ITileEntityPr
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileFluidMixture();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* NO-OP. Not yet properly implemented. We're not using TEs for now.
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
|
@ -38,7 +39,7 @@ public class TileFluidMixture extends TileMaterial
|
|||
|
||||
public boolean mix(ItemStack itemStack)
|
||||
{
|
||||
if (MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, itemStack).length > 0)
|
||||
if (MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, itemStack).length > 0 && getBlockMetadata() < 8)
|
||||
{
|
||||
// TODO: Maybe we need to merge the stacks?
|
||||
items.add(itemStack);
|
||||
|
@ -48,6 +49,7 @@ public class TileFluidMixture extends TileMaterial
|
|||
name = ResourceGenerator.getName(itemStack.getItemDamage());
|
||||
}
|
||||
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, getBlockMetadata() + 1, 3);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import resonantinduction.core.prefab.block.BlockRI;
|
|||
import resonantinduction.core.resource.fluid.BlockFluidMixture;
|
||||
import resonantinduction.core.resource.fluid.TileFluidMixture;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.utility.LanguageUtility;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
|
||||
/**
|
||||
|
@ -50,63 +51,46 @@ public class BlockFilter extends BlockRI implements ITileEntityProvider
|
|||
Vector3 checkAbove = position.clone().translate(ForgeDirection.UP);
|
||||
Vector3 checkBelow = position.clone().translate(ForgeDirection.DOWN);
|
||||
|
||||
TileEntity tileAbove = checkAbove.getTileEntity(world);
|
||||
TileEntity tileBelow = checkBelow.getTileEntity(world);
|
||||
Block bAbove = Block.blocksList[checkAbove.getBlockID(world)];
|
||||
Block bBelow = Block.blocksList[checkAbove.getBlockID(world)];
|
||||
|
||||
if (tileAbove instanceof TileFluidMixture && (tileBelow == null || tileBelow instanceof TileFluidMixture))
|
||||
if (bAbove instanceof BlockFluidMixture && world.isAirBlock(checkBelow.intX(), checkBelow.intY(), checkBelow.intZ()))
|
||||
{
|
||||
world.spawnParticle("dripWater", x + 0.5, y, z + 0.5, 0, 0, 0);
|
||||
|
||||
if (((TileFluidMixture) tileAbove).items.size() > 0)
|
||||
/**
|
||||
* Leak the fluid down.
|
||||
*/
|
||||
BlockFluidMixture fluidBlock = (BlockFluidMixture) bAbove;
|
||||
int amount = fluidBlock.getQuantaValue(world, checkAbove.intX(), checkAbove.intY(), checkAbove.intZ());
|
||||
|
||||
/**
|
||||
* Drop item from fluid.
|
||||
*/
|
||||
for (Resource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, "dust" + LanguageUtility.capitalizeFirst(fluidBlock.getFluid().getName().replace("mixture", ""))))
|
||||
{
|
||||
/**
|
||||
* Leak the fluid down.
|
||||
*/
|
||||
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)
|
||||
{
|
||||
System.out.println("filter dropped");
|
||||
for (ItemStack itemStack : ((TileFluidMixture) tileAbove).items)
|
||||
{
|
||||
for (Resource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, itemStack))
|
||||
{
|
||||
InventoryUtility.dropItemStack(world, checkAbove.clone().add(0.5), resoure.getItemStack().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int remaining = amount - 1;
|
||||
|
||||
/**
|
||||
* Remove liquid from top.
|
||||
*/
|
||||
if (remaining > 0)
|
||||
{
|
||||
fluidBlock.setQuanta(world, checkAbove.intX(), checkAbove.intY(), checkAbove.intZ(), remaining);
|
||||
world.scheduleBlockUpdate(x, y, z, blockID, 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkAbove.setBlock(world, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add liquid to bottom.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkBelow.setBlock(world, Block.waterStill.blockID, 3);
|
||||
}
|
||||
InventoryUtility.dropItemStack(world, checkAbove.clone().add(0.5), resoure.getItemStack().copy());
|
||||
}
|
||||
|
||||
int remaining = amount - 1;
|
||||
|
||||
/**
|
||||
* Remove liquid from top.
|
||||
*/
|
||||
if (remaining > 0)
|
||||
{
|
||||
fluidBlock.setQuanta(world, checkAbove.intX(), checkAbove.intY(), checkAbove.intZ(), remaining);
|
||||
world.scheduleBlockUpdate(x, y, z, blockID, 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkAbove.setBlock(world, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add liquid to bottom.
|
||||
*/
|
||||
checkBelow.setBlock(world, Block.waterStill.blockID, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.LinkedHashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -14,6 +15,7 @@ import resonantinduction.api.recipe.MachineRecipes;
|
|||
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.resource.fluid.BlockFluidMixture;
|
||||
import resonantinduction.core.resource.fluid.TileFluidMixture;
|
||||
import resonantinduction.mechanical.network.TileMechanical;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
|
@ -52,7 +54,7 @@ public class TileMixer extends TileMechanical
|
|||
public void doWork()
|
||||
{
|
||||
boolean didWork = false;
|
||||
|
||||
|
||||
// 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);
|
||||
|
@ -137,21 +139,21 @@ public class TileMixer extends TileMechanical
|
|||
private boolean doneWork(EntityItem entity)
|
||||
{
|
||||
Vector3 mixPosition = new Vector3(entity.posX, yCoord, entity.posZ);
|
||||
TileEntity tileEntity = mixPosition.getTileEntity(worldObj);
|
||||
Block block = Block.blocksList[mixPosition.getBlockID(worldObj)];
|
||||
|
||||
if (tileEntity instanceof TileFluidMixture)
|
||||
if (block instanceof BlockFluidMixture)
|
||||
{
|
||||
ItemStack itemStack = entity.getEntityItem().copy();
|
||||
|
||||
if (((TileFluidMixture) tileEntity).mix(itemStack))
|
||||
if (((BlockFluidMixture) block).mix(worldObj, mixPosition.intX(), mixPosition.intY(), mixPosition.intZ(), itemStack))
|
||||
{
|
||||
worldObj.notifyBlocksOfNeighborChange(mixPosition.intX(), mixPosition.intY(), mixPosition.intZ(), mixPosition.getBlockID(worldObj));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (worldObj.isAirBlock(mixPosition.intX(), mixPosition.intY(), mixPosition.intZ()))
|
||||
{
|
||||
mixPosition.setBlock(worldObj, ResonantInduction.blockFluidMixtures.get(entity.getEntityItem().getItemDamage()).blockID, 8);
|
||||
mixPosition.setBlock(worldObj, ResonantInduction.blockFluidMixtures.get(entity.getEntityItem().getItemDamage()).blockID);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue