Various config changes

master
einsteinsci 2015-08-18 11:12:18 -07:00
parent f4b411ee7c
commit f283ce6c5b
9 changed files with 148 additions and 172 deletions

View File

@ -7,60 +7,79 @@ import java.util.*;
public class BBConfig
{
public static final String GENERAL = Configuration.CATEGORY_GENERAL;
public static final String CRAFTING = "crafting";
public static final String CRAFTING = "otherCrafting";
public static final String SMELTING = "smelting";
public static final String MOBDROPS = "mobdrops";
public static final String WORLDGEN = "worldgen";
public static final String TWEAKS = "tweaks";
public static boolean greetUser;
public static boolean debugLogging;
public static boolean moduleBlockBreaking;
public static boolean moduleAdvancedCrafting;
public static boolean moduleInfusionRepair;
public static boolean moduleCampfire;
public static boolean advancedCraftingForLotsOfThings;
public static boolean requireAdvancedCrafting;
public static boolean removeCraftedFoodRecipes;
public static boolean canMakeVanillaWorkbench;
public static boolean canMakeVanillaFurnace;
public static boolean canMakeChainArmor;
public static boolean removeWoodToolRecipes;
public static boolean flamingAnimalsDropCharredMeat;
public static boolean spidersDropString;
public static boolean moreBones;
public static boolean moreBonesPeacefulOnly;
public static boolean spawnMarshmallows;
public static boolean canSmelterDoKilnStuff;
public static boolean removeSmeltingRecipes;
public static boolean removeOnlyVanillaSmeltingRecipes;
public static boolean makeStuffStackable;
public static boolean canCampfireDoAllKilnStuff;
public static boolean makeStuffStackable;
public static boolean noDamageOnBadBreak;
public static List<String> alwaysBreakable;
public static List<String> alsoAxes;
public static List<String> alsoPickaxes;
public static List<String> alsoKnives;
//public static List<String> alsoAxes;
//public static List<String> alsoPickaxes;
//public static List<String> alsoKnives;
public static void initialize()
{
greetUser = true;
debugLogging = false;
moduleBlockBreaking = true;
moduleAdvancedCrafting = true;
moduleInfusionRepair = true;
moduleCampfire = true;
advancedCraftingForLotsOfThings = true;
requireAdvancedCrafting = true;
removeCraftedFoodRecipes = true;
canMakeVanillaWorkbench = false;
canMakeVanillaFurnace = false;
canMakeVanillaFurnace = true;
canMakeChainArmor = true;
removeWoodToolRecipes = true;
flamingAnimalsDropCharredMeat = true;
spidersDropString = false;
moreBones = true;
moreBonesPeacefulOnly = true;
spawnMarshmallows = true;
canSmelterDoKilnStuff = false;
removeSmeltingRecipes = true;
removeOnlyVanillaSmeltingRecipes = true;
makeStuffStackable = true;
canCampfireDoAllKilnStuff = false;
alwaysBreakable = new ArrayList<String>();
alsoAxes = new ArrayList<String>();
alsoPickaxes = new ArrayList<String>();
alsoKnives = new ArrayList<String>();
makeStuffStackable = true;
noDamageOnBadBreak = false;
alwaysBreakable = new ArrayList<>();
//alsoAxes = new ArrayList<>();
//alsoPickaxes = new ArrayList<>();
//alsoKnives = new ArrayList<>();
}
public static void syncConfig(Configuration config)
@ -72,84 +91,69 @@ public class BBConfig
// General
greetUser = config.getBoolean("Greet user", GENERAL, true, "Greet user upon login");
debugLogging = config.getBoolean("Debug logging", GENERAL, false, "Log all kinds of stuff, for debug purposes");
flamingAnimalsDropCharredMeat = config.getBoolean("Burn, Baby, Burn", GENERAL, true,
"Animals that die by flame drop charred meat instead of vanilla cooked meat");
spidersDropString = config.getBoolean("Spiders drop string", GENERAL, false,
"Spiders drop vanilla string as well as silk.");
moreBones = config.getBoolean("All bones", GENERAL, true,
"Almost all mobs drop bones, not just skeletons");
moreBonesPeacefulOnly = config.getBoolean("More bones only works on peaceful", GENERAL, true,
"Non-skeleton mobs only drop bones on peaceful. Requires" +
" 'All bones' to be true in order to do anything.");
spawnMarshmallows = config.getBoolean("Generate marshmallows", GENERAL, true,
"Marshmallows spawn in dungeons, mineshafts, desert temples, " +
"and jungle temples.");
makeStuffStackable = config.getBoolean("Make stuff stackable", GENERAL, true,
"Makes items that should be stackable (doors, " +
"minecarts, potions) stackable.");
moduleBlockBreaking = config.getBoolean("Module - Block breaking", GENERAL, true,
"Enable BetterBeginnings block breaking mechanics. Set to false for vanilla mechanics.");
moduleAdvancedCrafting = config.getBoolean("Module - Force Advanced crafting", GENERAL, true,
"Disable vanilla crafting for some recipes that require advanced crafting table.");
moduleInfusionRepair = config.getBoolean("Module - Infusion Repair", GENERAL, true,
"Enable Infusion Repair Table recipe. Set to false to force anvil repairs.");
moduleCampfire = config.getBoolean("Module - Campfire", GENERAL, true,
"Enable Campfire recipe. Set to false to make the beginning even harder.");
// Mob Drops
flamingAnimalsDropCharredMeat = config.getBoolean("Burn, Baby Burn", MOBDROPS, true,
"Animals that die by flame drop charred meat instead of vanilla cooked meat");
spidersDropString = config.getBoolean("Spiders drop string", MOBDROPS, false,
"Spiders drop vanilla string as well as silk.");
moreBones = config.getBoolean("All bones", MOBDROPS, true, "Almost all mobs drop bones, not just skeletons.");
moreBonesPeacefulOnly = config.getBoolean("More bones only works on peaceful", MOBDROPS, true,
"Non-skeleton mobs only drop bones on peaceful. Requires 'All bones' to be true in order to do anything.");
// Worldgen
spawnMarshmallows = config.getBoolean("Generate marshmallows", WORLDGEN, true,
"[WIP] Marshmallows spawn in dungeons, mineshafts, desert temples, and jungle temples.");
// Tweaks
makeStuffStackable = config.getBoolean("Make stuff stackable", TWEAKS, true,
"Makes items that should be stackable (minecarts, potions, etc.) stackable.");
noDamageOnBadBreak = config.getBoolean("No damage on wrong block breaking", TWEAKS, false,
"Set to true to disable damage when breaking certain blocks with your hands/face.");
// Crafting
advancedCraftingForLotsOfThings = config.getBoolean("Advanced crafting for lots of things", CRAFTING, true,
"Require Advanced Crafting for things like doors, " +
"pistons, chests, etc.");
requireAdvancedCrafting = config.getBoolean("Require Advanced Crafting", CRAFTING, true,
"Disable vanilla crafting for recipes that require advanced " +
"crafting table. Setting this to false sort of makes " +
"this part of the mod pointless.");
"Require Advanced Crafting for things like doors, pistons, chests, etc.");
removeCraftedFoodRecipes = config.getBoolean("Remove Crafted Food Recipes", CRAFTING, true,
"Remove crafting recipes of vanilla food items, enforcing the " +
"use of the ovens.");
canMakeVanillaWorkbench = config.getBoolean("Enable vanilla workbench recipe", CRAFTING, true,
"Provide alternative recipe for vanilla crafting table");
"Remove crafting recipes of vanilla food items, enforcing the use of the brick ovens.");
canMakeVanillaFurnace = config.getBoolean("Enable vanilla furnace recipe", CRAFTING, true,
"Provide alternative recipe for vanilla furnace");
"Provide alternative recipe for vanilla furnace");
canMakeChainArmor = config.getBoolean("Enable chain armor", CRAFTING, true,
"Allow vanilla chain armor to be craftable from iron nuggets");
"Allow vanilla chain armor to be craftable from iron nuggets");
removeWoodToolRecipes = config.getBoolean("Remove wooden tool recipes", CRAFTING, true,
"Remove recipes for wooden pickaxe, axe, shovel, and hoe.");
"Remove recipes for wooden pickaxe, axe, shovel, and hoe.");
// Smelting
canSmelterDoKilnStuff = config.getBoolean("Smelter can make kiln products", SMELTING, false,
"Allow smelter to make glass, bricks, smooth stone, etc.");
"Allow smelter to make glass, bricks, smooth stone, etc.");
removeSmeltingRecipes = config.getBoolean("Disable vanilla smelting", SMELTING, true,
"Remove recipes that normally use the vanilla furnace");
"Remove recipes that normally use the vanilla furnace");
removeOnlyVanillaSmeltingRecipes = config.getBoolean("Only remove smelting recipes for vanilla items",
SMELTING, true,
"Only remove furnace recipes for vanilla items/blocks. " +
"Requires 'Disable vanilla smelting'.");
canCampfireDoAllKilnStuff = config.getBoolean("Can campfire handle all kiln smelting", SMELTING, true,
"Allow campfire to process all recipes kiln can, instead of " +
"just a few.");
SMELTING, true, "Only remove furnace recipes for vanilla items/blocks. Requires" +
" 'Disable vanilla smelting'.");
canCampfireDoAllKilnStuff = config.getBoolean("Allow campfire to use all kiln recipes", SMELTING, false,
"Allow campfire to process all recipes kiln can, instead of just a few.");
////////////
// Arrays //
////////////
String[] _alwaysBreakable = config.getStringList("Always breakable", GENERAL, new String[] {},
"List of blocks always breakable. Use this format: " +
"List of blocks to always be breakable. Use this format: " +
"'modid:blockName'.");
alwaysBreakable.clear();
Collections.addAll(alwaysBreakable, _alwaysBreakable);
String[] _alsoAxes = config.getStringList("Also axes", GENERAL, new String[] {},
"List of items that qualify as axes for breakable checks. " +
"Use this format: 'modid:itemName'.");
alsoAxes.clear();
Collections.addAll(alsoAxes, _alsoAxes);
String[] _alsoPickaxes = config.getStringList("Also pickaxes", GENERAL, new String[] {},
"List of items that qualify as pickaxes for breakable checks. " +
"Use this format: 'modid:itemName'.");
alsoPickaxes.clear();
Collections.addAll(alsoPickaxes, _alsoPickaxes);
String[] _alsoKnives = config.getStringList("Also knives", GENERAL, new String[] {},
"List of items that qualify as knives for breakable checks. " +
"Use this format: 'modid:itemName'.");
alsoKnives.clear();
Collections.addAll(alsoKnives, _alsoKnives);
//////////
// Save //
//////////

View File

@ -44,7 +44,8 @@ public class BBEventHandler
{
if (BBConfig.greetUser)
{
ChatUtil.sendModChatToPlayer(e.player, ChatUtil.LIME + "Better Beginnings loaded successfully.");
ChatUtil.sendModChatToPlayer(e.player, ChatUtil.LIME + "Better Beginnings " + ModMain.VERSION +
" loaded successfully.");
}
}
@ -115,6 +116,8 @@ public class BBEventHandler
wip.add(new ItemStack(RegisterItems.roastingStick));
wip.add(new ItemStack(RegisterItems.roastingStickRawMallow));
wip.add(new ItemStack(RegisterItems.roastingStickCookedMallow));
wip.add(new ItemStack(RegisterItems.fireBow));
wip.add(new ItemStack(RegisterBlocks.campfire));
for (ItemStack test : wip)
{

View File

@ -1,9 +1,11 @@
package net.einsteinsci.betterbeginnings.event;
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.config.BBConfig;
import net.einsteinsci.betterbeginnings.items.ItemKnife;
import net.einsteinsci.betterbeginnings.util.ChatUtil;
import net.minecraft.block.Block;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
@ -15,15 +17,29 @@ import java.util.Map;
public class BlockBreakHelper
{
// Stores the last block the player failed to break.
public static final Map<EntityPlayer, BlockPos> brokenOnce = new HashMap<>();
// returns whether to cancel drops or not
// This is the magic function
public static void handleBlockBreaking(BlockEvent.BreakEvent e)
{
if (!BBConfig.moduleBlockBreaking)
{
return;
}
Block block = e.state.getBlock();
EntityPlayer player = e.getPlayer();
ItemStack heldItemStack = player.getHeldItem();
for (String blockID : BBConfig.alwaysBreakable)
{
if (block.getUnlocalizedName().equals(blockID))
{
return;
}
}
if (player.capabilities.isCreativeMode)
{
return;
@ -52,16 +68,14 @@ public class BlockBreakHelper
if (heldItemStack != null)
{
if (heldItemStack.getItem() instanceof ItemKnife &&
ItemKnife.getBreakable().contains(block))
if (heldItemStack.getItem() instanceof ItemKnife && ItemKnife.getBreakable().contains(block))
{
return; // allows knife to do stuff.
}
}
if (neededToolClass == null ||
neededToolClass.equalsIgnoreCase("shovel") ||
neededToolClass.equalsIgnoreCase("null"))
if (neededToolClass == null || neededToolClass.equalsIgnoreCase("shovel") ||
neededToolClass.equalsIgnoreCase("null"))
{
return;
}
@ -77,7 +91,7 @@ public class BlockBreakHelper
{
if (usedToolClass == null || usedToolClass.equalsIgnoreCase("null"))
{
if (e.world.getDifficulty() != EnumDifficulty.PEACEFUL)
if (e.world.getDifficulty() != EnumDifficulty.PEACEFUL && !BBConfig.noDamageOnBadBreak)
{
player.attackEntityFrom(new DamageSourceFace(block), 6.0f);
}
@ -85,7 +99,7 @@ public class BlockBreakHelper
if (!brokenOnce.containsKey(player) || brokenOnce.get(player) == null ||
!brokenOnce.get(player).equals(e.pos))
{
ChatUtil.sendModChatToPlayer(player, "Almost. Once more should do it.");
ChatUtil.sendModChatToPlayer(player, I18n.format("blockbreak.fail"));
brokenOnce.put(player, e.pos);
// skip other notification
@ -94,14 +108,14 @@ public class BlockBreakHelper
}
else
{
ChatUtil.sendModChatToPlayer(player, "Ouch! But at least it worked.");
ChatUtil.sendModChatToPlayer(player, I18n.format("blockbreak.success"));
brokenOnce.put(player, null);
}
ModMain.Log(Level.INFO, "Block break failed for " + stackName + " on " + block.getUnlocalizedName());
ModMain.Log(Level.INFO, " Required tool class: " + neededToolClass + ", supplied: " + usedToolClass);
ModMain.Log(Level.INFO, " Minimum harvest level: " + neededHarvestLevel + ", supplied: " +
usedHarvestLevel);
usedHarvestLevel);
}
else
{
@ -114,11 +128,11 @@ public class BlockBreakHelper
ModMain.Log(Level.INFO, "Block break failed for " + stackName + " on " + block.getUnlocalizedName());
ModMain.Log(Level.INFO, " Required tool class: " + neededToolClass + ", supplied: " + usedToolClass);
ModMain.Log(Level.INFO, " Minimum harvest level: " + neededHarvestLevel + ", supplied: " +
usedHarvestLevel);
usedHarvestLevel);
ChatUtil.sendModChatToPlayer(player, "Wrong tool!");
ChatUtil.sendModChatToPlayer(player,
"Requires " + getToolLevelName(neededHarvestLevel) + " " + neededToolClass);
ChatUtil.sendModChatToPlayer(player, I18n.format("blockbreak.wrongtool"));
ChatUtil.sendModChatToPlayer(player, I18n.format("blockbreak.wrongtool.message",
getToolLevelName(neededHarvestLevel), neededToolClass));
e.setCanceled(true);
}

View File

@ -3,6 +3,7 @@ package net.einsteinsci.betterbeginnings.register;
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.blocks.*;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.logging.log4j.Level;
@ -59,37 +60,11 @@ public class RegisterBlocks
RegisterHelper.registerBlock(enderSmelterLit);
oreDictionary();
loadAllBlocks();
}
public static void oreDictionary()
{
OreDictionary.registerOre("craftingTableWood", doubleWorkbench);
}
private static void loadAllBlocks()
{
List<Field> fields = new ArrayList<>();
Field[] allFields = RegisterBlocks.class.getFields();
for (Field f : allFields)
{
if (Block.class.isAssignableFrom(f.getType()) &&
IBBName.class.isAssignableFrom(f.getType()))
{
fields.add(f);
}
}
for (Field f : fields)
{
try
{
allBlocks.add((Block)f.get(null));
}
catch (Exception e)
{
ModMain.Log(Level.ERROR, "Field " + f.getName() + " does not inherit from Block.");
}
}
OreDictionary.registerOre("craftingTableWood", Blocks.crafting_table);
}
}

View File

@ -14,11 +14,13 @@ public class RegisterHelper
public static <T extends Item & IBBName> void registerItem(T item)
{
GameRegistry.registerItem(item, item.getName());
RegisterItems.allItems.add(item);
}
public static <T extends Block & IBBName> void registerBlock(T block)
{
GameRegistry.registerBlock(block, block.getName());
RegisterBlocks.allBlocks.add(block);
}
public static void registerSmelterOreRecipe(String input, ItemStack output, float experience, int gravel, int bonus,

View File

@ -92,7 +92,6 @@ public class RegisterItems
RegisterHelper.registerItem(noobWoodSword);
oreDictRegistry();
loadAllItems();
}
public static void oreDictRegistry()
@ -109,32 +108,6 @@ public class RegisterItems
OreDictionary.registerOre("itemString", new ItemStack(twine));
}
private static void loadAllItems()
{
List<Field> fields = new ArrayList<>();
Field[] allFields = RegisterItems.class.getFields();
for (Field f : allFields)
{
if (Item.class.isAssignableFrom(f.getType()) &&
IBBName.class.isAssignableFrom(f.getType()))
{
fields.add(f);
}
}
for (Field f : fields)
{
try
{
allItems.add((Item)f.get(null));
}
catch (Exception e)
{
ModMain.Log(Level.ERROR, "Field " + f.getName() + " does not inherit from Item.");
}
}
}
public static void tweakVanilla()
{
((ItemFood)GameRegistry.findItem("minecraft", "beef")).setPotionEffect(17, 20, 0, 20);

View File

@ -191,6 +191,7 @@ public class RegisterRecipes
public static void addAdvancedRecipes()
{
// region advancedCraftingForLotsOfThings
if (BBConfig.advancedCraftingForLotsOfThings)
{
// Wooden Doors
@ -348,8 +349,7 @@ public class RegisterRecipes
'/', "stickWood");
// Enchanting Table
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.enchanting_table),
new Object[] {new ItemStack(Items.leather),
"dyeRed", 1, "dyeBlue", 1},
new Object[] {new ItemStack(Items.leather), "dyeRed", 2, "gemLapis", 4},
" B ", "D#D", "###",
'B', Items.book,
'D', "gemDiamond",
@ -434,7 +434,7 @@ public class RegisterRecipes
new Object[] {"dustRedstone", 2},
" R ", "R#R", " R ",
'R', "dustRedstone",
'#', Blocks.glowstone);
'#', "glowstone");
// Ender Chest
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.ender_chest),
@ -487,6 +487,7 @@ public class RegisterRecipes
'/', "stickWood",
'-', new ItemStack(Blocks.stone_slab, 1, 0));
}
// endregion
// Bow
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.bow),
@ -830,15 +831,27 @@ public class RegisterRecipes
'D', "gemDiamond",
'/', "stickWood");
// Repair Infusion Station
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterBlocks.infusionRepairStation),
new Object[] {"dustRedstone", 32, "dyeBlue", 32,
new ItemStack(Items.blaze_powder, 16)},
"DID", "OSO", "OOO",
'D', "gemDiamond",
'I', "blockIron",
'S', Blocks.bookshelf,
'O', Blocks.obsidian);
if (BBConfig.moduleInfusionRepair)
{
// Repair Infusion Station
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterBlocks.infusionRepairStation),
new Object[]{
"dustRedstone", 32, "gemLapis", 32,
new ItemStack(Items.blaze_powder, 16)
},
"DID", "OSO", "OOO",
'D', "gemDiamond",
'I', "blockIron",
'S', Blocks.bookshelf,
'O', Blocks.obsidian);
// Infusion Scroll
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.infusionScroll),
new Object[] { "gemDiamond", 2, "stickWood", 2 },
"PPP", "RPR", "PPP",
'P', Items.paper,
'R', "dustRedstone");
}
// Obsidian Kiln
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterBlocks.obsidianKiln),
@ -878,13 +891,6 @@ public class RegisterRecipes
"/ ", " II",
'/', "stickWood",
'I', "ingotIron");
// Infusion Scroll
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.infusionScroll),
new Object[] { "gemDiamond", 2, "stickWood", 2 },
"PPP", "RPR", "PPP",
'P', Items.paper,
'R', "dustRedstone");
}
public static void addShapedRecipes()
@ -959,28 +965,22 @@ public class RegisterRecipes
}
// Craft vanilla benches into BB workbenches
//GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RegisterBlocks.doubleWorkbench, 2), "##", '#',
// "craftingTableWood"));
GameRegistry.addShapedRecipe(new ItemStack(RegisterBlocks.doubleWorkbench, 2), "##", '#',
Blocks.crafting_table);
// Craft BB workbenches into vanilla ones
if (BBConfig.canMakeVanillaWorkbench)
{
GameRegistry.addShapedRecipe(
new ItemStack(Blocks.crafting_table), "#", '#', RegisterBlocks.doubleWorkbench);
}
GameRegistry.addShapedRecipe(new ItemStack(Blocks.crafting_table), "#", '#', RegisterBlocks.doubleWorkbench);
// Campfire
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RegisterBlocks.campfire),
"//", "ss",
'/', "stickWood",
's', "itemString"));
"//", "ss",
'/', "stickWood",
's', "itemString"));
// Fire Bow
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RegisterItems.fireBow),
"//", "/s",
'/', "stickWood",
's', "itemString"));
"//", "/s",
'/', "stickWood",
's', "itemString"));
}
}

View File

@ -31,7 +31,7 @@ public class RemoveRecipes
}
// Advanced Crafting
if (BBConfig.requireAdvancedCrafting)
if (BBConfig.moduleAdvancedCrafting)
{
if (BBConfig.advancedCraftingForLotsOfThings)
{

View File

@ -112,3 +112,8 @@ achievement.notchApple=Food of the Gods
achievement.notchApple.desc=Bake an enchanted golden apple
death.face=%1$s broke their face on a %2$s
blockbreak.fail=Almost. Once more should do it.
blockbreak.success=Ouch! But at least it worked.
blockbreak.wrongtool=Wrong tool!
blockbreak.wrongtool.message=Requires %1$s %2$s.