Fix stuff

This commit is contained in:
Shadowfacts 2016-06-15 09:57:50 -04:00
parent f93eac4a87
commit 5eb211828a
4 changed files with 54 additions and 33 deletions

View File

@ -1,4 +1,4 @@
mod_version = 1.0.0
mod_version = 1.0.1
group = net.shadowfacts
archivesBaseName = Funnels

View File

@ -15,7 +15,7 @@ public class FunnelsConfig {
static Configuration config;
@Config.Prop
public static int size = 4000;
public static int size = 1000;
@Config.Prop
public static boolean pickupWorldFluids = true;

View File

@ -34,38 +34,59 @@ public class TileEntityFunnel extends BaseTileEntity implements ITickable {
@Override
public void update() {
if (!worldObj.isRemote) {
if (tank.getFluidAmount() > 0) {
EnumFacing facing = worldObj.getBlockState(pos).getValue(BlockFunnel.FACING);
BlockPos handlerPos = pos.offset(facing);
TileEntity te = worldObj.getTileEntity(handlerPos);
if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite())) {
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite());
tank.drain(handler.fill(tank.drain(20, false), true), true);
save();
}
}
tick++;
if (tick % 40 == 0) {
if (FunnelsConfig.pickupWorldFluids) {
tick = 0;
if (FluidUtils.isFluidBlock(worldObj, pos.up())) {
FluidStack toDrain = FluidUtils.drainFluidBlock(worldObj, pos.up(), false);
if (toDrain.amount <= tank.getCapacity() - tank.getFluidAmount()) {
tank.fill(FluidUtils.drainFluidBlock(worldObj, pos.up(), true), true);
save();
}
handlers:
{
// up handler -> tank
if (tank.getFluidAmount() < tank.getCapacity()) {
BlockPos handlerPos = pos.up();
TileEntity te = worldObj.getTileEntity(handlerPos);
if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN)) {
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN);
tank.fill(handler.drain(tank.getCapacity() - tank.getFluidAmount(), true), true);
save();
break handlers;
}
}
} else {
if (FunnelsConfig.placeFluidsInWorld && tank.getFluidAmount() >= Fluid.BUCKET_VOLUME) {
FluidStack fluid = tank.getFluid();
if (fluid.getFluid().canBePlacedInWorld()) {
Block fluidBlock = fluid.getFluid().getBlock();
BlockPos newPos = pos.offset(worldObj.getBlockState(pos).getValue(BlockFunnel.FACING));
if (fluidBlock.canPlaceBlockAt(worldObj, newPos)) {
tank.drain(Fluid.BUCKET_VOLUME, true);
save();
worldObj.setBlockState(newPos, fluidBlock.getDefaultState());
// tank -> front handler
if (tank.getFluidAmount() > 0) {
EnumFacing facing = worldObj.getBlockState(pos).getValue(BlockFunnel.FACING);
BlockPos handlerPos = pos.offset(facing);
TileEntity te = worldObj.getTileEntity(handlerPos);
if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite())) {
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite());
tank.drain(handler.fill(tank.drain(20, false), true), true);
save();
}
}
}
world:
{
tick++;
if (tick % 40 == 0) {
// pickup from world
if (FunnelsConfig.pickupWorldFluids && tank.getFluidAmount() <= tank.getCapacity() - Fluid.BUCKET_VOLUME) {
tick = 0;
if (FluidUtils.isFluidBlock(worldObj, pos.up())) {
FluidStack toDrain = FluidUtils.drainFluidBlock(worldObj, pos.up(), false);
if (toDrain.amount <= tank.getCapacity() - tank.getFluidAmount()) {
tank.fill(FluidUtils.drainFluidBlock(worldObj, pos.up(), true), true);
save();
break world;
}
}
}
// place in world
if (FunnelsConfig.placeFluidsInWorld && tank.getFluidAmount() >= Fluid.BUCKET_VOLUME) {
FluidStack fluid = tank.getFluid();
if (fluid.getFluid().canBePlacedInWorld()) {
Block fluidBlock = fluid.getFluid().getBlock();
BlockPos newPos = pos.offset(worldObj.getBlockState(pos).getValue(BlockFunnel.FACING));
if (fluidBlock.canPlaceBlockAt(worldObj, newPos)) {
tank.drain(Fluid.BUCKET_VOLUME, true);
save();
worldObj.setBlockState(newPos, fluidBlock.getDefaultState());
}
}
}
}

View File

@ -4,7 +4,7 @@
"name": "Funnels",
"version": "$version",
"mcversion": "$mcversion",
"description": "Fluid funnels",
"description": "Fantastic Fluid funnels",
"credits": "",
"url": "https://github.com/shadowfacts/Funnels",
"updateUrl": "",