From 8d1b33b268b232d12c24b6c638214f60581b5394 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 25 Jun 2013 01:29:11 -0700 Subject: [PATCH] Pipes won't connect to a receptor with no provider And a tweak to powerRequest() --- common/buildcraft/api/power/PowerProvider.java | 5 ++--- common/buildcraft/transport/IPipeTransportPowerHook.java | 2 +- common/buildcraft/transport/PipeTransportPower.java | 7 ++++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/buildcraft/api/power/PowerProvider.java b/common/buildcraft/api/power/PowerProvider.java index 72f1cd32..a905d0cc 100644 --- a/common/buildcraft/api/power/PowerProvider.java +++ b/common/buildcraft/api/power/PowerProvider.java @@ -130,9 +130,8 @@ public final class PowerProvider { data.setCompoundTag(tag, nbt); } - public int powerRequest() { - float needed = maxEnergyStored - energyStored; - return (int) Math.ceil(Math.min(maxEnergyReceived, needed)); + public float powerRequest() { + return Math.min(maxEnergyReceived, maxEnergyStored - energyStored); } public float receiveEnergy(float quantity, ForgeDirection from) { diff --git a/common/buildcraft/transport/IPipeTransportPowerHook.java b/common/buildcraft/transport/IPipeTransportPowerHook.java index 0bd9393f..48cae72e 100644 --- a/common/buildcraft/transport/IPipeTransportPowerHook.java +++ b/common/buildcraft/transport/IPipeTransportPowerHook.java @@ -15,5 +15,5 @@ public interface IPipeTransportPowerHook { public double receiveEnergy(ForgeDirection from, double val); - public void requestEnergy(ForgeDirection from, int i); + public void requestEnergy(ForgeDirection from, float amount); } diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index e30243a5..44e129b3 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -70,9 +70,10 @@ public class PipeTransportPower extends PipeTransport { Pipe pipe2 = ((TileGenericPipe) tile).pipe; if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportPower)) return false; + return true; } - return tile instanceof TileGenericPipe || tile instanceof IMachine || tile instanceof IPowerReceptor; + return tile instanceof IPowerReceptor && ((IPowerReceptor)tile).getPowerProvider(side) != null; } @Override @@ -180,7 +181,7 @@ public class PipeTransportPower extends PipeTransport { IPowerReceptor receptor = (IPowerReceptor) tiles[i]; PowerProvider prov = receptor.getPowerProvider(ForgeDirection.VALID_DIRECTIONS[i].getOpposite()); if (prov != null && prov.canAcceptPowerFromPipes) { - int request = prov.powerRequest(); + float request = prov.powerRequest(); if (request > 0) { requestEnergy(ForgeDirection.VALID_DIRECTIONS[i], request); @@ -284,7 +285,7 @@ public class PipeTransportPower extends PipeTransport { return val; } - public void requestEnergy(ForgeDirection from, int amount) { + public void requestEnergy(ForgeDirection from, float amount) { step(); if (this.container.pipe instanceof IPipeTransportPowerHook) { ((IPipeTransportPowerHook) this.container.pipe).requestEnergy(from, amount);