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