Some minor work on the filter

This commit is contained in:
Calclavia 2014-01-27 01:02:16 +08:00
parent 56ab302f0e
commit 9c3700382f
7 changed files with 68 additions and 65 deletions

View file

@ -4,6 +4,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -36,7 +37,7 @@ public class BlockFluidMixture extends BlockFluidFinite implements ITileEntityPr
{ {
TileLiquidMixture tileFluid = (TileLiquidMixture) world.getBlockTileEntity(x, y, z); TileLiquidMixture tileFluid = (TileLiquidMixture) world.getBlockTileEntity(x, y, z);
FluidStack stack = new FluidStack(ResonantInduction.MIXTURE, (int) (FluidContainerRegistry.BUCKET_VOLUME * this.getFilledPercentage(world, x, y, z))); FluidStack stack = new FluidStack(ResonantInduction.MIXTURE, (int) (FluidContainerRegistry.BUCKET_VOLUME * this.getFilledPercentage(world, x, y, z)));
tileFluid.writeFluidToNBT(stack.tag); tileFluid.writeFluidToNBT(stack.tag != null ? stack.tag : new NBTTagCompound());
return stack; return stack;
} }

View file

@ -86,6 +86,8 @@ public class TileGenerator extends TileElectrical implements IRotatable
IMechanical mech = ((IMechanical) tile).getInstance(outputDir.getOpposite()); IMechanical mech = ((IMechanical) tile).getInstance(outputDir.getOpposite());
long extract = energy.extractEnergy(false); long extract = energy.extractEnergy(false);
if (mech != null)
{
if (extract > 0) if (extract > 0)
{ {
final float maxAngularVelocity = energy.getEnergyCapacity() / (float) torqueRatio; final float maxAngularVelocity = energy.getEnergyCapacity() / (float) torqueRatio;
@ -115,6 +117,7 @@ public class TileGenerator extends TileElectrical implements IRotatable
} }
} }
} }
}
@Override @Override
public EnumSet<ForgeDirection> getInputDirections() public EnumSet<ForgeDirection> getInputDirections()

View file

@ -93,8 +93,6 @@ public class LiquidPathFinder
{ {
return false; return false;
} }
try
{
this.addNode(node); this.addNode(node);
if (this.isValidResult(node)) if (this.isValidResult(node))
@ -127,11 +125,6 @@ public class LiquidPathFinder
{ {
return true; return true;
} }
}
catch (Exception e)
{
e.printStackTrace();
}
return false; return false;
} }

View file

@ -37,6 +37,8 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
@Override @Override
public void update() public void update()
{ {
super.update();
if (!this.world().isRemote) if (!this.world().isRemote)
{ {
if (manualCrankTime > 0) if (manualCrankTime > 0)
@ -69,16 +71,18 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
} }
getMultiBlock().update(); getMultiBlock().update();
if (getMultiBlock().isPrimary())
{
super.update();
} }
public void checkClientUpdate()
{
if (getMultiBlock().isPrimary())
super.checkClientUpdate();
} }
@Override @Override
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack item) public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack item)
{ {
// System.out.println(getNetwork());
if (BlockAdvanced.isUsableWrench(player, player.getCurrentEquippedItem(), x(), y(), z())) if (BlockAdvanced.isUsableWrench(player, player.getCurrentEquippedItem(), x(), y(), z()))
{ {
if (player.isSneaking()) if (player.isSneaking())

View file

@ -73,9 +73,19 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
@Override @Override
public void update() public void update()
{ {
if (ticks == 0)
{
getNetwork().addConnector(this);
}
ticks++; ticks++;
angle += angularVelocity / 20; angle += angularVelocity / 20;
super.update();
}
public void checkClientUpdate()
{
if (Math.abs(prevAngularVelocity - angularVelocity) > 0.1f) if (Math.abs(prevAngularVelocity - angularVelocity) > 0.1f)
{ {
prevAngularVelocity = angularVelocity; prevAngularVelocity = angularVelocity;
@ -87,8 +97,6 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
sendRotationPacket(); sendRotationPacket();
markPacketUpdate = false; markPacketUpdate = false;
} }
super.update();
} }
@Override @Override

View file

@ -69,11 +69,12 @@ public class BlockFilter extends BlockRI implements ITileEntityProvider
*/ */
if (amount <= 1) if (amount <= 1)
{ {
System.out.println("filter dropped");
for (ItemStack itemStack : ((TileLiquidMixture) tileAbove).items) for (ItemStack itemStack : ((TileLiquidMixture) tileAbove).items)
{ {
for (Resource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, itemStack)) for (Resource resoure : MachineRecipes.INSTANCE.getOutput(RecipeType.MIXER, itemStack))
{ {
InventoryUtility.dropItemStack(world, checkAbove, resoure.getItemStack()); InventoryUtility.dropItemStack(world, checkAbove.clone().add(0.5), resoure.getItemStack());
} }
} }
} }

View file

@ -29,16 +29,12 @@ public class TileMixer extends TileMechanical
public static final long POWER = 500000; public static final long POWER = 500000;
public static final int PROCESS_TIME = 5 * 20; public static final int PROCESS_TIME = 5 * 20;
public static final Timer<EntityItem> timer = new Timer<EntityItem>(); public static final Timer<EntityItem> timer = new Timer<EntityItem>();
private final long requiredTorque = 1000;
private long counter = 0;
@Override @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
counter = Math.max(counter + torque, 0);
if (canWork()) if (canWork())
{ {
doWork(); doWork();
@ -52,7 +48,7 @@ public class TileMixer extends TileMechanical
*/ */
public boolean canWork() public boolean canWork()
{ {
return counter >= requiredTorque; return angularVelocity > 0;
} }
public void doWork() public void doWork()
@ -70,8 +66,7 @@ public class TileMixer extends TileMechanical
if (checkVector.getBlockID(worldObj) == Block.waterStill.blockID) if (checkVector.getBlockID(worldObj) == Block.waterStill.blockID)
{ {
checkVector.setBlock(worldObj, ResonantInduction.blockFluidMixture.blockID, 8); checkVector.setBlock(worldObj, ResonantInduction.blockFluidMixture.blockID, 8, 4);
System.out.println("SET");
} }
} }
} }
@ -86,7 +81,7 @@ public class TileMixer extends TileMechanical
/** /**
* Rotate entities around the mixer * Rotate entities around the mixer
*/ */
double speed = 1; double speed = angularVelocity;
Vector3 originalPosition = new Vector3(entity); Vector3 originalPosition = new Vector3(entity);
Vector3 relativePosition = originalPosition.clone().subtract(new Vector3(this).add(0.5)); Vector3 relativePosition = originalPosition.clone().subtract(new Vector3(this).add(0.5));
@ -156,8 +151,6 @@ public class TileMixer extends TileMechanical
{ {
this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.PREFIX + "mixer", 0.5f, 1); this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.PREFIX + "mixer", 0.5f, 1);
} }
counter -= requiredTorque;
} }
} }