Added config for overriding vanilla blocks.

This commit is contained in:
Vasco Lavos committed 2014-03-12 16:34:22 +00:00
1 parent 8462a8589e
commit fa32a76d6b
3 files changed
+34 -24

No files matched your search

@@ -18,8 +18,8 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.ForgeDirection;
import vazkii.botania.client.lib.LibRenderIDs;
import vazkii.botania.common.block.vanilla.BlockSnowOverride;
import vazkii.botania.common.core.handler.ConfigHandler;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class RenderSpecialFlower implements ISimpleBlockRenderingHandler {
@@ -66,24 +66,26 @@ public class RenderSpecialFlower implements ISimpleBlockRenderingHandler {
drawCrossedSquares(blockAccess, par1Block, par2, par3, par4, d0, d1, d2, 1.0F, render);
int snow = -1;
boolean foundSnow = false;
ForgeDirection[] directions = new ForgeDirection[] {
ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST
};
for(ForgeDirection dir : directions)
if(blockAccess.getBlockId(par2 + dir.offsetX, par3 + dir.offsetY, par4 + dir.offsetZ) == Block.snow.blockID) {
int meta = blockAccess.getBlockMetadata(par2 + dir.offsetX, par3 + dir.offsetY, par4 + dir.offsetZ);
snow = foundSnow ? Math.min(snow, meta) : meta;
foundSnow = true;
}
if(ConfigHandler.overrideVanillaBlocks) {
int snow = -1;
boolean foundSnow = false;
ForgeDirection[] directions = new ForgeDirection[] {
ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST
};
for(ForgeDirection dir : directions)
if(blockAccess.getBlockId(par2 + dir.offsetX, par3 + dir.offsetY, par4 + dir.offsetZ) == Block.snow.blockID) {
int meta = blockAccess.getBlockMetadata(par2 + dir.offsetX, par3 + dir.offsetY, par4 + dir.offsetZ);
snow = foundSnow ? Math.min(snow, meta) : meta;
foundSnow = true;
}
if(snow >= 0) {
BlockSnowOverride.forcedMeta = snow;
render.renderBlockByRenderType(Block.blocksList[Block.snow.blockID], par2, par3, par4);
}
if(snow >= 0) {
BlockSnowOverride.forcedMeta = snow;
render.renderBlockByRenderType(Block.blocksList[Block.snow.blockID], par2, par3, par4);
}
}
return true;
}
@@ -37,6 +37,7 @@ import vazkii.botania.common.block.tile.TileSpecialFlower;
import vazkii.botania.common.block.tile.TileSpreader;
import vazkii.botania.common.block.vanilla.BlockFlowerOverride;
import vazkii.botania.common.block.vanilla.BlockSnowOverride;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.lib.LibBlockNames;
import vazkii.botania.common.lib.LibOreDict;
import cpw.mods.fml.common.Loader;
@@ -89,13 +90,15 @@ public final class ModBlocks {
// Vanilla ores (because forge doesn't do this by default for some reason)
OreDictionary.registerOre("oreCoal", Block.oreCoal);
Block.blocksList[Block.snow.blockID] = null;
Block.blocksList[Block.plantRed.blockID] = null;
Block.blocksList[Block.plantYellow.blockID] = null;
if(ConfigHandler.overrideVanillaBlocks) {
Block.blocksList[Block.snow.blockID] = null;
Block.blocksList[Block.plantRed.blockID] = null;
Block.blocksList[Block.plantYellow.blockID] = null;
new BlockSnowOverride(Block.snow.blockID).setHardness(0.1F).setStepSound(Block.soundSnowFootstep).setUnlocalizedName("snow").setLightOpacity(0).setTextureName("snow");
new BlockFlowerOverride(Block.plantRed.blockID).setHardness(0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("flower").setTextureName("flower_dandelion");
new BlockFlowerOverride(Block.plantYellow.blockID).setHardness(0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("rose").setTextureName("flower_rose");
new BlockSnowOverride(Block.snow.blockID).setHardness(0.1F).setStepSound(Block.soundSnowFootstep).setUnlocalizedName("snow").setLightOpacity(0).setTextureName("snow");
new BlockFlowerOverride(Block.plantRed.blockID).setHardness(0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("flower").setTextureName("flower_dandelion");
new BlockFlowerOverride(Block.plantYellow.blockID).setHardness(0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("rose").setTextureName("flower_rose");
}
}
private static void initTileEntities() {
@@ -27,6 +27,7 @@ public final class ConfigHandler {
public static boolean lexiconRotatingItems = true;
public static boolean subtlePowerSystem = false;
public static boolean staticWandBeam = false;
public static boolean overrideVanillaBlocks = true;
public static void loadConfig(File configFile) {
config = new Configuration(configFile);
@@ -44,6 +45,10 @@ public final class ConfigHandler {
Property staticWandBeamProp = config.get(Configuration.CATEGORY_GENERAL, "wandBeam.static", false);
staticWandBeamProp.comment = "Set to true to use a static wand beam that shows every single position of the burst, similar to the way it used to work on old botania versions. Warning: Disabled by default because it may be laggy.";
staticWandBeam = staticWandBeamProp.getBoolean(false);
Property overrideVanillaBlocksProp = config.get(Configuration.CATEGORY_GENERAL, "override.vanillaBlocks", true);
overrideVanillaBlocksProp.comment = "Set to false to remove the overriding of vanilla blocks (snow, red and yellow flowers). Setting this to false will remove the snow on flowers tweak.";
overrideVanillaBlocks = overrideVanillaBlocksProp.getBoolean(true);
// Block IDs
LibBlockIDs.idFlower = loadBlock(LibBlockNames.FLOWER, LibBlockIDs.idFlower);