mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 19:59:36 +00:00
Let it snow~
This commit is contained in:
1 parent
083a84a31f
commit
ecab978c5e
4 files changed
+65
-1
No files matched your search
@@ -17,7 +17,9 @@ import net.minecraft.client.renderer.RenderBlocks;
|
||||
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.BlockSnowNew;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
public class RenderSpecialFlower implements ISimpleBlockRenderingHandler {
|
||||
@@ -33,7 +35,7 @@ public class RenderSpecialFlower implements ISimpleBlockRenderingHandler {
|
||||
}
|
||||
|
||||
// Copied from RenderBlocks
|
||||
public boolean renderCrossedSquares(IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, RenderBlocks render) {
|
||||
public boolean renderCrossedSquares(IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, RenderBlocks render) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(blockAccess, par2, par3, par4));
|
||||
float f = 1.0F;
|
||||
@@ -57,6 +59,26 @@ public class RenderSpecialFlower implements ISimpleBlockRenderingHandler {
|
||||
double d2 = par4;
|
||||
|
||||
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(snow >= 0) {
|
||||
BlockSnowNew.forcedMeta = snow;
|
||||
render.renderBlockByRenderType(Block.blocksList[Block.snow.blockID], par2, par3, par4);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import vazkii.botania.api.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.BotaniaCreativeTab;
|
||||
import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
|
||||
@@ -78,6 +79,11 @@ public class BlockModFlower extends BlockFlower implements ILexiconable {
|
||||
public Icon getIcon(int par1, int par2) {
|
||||
return icons[par2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return LibRenderIDs.idSpecialFlower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Mar 12, 2014, 4:08:35 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import net.minecraft.block.BlockSnow;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockSnowNew extends BlockSnow {
|
||||
|
||||
public static int forcedMeta = -1;
|
||||
|
||||
protected BlockSnowNew(int par1) {
|
||||
super(par1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
|
||||
if(forcedMeta != -1) {
|
||||
setBlockBoundsForSnowDepth(forcedMeta);
|
||||
forcedMeta = -1;
|
||||
} else super.setBlockBoundsBasedOnState(par1IBlockAccess, par2, par3, par4);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -86,6 +86,9 @@ 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;
|
||||
new BlockSnowNew(Block.snow.blockID).setHardness(0.1F).setStepSound(Block.soundSnowFootstep).setUnlocalizedName("snow").setLightOpacity(0).setTextureName("snow");
|
||||
}
|
||||
|
||||
private static void initTileEntities() {
|
||||
|
||||
Reference in new issue
Block a user