Port to 1.11

This commit is contained in:
yueh
2016-12-08 12:42:00 +01:00
parent 589730bfad
commit ed9e6dd21c
262 changed files with 4027 additions and 3954 deletions
@@ -1,75 +1,75 @@
/*
* 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.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
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;
/**
* Default implementation of {@link appeng.integration.modules.waila.part.IPartWailaDataProvider}
*
* @author thatsIch
* @version rv2
* @since rv2
*/
public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider
{
@Override
public ItemStack getWailaStack( final IPart part, final IWailaConfigHandler config, final ItemStack partStack )
{
return null;
}
@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> 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;
}
}
///*
// * 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.util.List;
//
//import net.minecraft.entity.player.EntityPlayerMP;
//import net.minecraft.item.ItemStack;
//import net.minecraft.nbt.NBTTagCompound;
//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;
//
//
///**
// * Default implementation of {@link appeng.integration.modules.waila.part.IPartWailaDataProvider}
// *
// * @author thatsIch
// * @version rv2
// * @since rv2
// */
//public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider
//{
// @Override
// public ItemStack getWailaStack( final IPart part, final IWailaConfigHandler config, final ItemStack partStack )
// {
// return null;
// }
//
// @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> 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;
// }
//}
@@ -1,163 +1,163 @@
/*
* 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.util.List;
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 gnu.trove.map.TObjectByteMap;
import gnu.trove.map.hash.TObjectByteHashMap;
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.PartDenseCable;
/**
* Channel-information provider for WAILA
*
* @author thatsIch
* @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";
/**
* 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 TObjectByteMap<IPart> cache = new TObjectByteHashMap<IPart>();
/**
* 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( part instanceof PartCableSmart || part instanceof PartDenseCable )
{
final NBTTagCompound tag = accessor.getNBTData();
final byte usedChannels = this.getUsedChannels( part, tag, this.cache );
if( usedChannels >= 0 )
{
final byte maxChannels = (byte) ( ( part instanceof PartDenseCable ) ? 32 : 8 );
final String formattedToolTip = String.format( WailaText.Channels.getLocal(), usedChannels, maxChannels );
currentToolTip.add( formattedToolTip );
}
}
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 TObjectByteMap<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;
}
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 PartDenseCable )
{
final NBTTagCompound tempTag = new NBTTagCompound();
part.writeToNBT( tempTag );
if( tempTag.hasKey( ID_USED_CHANNELS ) )
{
final byte usedChannels = tempTag.getByte( ID_USED_CHANNELS );
tag.setByte( ID_USED_CHANNELS, usedChannels );
}
}
return tag;
}
}
///*
// * 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.util.List;
//
//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 gnu.trove.map.TObjectByteMap;
//import gnu.trove.map.hash.TObjectByteHashMap;
//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.PartDenseCable;
//
//
///**
// * Channel-information provider for WAILA
// *
// * @author thatsIch
// * @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";
//
// /**
// * 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 TObjectByteMap<IPart> cache = new TObjectByteHashMap<IPart>();
//
// /**
// * 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( part instanceof PartCableSmart || part instanceof PartDenseCable )
// {
// final NBTTagCompound tag = accessor.getNBTData();
//
// final byte usedChannels = this.getUsedChannels( part, tag, this.cache );
//
// if( usedChannels >= 0 )
// {
// final byte maxChannels = (byte) ( ( part instanceof PartDenseCable ) ? 32 : 8 );
//
// final String formattedToolTip = String.format( WailaText.Channels.getLocal(), usedChannels, maxChannels );
// currentToolTip.add( formattedToolTip );
// }
// }
//
// 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 TObjectByteMap<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;
// }
//
// 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 PartDenseCable )
// {
// final NBTTagCompound tempTag = new NBTTagCompound();
//
// part.writeToNBT( tempTag );
//
// if( tempTag.hasKey( ID_USED_CHANNELS ) )
// {
// final byte usedChannels = tempTag.getByte( ID_USED_CHANNELS );
//
// tag.setByte( ID_USED_CHANNELS, usedChannels );
// }
// }
//
// return tag;
// }
//}
@@ -1,56 +1,56 @@
/*
* 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.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
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;
/**
* An abstraction layer of the {@link appeng.integration.modules.waila.part.IPartWailaDataProvider} for
* {@link appeng.api.parts.IPart}.
*
* @author thatsIch
* @version rv2
* @since rv2
*/
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> getWailaBody( 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 );
}
///*
// * 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.util.List;
//
//import net.minecraft.entity.player.EntityPlayerMP;
//import net.minecraft.item.ItemStack;
//import net.minecraft.nbt.NBTTagCompound;
//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;
//
//
///**
// * An abstraction layer of the {@link appeng.integration.modules.waila.part.IPartWailaDataProvider} for
// * {@link appeng.api.parts.IPart}.
// *
// * @author thatsIch
// * @version rv2
// * @since rv2
// */
//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> getWailaBody( 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 );
//}
@@ -1,158 +1,158 @@
/*
* 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.util.List;
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.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 appeng.core.localization.WailaText;
import appeng.me.GridAccessException;
import appeng.parts.p2p.PartP2PTunnel;
/**
* 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";
/**
* 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;
}
}
}
}
return currentToolTip;
}
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
{
if( part instanceof PartP2PTunnel )
{
PartP2PTunnel tunnel = (PartP2PTunnel) part;
// 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 );
}
}
}
///*
// * 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.util.List;
//
//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.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 appeng.core.localization.WailaText;
//import appeng.me.GridAccessException;
//import appeng.parts.p2p.PartP2PTunnel;
//
//
///**
// * 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";
//
// /**
// * 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;
// }
// }
// }
// }
//
// return currentToolTip;
// }
//
// @Override
// public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
// {
// if( part instanceof PartP2PTunnel )
// {
// PartP2PTunnel tunnel = (PartP2PTunnel) part;
//
// // 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 );
// }
// }
//
//}
@@ -1,47 +1,47 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, 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 net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
import appeng.api.parts.IPart;
import appeng.api.parts.PartItemStack;
/**
* Part ItemStack provider for WAILA
*
* @author TheJulianJES
* @version rv2
* @since rv2
*/
public class PartStackWailaDataProvider extends BasePartWailaDataProvider
{
@Override
public ItemStack getWailaStack( final IPart part, final IWailaConfigHandler config, ItemStack partStack )
{
partStack = part.getItemStack( PartItemStack.PICK );
return partStack;
}
}
///*
// * This file is part of Applied Energistics 2.
// * Copyright (c) 2013 - 2015, 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 net.minecraft.item.ItemStack;
//
//import mcp.mobius.waila.api.IWailaConfigHandler;
//
//import appeng.api.parts.IPart;
//import appeng.api.parts.PartItemStack;
//
//
///**
// * Part ItemStack provider for WAILA
// *
// * @author TheJulianJES
// * @version rv2
// * @since rv2
// */
//public class PartStackWailaDataProvider extends BasePartWailaDataProvider
//{
//
// @Override
// public ItemStack getWailaStack( final IPart part, final IWailaConfigHandler config, ItemStack partStack )
// {
// partStack = part.getItemStack( PartItemStack.PICK );
// return partStack;
// }
//
//}
@@ -1,91 +1,91 @@
/*
* 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.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;
/**
* Power state provider for WAILA
*
* @author thatsIch
* @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;
currentToolTip.add( this.getToolTip( state.isActive(), state.isPowered() ) );
}
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;
if( isActive && isPowered )
{
result = WailaText.DeviceOnline.getLocal();
}
else if( isPowered )
{
result = WailaText.DeviceMissingChannel.getLocal();
}
else
{
result = WailaText.DeviceOffline.getLocal();
}
return result;
}
}
///*
// * 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.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;
//
//
///**
// * Power state provider for WAILA
// *
// * @author thatsIch
// * @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;
//
// currentToolTip.add( this.getToolTip( state.isActive(), state.isPowered() ) );
// }
//
// 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;
//
// if( isActive && isPowered )
// {
// result = WailaText.DeviceOnline.getLocal();
// }
// else if( isPowered )
// {
// result = WailaText.DeviceMissingChannel.getLocal();
// }
// else
// {
// result = WailaText.DeviceOffline.getLocal();
// }
//
// return result;
// }
//}
@@ -1,81 +1,81 @@
/*
* 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.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;
/**
* Storage monitor provider for WAILA
*
* @author thatsIch
* @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;
final IAEStack<?> displayed = monitor.getDisplayed();
final boolean isLocked = monitor.isLocked();
if( displayed instanceof IAEItemStack )
{
final IAEItemStack ais = (IAEItemStack) displayed;
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getItemStack().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() );
}
return currentToolTip;
}
}
///*
// * 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.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;
//
//
///**
// * Storage monitor provider for WAILA
// *
// * @author thatsIch
// * @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;
//
// final IAEStack<?> displayed = monitor.getDisplayed();
// final boolean isLocked = monitor.isLocked();
//
// if( displayed instanceof IAEItemStack )
// {
// final IAEItemStack ais = (IAEItemStack) displayed;
// currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getItemStack().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() );
// }
//
// return currentToolTip;
// }
//}
@@ -72,7 +72,7 @@ public final class Tracer
double y = player.posY;
double z = player.posZ;
if( player.worldObj.isRemote )
if( player.world.isRemote )
{
// compatibility with eye height changing mods
y += player.getEyeHeight() - player.getDefaultEyeHeight();