Added mixer and rubble washing
This commit is contained in:
parent
4652c40538
commit
99030c23c0
9 changed files with 163 additions and 34 deletions
|
@ -1,17 +0,0 @@
|
|||
package resonantinduction.archaic.imprint;
|
||||
|
||||
import resonantinduction.core.prefab.block.BlockRIRotatable;
|
||||
|
||||
/**
|
||||
* A block that represents a filter for item transportation.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockFilter extends BlockRIRotatable
|
||||
{
|
||||
public BlockFilter(int id)
|
||||
{
|
||||
super("filter", id);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ package resonantinduction.core.resource.fluid;
|
|||
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.BlockFluidFinite;
|
||||
|
@ -23,6 +22,11 @@ public class BlockFluidMixture extends BlockFluidFinite implements ITileEntityPr
|
|||
this.setTextureName("water_flow");
|
||||
}
|
||||
|
||||
public void setQuanta(World world, int x, int y, int z, int quanta)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, quanta - 1, 3);
|
||||
}
|
||||
|
||||
/* IFluidBlock */
|
||||
@Override
|
||||
public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
|
||||
|
|
|
@ -30,7 +30,6 @@ public class TileLiquidMixture extends TileAdvanced
|
|||
{
|
||||
if (MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, itemStack).length > 0)
|
||||
{
|
||||
System.out.println("Mixed");
|
||||
// TODO: Maybe we need to merge the stacks?
|
||||
items.add(itemStack);
|
||||
return true;
|
||||
|
|
|
@ -27,6 +27,7 @@ import resonantinduction.mechanical.logistic.TileManipulator;
|
|||
import resonantinduction.mechanical.logistic.TileRejector;
|
||||
import resonantinduction.mechanical.network.IMechanical;
|
||||
import resonantinduction.mechanical.network.PacketNetwork;
|
||||
import resonantinduction.mechanical.process.BlockFilter;
|
||||
import resonantinduction.mechanical.process.BlockGrinderWheel;
|
||||
import resonantinduction.mechanical.process.TileGrinderWheel;
|
||||
import resonantinduction.mechanical.process.TileMixer;
|
||||
|
@ -85,9 +86,10 @@ public class Mechanical
|
|||
public static Item itemPipe;
|
||||
public static Item itemPipeGuage;
|
||||
|
||||
// Machines
|
||||
// Machines/Processes
|
||||
public static Block blockGrinderWheel;
|
||||
public static Block blockPurifier;
|
||||
public static Block blockFilter;
|
||||
|
||||
public static final PacketNetwork PACKET_NETWORK = new PacketNetwork(IMechanical.class, Reference.CHANNEL);
|
||||
|
||||
|
@ -113,7 +115,7 @@ public class Mechanical
|
|||
// Machines
|
||||
blockGrinderWheel = contentRegistry.createTile(BlockGrinderWheel.class, TileGrinderWheel.class);
|
||||
blockPurifier = contentRegistry.createTile(BlockMixer.class, TileMixer.class);
|
||||
|
||||
blockFilter = contentRegistry.createBlock(BlockFilter.class);
|
||||
OreDictionary.registerOre("gear", itemGear);
|
||||
|
||||
proxy.preInit();
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
package resonantinduction.mechanical.process;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.api.recipe.MachineRecipes;
|
||||
import resonantinduction.api.recipe.MachineRecipes.RecipeType;
|
||||
import resonantinduction.api.recipe.RecipeUtils.Resource;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.prefab.block.BlockRI;
|
||||
import resonantinduction.core.resource.fluid.BlockFluidMixture;
|
||||
import resonantinduction.core.resource.fluid.TileLiquidMixture;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||
|
||||
/**
|
||||
* Used for filtering liquid mixtures
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockFilter extends BlockRI implements ITileEntityProvider
|
||||
{
|
||||
public BlockFilter()
|
||||
{
|
||||
super("filter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
world.scheduleBlockUpdate(x, y, z, blockID, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID)
|
||||
{
|
||||
world.scheduleBlockUpdate(x, y, z, blockID, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
Vector3 position = new Vector3(x, y, z);
|
||||
Vector3 checkAbove = position.clone().translate(ForgeDirection.UP);
|
||||
Vector3 checkBelow = position.clone().translate(ForgeDirection.DOWN);
|
||||
|
||||
TileEntity tileAbove = checkAbove.getTileEntity(world);
|
||||
TileEntity tileBelow = checkBelow.getTileEntity(world);
|
||||
|
||||
if (tileAbove instanceof TileLiquidMixture && (tileBelow == null || tileBelow instanceof TileLiquidMixture))
|
||||
{
|
||||
if (((TileLiquidMixture) tileAbove).items.size() > 0)
|
||||
{
|
||||
world.spawnParticle("dripWater", x + 0.5, y, z + 0.5, 0, 0, 0);
|
||||
|
||||
/**
|
||||
* Leak the fluid down.
|
||||
*/
|
||||
BlockFluidMixture fluidBlock = (BlockFluidMixture) ResonantInduction.blockFluidMixture;
|
||||
int amount = fluidBlock.getQuantaValue(world, x, y, z);
|
||||
|
||||
/**
|
||||
* All fluid is filtered out, spawn all the items.
|
||||
*/
|
||||
if (amount <= 1)
|
||||
{
|
||||
for (ItemStack itemStack : ((TileLiquidMixture) tileAbove).items)
|
||||
{
|
||||
for (Resource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, itemStack))
|
||||
{
|
||||
InventoryUtility.dropItemStack(world, checkAbove, resoure.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (checkBelow.getBlockID(world) == ResonantInduction.blockFluidMixture.blockID)
|
||||
{
|
||||
fluidBlock.setQuanta(world, checkBelow.intX(), checkBelow.intY(), checkBelow.intZ(), fluidBlock.getQuantaValue(world, checkBelow.intX(), checkBelow.intY(), checkBelow.intZ()) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkBelow.setBlock(world, ResonantInduction.blockFluidMixture.blockID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -93,7 +93,7 @@ public class TileGrinderWheel extends TileMechanical implements IRotatable
|
|||
}
|
||||
else
|
||||
{
|
||||
this.worldObj.spawnParticle("crit", grindingItem.posX, grindingItem.posY, grindingItem.posZ, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3);
|
||||
worldObj.spawnParticle("crit", grindingItem.posX, grindingItem.posY, grindingItem.posZ, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 3, (Math.random() - 0.5f) * 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;
|
||||
|
@ -25,7 +26,7 @@ import universalelectricity.api.vector.Vector3;
|
|||
public class TileMixer extends TileMechanical
|
||||
{
|
||||
public static final long POWER = 500000;
|
||||
public static final int DEFAULT_TIME = 10 * 20;
|
||||
public static final int DEFAULT_TIME = 5 * 20;
|
||||
public static final Timer<EntityItem> timer = new Timer<EntityItem>();
|
||||
|
||||
@Override
|
||||
|
@ -53,6 +54,23 @@ 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.setBlock(worldObj, ResonantInduction.blockFluidMixture.blockID, 8);
|
||||
System.out.println("SET");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
@ -72,6 +90,7 @@ public class TileMixer extends TileMechanical
|
|||
Vector3 difference = newPosition.difference(originalPosition).scale(0.5);
|
||||
|
||||
entity.addVelocity(difference.x, difference.y, difference.z);
|
||||
entity.onGround = false;
|
||||
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
|
@ -137,18 +156,18 @@ public class TileMixer extends TileMechanical
|
|||
|
||||
private boolean doneWork(EntityItem entity)
|
||||
{
|
||||
TileEntity tileEntity = new Vector3(entity).getTileEntity(worldObj);
|
||||
Vector3 mixPosition = new Vector3(entity.posX, yCoord, entity.posZ);
|
||||
TileEntity tileEntity = mixPosition.getTileEntity(worldObj);
|
||||
|
||||
if (tileEntity instanceof TileLiquidMixture)
|
||||
{
|
||||
System.out.println("MIXING!");
|
||||
ItemStack itemStack = entity.getEntityItem().copy();
|
||||
return ((TileLiquidMixture) tileEntity).mix(itemStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("transformed block!");
|
||||
new Vector3(entity).setBlock(worldObj, ResonantInduction.blockFluidMixture.blockID);
|
||||
if (((TileLiquidMixture) tileEntity).mix(itemStack))
|
||||
{
|
||||
System.out.println("MIXED");
|
||||
worldObj.notifyBlocksOfNeighborChange(mixPosition.intX(), mixPosition.intY(), mixPosition.intZ(), mixPosition.getBlockID(worldObj));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -75,10 +75,10 @@ tile.resonantinduction\:fluidPipe.14.name=Magenta Wood Trough
|
|||
tile.resonantinduction\:fluidPipe.15.name=Orange Wood Trough
|
||||
tile.resonantinduction\:fluidPipe.16.name=White Wood Trough
|
||||
|
||||
|
||||
## Machines
|
||||
## Machines and Processing
|
||||
tile.resonantinduction\:mixer.name=Mixer
|
||||
tile.resonantinduction\:grindingWheel.name=Grinder Wheel
|
||||
tile.resonantinduction\:filter.name=Filter
|
||||
|
||||
### Electrical Module
|
||||
## Blocks
|
||||
|
@ -86,7 +86,6 @@ tile.resonantinduction\:tesla.name=Tesla Coil
|
|||
tile.resonantinduction\:levitator.name=Electromagnetic Levitator
|
||||
tile.resonantinduction\:battery.name=Battery
|
||||
tile.resonantinduction\:material.name=Material
|
||||
tile.resonantinduction\:filter.name=Filter
|
||||
tile.resonantinduction\:armbot.name=Armbot
|
||||
tile.resonantinduction\:encoder.name=Encoder
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Loading…
Add table
Reference in a new issue