This commit is contained in:
AlgorithmX2 2014-05-18 21:42:43 -05:00
commit bd926374db
3 changed files with 52 additions and 14 deletions

View file

@ -10,6 +10,7 @@ import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import appeng.client.gui.implementations.GuiCraftingTerm;
import appeng.integration.BaseModule;
import appeng.integration.IIntegrationModule;
import appeng.integration.abstraction.INEI;
import appeng.integration.modules.NEIHelpers.NEIAEShapedRecipeHandler;
@ -20,7 +21,7 @@ import appeng.integration.modules.NEIHelpers.NEIInscriberRecipeHandler;
import appeng.integration.modules.NEIHelpers.NEIWorldCraftingHandler;
import codechicken.nei.guihook.GuiContainerManager;
public class NEI implements IIntegrationModule, INEI
public class NEI extends BaseModule implements IIntegrationModule, INEI
{
public static NEI instance;
@ -32,6 +33,9 @@ public class NEI implements IIntegrationModule, INEI
Method registerUsageHandler;
public NEI() throws ClassNotFoundException {
TestClass( GuiContainerManager.class );
TestClass( codechicken.nei.recipe.ICraftingHandler.class );
TestClass( codechicken.nei.recipe.IUsageHandler.class );
API = Class.forName( "codechicken.nei.api.API" );
}
@ -94,9 +98,16 @@ public class NEI implements IIntegrationModule, INEI
@Override
public RenderItem setItemRender(RenderItem aeri2)
{
RenderItem ri = GuiContainerManager.drawItems;
GuiContainerManager.drawItems = aeri2;
return ri;
try
{
RenderItem ri = GuiContainerManager.drawItems;
GuiContainerManager.drawItems = aeri2;
return ri;
}
catch (Throwable t)
{
throw new RuntimeException( "Invalid version of NEI, please update", t );
}
}
}

View file

@ -36,20 +36,24 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
throw new RuntimeException( "IC2 Not installed!" );
}
double OutputPacket;
// two packet buffering...
double OutputPacketA;
double OutputPacketB;
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT( tag );
tag.setDouble( "OutputPacket", OutputPacket );
tag.setDouble( "OutputPacket", OutputPacketA );
tag.setDouble( "OutputPacket2", OutputPacketB );
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT( tag );
OutputPacket = tag.getDouble( "OutputPacket" );
OutputPacketA = tag.getDouble( "OutputPacket" );
OutputPacketB = tag.getDouble( "OutputPacket2" );
}
@SideOnly(Side.CLIENT)
@ -84,7 +88,7 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
{
for (PartP2PIC2Power t : getOutputs())
{
if ( t.OutputPacket <= 0.0001 )
if ( t.OutputPacketA <= 0.0001 || t.OutputPacketB <= 0.0001 )
{
return 2048;
}
@ -128,10 +132,17 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
LinkedList<PartP2PIC2Power> Options = new LinkedList();
for (PartP2PIC2Power o : outs)
{
if ( o.OutputPacket <= 0.01 )
if ( o.OutputPacketA <= 0.01 )
Options.add( o );
}
if ( Options.isEmpty() )
{
for (PartP2PIC2Power o : outs)
if ( o.OutputPacketB <= 0.01 )
Options.add( o );
}
if ( Options.isEmpty() )
{
for (PartP2PIC2Power o : outs)
@ -142,10 +153,18 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
return amount;
PartP2PIC2Power x = (PartP2PIC2Power) Platform.pickRandom( Options );
if ( x != null && x.OutputPacket <= 0.001 )
if ( x != null && x.OutputPacketA <= 0.001 )
{
QueueTunnelDrain( PowerUnits.EU, amount );
x.OutputPacket = amount;
x.OutputPacketA = amount;
return 0;
}
if ( x != null && x.OutputPacketB <= 0.001 )
{
QueueTunnelDrain( PowerUnits.EU, amount );
x.OutputPacketB = amount;
return 0;
}
@ -162,14 +181,19 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
public double getOfferedEnergy()
{
if ( output )
return OutputPacket;
return OutputPacketA;
return 0;
}
@Override
public void drawEnergy(double amount)
{
OutputPacket -= amount;
OutputPacketA -= amount;
if ( OutputPacketA < 0.001 )
{
OutputPacketA = OutputPacketB;
OutputPacketB = 0;
}
}
}

View file

@ -1,5 +1,6 @@
package appeng.parts.p2p;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.client.renderer.RenderBlocks;
@ -265,7 +266,9 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
public TunnelCollection<T> getOutputs() throws GridAccessException
{
return (TunnelCollection<T>) proxy.getP2P().getOutputs( freq, getClass() );
if ( proxy.isActive() )
return (TunnelCollection<T>) proxy.getP2P().getOutputs( freq, getClass() );
return new TunnelCollection( new ArrayList(), getClass() );
}
public void onChange()