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 group = net.shadowfacts
archivesBaseName = Funnels archivesBaseName = Funnels

View File

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

View File

@ -34,38 +34,59 @@ public class TileEntityFunnel extends BaseTileEntity implements ITickable {
@Override @Override
public void update() { public void update() {
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
if (tank.getFluidAmount() > 0) { handlers:
EnumFacing facing = worldObj.getBlockState(pos).getValue(BlockFunnel.FACING); {
BlockPos handlerPos = pos.offset(facing); // up handler -> tank
TileEntity te = worldObj.getTileEntity(handlerPos); if (tank.getFluidAmount() < tank.getCapacity()) {
if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite())) { BlockPos handlerPos = pos.up();
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite()); TileEntity te = worldObj.getTileEntity(handlerPos);
tank.drain(handler.fill(tank.drain(20, false), true), true); if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN)) {
save(); IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN);
} tank.fill(handler.drain(tank.getCapacity() - tank.getFluidAmount(), true), true);
} save();
tick++; break handlers;
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();
}
} }
} }
} else { // tank -> front handler
if (FunnelsConfig.placeFluidsInWorld && tank.getFluidAmount() >= Fluid.BUCKET_VOLUME) { if (tank.getFluidAmount() > 0) {
FluidStack fluid = tank.getFluid(); EnumFacing facing = worldObj.getBlockState(pos).getValue(BlockFunnel.FACING);
if (fluid.getFluid().canBePlacedInWorld()) { BlockPos handlerPos = pos.offset(facing);
Block fluidBlock = fluid.getFluid().getBlock(); TileEntity te = worldObj.getTileEntity(handlerPos);
BlockPos newPos = pos.offset(worldObj.getBlockState(pos).getValue(BlockFunnel.FACING)); if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite())) {
if (fluidBlock.canPlaceBlockAt(worldObj, newPos)) { IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite());
tank.drain(Fluid.BUCKET_VOLUME, true); tank.drain(handler.fill(tank.drain(20, false), true), true);
save(); save();
worldObj.setBlockState(newPos, fluidBlock.getDefaultState()); }
}
}
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", "name": "Funnels",
"version": "$version", "version": "$version",
"mcversion": "$mcversion", "mcversion": "$mcversion",
"description": "Fluid funnels", "description": "Fantastic Fluid funnels",
"credits": "", "credits": "",
"url": "https://github.com/shadowfacts/Funnels", "url": "https://github.com/shadowfacts/Funnels",
"updateUrl": "", "updateUrl": "",