Make ME Controller still usable even without channels on. gives energy

discount. 
Hide channel count from Waila and TOP, if channels are disabled
This commit is contained in:
PrototypeTrousers
2022-08-15 01:12:23 -03:00
parent f5e9df07d4
commit 7996c44075
3 changed files with 26 additions and 28 deletions
@@ -19,6 +19,8 @@
package appeng.integration.modules.theoneprobe.part;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
@@ -40,6 +42,10 @@ public class ChannelInfoProvider implements IPartProbInfoProvider
@Override
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( !AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) )
{
return;
}
if( part instanceof PartDenseCableSmart || part instanceof PartCableSmart )
{
final int usedChannels;
@@ -21,6 +21,8 @@ package appeng.integration.modules.waila.part;
import java.util.List;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@@ -65,16 +67,19 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
/**
* Adds the used and max channel to the tool tip
*
* @param part being looked at part
* @param part being looked at part
* @param currentToolTip current tool tip
* @param accessor wrapper for various world information
* @param config config to react to various settings
*
* @param accessor wrapper for various world information
* @param config config to react to various settings
* @return modified tool tip
*/
@Override
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
if( !AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) )
{
return currentToolTip;
}
if( part instanceof PartCableSmart || part instanceof PartDenseCableSmart )
{
final NBTTagCompound tag = accessor.getNBTData();
@@ -99,10 +104,9 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
* If the client received information of the channels on the server, they are used, else if the cache contains a
* previous stored value, this will be used. Default value is 0.
*
* @param part part to be looked at
* @param tag tag maybe containing the channel information
* @param part part to be looked at
* @param tag tag maybe containing the channel information
* @param cache cache with previous knowledge
*
* @return used channels on the cable
*/
private byte getUsedChannels( final IPart part, final NBTTagCompound tag, final Object2ByteMap<IPart> cache )
@@ -133,12 +137,11 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
* key.
*
* @param player player looking at the part
* @param part part being looked at
* @param te host of the part
* @param tag transferred tag which is send to the client
* @param world world of the part
* @param pos pos of the part
*
* @param part part being looked at
* @param te host of the part
* @param tag transferred tag which is send to the client
* @param world world of the part
* @param pos pos of the part
* @return tag send to the client
*/
@Override
+4 -15
View File
@@ -103,22 +103,11 @@ public class PathGridCache implements IPathingGrid
this.updateNetwork = false;
this.setChannelsInUse( 0 );
if( !AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) )
{
final int used = this.calculateRequiredChannels();
final int nodes = this.myGrid.getNodes().size();
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
this.setChannelsByBlocks( nodes * used );
this.setChannelPowerUsage( this.getChannelsByBlocks() / 128.0 );
this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
}
else if( this.controllerState == ControllerState.NO_CONTROLLER )
if( this.controllerState == ControllerState.NO_CONTROLLER )
{
final int requiredChannels = this.calculateRequiredChannels();
int used = requiredChannels;
if( requiredChannels > 8 )
if( AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) && requiredChannels > 8 )
{
used = 0;
}
@@ -168,7 +157,7 @@ public class PathGridCache implements IPathingGrid
if( !this.active.isEmpty() || this.ticksUntilReady > 0 )
{
final Iterator<PathSegment> i = this.active.iterator();
while( i.hasNext() )
while ( i.hasNext() )
{
final PathSegment pat = i.next();
if( pat.step() )
@@ -330,7 +319,7 @@ public class PathGridCache implements IPathingGrid
{
final IGridMultiblock gmb = (IGridMultiblock) gb;
final Iterator<IGridNode> i = gmb.getMultiblockNodes();
while( i.hasNext() )
while ( i.hasNext() )
{
this.semiOpen.add( (IPathItem) i.next() );
}