Work on christmas lights

This commit is contained in:
Matt Caughey 2013-12-25 12:38:11 -05:00
parent 9de457cfa1
commit 51b8f75bb1
9 changed files with 137 additions and 17 deletions

View file

@ -14,6 +14,7 @@ import biomesoplenty.blocks.renderers.BambooRenderer;
import biomesoplenty.blocks.renderers.ColorizedLeavesRenderer; import biomesoplenty.blocks.renderers.ColorizedLeavesRenderer;
import biomesoplenty.blocks.renderers.FoliageRenderer; import biomesoplenty.blocks.renderers.FoliageRenderer;
import biomesoplenty.blocks.renderers.GraveRenderer; import biomesoplenty.blocks.renderers.GraveRenderer;
import biomesoplenty.blocks.renderers.LeavesRenderer;
import biomesoplenty.blocks.renderers.PlantsRenderer; import biomesoplenty.blocks.renderers.PlantsRenderer;
import biomesoplenty.blocks.renderers.PuddleRender; import biomesoplenty.blocks.renderers.PuddleRender;
import biomesoplenty.blocks.renderers.RenderUtils; import biomesoplenty.blocks.renderers.RenderUtils;
@ -57,6 +58,7 @@ public class ClientProxy extends CommonProxy {
RenderUtils.graveModel = RenderingRegistry.getNextAvailableRenderId(); RenderUtils.graveModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.bambooModel = RenderingRegistry.getNextAvailableRenderId(); RenderUtils.bambooModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.colorizedLeavesModel = RenderingRegistry.getNextAvailableRenderId(); RenderUtils.colorizedLeavesModel = RenderingRegistry.getNextAvailableRenderId();
RenderUtils.leavesModel = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, new RenderSnowball(Items.mudball.get(), 0)); RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, new RenderSnowball(Items.mudball.get(), 0));
RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart()); RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart());
@ -103,6 +105,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerBlockHandler(new GraveRenderer()); RenderingRegistry.registerBlockHandler(new GraveRenderer());
RenderingRegistry.registerBlockHandler(new BambooRenderer()); RenderingRegistry.registerBlockHandler(new BambooRenderer());
RenderingRegistry.registerBlockHandler(new ColorizedLeavesRenderer()); RenderingRegistry.registerBlockHandler(new ColorizedLeavesRenderer());
RenderingRegistry.registerBlockHandler(new LeavesRenderer());
} }
@Override @Override

View file

@ -42,6 +42,7 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab
private static final String[] leaves = new String[] {"acacia", "mangrove", "palm", "redwood", "willow", "pine"}; private static final String[] leaves = new String[] {"acacia", "mangrove", "palm", "redwood", "willow", "pine"};
private Icon[][] textures; private Icon[][] textures;
public Icon christmasLights; public Icon christmasLights;
public Icon christmasLightsOff;
private final ColourizedLeafCategory category; private final ColourizedLeafCategory category;
int[] adjacentTreeBlocks; int[] adjacentTreeBlocks;
@ -77,6 +78,7 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab
} }
christmasLights = iconRegister.registerIcon("biomesoplenty:christmaslights"); christmasLights = iconRegister.registerIcon("biomesoplenty:christmaslights");
christmasLightsOff = iconRegister.registerIcon("biomesoplenty:christmaslightsoff");
} }
public Icon getIconBetterLeaves(int metadata, float randomIndex) public Icon getIconBetterLeaves(int metadata, float randomIndex)

View file

@ -18,6 +18,7 @@ import net.minecraftforge.common.IShearable;
import biomesoplenty.BiomesOPlenty; import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Blocks; import biomesoplenty.api.Blocks;
import biomesoplenty.api.Items; import biomesoplenty.api.Items;
import biomesoplenty.blocks.renderers.RenderUtils;
import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -56,6 +57,8 @@ public class BlockBOPLeaves extends BlockLeavesBase implements IShearable
private static final float[] fallingLeavesChance = new float[] {0.1F, 0.008F, 0.016F, 0.008F, 0.0F, 0.008F, 0.016F, 0.1F, 0.008F, 0.1F, 0.008F, 0.1F, 0.008F, 0.008F}; private static final float[] fallingLeavesChance = new float[] {0.1F, 0.008F, 0.016F, 0.008F, 0.0F, 0.008F, 0.016F, 0.1F, 0.008F, 0.1F, 0.008F, 0.1F, 0.008F, 0.008F};
private Icon[][] textures; private Icon[][] textures;
public Icon christmasLights;
public Icon christmasLightsOff;
private final LeafCategory category; private final LeafCategory category;
int[] adjacentTreeBlocks; int[] adjacentTreeBlocks;
@ -87,6 +90,9 @@ public class BlockBOPLeaves extends BlockLeavesBase implements IShearable
textures[0][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_fancy"); textures[0][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_fancy");
textures[1][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_fast"); textures[1][i] = iconRegister.registerIcon("biomesoplenty:leaves_" + leaves[i] + "_fast");
} }
christmasLights = iconRegister.registerIcon("biomesoplenty:christmaslights");
christmasLightsOff = iconRegister.registerIcon("biomesoplenty:christmaslightsoff");
} }
public Icon getIconBetterLeaves(int metadata, float randomIndex) public Icon getIconBetterLeaves(int metadata, float randomIndex)
@ -119,6 +125,12 @@ public class BlockBOPLeaves extends BlockLeavesBase implements IShearable
{ {
return Block.leaves.isOpaqueCube(); return Block.leaves.isOpaqueCube();
} }
@Override
public int getRenderType()
{
return RenderUtils.leavesModel;
}
@Override @Override
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })

View file

@ -3,10 +3,12 @@ package biomesoplenty.blocks.renderers;
import java.util.Calendar; import java.util.Calendar;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import biomesoplenty.api.Blocks;
import biomesoplenty.blocks.BlockBOPColorizedLeaves; import biomesoplenty.blocks.BlockBOPColorizedLeaves;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
@ -25,6 +27,7 @@ public class ColorizedLeavesRenderer implements ISimpleBlockRenderingHandler
BlockBOPColorizedLeaves colorizedLeaves = (BlockBOPColorizedLeaves)block; BlockBOPColorizedLeaves colorizedLeaves = (BlockBOPColorizedLeaves)block;
Icon christmasLights = colorizedLeaves.christmasLights; Icon christmasLights = colorizedLeaves.christmasLights;
Icon christmasLightsOff = colorizedLeaves.christmasLightsOff;
renderer.renderStandardBlock(block, x, y, z); renderer.renderStandardBlock(block, x, y, z);
@ -32,23 +35,33 @@ public class ColorizedLeavesRenderer implements ISimpleBlockRenderingHandler
if (calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26) if (calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26)
{ {
if (world.getBlockMetadata(x, y, z) == 5 || world.getBlockMetadata(x, y, z) == 9) if (world.getBlockId(x, y, z) == Blocks.leavesColorized2.get().blockID)
{ {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) if (world.getBlockMetadata(x, y, z) == 1 || world.getBlockMetadata(x, y, z) == 5 || world.getBlockMetadata(x, y, z) == 9)
{ {
if (direction != ForgeDirection.UP && direction != ForgeDirection.DOWN) for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{ {
RenderUtils.renderFace(renderer, block, christmasLights, world, x, y, z, 200, direction); if (direction != ForgeDirection.UP && direction != ForgeDirection.DOWN)
} {
else if (Minecraft.getMinecraft().theWorld.isDaytime())
{ {
renderer.aoBrightnessXYNN = 150; RenderUtils.renderFace(renderer, block, christmasLightsOff, world, x, y, z, direction);
renderer.aoBrightnessYZNN = 150; }
renderer.aoBrightnessYZNP = 150; else
renderer.aoBrightnessXYPN = 150; {
} RenderUtils.renderFace(renderer, block, christmasLights, world, x, y, z, 200, direction);
} }
} }
else
{
renderer.aoBrightnessXYNN = 150;
renderer.aoBrightnessYZNN = 150;
renderer.aoBrightnessYZNP = 150;
renderer.aoBrightnessXYPN = 150;
}
}
}
}
} }

View file

@ -0,0 +1,84 @@
package biomesoplenty.blocks.renderers;
import java.util.Calendar;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.ForgeDirection;
import biomesoplenty.api.Blocks;
import biomesoplenty.blocks.BlockBOPColorizedLeaves;
import biomesoplenty.blocks.BlockBOPLeaves;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class LeavesRenderer implements ISimpleBlockRenderingHandler
{
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
RenderUtils.renderStandardInvBlock(renderer, block, metadata);
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
BlockBOPLeaves leaves = (BlockBOPLeaves)block;
Icon christmasLights = leaves.christmasLights;
Icon christmasLightsOff = leaves.christmasLightsOff;
renderer.renderStandardBlock(block, x, y, z);
Calendar calendar = Calendar.getInstance();
if (calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26)
{
if (world.getBlockId(x, y, z) == Blocks.leaves2.get().blockID)
{
if (world.getBlockMetadata(x, y, z) == 1 || world.getBlockMetadata(x, y, z) == 5 || world.getBlockMetadata(x, y, z) == 9)
{
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
if (direction != ForgeDirection.UP && direction != ForgeDirection.DOWN)
{
if (Minecraft.getMinecraft().theWorld.isDaytime())
{
RenderUtils.renderFace(renderer, block, christmasLightsOff, world, x, y, z, direction);
}
else
{
RenderUtils.renderFace(renderer, block, christmasLights, world, x, y, z, 200, direction);
}
}
else
{
renderer.aoBrightnessXYNN = 150;
renderer.aoBrightnessYZNN = 150;
renderer.aoBrightnessYZNP = 150;
renderer.aoBrightnessXYPN = 150;
}
}
}
}
}
return true;
}
@Override
public boolean shouldRender3DInInventory()
{
return true;
}
@Override
public int getRenderId()
{
return RenderUtils.leavesModel;
}
}

View file

@ -20,6 +20,7 @@ public class RenderUtils
public static int graveModel = -1; public static int graveModel = -1;
public static int bambooModel = -1; public static int bambooModel = -1;
public static int colorizedLeavesModel = -1; public static int colorizedLeavesModel = -1;
public static int leavesModel = -1;
public static void renderStandardInvBlock(RenderBlocks renderblocks, Block block, int meta) public static void renderStandardInvBlock(RenderBlocks renderblocks, Block block, int meta)
{ {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 1,000 B

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 12
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B