More config updates; disabling of blocks is now functional.

This commit is contained in:
Justin Aquadro committed 2014-09-07 03:01:35 -04:00
1 parent a5a24bb3c2
commit edb2e0f9a5
4 files changed
+76 -24

No files matched your search

@@ -59,4 +59,11 @@ storageDrawers.config.blocks.halfDrawers2=Compact Drawers 1x2
storageDrawers.config.blocks.halfDrawers4=Compact Drawers 2x2
storageDrawers.config.upgrades=Upgrade Settings
storageDrawers.config.upgrades.tooltip=Configure individual storage upgrades.
storageDrawers.config.upgrades.tooltip=Configure individual storage upgrades.
storageDrawers.config.prop.itemRenderType=Item Render Type
storageDrawers.config.prop.itemRenderType.tooltip=Render items in 3D or flat.
storageDrawers.config.prop.enabled=Enabled
storageDrawers.config.prop.enabled.tooltip=Enable block in game.
storageDrawers.config.prop.baseStorage=Base Storage
storageDrawers.config.prop.baseStorage.tooltip=Number of stacks held per drawer.
@@ -7,6 +7,7 @@ import net.minecraftforge.common.config.Property;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -64,7 +65,7 @@ public class ConfigManager
public final ConfigSection sectionBlocksHalfDrawers1x2 = new ConfigSection(blockSections, sectionBlocks, "halfdrawers2", "blocks.halfDrawers2");
public final ConfigSection sectionBlocksHalfDrawers2x2 = new ConfigSection(blockSections, sectionBlocks, "halfdrawers4", "blocks.halfDrawers4");
public Map<String, ConfigCategory> blockSubcategories;
public Map<String, ConfigSection> blockSectionsMap = new HashMap<String, ConfigSection>();
private Property itemRenderType;
@@ -74,32 +75,35 @@ public class ConfigManager
for (ConfigSection section : sections)
section.getCategory();
for (ConfigSection section : blockSections)
for (ConfigSection section : blockSections) {
section.getCategory();
blockSectionsMap.put(section.name, section);
}
syncConfig();
}
public void syncConfig () {
itemRenderType = config.get(Configuration.CATEGORY_GENERAL, "Item Render Type", "fancy", null, new String[] { "fancy", "fast" });
itemRenderType = config.get(Configuration.CATEGORY_GENERAL, "itemRenderType", "fancy", null, new String[] { "fancy", "fast" });
itemRenderType.setLanguageKey(LANG_PREFIX + "prop.itemRenderType");
config.get(sectionBlocksFullDrawers1x2.getQualifiedName(), "enabled", true);
config.get(sectionBlocksFullDrawers1x2.getQualifiedName(), "baseStorage", 8);
config.get(sectionBlocksFullDrawers1x2.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers1x2.getQualifiedName(), "baseStorage", 8).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
config.get(sectionBlocksFullDrawers2x2.getQualifiedName(), "enabled", true);
config.get(sectionBlocksFullDrawers2x2.getQualifiedName(), "baseStorage", 4);
config.get(sectionBlocksFullDrawers2x2.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers2x2.getQualifiedName(), "baseStorage", 4).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
config.get(sectionBlocksHalfDrawers1x2.getQualifiedName(), "enabled", true);
config.get(sectionBlocksHalfDrawers1x2.getQualifiedName(), "baseStorage", 4);
config.get(sectionBlocksHalfDrawers1x2.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksHalfDrawers1x2.getQualifiedName(), "baseStorage", 4).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
config.get(sectionBlocksHalfDrawers2x2.getQualifiedName(), "enabled", true);
config.get(sectionBlocksHalfDrawers2x2.getQualifiedName(), "baseStorage", 2);
config.get(sectionBlocksHalfDrawers2x2.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksHalfDrawers2x2.getQualifiedName(), "baseStorage", 2).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
if (config.hasChanged())
config.save();
}
public boolean fancyItemRenderEnabled () {
public boolean isFancyItemRenderEnabled () {
if (itemRenderType.getString().equals("fancy"))
return true;
return false;
@@ -109,7 +113,19 @@ public class ConfigManager
return config.toString();
}
private String getBlockName (Block block) {
return block.getUnlocalizedName().replace("tile.", "");
public boolean isBlockEnabled (String blockName) {
if (!blockSectionsMap.containsKey(blockName))
return false;
ConfigSection section = blockSectionsMap.get(blockName);
return section.getCategory().get("enabled").getBoolean();
}
public int getBlockBaseStorage (String blockName) {
if (!blockSectionsMap.containsKey(blockName))
return 0;
ConfigSection section = blockSectionsMap.get(blockName);
return section.getCategory().get("baseStorage").getInt();
}
}
@@ -1,7 +1,9 @@
package com.jaquadro.minecraft.storagedrawers.core;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
import com.jaquadro.minecraft.storagedrawers.item.ItemDrawers;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -20,15 +22,24 @@ public class ModBlocks
halfDrawers2 = new BlockDrawers("halfDrawers2", 2, true);
halfDrawers4 = new BlockDrawers("halfDrawers4", 4, true);
GameRegistry.registerBlock(fullDrawers2, ItemDrawers.class, "fullDrawers2");
GameRegistry.registerBlock(fullDrawers4, ItemDrawers.class, "fullDrawers4");
GameRegistry.registerBlock(halfDrawers2, ItemDrawers.class, "halfDrawers2");
GameRegistry.registerBlock(halfDrawers4, ItemDrawers.class, "halfDrawers4");
ConfigManager config = StorageDrawers.config;
GameRegistry.registerTileEntity(TileEntityDrawers.class, ModBlocks.getQualifiedName(fullDrawers2));
GameRegistry.registerTileEntity(TileEntityDrawers.class, ModBlocks.getQualifiedName(fullDrawers4));
GameRegistry.registerTileEntity(TileEntityDrawers.class, ModBlocks.getQualifiedName(halfDrawers2));
GameRegistry.registerTileEntity(TileEntityDrawers.class, ModBlocks.getQualifiedName(halfDrawers4));
if (config.isBlockEnabled("fulldrawers2")) {
GameRegistry.registerBlock(fullDrawers2, ItemDrawers.class, "fullDrawers2");
GameRegistry.registerTileEntity(TileEntityDrawers.class, ModBlocks.getQualifiedName(fullDrawers2));
}
if (config.isBlockEnabled("fulldrawers4")) {
GameRegistry.registerBlock(fullDrawers4, ItemDrawers.class, "fullDrawers4");
GameRegistry.registerTileEntity(TileEntityDrawers.class, ModBlocks.getQualifiedName(fullDrawers4));
}
if (config.isBlockEnabled("halfdrawers2")) {
GameRegistry.registerBlock(halfDrawers2, ItemDrawers.class, "halfDrawers2");
GameRegistry.registerTileEntity(TileEntityDrawers.class, ModBlocks.getQualifiedName(halfDrawers2));
}
if (config.isBlockEnabled("halfdrawers4")) {
GameRegistry.registerBlock(halfDrawers4, ItemDrawers.class, "halfDrawers4");
GameRegistry.registerTileEntity(TileEntityDrawers.class, ModBlocks.getQualifiedName(halfDrawers4));
}
}
public static String getQualifiedName (Block block) {
@@ -1,8 +1,11 @@
package com.jaquadro.minecraft.storagedrawers.core;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
public final class ModCreativeTabs
@@ -13,7 +16,22 @@ public final class ModCreativeTabs
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem () {
return Item.getItemFromBlock(ModBlocks.fullDrawers2);
return getTabItem();
}
};
private static Item getTabItem () {
ConfigManager config = StorageDrawers.config;
if (config.isBlockEnabled("fulldrawers2"))
return Item.getItemFromBlock(ModBlocks.fullDrawers2);
if (config.isBlockEnabled("fulldrawers4"))
return Item.getItemFromBlock(ModBlocks.fullDrawers4);
if (config.isBlockEnabled("halfdrawers2"))
return Item.getItemFromBlock(ModBlocks.halfDrawers2);
if (config.isBlockEnabled("halfdrawers4"))
return Item.getItemFromBlock(ModBlocks.halfDrawers4);
return Item.getItemFromBlock(Blocks.chest);
}
}