Seperated configurations into a new class.

This commit is contained in:
Fenn committed 2014-07-17 22:05:29 +01:00
1 parent 0eccfcda10
commit a8152e626f
12 files changed
+94 -81

No files matched your search

@@ -51,22 +51,10 @@ public class Chisel
public static boolean multipartLoaded = false;
public static boolean configExists;
public static boolean oldPillars;
public static boolean disableCTM;
public static double concreteVelocity;
public static int particlesTickrate;
public static boolean blockDescriptions;
public static boolean ghostCloud;
public static int factoryBlockAmount;
public static boolean allowMossy;
public static final StepSoundEx soundHolystoneFootstep = new StepSoundEx("chisel:holystone", "chisel:holystone", "chisel:holystone", 1.0f);
public static final StepSoundEx soundTempleFootstep = new StepSoundEx("dig.stone", "chisel:temple-footstep", "dig.stone", 1.0f);
public static final StepSoundEx soundMetalFootstep = new StepSoundEx("chisel:metal", "chisel:metal", "chisel:metal", 1.0f);
public static Configuration config;
public static int RenderEldritchId;
public static int RenderCTMId;
public static int RenderCarpetId;
@@ -77,12 +65,11 @@ public class Chisel
@SidedProxy(clientSide = "info.jbcs.minecraft.chisel.ClientProxy", serverSide = "info.jbcs.minecraft.chisel.CommonProxy")
public static CommonProxy proxy;
public static boolean chiselStoneToCobbleBricks;
public static boolean enableChiseling;
public static boolean featureEnabled(String feature)
{
return Chisel.config.get("features", feature, true).getBoolean(true);
return Configurations.config.get("features", feature, true).getBoolean(true);
}
@EventHandler
@@ -104,10 +91,10 @@ public class Chisel
public void preInit(FMLPreInitializationEvent event)
{
File configFile = event.getSuggestedConfigurationFile();
configExists = configFile.exists();
config = new Configuration(configFile);
config.load();
refreshConfig();
Configurations.configExists = configFile.exists();
Configurations.config = new Configuration(configFile);
Configurations.config.load();
Configurations.refreshConfig();
tabChisel = new CreativeTabs("tabChisel")
{
@@ -166,8 +153,8 @@ public class Chisel
});
GameRegistry.registerWorldGenerator(new ChiselWorldGenerator(ChiselBlocks.blockMarble, 32, config.get("worldgen", "marbleAmount", 8, "Amount of marble to generate in the world; use 0 for none").getInt(8)), 1000);
GameRegistry.registerWorldGenerator(new ChiselWorldGenerator(ChiselBlocks.blockLimestone, 32, config.get("worldgen", "limestoneAmount", 4, "Amount of limestone to generate in the world; use 0 for none").getInt(4)), 1000);
GameRegistry.registerWorldGenerator(new ChiselWorldGenerator(ChiselBlocks.blockMarble, 32, Configurations.config.get("worldgen", "marbleAmount", 8, "Amount of marble to generate in the world; use 0 for none").getInt(8)), 1000);
GameRegistry.registerWorldGenerator(new ChiselWorldGenerator(ChiselBlocks.blockLimestone, 32, Configurations.config.get("worldgen", "limestoneAmount", 4, "Amount of limestone to generate in the world; use 0 for none").getInt(4)), 1000);
proxy.init();
MinecraftForge.EVENT_BUS.register(this);
@@ -180,24 +167,7 @@ public class Chisel
new ChiselModCompatibility().postInit(event);
}
public static void refreshConfig()
{
concreteVelocity = config.get("general", "concreteVelocity", 0.45, "Traversing concrete roads, players will acceleration to this velocity. For reference, normal running speed is about 0.28. Set to 0 to disable acceleration.").getDouble(0.45);
particlesTickrate = config.get("client", "particleTickrate", 1, "Particle tick rate. Greater value = less particles.").getInt(1);
oldPillars = config.get("client", "pillarOldGraphics", false, "Use old pillar textures").getBoolean(false);
disableCTM = !config.get("client", "connectedTextures", true, "Enable connected textures").getBoolean(true);
blockDescriptions = config.get("client", "tooltipsUseBlockDescriptions", true, "Make variations of blocks have the same name, and use the description in tooltip to distinguish them.").getBoolean(true);
chiselStoneToCobbleBricks = config.get("general", "chiselStoneToCobbleBricks", true, "Chisel stone to cobblestone and bricks by left-click.").getBoolean(true);
enableChiseling = config.get("general", "enableChiselingLeftClicking", false, "Change blocks to another block using the Chisel and left-click.").getBoolean(false);
ghostCloud = config.get("general", "doesCloudRenderLikeGhost", true).getBoolean(true);
factoryBlockAmount = config.get("general", "amountYouGetFromFactoryBlockCrafting", 32).getInt(32);
allowMossy = config.get("general", "allowCobbleToMossyInChisel", true).getBoolean(true);
if(config.hasChanged())
{
config.save();
}
}
@SubscribeEvent
@@ -205,7 +175,7 @@ public class Chisel
{
if(event.modID.equals("chisel"))
{
Chisel.refreshConfig();
Configurations.refreshConfig();
}
}
}
@@ -130,7 +130,7 @@ public class ChiselBlocks
if(Chisel.featureEnabled("marblePillar"))
{
if(Chisel.oldPillars)
if(Configurations.oldPillars)
{
blockMarblePillar = (BlockCarvable) new BlockCarvable().setHardness(2.0F).setResistance(10F).setStepSound(Block.soundTypeStone);
blockMarblePillar.carverHelper.setChiselBlockName("Marble Pillar");
@@ -176,7 +176,7 @@ public class ChiselBlocks
blockMarblePillarSlab = (BlockMarbleSlab) new BlockMarbleSlab(blockMarblePillar).setHardness(2.0F).setResistance(10F).setStepSound(Block.soundTypeStone);
blockMarblePillarSlab.carverHelper.setChiselBlockName("Marble Pillar Slab");
if(Chisel.oldPillars)
if(Configurations.oldPillars)
{
blockMarblePillarSlab.carverHelper.addVariation(StatCollector.translateToLocal("chisel.tile.marblePillarSlabOld.0.desc"), 0, "marblepillarslabold/column");
blockMarblePillarSlab.carverHelper.addVariation(StatCollector.translateToLocal("chisel.tile.marblePillarSlabOld.1.desc"), 1, "marblepillarslabold/capstone");
@@ -631,7 +631,7 @@ public class ChiselBlocks
{
if(i == 1)
{
if(Chisel.allowMossy)
if(Configurations.allowMossy)
Carving.chisel.addVariation("stoneBrick", Blocks.stonebrick, i, i);
} else
Carving.chisel.addVariation("stoneBrick", Blocks.stonebrick, i, i);
@@ -0,0 +1,45 @@
package info.jbcs.minecraft.chisel;
import net.minecraftforge.common.config.Configuration;
/**
* Created by Pokefenn.
* Licensed under MIT (If this is one of my Mods)
*/
public class Configurations
{
public static Configuration config;
public static boolean configExists;
public static boolean oldPillars;
public static boolean disableCTM;
public static boolean blockDescriptions;
public static boolean ghostCloud;
public static boolean allowMossy;
public static boolean chiselStoneToCobbleBricks;
public static boolean enableChiseling;
public static int factoryBlockAmount;
public static int particlesTickrate;
public static double concreteVelocity;
public static void refreshConfig()
{
concreteVelocity = config.get("general", "concreteVelocity", 0.45, "Traversing concrete roads, players will acceleration to this velocity. For reference, normal running speed is about 0.28. Set to 0 to disable acceleration.").getDouble(0.45);
particlesTickrate = config.get("client", "particleTickrate", 1, "Particle tick rate. Greater value = less particles.").getInt(1);
oldPillars = config.get("client", "pillarOldGraphics", false, "Use old pillar textures").getBoolean(false);
disableCTM = !config.get("client", "connectedTextures", true, "Enable connected textures").getBoolean(true);
blockDescriptions = config.get("client", "tooltipsUseBlockDescriptions", true, "Make variations of blocks have the same name, and use the description in tooltip to distinguish them.").getBoolean(true);
chiselStoneToCobbleBricks = config.get("general", "chiselStoneToCobbleBricks", true, "Chisel stone to cobblestone and bricks by left-click.").getBoolean(true);
enableChiseling = config.get("general", "enableChiselingLeftClicking", false, "Change blocks to another block using the Chisel and left-click.").getBoolean(false);
ghostCloud = config.get("general", "doesCloudRenderLikeGhost", true).getBoolean(true);
factoryBlockAmount = config.get("general", "amountYouGetFromFactoryBlockCrafting", 32).getInt(32);
allowMossy = config.get("general", "allowCobbleToMossyInChisel", true).getBoolean(true);
if(config.hasChanged())
{
config.save();
}
}
}
@@ -16,7 +16,7 @@ public class Crafting
public static void init()
{
Block concreteRecipeBlock = Block.getBlockFromName(Chisel.config.get("tweaks", "concrete recipe block", "gravel", "Unlocalized name of the block that, when burned, will produce concrete (examples: lightgem, stone)").getString());
Block concreteRecipeBlock = Block.getBlockFromName(Configurations.config.get("tweaks", "concrete recipe block", "gravel", "Unlocalized name of the block that, when burned, will produce concrete (examples: lightgem, stone)").getString());
if(concreteRecipeBlock == null) concreteRecipeBlock = Blocks.gravel;
FurnaceRecipes.smelting().func_151393_a(concreteRecipeBlock, new ItemStack(ChiselBlocks.blockConcrete), 0.1F);
@@ -45,10 +45,10 @@ public class Crafting
GameRegistry.addRecipe(new ItemStack(ChiselBlocks.blockFft, 8, 0), new Object[]{"***", "*X*", "***", '*', new ItemStack(Blocks.stone, 1), 'X', new ItemStack(Items.gold_nugget, 1)});
GameRegistry.addRecipe(new ItemStack(ChiselBlocks.blockTyrian, 8, 0), new Object[]{"***", "*X*", "***", '*', new ItemStack(Blocks.stone, 1), 'X', new ItemStack(Items.iron_ingot, 1)});
GameRegistry.addRecipe(new ItemStack(ChiselBlocks.blockTemple, 8, 0), new Object[]{"***", "*X*", "***", '*', new ItemStack(Blocks.stone, 1), 'X', new ItemStack(Items.dye, 1, 4)});
GameRegistry.addRecipe(new ItemStack(ChiselBlocks.blockFactory, Chisel.factoryBlockAmount, 0), new Object[]{"*X*", "X X", "*X*", '*', new ItemStack(Blocks.stone, 1), 'X', new ItemStack(Items.iron_ingot, 1)});
GameRegistry.addRecipe(new ItemStack(ChiselBlocks.blockFactory, Configurations.factoryBlockAmount, 0), new Object[]{"*X*", "X X", "*X*", '*', new ItemStack(Blocks.stone, 1), 'X', new ItemStack(Items.iron_ingot, 1)});
if(Chisel.config.get("general", "chiselAlternateRecipe", false, "Use alternative crafting recipe for the chisel").getBoolean(false))
if(Configurations.config.get("general", "chiselAlternateRecipe", false, "Use alternative crafting recipe for the chisel").getBoolean(false))
{
GameRegistry.addRecipe(new ItemStack(Chisel.chisel, 1), new Object[]{" YY", " YY", "X ", 'X', Items.stick, 'Y', Items.iron_ingot});
} else
@@ -1,9 +1,7 @@
package info.jbcs.minecraft.chisel.block;
import java.util.Random;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.Configurations;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
@@ -11,13 +9,14 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.Random;
public class BlockCloud extends BlockCarvable
{
public BlockCloud()
{
super(Material.ice);
useNeighborBrightness = true;
}
@@ -45,7 +44,7 @@ public class BlockCloud extends BlockCarvable
@Override
public int getRenderBlockPass()
{
return Chisel.ghostCloud ? 1 : 0;
return Configurations.ghostCloud ? 1 : 0;
}
@@ -1,12 +1,12 @@
package info.jbcs.minecraft.chisel.block;
import info.jbcs.minecraft.chisel.Chisel;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import info.jbcs.minecraft.chisel.Configurations;
import info.jbcs.minecraft.chisel.client.GeneralChiselClient;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
public class BlockConcrete extends BlockCarvable
{
@@ -28,10 +28,10 @@ public class BlockConcrete extends BlockCarvable
{
if(FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT)
return;
if(Chisel.concreteVelocity == 0)
if(Configurations.concreteVelocity == 0)
return;
GeneralChiselClient.speedupPlayer(world, entity, Chisel.concreteVelocity);
GeneralChiselClient.speedupPlayer(world, entity, Configurations.concreteVelocity);
}
}
@@ -1,6 +1,8 @@
package info.jbcs.minecraft.chisel.block;
import info.jbcs.minecraft.chisel.Chisel;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import info.jbcs.minecraft.chisel.Configurations;
import info.jbcs.minecraft.chisel.client.GeneralChiselClient;
import info.jbcs.minecraft.chisel.client.render.BlockSpikesRenderer;
import info.jbcs.minecraft.utilities.General;
@@ -12,8 +14,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
public class BlockSpikes extends Block
{
@@ -42,7 +42,7 @@ public class BlockSpikes extends Block
double dy = entity.posY - entity.prevPosY;
GeneralChiselClient.speedupPlayer(world, entity, Chisel.concreteVelocity);
GeneralChiselClient.speedupPlayer(world, entity, Configurations.concreteVelocity);
}
@Override
@@ -2,6 +2,7 @@ package info.jbcs.minecraft.chisel.carving;
import cpw.mods.fml.common.registry.GameRegistry;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.Configurations;
import info.jbcs.minecraft.chisel.block.BlockMarbleSlab;
import info.jbcs.minecraft.chisel.carving.CarvableVariation.CarvableVariationCTM;
import info.jbcs.minecraft.chisel.client.render.CTM;
@@ -120,7 +121,7 @@ public class CarvableHelper
} else if(v4)
{
variation.kind = V4;
} else if(any && ctmx && !Chisel.disableCTM)
} else if(any && ctmx && !Configurations.disableCTM)
{
variation.kind = CTMX;
} else if(any)
@@ -1,6 +1,6 @@
package info.jbcs.minecraft.chisel.client;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.Configurations;
import info.jbcs.minecraft.chisel.block.BlockHolystone;
import info.jbcs.minecraft.chisel.block.BlockLavastone;
import info.jbcs.minecraft.chisel.block.BlockSnakestoneObsidian;
@@ -8,9 +8,6 @@ import info.jbcs.minecraft.chisel.entity.EntityBallOMossFX;
import info.jbcs.minecraft.chisel.entity.EntityHolystoneFX;
import info.jbcs.minecraft.chisel.entity.EntitySnakestoneObsidianFX;
import info.jbcs.minecraft.utilities.GeneralClient;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
@@ -20,6 +17,8 @@ import net.minecraft.client.particle.EntityLavaFX;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import java.util.Random;
public class GeneralChiselClient
{
@@ -28,7 +27,7 @@ public class GeneralChiselClient
public static void spawnLavastoneFX(World world, BlockLavastone block, int x, int y, int z)
{
if(Chisel.particlesTickrate != 0 && tick++ % Chisel.particlesTickrate != 0) return;
if(Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0) return;
float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
@@ -79,7 +78,7 @@ public class GeneralChiselClient
public static void spawnHolystoneFX(World world, BlockHolystone block, int x, int y, int z)
{
if(Chisel.particlesTickrate != 0 && tick++ % Chisel.particlesTickrate != 0) return;
if(Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0) return;
float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX();
@@ -122,7 +121,7 @@ public class GeneralChiselClient
public static void spawnSnakestoneObsidianFX(World world, BlockSnakestoneObsidian block, int x, int y, int z)
{
if(Chisel.particlesTickrate == 0 || tick++ % Chisel.particlesTickrate == 0)
if(Configurations.particlesTickrate == 0 || tick++ % Configurations.particlesTickrate == 0)
{
EntitySnakestoneObsidianFX res = new EntitySnakestoneObsidianFX(world, block, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(res);
@@ -131,7 +130,7 @@ public class GeneralChiselClient
public static void spawnBallOMossFX(World world, double x, double y, double z)
{
if(Chisel.particlesTickrate == 0 || tick++ % Chisel.particlesTickrate == 0)
if(Configurations.particlesTickrate == 0 || tick++ % Configurations.particlesTickrate == 0)
{
EntityBallOMossFX res = new EntityBallOMossFX(world, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(res);
@@ -209,15 +208,15 @@ public class GeneralChiselClient
if(!(entity instanceof EntityPlayerSP)) return;
if(velocity == 0) return;
if(velocity >= Chisel.concreteVelocity) return;
if(velocity >= Configurations.concreteVelocity) return;
EntityPlayerSP player = (EntityPlayerSP) entity;
if(Math.abs(player.movementInput.moveForward) < 0.75f && Math.abs(player.movementInput.moveStrafe) < 0.75f)
return;
entity.motionX = Chisel.concreteVelocity * entity.motionX / velocity;
entity.motionZ = Chisel.concreteVelocity * entity.motionZ / velocity;
entity.motionX = Configurations.concreteVelocity * entity.motionX / velocity;
entity.motionZ = Configurations.concreteVelocity * entity.motionZ / velocity;
}
}
@@ -1,7 +1,7 @@
package info.jbcs.minecraft.chisel.client.gui;
import cpw.mods.fml.client.config.GuiConfig;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.Configurations;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
@@ -11,7 +11,6 @@ public class GuiChiselConfig extends GuiConfig
public GuiChiselConfig(GuiScreen parent)
{
super(parent, new ConfigElement(Chisel.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
"chisel", false, false, GuiConfig.getAbridgedConfigPath(Chisel.config.toString()));
super(parent, new ConfigElement(Configurations.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), "chisel", false, false, GuiConfig.getAbridgedConfigPath(Configurations.config.toString()));
}
}
@@ -1,12 +1,9 @@
package info.jbcs.minecraft.chisel.item;
import info.jbcs.minecraft.chisel.Configurations;
import info.jbcs.minecraft.chisel.api.ICarvable;
import info.jbcs.minecraft.chisel.carving.CarvableVariation;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.utilities.General;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@@ -14,6 +11,8 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import java.util.List;
public class ItemCarvable extends ItemBlock
{
@@ -46,7 +45,7 @@ public class ItemCarvable extends ItemBlock
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips)
{
if(!Chisel.blockDescriptions) return;
if(!Configurations.blockDescriptions) return;
Item item = General.getItem(stack);
if(item == null) return;
@@ -3,6 +3,7 @@ package info.jbcs.minecraft.chisel.item;
import cpw.mods.fml.common.FMLCommonHandler;
import info.jbcs.minecraft.chisel.Chisel;
import info.jbcs.minecraft.chisel.ChiselBlocks;
import info.jbcs.minecraft.chisel.Configurations;
import info.jbcs.minecraft.chisel.carving.CarvableHelper;
import info.jbcs.minecraft.chisel.carving.Carving;
import info.jbcs.minecraft.chisel.carving.CarvingVariation;
@@ -61,7 +62,7 @@ public class ItemChisel extends ItemTool
@Override
public boolean onBlockStartBreak(ItemStack stack, final int x, final int y, final int z, EntityPlayer player)
{
if(!Chisel.enableChiseling) return true;
if(!Configurations.enableChiseling) return true;
World world = player.worldObj;
Block block = world.getBlock(x, y, z);
@@ -123,7 +124,7 @@ public class ItemChisel extends ItemTool
result = target;
/* special case: stone can be carved to cobble and bricks */
if(Chisel.chiselStoneToCobbleBricks)
if(Configurations.chiselStoneToCobbleBricks)
{
if(!match && block.equals(Blocks.stone) && Block.getBlockFromItem(target).equals(ChiselBlocks.blockCobblestone))
match = true;