reformatted all src files (#141)
This commit is contained in:
+25
-33
@@ -19,8 +19,9 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -28,10 +29,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -41,35 +39,29 @@ import appeng.api.parts.IPart;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider
|
||||
{
|
||||
@Override
|
||||
public ItemStack getWailaStack( final IPart part, final IWailaConfigHandler config, final ItemStack partStack )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider {
|
||||
@Override
|
||||
public ItemStack getWailaStack(final IPart part, final IWailaConfigHandler config, final ItemStack partStack) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaHead(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaBody(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
return currentToolTip;
|
||||
}
|
||||
@Override
|
||||
public List<String> getWailaTail(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
+97
-113
@@ -19,25 +19,23 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCableSmart;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCableSmart;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,120 +45,106 @@ import appeng.parts.networking.PartDenseCableSmart;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Channel key used for the transferred {@link net.minecraft.nbt.NBTTagCompound}
|
||||
*/
|
||||
private static final String ID_USED_CHANNELS = "usedChannels";
|
||||
public final class ChannelWailaDataProvider extends BasePartWailaDataProvider {
|
||||
/**
|
||||
* Channel key used for the transferred {@link net.minecraft.nbt.NBTTagCompound}
|
||||
*/
|
||||
private static final String ID_USED_CHANNELS = "usedChannels";
|
||||
|
||||
/**
|
||||
* Used cache for channels if the channel was not transmitted through the server.
|
||||
* <p/>
|
||||
* This is useful, when a player just started to look at a tile and thus just requested the new information from the
|
||||
* server.
|
||||
* <p/>
|
||||
* The cache will be updated from the server.
|
||||
*/
|
||||
private final Object2ByteMap<IPart> cache = new Object2ByteOpenHashMap<>();
|
||||
/**
|
||||
* Used cache for channels if the channel was not transmitted through the server.
|
||||
* <p/>
|
||||
* This is useful, when a player just started to look at a tile and thus just requested the new information from the
|
||||
* server.
|
||||
* <p/>
|
||||
* The cache will be updated from the server.
|
||||
*/
|
||||
private final Object2ByteMap<IPart> cache = new Object2ByteOpenHashMap<>();
|
||||
|
||||
/**
|
||||
* Adds the used and max channel to the tool tip
|
||||
*
|
||||
* @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
|
||||
* @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();
|
||||
/**
|
||||
* Adds the used and max channel to the tool tip
|
||||
*
|
||||
* @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
|
||||
* @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();
|
||||
|
||||
final byte usedChannels = this.getUsedChannels( part, tag, this.cache );
|
||||
final byte usedChannels = this.getUsedChannels(part, tag, this.cache);
|
||||
|
||||
if( usedChannels >= 0 )
|
||||
{
|
||||
final byte maxChannels = (byte) ( ( part instanceof PartDenseCableSmart ) ? 32 : 8 );
|
||||
if (usedChannels >= 0) {
|
||||
final byte maxChannels = (byte) ((part instanceof PartDenseCableSmart) ? 32 : 8);
|
||||
|
||||
final String formattedToolTip = String.format( WailaText.Channels.getLocal(), usedChannels, maxChannels );
|
||||
currentToolTip.add( formattedToolTip );
|
||||
}
|
||||
}
|
||||
final String formattedToolTip = String.format(WailaText.Channels.getLocal(), usedChannels, maxChannels);
|
||||
currentToolTip.add(formattedToolTip);
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the source of the channel.
|
||||
* <p/>
|
||||
* 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 cache cache with previous knowledge
|
||||
* @return used channels on the cable
|
||||
*/
|
||||
private byte getUsedChannels( final IPart part, final NBTTagCompound tag, final Object2ByteMap<IPart> cache )
|
||||
{
|
||||
final byte usedChannels;
|
||||
/**
|
||||
* Determines the source of the channel.
|
||||
* <p/>
|
||||
* 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 cache cache with previous knowledge
|
||||
* @return used channels on the cable
|
||||
*/
|
||||
private byte getUsedChannels(final IPart part, final NBTTagCompound tag, final Object2ByteMap<IPart> cache) {
|
||||
final byte usedChannels;
|
||||
|
||||
if( tag.hasKey( ID_USED_CHANNELS ) )
|
||||
{
|
||||
usedChannels = tag.getByte( ID_USED_CHANNELS );
|
||||
this.cache.put( part, usedChannels );
|
||||
}
|
||||
else if( this.cache.containsKey( part ) )
|
||||
{
|
||||
usedChannels = this.cache.get( part );
|
||||
}
|
||||
else
|
||||
{
|
||||
usedChannels = -1;
|
||||
}
|
||||
if (tag.hasKey(ID_USED_CHANNELS)) {
|
||||
usedChannels = tag.getByte(ID_USED_CHANNELS);
|
||||
this.cache.put(part, usedChannels);
|
||||
} else if (this.cache.containsKey(part)) {
|
||||
usedChannels = this.cache.get(part);
|
||||
} else {
|
||||
usedChannels = -1;
|
||||
}
|
||||
|
||||
return usedChannels;
|
||||
}
|
||||
return usedChannels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on server to transfer information from server to client.
|
||||
* <p/>
|
||||
* If the part is a cable, it writes the channel information in the {@code #tag} using the {@code ID_USED_CHANNELS}
|
||||
* 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
|
||||
* @return tag send to the client
|
||||
*/
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
|
||||
{
|
||||
if( part instanceof PartCableSmart || part instanceof PartDenseCableSmart )
|
||||
{
|
||||
final NBTTagCompound tempTag = new NBTTagCompound();
|
||||
/**
|
||||
* Called on server to transfer information from server to client.
|
||||
* <p/>
|
||||
* If the part is a cable, it writes the channel information in the {@code #tag} using the {@code ID_USED_CHANNELS}
|
||||
* 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
|
||||
* @return tag send to the client
|
||||
*/
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
||||
if (part instanceof PartCableSmart || part instanceof PartDenseCableSmart) {
|
||||
final NBTTagCompound tempTag = new NBTTagCompound();
|
||||
|
||||
part.writeToNBT( tempTag );
|
||||
part.writeToNBT(tempTag);
|
||||
|
||||
if( tempTag.hasKey( ID_USED_CHANNELS ) )
|
||||
{
|
||||
final byte usedChannels = tempTag.getByte( ID_USED_CHANNELS );
|
||||
if (tempTag.hasKey(ID_USED_CHANNELS)) {
|
||||
final byte usedChannels = tempTag.getByte(ID_USED_CHANNELS);
|
||||
|
||||
tag.setByte( ID_USED_CHANNELS, usedChannels );
|
||||
}
|
||||
}
|
||||
tag.setByte(ID_USED_CHANNELS, usedChannels);
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -28,10 +29,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -42,15 +40,14 @@ import appeng.api.parts.IPart;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public interface IPartWailaDataProvider
|
||||
{
|
||||
ItemStack getWailaStack( IPart part, IWailaConfigHandler config, ItemStack partStack );
|
||||
public interface IPartWailaDataProvider {
|
||||
ItemStack getWailaStack(IPart part, IWailaConfigHandler config, ItemStack partStack);
|
||||
|
||||
List<String> getWailaHead( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
|
||||
List<String> getWailaHead(IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
|
||||
List<String> getWailaBody( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
|
||||
List<String> getWailaBody(IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
|
||||
List<String> getWailaTail( IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config );
|
||||
List<String> getWailaTail(IPart part, List<String> currentToolTip, IWailaDataAccessor accessor, IWailaConfigHandler config);
|
||||
|
||||
NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos );
|
||||
NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos);
|
||||
}
|
||||
|
||||
+112
-147
@@ -19,11 +19,14 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -31,170 +34,132 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
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;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Provides information about a P2P tunnel to WAILA.
|
||||
*/
|
||||
public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
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";
|
||||
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];
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
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 short freq = nbtData.getShort( TAG_P2P_FREQUENCY );
|
||||
final String freqTooltip = Platform.p2p().toHexString( freq );
|
||||
currentToolTip.add( I18n.translateToLocalFormatted( "gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip ) );
|
||||
}
|
||||
}
|
||||
final short freq = nbtData.getShort(TAG_P2P_FREQUENCY);
|
||||
final String freqTooltip = Platform.p2p().toHexString(freq);
|
||||
currentToolTip.add(I18n.translateToLocalFormatted("gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip));
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
|
||||
{
|
||||
if( part instanceof PartP2PTunnel )
|
||||
{
|
||||
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
||||
if (part instanceof PartP2PTunnel) {
|
||||
final PartP2PTunnel tunnel = (PartP2PTunnel) part;
|
||||
|
||||
if( !tunnel.isPowered() )
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
if (!tunnel.isPowered()) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
// Frquency
|
||||
final short frequency = tunnel.getFrequency();
|
||||
tag.setShort( TAG_P2P_FREQUENCY, frequency );
|
||||
// Frquency
|
||||
final short frequency = tunnel.getFrequency();
|
||||
tag.setShort(TAG_P2P_FREQUENCY, frequency);
|
||||
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = getOutputCount( tunnel );
|
||||
int inputCount = getInputCount( tunnel );
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = getOutputCount(tunnel);
|
||||
int inputCount = getInputCount(tunnel);
|
||||
|
||||
if( !tunnel.isOutput() )
|
||||
{
|
||||
if( outputCount > 0 )
|
||||
{
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( inputCount > 0 )
|
||||
{
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
if (!tunnel.isOutput()) {
|
||||
if (outputCount > 0) {
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
state = STATE_INPUT;
|
||||
}
|
||||
} else {
|
||||
if (inputCount > 0) {
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
}
|
||||
|
||||
tag.setIntArray( TAG_P2P_STATE, new int[] {
|
||||
state,
|
||||
outputCount
|
||||
} );
|
||||
tag.setIntArray(TAG_P2P_STATE, new int[]{
|
||||
state,
|
||||
outputCount
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
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 int getOutputCount(PartP2PTunnel tunnel) {
|
||||
try {
|
||||
return Iterators.size(tunnel.getOutputs().iterator());
|
||||
} catch (GridAccessException e) {
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getInputCount( PartP2PTunnel tunnel )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Iterators.size( tunnel.getInputs().iterator() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
private static int getInputCount(PartP2PTunnel tunnel) {
|
||||
try {
|
||||
return Iterators.size(tunnel.getInputs().iterator());
|
||||
} catch (GridAccessException e) {
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOutputText( int outputs )
|
||||
{
|
||||
if( outputs <= 1 )
|
||||
{
|
||||
return WailaText.P2P_INPUT_ONE_OUTPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( WailaText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs );
|
||||
}
|
||||
}
|
||||
private static String getOutputText(int outputs) {
|
||||
if (outputs <= 1) {
|
||||
return WailaText.P2P_INPUT_ONE_OUTPUT.getLocal();
|
||||
} else {
|
||||
return String.format(WailaText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getInputText( int inputs )
|
||||
{
|
||||
if( inputs <= 1 )
|
||||
{
|
||||
return WailaText.P2P_OUTPUT_ONE_INPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( WailaText.P2P_OUTPUT_MANY_INPUTS.getLocal(), inputs );
|
||||
}
|
||||
}
|
||||
private static String getInputText(int inputs) {
|
||||
if (inputs <= 1) {
|
||||
return WailaText.P2P_OUTPUT_ONE_INPUT.getLocal();
|
||||
} else {
|
||||
return String.format(WailaText.P2P_OUTPUT_MANY_INPUTS.getLocal(), inputs);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,16 +19,15 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
@@ -38,34 +37,29 @@ import appeng.api.parts.SelectedPart;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PartAccessor
|
||||
{
|
||||
/**
|
||||
* Hits a {@link IPartHost} with {@link BlockPos}.
|
||||
* <p/>
|
||||
* You can derive the looked at {@link IPart} by doing that. If a facade is being looked at, it is
|
||||
* defined as being absent.
|
||||
*
|
||||
* @param te being looked at {@link TileEntity}
|
||||
* @param mop type of ray-trace
|
||||
*
|
||||
* @return maybe the looked at {@link IPart}
|
||||
*/
|
||||
public Optional<IPart> getMaybePart( final TileEntity te, final RayTraceResult mop )
|
||||
{
|
||||
if( te instanceof IPartHost )
|
||||
{
|
||||
BlockPos pos = mop.getBlockPos();
|
||||
final Vec3d position = mop.hitVec.addVector( -pos.getX(), -pos.getY(), -pos.getZ() );
|
||||
final IPartHost host = (IPartHost) te;
|
||||
final SelectedPart sp = host.selectPart( position );
|
||||
public final class PartAccessor {
|
||||
/**
|
||||
* Hits a {@link IPartHost} with {@link BlockPos}.
|
||||
* <p/>
|
||||
* You can derive the looked at {@link IPart} by doing that. If a facade is being looked at, it is
|
||||
* defined as being absent.
|
||||
*
|
||||
* @param te being looked at {@link TileEntity}
|
||||
* @param mop type of ray-trace
|
||||
* @return maybe the looked at {@link IPart}
|
||||
*/
|
||||
public Optional<IPart> getMaybePart(final TileEntity te, final RayTraceResult mop) {
|
||||
if (te instanceof IPartHost) {
|
||||
BlockPos pos = mop.getBlockPos();
|
||||
final Vec3d position = mop.hitVec.addVector(-pos.getX(), -pos.getY(), -pos.getZ());
|
||||
final IPartHost host = (IPartHost) te;
|
||||
final SelectedPart sp = host.selectPart(position);
|
||||
|
||||
if( sp.part != null )
|
||||
{
|
||||
return Optional.of( sp.part );
|
||||
}
|
||||
}
|
||||
if (sp.part != null) {
|
||||
return Optional.of(sp.part);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-12
@@ -19,12 +19,10 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
/**
|
||||
@@ -34,14 +32,12 @@ import appeng.api.parts.PartItemStack;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public class PartStackWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
public class PartStackWailaDataProvider extends BasePartWailaDataProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack( final IPart part, final IWailaConfigHandler config, ItemStack partStack )
|
||||
{
|
||||
partStack = part.getItemStack( PartItemStack.PICK );
|
||||
return partStack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getWailaStack(final IPart part, final IWailaConfigHandler config, ItemStack partStack) {
|
||||
partStack = part.getItemStack(PartItemStack.PICK);
|
||||
return partStack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+40
-52
@@ -19,14 +19,13 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.localization.WailaText;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -36,56 +35,45 @@ import appeng.core.localization.WailaText;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class PowerStateWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* 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 IPowerChannelState )
|
||||
{
|
||||
final IPowerChannelState state = (IPowerChannelState) part;
|
||||
public final class PowerStateWailaDataProvider extends BasePartWailaDataProvider {
|
||||
/**
|
||||
* 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 IPowerChannelState) {
|
||||
final IPowerChannelState state = (IPowerChannelState) part;
|
||||
|
||||
currentToolTip.add( this.getToolTip( state.isActive(), state.isPowered() ) );
|
||||
}
|
||||
currentToolTip.add(this.getToolTip(state.isActive(), state.isPowered()));
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the corresponding tool tip for different values of {@code #isActive} and {@code #isPowered}
|
||||
*
|
||||
* @param isActive if part is active
|
||||
* @param isPowered if part is powered
|
||||
*
|
||||
* @return tooltip of the state
|
||||
*/
|
||||
private String getToolTip( final boolean isActive, final boolean isPowered )
|
||||
{
|
||||
final String result;
|
||||
/**
|
||||
* Gets the corresponding tool tip for different values of {@code #isActive} and {@code #isPowered}
|
||||
*
|
||||
* @param isActive if part is active
|
||||
* @param isPowered if part is powered
|
||||
* @return tooltip of the state
|
||||
*/
|
||||
private String getToolTip(final boolean isActive, final boolean isPowered) {
|
||||
final String result;
|
||||
|
||||
if( isActive && isPowered )
|
||||
{
|
||||
result = WailaText.DeviceOnline.getLocal();
|
||||
}
|
||||
else if( isPowered )
|
||||
{
|
||||
result = WailaText.DeviceMissingChannel.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = WailaText.DeviceOffline.getLocal();
|
||||
}
|
||||
if (isActive && isPowered) {
|
||||
result = WailaText.DeviceOnline.getLocal();
|
||||
} else if (isPowered) {
|
||||
result = WailaText.DeviceMissingChannel.getLocal();
|
||||
} else {
|
||||
result = WailaText.DeviceOffline.getLocal();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+33
-41
@@ -19,17 +19,16 @@
|
||||
package appeng.integration.modules.waila.part;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import appeng.api.implementations.parts.IPartStorageMonitor;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.core.localization.WailaText;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -39,44 +38,37 @@ import appeng.core.localization.WailaText;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class StorageMonitorWailaDataProvider extends BasePartWailaDataProvider
|
||||
{
|
||||
/**
|
||||
* Displays the stack if present and if the monitor is locked.
|
||||
* Can handle fluids and items.
|
||||
*
|
||||
* @param part maybe storage monitor
|
||||
* @param currentToolTip to be written to tooltip
|
||||
* @param accessor information wrapper
|
||||
* @param config config option
|
||||
*
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
|
||||
{
|
||||
if( part instanceof IPartStorageMonitor )
|
||||
{
|
||||
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
|
||||
public final class StorageMonitorWailaDataProvider extends BasePartWailaDataProvider {
|
||||
/**
|
||||
* Displays the stack if present and if the monitor is locked.
|
||||
* Can handle fluids and items.
|
||||
*
|
||||
* @param part maybe storage monitor
|
||||
* @param currentToolTip to be written to tooltip
|
||||
* @param accessor information wrapper
|
||||
* @param config config option
|
||||
* @return modified tooltip
|
||||
*/
|
||||
@Override
|
||||
public List<String> getWailaBody(final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
if (part instanceof IPartStorageMonitor) {
|
||||
final IPartStorageMonitor monitor = (IPartStorageMonitor) part;
|
||||
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
final IAEStack<?> displayed = monitor.getDisplayed();
|
||||
final boolean isLocked = monitor.isLocked();
|
||||
|
||||
// TODO: generalize
|
||||
if( displayed instanceof IAEItemStack )
|
||||
{
|
||||
final IAEItemStack ais = (IAEItemStack) displayed;
|
||||
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.asItemStackRepresentation().getDisplayName() );
|
||||
}
|
||||
else if( displayed instanceof IAEFluidStack )
|
||||
{
|
||||
final IAEFluidStack ais = (IAEFluidStack) displayed;
|
||||
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
|
||||
}
|
||||
// TODO: generalize
|
||||
if (displayed instanceof IAEItemStack) {
|
||||
final IAEItemStack ais = (IAEItemStack) displayed;
|
||||
currentToolTip.add(WailaText.Showing.getLocal() + ": " + ais.asItemStackRepresentation().getDisplayName());
|
||||
} else if (displayed instanceof IAEFluidStack) {
|
||||
final IAEFluidStack ais = (IAEFluidStack) displayed;
|
||||
currentToolTip.add(WailaText.Showing.getLocal() + ": " + ais.getFluid().getLocalizedName(ais.getFluidStack()));
|
||||
}
|
||||
|
||||
currentToolTip.add( ( isLocked ) ? WailaText.Locked.getLocal() : WailaText.Unlocked.getLocal() );
|
||||
}
|
||||
currentToolTip.add((isLocked) ? WailaText.Locked.getLocal() : WailaText.Unlocked.getLocal());
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,66 +35,55 @@ import net.minecraft.world.World;
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public final class Tracer
|
||||
{
|
||||
/**
|
||||
* Trace view of players to blocks.
|
||||
* Ignore all which are out of reach.
|
||||
*
|
||||
* @param world word of block
|
||||
* @param player player viewing block
|
||||
* @param pos pos of block
|
||||
*
|
||||
* @return trace movement. Can be null
|
||||
*/
|
||||
public RayTraceResult retraceBlock( final World world, final EntityPlayerMP player, BlockPos pos )
|
||||
{
|
||||
IBlockState blockState = world.getBlockState( pos );
|
||||
public final class Tracer {
|
||||
/**
|
||||
* Trace view of players to blocks.
|
||||
* Ignore all which are out of reach.
|
||||
*
|
||||
* @param world word of block
|
||||
* @param player player viewing block
|
||||
* @param pos pos of block
|
||||
* @return trace movement. Can be null
|
||||
*/
|
||||
public RayTraceResult retraceBlock(final World world, final EntityPlayerMP player, BlockPos pos) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
|
||||
final Vec3d headVec = this.getCorrectedHeadVec( player );
|
||||
final Vec3d lookVec = player.getLook( 1.0F );
|
||||
final double reach = this.getBlockReachDistance_server( player );
|
||||
final Vec3d endVec = headVec.addVector( lookVec.x * reach, lookVec.y * reach, lookVec.z * reach );
|
||||
final Vec3d headVec = this.getCorrectedHeadVec(player);
|
||||
final Vec3d lookVec = player.getLook(1.0F);
|
||||
final double reach = this.getBlockReachDistance_server(player);
|
||||
final Vec3d endVec = headVec.addVector(lookVec.x * reach, lookVec.y * reach, lookVec.z * reach);
|
||||
|
||||
return blockState.collisionRayTrace( world, pos, headVec, endVec );
|
||||
}
|
||||
return blockState.collisionRayTrace(world, pos, headVec, endVec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the view point of a player
|
||||
*
|
||||
* @param player player with head
|
||||
*
|
||||
* @return view point of player
|
||||
*/
|
||||
private Vec3d getCorrectedHeadVec( final EntityPlayer player )
|
||||
{
|
||||
double x = player.posX;
|
||||
double y = player.posY;
|
||||
double z = player.posZ;
|
||||
/**
|
||||
* Gets the view point of a player
|
||||
*
|
||||
* @param player player with head
|
||||
* @return view point of player
|
||||
*/
|
||||
private Vec3d getCorrectedHeadVec(final EntityPlayer player) {
|
||||
double x = player.posX;
|
||||
double y = player.posY;
|
||||
double z = player.posZ;
|
||||
|
||||
if( player.world.isRemote )
|
||||
{
|
||||
// compatibility with eye height changing mods
|
||||
y += player.getEyeHeight() - player.getDefaultEyeHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
y += player.getEyeHeight();
|
||||
if( player instanceof EntityPlayerMP && player.isSneaking() )
|
||||
{
|
||||
y -= 0.08;
|
||||
}
|
||||
}
|
||||
return new Vec3d( x, y, z );
|
||||
}
|
||||
if (player.world.isRemote) {
|
||||
// compatibility with eye height changing mods
|
||||
y += player.getEyeHeight() - player.getDefaultEyeHeight();
|
||||
} else {
|
||||
y += player.getEyeHeight();
|
||||
if (player instanceof EntityPlayerMP && player.isSneaking()) {
|
||||
y -= 0.08;
|
||||
}
|
||||
}
|
||||
return new Vec3d(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player multi-player player
|
||||
*
|
||||
* @return block reach distance of player
|
||||
*/
|
||||
private double getBlockReachDistance_server( final EntityPlayerMP player )
|
||||
{
|
||||
return player.interactionManager.getBlockReachDistance();
|
||||
}
|
||||
/**
|
||||
* @param player multi-player player
|
||||
* @return block reach distance of player
|
||||
*/
|
||||
private double getBlockReachDistance_server(final EntityPlayerMP player) {
|
||||
return player.interactionManager.getBlockReachDistance();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user