Facade Creative Tab and Config.
This commit is contained in:
parent
ee99dce791
commit
fbcee6ca12
|
@ -112,10 +112,12 @@ public class AppEng
|
|||
AELog.info( "Starting ( PreInit )" );
|
||||
|
||||
Configuration.instance = new Configuration( event.getModConfigurationDirectory() );
|
||||
FacadeConfig.instance = new FacadeConfig( event.getModConfigurationDirectory() );
|
||||
|
||||
if ( Platform.isClient() )
|
||||
{
|
||||
CreativeTab.init();
|
||||
CreativeTabFacade.init();
|
||||
CommonHelper.proxy.init();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ import appeng.core.AELog;
|
|||
import appeng.core.CommonHelper;
|
||||
import appeng.core.Configuration;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
|
@ -74,9 +76,13 @@ public class AEFeatureHandler implements AEItemDefinition
|
|||
|
||||
String name = getName( i.getClass(), subname );
|
||||
i.setTextureName( "appliedenergistics2:" + name );
|
||||
i.setCreativeTab( CreativeTab.instance );
|
||||
i.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
|
||||
if ( i instanceof ItemFacade )
|
||||
i.setCreativeTab( CreativeTabFacade.instance );
|
||||
else
|
||||
i.setCreativeTab( CreativeTab.instance );
|
||||
|
||||
GameRegistry.registerItem( i, "item." + name );
|
||||
AELog.localization( "item", i.getUnlocalizedName() );
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockGlass;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -16,6 +17,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import appeng.api.AEApi;
|
||||
import appeng.block.solids.OreQuartz;
|
||||
import appeng.client.render.BusRenderer;
|
||||
import appeng.core.FacadeConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.facade.FacadePart;
|
||||
import appeng.facade.IFacadeItem;
|
||||
|
@ -59,6 +61,14 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem
|
|||
|
||||
List<ItemStack> subTypes = null;
|
||||
|
||||
public ItemStack getCreativeTabIcon()
|
||||
{
|
||||
calculateSubTypes();
|
||||
if ( subTypes.isEmpty() )
|
||||
return new ItemStack( Item.cake );
|
||||
return subTypes.get( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int number, CreativeTabs tab, List list)
|
||||
{
|
||||
|
@ -89,9 +99,12 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem
|
|||
if ( subTypes == null )
|
||||
{
|
||||
subTypes = new ArrayList();
|
||||
for (Block b : Block.blocksList)
|
||||
for (int id = 0; id < Block.blocksList.length; id++)
|
||||
{
|
||||
if ( b != null && (b.isOpaqueCube() && !b.getTickRandomly() && !(b instanceof OreQuartz)) || b instanceof BlockGlass )
|
||||
Block b = Block.blocksList[id];
|
||||
if ( b != null
|
||||
&& FacadeConfig.instance.checkEnabled( b, b.isOpaqueCube() && !b.getTickRandomly() && !(b instanceof OreQuartz)
|
||||
|| b instanceof BlockGlass ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -116,7 +129,11 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( FacadeConfig.instance.hasChanged() )
|
||||
FacadeConfig.instance.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -111,6 +111,31 @@ public class Platform
|
|||
|
||||
private static HashMap<String, String> modIDToName;
|
||||
private static HashMap<Integer, String> itemTomodID;
|
||||
private static HashMap<Integer, String> itemNames;
|
||||
|
||||
public static String getBlockName(Block id)
|
||||
{
|
||||
populateModInfo();
|
||||
|
||||
String out = itemNames.get( id.blockID );
|
||||
|
||||
if ( out == null )
|
||||
return "Unknown";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public static String getItemName(Item id)
|
||||
{
|
||||
populateModInfo();
|
||||
|
||||
String out = itemNames.get( id.itemID );
|
||||
|
||||
if ( out == null )
|
||||
return "Unknown";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public static String getMod(String modID)
|
||||
{
|
||||
|
@ -125,10 +150,23 @@ public class Platform
|
|||
}
|
||||
|
||||
public static String getMod(ItemStack is)
|
||||
{
|
||||
populateModInfo();
|
||||
|
||||
String out = itemTomodID.get( is.itemID );
|
||||
|
||||
if ( out == null )
|
||||
return "Unknown";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
private static void populateModInfo()
|
||||
{
|
||||
if ( itemTomodID == null )
|
||||
{
|
||||
itemTomodID = new HashMap<Integer, String>();
|
||||
itemNames = new HashMap<Integer, String>();
|
||||
ImmutableTable<String, String, Integer> modObjectTable;
|
||||
|
||||
for (Field f : Block.class.getDeclaredFields())
|
||||
|
@ -138,6 +176,7 @@ public class Platform
|
|||
Object o = f.get( Block.class );
|
||||
if ( o instanceof Block )
|
||||
{
|
||||
itemNames.put( ((Block) o).blockID, f.getName() );
|
||||
itemTomodID.put( ((Block) o).blockID, "minecraft" );
|
||||
}
|
||||
}
|
||||
|
@ -154,10 +193,14 @@ public class Platform
|
|||
f.setAccessible( false );
|
||||
|
||||
ImmutableMap<String, Map<String, Integer>> fish = modObjectTable.rowMap();
|
||||
for (Map<String, Integer> g : fish.values())
|
||||
for (String MODID : fish.keySet())
|
||||
{
|
||||
Map<String, Integer> g = fish.get( MODID );
|
||||
for (String key : g.keySet())
|
||||
itemTomodID.put( g.get( key ), key );
|
||||
{
|
||||
itemNames.put( g.get( key ), key );
|
||||
itemTomodID.put( g.get( key ), MODID );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
|
@ -165,12 +208,6 @@ public class Platform
|
|||
}
|
||||
}
|
||||
|
||||
String out = itemTomodID.get( is.itemID );
|
||||
|
||||
if ( out == null )
|
||||
return "Unknown";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public static ForgeDirection crossProduct(ForgeDirection forward, ForgeDirection up)
|
||||
|
@ -1472,5 +1509,4 @@ public class Platform
|
|||
|
||||
return !gs.hasPermission( playerID, SecurityPermissions.BUILD );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue