-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
228 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/mods/betterfoliage/client/gui/ConfigGuiAlgae.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package mods.betterfoliage.client.gui; | ||
|
||
import mods.betterfoliage.BetterFoliage; | ||
import mods.betterfoliage.client.gui.widget.OptionDoubleWidget; | ||
import mods.betterfoliage.client.gui.widget.OptionIntegerWidget; | ||
import net.minecraft.client.gui.GuiButton; | ||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraft.client.resources.I18n; | ||
import cpw.mods.fml.client.FMLClientHandler; | ||
|
||
public class ConfigGuiAlgae extends ConfigGuiScreenBase { | ||
|
||
public ConfigGuiAlgae(GuiScreen parent) { | ||
super(parent); | ||
int id = 10; | ||
widgets.add(new OptionDoubleWidget(BetterFoliage.config.algaeHOffset, -100, -70, 200, 50, id++, id++, "message.betterfoliage.hOffset", "%.3f")); | ||
widgets.add(new OptionDoubleWidget(BetterFoliage.config.algaeSize, -100, -40, 200, 50, id++, id++, "message.betterfoliage.size", "%.2f")); | ||
widgets.add(new OptionDoubleWidget(BetterFoliage.config.algaeHeightMin, -100, -10, 200, 50, id++, id++, "message.betterfoliage.minHeight", "%.2f")); | ||
widgets.add(new OptionDoubleWidget(BetterFoliage.config.algaeHeightMax, -100, 20, 200, 50, id++, id++, "message.betterfoliage.maxHeight", "%.2f")); | ||
widgets.add(new OptionIntegerWidget(BetterFoliage.config.algaeChance, -100, 50, 200, 50, id++, id++, "message.betterfoliage.algaeChance")); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public void addButtons(int x, int y) { | ||
buttonList.add(new GuiButton(0, x - 50, y + 100, 100, 20, I18n.format("message.betterfoliage.back"))); | ||
} | ||
|
||
@Override | ||
protected void onButtonPress(int id) { | ||
if (id == 0) FMLClientHandler.instance().showGuiScreen(parent); | ||
|
||
if (BetterFoliage.config.algaeHeightMin.value > BetterFoliage.config.algaeHeightMax.value) BetterFoliage.config.algaeHeightMin.value = BetterFoliage.config.algaeHeightMax.value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/java/mods/betterfoliage/client/render/FakeRenderBlockAOBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/java/mods/betterfoliage/client/render/IRenderBlockDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/mods/betterfoliage/client/render/impl/RenderBlockBetterAlgae.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package mods.betterfoliage.client.render.impl; | ||
|
||
import java.util.Random; | ||
|
||
import mods.betterfoliage.BetterFoliage; | ||
import mods.betterfoliage.client.render.IRenderBlockDecorator; | ||
import mods.betterfoliage.client.render.IconSet; | ||
import mods.betterfoliage.client.render.RenderBlockAOBase; | ||
import mods.betterfoliage.common.util.Double3; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockDirt; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.client.renderer.RenderBlocks; | ||
import net.minecraft.client.renderer.Tessellator; | ||
import net.minecraft.util.IIcon; | ||
import net.minecraft.util.MathHelper; | ||
import net.minecraft.world.IBlockAccess; | ||
import net.minecraft.world.gen.NoiseGeneratorSimplex; | ||
import net.minecraftforge.client.event.TextureStitchEvent; | ||
import net.minecraftforge.common.util.ForgeDirection; | ||
import net.minecraftforge.event.world.WorldEvent; | ||
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
import cpw.mods.fml.relauncher.Side; | ||
import cpw.mods.fml.relauncher.SideOnly; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class RenderBlockBetterAlgae extends RenderBlockAOBase implements IRenderBlockDecorator { | ||
|
||
public IconSet algaeIcons = new IconSet("bettergrassandleaves", "better_algae_%d"); | ||
public NoiseGeneratorSimplex noise; | ||
|
||
public boolean isBlockAccepted(IBlockAccess blockAccess, int x, int y, int z, Block block, int original) { | ||
if (!BetterFoliage.config.algaeEnabled) return false; | ||
if (y >= 254 || !(block instanceof BlockDirt)) return false; | ||
if (blockAccess.getBlock(x, y + 1, z).getMaterial() != Material.water) return false; | ||
if (blockAccess.getBlock(x, y + 2, z).getMaterial() != Material.water) return false; | ||
if (blockAccess.getBiomeGenForCoords(x, z).temperature < 0.4f) return false; | ||
int terrainVariation = MathHelper.floor_double((noise.func_151605_a(x, z) + 1.0) * 32.0); | ||
return terrainVariation < BetterFoliage.config.algaeChance.value; | ||
} | ||
|
||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { | ||
// store world for later use | ||
blockAccess = world; | ||
|
||
// render grass block | ||
setPassCounters(1); | ||
setRenderBoundsFromBlock(block); | ||
renderStandardBlock(block, x, y, z); | ||
|
||
int variation = getSemiRandomFromPos(x, y, z, 0); | ||
int heightVariation = getSemiRandomFromPos(x, y, z, 1); | ||
|
||
IIcon renderIcon = algaeIcons.get(variation); | ||
if (renderIcon == null) return true; | ||
|
||
double scale = BetterFoliage.config.algaeSize.value * 0.5; | ||
double halfHeight = 0.5 * (BetterFoliage.config.algaeHeightMin.value + pRand[heightVariation] * (BetterFoliage.config.algaeHeightMax.value - BetterFoliage.config.algaeHeightMin.value)); | ||
Tessellator.instance.setBrightness(getBrightness(block, x, y + 1, z)); | ||
renderCrossedSideQuads(new Double3(x + 0.5, y + 1.0 - 0.125 * halfHeight, z + 0.5), ForgeDirection.UP, scale, halfHeight, pRot[variation], BetterFoliage.config.algaeHOffset.value, renderIcon, 0, false); | ||
|
||
return true; | ||
} | ||
|
||
@SubscribeEvent | ||
public void handleTextureReload(TextureStitchEvent.Pre event) { | ||
if (event.map.getTextureType() != 0) return; | ||
|
||
algaeIcons.registerIcons(event.map); | ||
BetterFoliage.log.info(String.format("Found %d algae textures", algaeIcons.numLoaded)); | ||
} | ||
|
||
@SubscribeEvent | ||
public void handleWorldLoad(WorldEvent.Load event) { | ||
noise = new NoiseGeneratorSimplex(new Random(event.world.getWorldInfo().getSeed() + 1)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.