From 7996c44075af1521859196ddc2b02efcc62f497e Mon Sep 17 00:00:00 2001 From: PrototypeTrousers Date: Mon, 15 Aug 2022 01:12:23 -0300 Subject: [PATCH] Make ME Controller still usable even without channels on. gives energy discount. Hide channel count from Waila and TOP, if channels are disabled --- .../theoneprobe/part/ChannelInfoProvider.java | 6 ++++ .../waila/part/ChannelWailaDataProvider.java | 29 ++++++++++--------- .../java/appeng/me/cache/PathGridCache.java | 19 +++--------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java b/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java index c0e9f2b72..dd908621b 100644 --- a/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java +++ b/src/main/java/appeng/integration/modules/theoneprobe/part/ChannelInfoProvider.java @@ -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; diff --git a/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java index 98ac67f13..705e64882 100644 --- a/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java +++ b/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java @@ -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 getWailaBody( final IPart part, final List 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 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 diff --git a/src/main/java/appeng/me/cache/PathGridCache.java b/src/main/java/appeng/me/cache/PathGridCache.java index 2891d6cc8..b874d4cd2 100644 --- a/src/main/java/appeng/me/cache/PathGridCache.java +++ b/src/main/java/appeng/me/cache/PathGridCache.java @@ -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 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 i = gmb.getMultiblockNodes(); - while( i.hasNext() ) + while ( i.hasNext() ) { this.semiOpen.add( (IPathItem) i.next() ); }