It's raining it's pouring the old man is snoring...

This commit is contained in:
Adubbz 2013-06-30 19:14:10 +10:00
parent 7c7d4f9f1b
commit 863cd4f4e8
5 changed files with 132 additions and 37 deletions

View file

@ -18,6 +18,7 @@ import biomesoplenty.handlers.BreakSpeedHandler;
import biomesoplenty.handlers.EntityEventHandler; import biomesoplenty.handlers.EntityEventHandler;
import biomesoplenty.handlers.SoundHandler; import biomesoplenty.handlers.SoundHandler;
import biomesoplenty.handlers.TickHandlerClient; import biomesoplenty.handlers.TickHandlerClient;
import biomesoplenty.handlers.TickHandlerServer;
import biomesoplenty.helpers.AchievementHelper; import biomesoplenty.helpers.AchievementHelper;
import biomesoplenty.helpers.BOPLiquidHelper; import biomesoplenty.helpers.BOPLiquidHelper;
import biomesoplenty.helpers.CreativeTabsBOP; import biomesoplenty.helpers.CreativeTabsBOP;
@ -120,5 +121,6 @@ public class BiomesOPlenty
BOPCrossIntegration.postInit(); BOPCrossIntegration.postInit();
TickRegistry.registerTickHandler(new TickHandlerClient(), Side.CLIENT); TickRegistry.registerTickHandler(new TickHandlerClient(), Side.CLIENT);
TickRegistry.registerTickHandler(new TickHandlerServer(), Side.SERVER);
} }
} }

View file

@ -32,6 +32,7 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
public class ClientProxy extends CommonProxy { public class ClientProxy extends CommonProxy {
public static Minecraft mc = Minecraft.getMinecraft(); public static Minecraft mc = Minecraft.getMinecraft();
public static int puddleRenderPass;
@Override @Override
public void registerRenderers() public void registerRenderers()

View file

@ -3,8 +3,8 @@ package biomesoplenty.blocks;
import java.util.Random; import java.util.Random;
import biomesoplenty.BiomesOPlenty; import biomesoplenty.BiomesOPlenty;
import biomesoplenty.ClientProxy;
import biomesoplenty.blocks.renderers.PuddleRender; import biomesoplenty.blocks.renderers.PuddleRender;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
@ -12,6 +12,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
@ -41,7 +42,7 @@ public class BlockPuddle extends Block
public boolean isOpaqueCube() public boolean isOpaqueCube()
{ {
return false; return false;
} }
public boolean renderAsNormalBlock() public boolean renderAsNormalBlock()
@ -49,24 +50,25 @@ public class BlockPuddle extends Block
return false; return false;
} }
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) public void updateTick(World world, int x, int y, int z, Random par5Random)
{ {
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 1); if (!world.isRaining() && world.rand.nextInt(750) == 0)
{
return par9; world.setBlock(x, y, z, Block.dirt.blockID);
}
} }
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) @Override
public int getRenderBlockPass()
{ {
Material material1 = par1World.getBlockMaterial(par2 + 1, par3, par4); return 1;
Material material2 = par1World.getBlockMaterial(par2 - 1, par3, par4); }
Material material3 = par1World.getBlockMaterial(par2, par3, par4 + 1);
Material material4 = par1World.getBlockMaterial(par2, par3, par4 - 1); @Override
public boolean canRenderInPass(int pass)
if (!material1.isSolid() || !material2.isSolid() || !material3.isSolid() || !material1.isSolid()) {
{ ClientProxy.puddleRenderPass = pass;
par1World.setBlock(par2, par3, par4, Block.dirt.blockID); return true;
}
} }
@Override @Override
@ -81,20 +83,6 @@ public class BlockPuddle extends Block
{ {
return Block.dirt.getBlockTextureFromSide(par1); return Block.dirt.getBlockTextureFromSide(par1);
} }
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
Material material = par1World.getBlockMaterial(par2, par3 + 1, par4);
if (material.isSolid())
{
par1World.setBlock(par2, par3, par4, Block.dirt.blockID);
}
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 1);
}
public int idDropped(int par1, Random par2Random, int par3) public int idDropped(int par1, Random par2Random, int par3)
{ {

View file

@ -11,7 +11,7 @@ import net.minecraftforge.liquids.LiquidStack;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import biomesoplenty.BiomesOPlenty; import biomesoplenty.BiomesOPlenty;
import biomesoplenty.ClientProxy;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
@ -33,13 +33,18 @@ public class PuddleRender implements ISimpleBlockRenderingHandler
{ {
if (modelID == puddleID) if (modelID == puddleID)
{ {
renderer.renderStandardBlock(block, x, y, z); if (ClientProxy.puddleRenderPass == 0)
{
//Liquid renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.0, 0.8135, 0.0, 1.0, 0.8880, 1.0); }
else
{
//Liquid
renderer.setRenderBounds(0.0, 0.8135, 0.0, 1.0, 0.8880, 1.0);
Block liquidBlock = Block.blocksList[Block.waterStill.blockID]; Block liquidBlock = Block.blocksList[Block.waterStill.blockID];
BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, 0, x, y, z, renderer, world); BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, 0, x, y, z, renderer, world);
}
} }
return true; return true;
} }

View file

@ -0,0 +1,99 @@
package biomesoplenty.handlers;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.WorldServer;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.ForgeDirection;
import biomesoplenty.api.Blocks;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
public class TickHandlerServer implements ITickHandler
{
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
WorldServer worldserver = (WorldServer)tickData[0];
Iterator iterator = worldserver.activeChunkSet.iterator();
int rand = new Random().nextInt();
while (iterator.hasNext())
{
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator.next();
int k = chunkcoordintpair.chunkXPos * 16;
int l = chunkcoordintpair.chunkZPos * 16;
worldserver.theProfiler.startSection("getChunk");
Chunk chunk = worldserver.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos);
worldserver.theProfiler.endStartSection("tickChunk");
if (worldserver.provider.canDoRainSnowIce(chunk) && worldserver.rand.nextInt(1000) == 0)
{
rand = rand * 3 + 1013904223;
int i1 = rand >> 2;
int j1 = i1 & 15;
int k1 = i1 >> 8 & 15;
int l1 = worldserver.getPrecipitationHeight(j1 + k, k1 + l);
if (worldserver.isRaining() && canCreatePuddle(worldserver, j1 + k, l1, k1 + l))
{
worldserver.setBlock(j1 + k, l1 - 1, k1 + l, Blocks.puddle.get().blockID);
}
}
}
}
public boolean canCreatePuddle(WorldServer worldserver, int par1, int par2, int par3)
{
BiomeGenBase biomegenbase = worldserver.getBiomeGenForCoords(par1, par3);
float f = biomegenbase.getFloatTemperature();
if (f > 0.15F)
{
if (par2 >= 0 && par2 < 256 && worldserver.getSavedLightValue(EnumSkyBlock.Block, par1, par2, par3) < 10)
{
int l = worldserver.getBlockId(par1, par2 - 1, par3);
if (l == Block.dirt.blockID || l == Block.grass.blockID)
{
if (worldserver.isBlockSolidOnSide(par1 + 1, par2 - 1, par3, ForgeDirection.UP) && worldserver.isBlockSolidOnSide(par1 - 1, par2 - 1, par3, ForgeDirection.UP) && worldserver.isBlockSolidOnSide(par1, par2 - 1, par3 + 1, ForgeDirection.UP) && worldserver.isBlockSolidOnSide(par1, par2 - 1, par3 - 1, ForgeDirection.UP))
{
return true;
}
}
}
return false;
}
else
{
return false;
}
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
}
@Override
public EnumSet<TickType> ticks()
{
return EnumSet.of(TickType.WORLD);
}
@Override
public String getLabel()
{
return "BiomesOPlenty - World tick";
}
}