Backport waila features from upstream:
Show P2P-Tunnel Link Status on WAILA Implemented QoL improvement for P2P tunnels by showing their link status via WAILA. Backport - Add P2P frequency to waila & memory card.
This commit is contained in:
parent
2676c7c09c
commit
52d91ddecb
|
@ -19,6 +19,7 @@
|
|||
package appeng.core.localization;
|
||||
|
||||
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
|
||||
|
@ -61,7 +62,7 @@ public enum ButtonToolTips
|
|||
BlockPlacement, BlockPlacementYes, BlockPlacementNo,
|
||||
|
||||
// Used in the tooltips of the items in the terminal, when moused over
|
||||
ItemsStored, ItemsRequestable,
|
||||
ItemsStored, ItemsRequestable, P2PFrequency,
|
||||
|
||||
SchedulingMode, SchedulingModeDefault, SchedulingModeRoundRobin, SchedulingModeRandom;
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ public enum WailaText
|
|||
|
||||
DeviceOnline, DeviceOffline, DeviceMissingChannel,
|
||||
|
||||
P2PUnlinked, P2PInputOneOutput, P2PInputManyOutputs, P2POutput,
|
||||
|
||||
Locked, Unlocked, Showing,
|
||||
|
||||
Contains, Channels;
|
||||
|
|
|
@ -19,13 +19,11 @@
|
|||
package appeng.integration.modules.waila;
|
||||
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.waila.part.*;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Lists;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -33,11 +31,23 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.waila.part.ChannelWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.IPartWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.P2PStateWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.PartAccessor;
|
||||
import appeng.integration.modules.waila.part.PartStackWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.PowerStateWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.StorageMonitorWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.Tracer;
|
||||
|
||||
|
||||
/**
|
||||
* Delegation provider for parts through {@link appeng.integration.modules.waila.part.IPartWailaDataProvider}
|
||||
* Delegation provider for parts through {@link IPartWailaDataProvider}
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
|
@ -68,9 +78,10 @@ public final class PartWailaDataProvider implements IWailaDataProvider
|
|||
final IPartWailaDataProvider channel = new ChannelWailaDataProvider();
|
||||
final IPartWailaDataProvider storageMonitor = new StorageMonitorWailaDataProvider();
|
||||
final IPartWailaDataProvider powerState = new PowerStateWailaDataProvider();
|
||||
final IPartWailaDataProvider p2pState = new P2PStateWailaDataProvider();
|
||||
final IPartWailaDataProvider partStack = new PartStackWailaDataProvider();
|
||||
|
||||
this.providers = Lists.newArrayList( channel, storageMonitor, powerState, partStack );
|
||||
this.providers = Lists.newArrayList( channel, storageMonitor, powerState, partStack, p2pState );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* Provides information about a P2P tunnel to WAILA.
|
||||
*/
|
||||
public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
|
||||
private static final int STATE_UNLINKED = 0;
|
||||
private static final int STATE_OUTPUT = 1;
|
||||
private static final int STATE_INPUT = 2;
|
||||
public static final String TAG_P2P_STATE = "p2p_state";
|
||||
public static final String TAG_P2P_FREQUENCY = "p2p_frequency";
|
||||
|
||||
/**
|
||||
* Adds state to the tooltip
|
||||
*
|
||||
* @param part part with state
|
||||
* @param currentToolTip to be added to tooltip
|
||||
* @param accessor wrapper for various information
|
||||
* @param config config settings
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
if( part instanceof PartP2PTunnel )
|
||||
{
|
||||
NBTTagCompound nbtData = accessor.getNBTData();
|
||||
if( nbtData.hasKey( TAG_P2P_STATE ) )
|
||||
{
|
||||
int[] stateArr = nbtData.getIntArray( TAG_P2P_STATE );
|
||||
if( stateArr.length == 2 )
|
||||
{
|
||||
int state = stateArr[0];
|
||||
int outputs = stateArr[1];
|
||||
|
||||
switch( state )
|
||||
{
|
||||
case STATE_UNLINKED:
|
||||
currentToolTip.add( WailaText.P2PUnlinked.getLocal() );
|
||||
break;
|
||||
case STATE_OUTPUT:
|
||||
currentToolTip.add( WailaText.P2POutput.getLocal() );
|
||||
break;
|
||||
case STATE_INPUT:
|
||||
currentToolTip.add( getOutputText( outputs ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final long freq = nbtData.getLong( TAG_P2P_FREQUENCY );
|
||||
final String freqTooltip = String.format("%X", freq ).replaceAll("(.{4})", "$0 ").trim();
|
||||
|
||||
final String local = ButtonToolTips.P2PFrequency.getLocal();
|
||||
|
||||
currentToolTip.add( String.format( local, freqTooltip ) );
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( final EntityPlayerMP player, final IPart part, final TileEntity te, final NBTTagCompound tag, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
if( part instanceof PartP2PTunnel )
|
||||
{
|
||||
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
|
||||
|
||||
if( !tunnel.isPowered() )
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
// Frquency
|
||||
final long frequency = tunnel.getFrequency();
|
||||
tag.setLong( TAG_P2P_FREQUENCY, frequency );
|
||||
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = 0;
|
||||
|
||||
if( !tunnel.isOutput() )
|
||||
{
|
||||
outputCount = getOutputCount( tunnel );
|
||||
if( outputCount > 0 )
|
||||
{
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PartP2PTunnel input = tunnel.getInput();
|
||||
if( input != null )
|
||||
{
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
|
||||
tag.setIntArray( TAG_P2P_STATE, new int[] {
|
||||
state,
|
||||
outputCount
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
private static int getOutputCount( PartP2PTunnel tunnel )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Iterators.size( tunnel.getOutputs().iterator() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOutputText( int outputs )
|
||||
{
|
||||
if( outputs <= 1 )
|
||||
{
|
||||
return WailaText.P2PInputOneOutput.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( WailaText.P2PInputManyOutputs.getLocal(), outputs );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -21,11 +21,14 @@ package appeng.items.tools;
|
|||
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -33,12 +36,15 @@ import net.minecraft.util.StatCollector;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
{
|
||||
|
||||
public ToolMemoryCard()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
|
@ -55,6 +61,16 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
|||
{
|
||||
lines.add( StatCollector.translateToLocal( this.getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) );
|
||||
}
|
||||
|
||||
if( data.hasKey( "freq" ) )
|
||||
{
|
||||
final long freq = data.getLong( "freq" );
|
||||
final String freqTooltip = String.format("%X", freq ).replaceAll("(.{4})", "$0 ").trim();
|
||||
|
||||
final String local = ButtonToolTips.P2PFrequency.getLocal();
|
||||
|
||||
lines.add( String.format( local, freqTooltip ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,12 @@ import appeng.api.config.TunnelType;
|
|||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.api.parts.*;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.me.GridAccessException;
|
||||
|
@ -75,7 +80,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
|||
return null;
|
||||
}
|
||||
|
||||
T getInput()
|
||||
public T getInput()
|
||||
{
|
||||
if( this.getFrequency() == 0 )
|
||||
{
|
||||
|
@ -97,7 +102,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
|||
return null;
|
||||
}
|
||||
|
||||
TunnelCollection<T> getOutputs() throws GridAccessException
|
||||
public TunnelCollection<T> getOutputs() throws GridAccessException
|
||||
{
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
|
@ -116,7 +121,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
|||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( final IPartRenderHelper rh, final RenderBlocks renderer )
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer)
|
||||
{
|
||||
rh.setTexture( this.getTypeTexture() );
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# GUI rendering
|
||||
public net.minecraft.client.gui.inventory.GuiContainer func_146977_a(Lnet/minecraft/inventory/Slot;)V # drawSlot
|
||||
public net.minecraft.client.gui.GuiTextField func_146188_c(IIII)V # drawSelectionBox
|
|
@ -325,6 +325,7 @@ gui.tooltips.appliedenergistics2.SchedulingModeRoundRobin=Export using round rob
|
|||
gui.tooltips.appliedenergistics2.SchedulingModeRandom=Export items in random mode.
|
||||
gui.tooltips.appliedenergistics2.ItemsStored=Items Stored: %s
|
||||
gui.tooltips.appliedenergistics2.ItemsRequestable=Items Requestable: %s
|
||||
gui.tooltips.appliedenergistics2.P2PFrequency=Frequency: %s
|
||||
|
||||
# Units
|
||||
gui.appliedenergistics2.units.appliedenergstics=AE
|
||||
|
@ -362,6 +363,10 @@ waila.appliedenergistics2.Unlocked=Unlocked
|
|||
waila.appliedenergistics2.Showing=Showing
|
||||
waila.appliedenergistics2.Contains=Contains
|
||||
waila.appliedenergistics2.Channels=%1$d of %2$d Channels
|
||||
waila.appliedenergistics2.P2PUnlinked=Unlinked
|
||||
waila.appliedenergistics2.P2PInputOneOutput=Linked (Input Side)
|
||||
waila.appliedenergistics2.P2PInputManyOutputs=Linked (Input Side) - %d Outputs
|
||||
waila.appliedenergistics2.P2POutput=Linked (Output Side)
|
||||
|
||||
# Items
|
||||
item.appliedenergistics2.ItemBasicStorageCell.1k.name=1k ME Storage Cell
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 295 B |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Loading…
Reference in New Issue