moved p2p forge event to an upper class
add an extra update after the network has finished booting
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ aechannel=stable
|
||||
aebuild=7
|
||||
aegroup=appeng
|
||||
aebasename=appliedenergistics2
|
||||
trousers=omni-fixes-v49e
|
||||
trousers=omni-fixes-v49f
|
||||
|
||||
#########################################################
|
||||
# Versions #
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
@@ -59,6 +60,12 @@ public abstract class PartBasicState extends AEBasePart implements IPowerChannel
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootingRender( final MENetworkBootingStatusChange bs )
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
|
||||
@@ -33,10 +33,6 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
@@ -174,51 +170,6 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IItemHa
|
||||
return wasReq ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateA( final MENetworkBootingStatusChange bs )
|
||||
{
|
||||
if( !this.isOutput() )
|
||||
{
|
||||
this.cachedInv = null;
|
||||
final int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSlots();
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateB( final MENetworkChannelsChanged bs )
|
||||
{
|
||||
if( !this.isOutput() )
|
||||
{
|
||||
this.cachedInv = null;
|
||||
final int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSlots();
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateC( final MENetworkPowerStatusChange bs )
|
||||
{
|
||||
if( !this.isOutput() )
|
||||
{
|
||||
this.cachedInv = null;
|
||||
final int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSlots();
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
|
||||
@@ -32,8 +32,6 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
@@ -41,7 +39,6 @@ import appeng.api.parts.IPartModel;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import org.apache.logging.log4j.core.appender.rolling.action.IfAll;
|
||||
|
||||
|
||||
public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTickable
|
||||
@@ -63,20 +60,6 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
super( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chanRender( final MENetworkChannelsChanged c )
|
||||
{
|
||||
this.onTunnelNetworkChange();
|
||||
super.chanRender( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void powerRender( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.onTunnelNetworkChange();
|
||||
super.powerRender( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
@@ -116,9 +99,17 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
this.lastValue = newLevel;
|
||||
try
|
||||
{
|
||||
int light = 0;
|
||||
for( PartP2PLight src : this.getInputs() )
|
||||
{
|
||||
if( src != null && src.getProxy().isActive() )
|
||||
{
|
||||
light = Math.max( light, src.lastValue );
|
||||
}
|
||||
}
|
||||
for( final PartP2PLight out : this.getOutputs() )
|
||||
{
|
||||
out.setLightLevel( this.lastValue );
|
||||
out.setLightLevel( light );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
@@ -199,24 +190,16 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
{
|
||||
try
|
||||
{
|
||||
boolean hasValidInput = false;
|
||||
int light = 0;
|
||||
for( PartP2PLight src : this.getInputs() )
|
||||
{
|
||||
if( src != null && src.getProxy().isActive() )
|
||||
{
|
||||
hasValidInput = true;
|
||||
light = Math.max( light, src.lastValue );
|
||||
}
|
||||
}
|
||||
if( hasValidInput )
|
||||
{
|
||||
this.setLightLevel( light );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
this.setLightLevel( light );
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
|
||||
@@ -31,10 +31,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -60,12 +56,6 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
super( is );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateA( final MENetworkBootingStatusChange bs )
|
||||
{
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
private void setNetworkReady()
|
||||
{
|
||||
if( this.isOutput() )
|
||||
@@ -97,12 +87,20 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
}
|
||||
|
||||
this.recursive = true;
|
||||
if( this.isOutput() && this.getProxy().isActive() )
|
||||
if( this.isOutput() )
|
||||
{
|
||||
final int newPower = (Integer) o;
|
||||
if( this.power != newPower )
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
this.power = newPower;
|
||||
final int newPower = (Integer) o;
|
||||
if( this.power != newPower )
|
||||
{
|
||||
this.power = newPower;
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.power = 0;
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
}
|
||||
@@ -122,18 +120,6 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateB( final MENetworkChannelsChanged bs )
|
||||
{
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void changeStateC( final MENetworkPowerStatusChange bs )
|
||||
{
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound tag )
|
||||
{
|
||||
|
||||
@@ -24,6 +24,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -152,6 +156,30 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
super.writeToStream( data );
|
||||
data.writeShort( this.getFrequency() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender( final MENetworkChannelsChanged c )
|
||||
{
|
||||
this.onTunnelNetworkChange();
|
||||
super.chanRender( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.onTunnelNetworkChange();
|
||||
super.powerRender( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void bootingRender( final MENetworkBootingStatusChange bs )
|
||||
{
|
||||
this.onTunnelNetworkChange();
|
||||
super.bootingRender( bs );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCableConnectionLength( AECableType cable )
|
||||
|
||||
Reference in New Issue
Block a user