Added particles and sounds for walking in puddles
This commit is contained in:
parent
863cd4f4e8
commit
907c6da775
|
@ -16,6 +16,7 @@ import biomesoplenty.handlers.BOPCraftHandler;
|
|||
import biomesoplenty.handlers.BonemealHandler;
|
||||
import biomesoplenty.handlers.BreakSpeedHandler;
|
||||
import biomesoplenty.handlers.EntityEventHandler;
|
||||
import biomesoplenty.handlers.MovementHandler;
|
||||
import biomesoplenty.handlers.SoundHandler;
|
||||
import biomesoplenty.handlers.TickHandlerClient;
|
||||
import biomesoplenty.handlers.TickHandlerServer;
|
||||
|
@ -101,6 +102,7 @@ public class BiomesOPlenty
|
|||
MinecraftForge.EVENT_BUS.register(new EntityEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new BOPLiquidHelper());
|
||||
MinecraftForge.EVENT_BUS.register(new BreakSpeedHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new MovementHandler());
|
||||
|
||||
proxy.registerRenderers();
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package biomesoplenty.handlers;
|
||||
|
||||
import biomesoplenty.api.Blocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFlower;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
|
||||
public class MovementHandler
|
||||
{
|
||||
@ForgeSubscribe
|
||||
public void onEntityLivingUpdate(LivingUpdateEvent event)
|
||||
{
|
||||
EntityLiving entity = event.entityLiving;
|
||||
|
||||
World world = entity.worldObj;
|
||||
|
||||
int x = MathHelper.floor_double(entity.posX);
|
||||
int y = MathHelper.floor_double(entity.boundingBox.minY);
|
||||
int z = MathHelper.floor_double(entity.posZ);
|
||||
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
|
||||
if (blockID == Blocks.puddle.get().blockID)
|
||||
{
|
||||
if ((entity.motionX > 0 || entity.motionX < 0) || (entity.motionZ > 0 || entity.motionZ < 0))
|
||||
{
|
||||
if (event.entityLiving.isCollidedVertically)
|
||||
{
|
||||
if (world.rand.nextInt(2) == 0)
|
||||
{
|
||||
if (world.rand.nextInt(2) == 0)
|
||||
{
|
||||
float f = MathHelper.sqrt_double(entity.motionX * entity.motionX * 0.20000000298023224D + entity.motionY * entity.motionY + entity.motionZ * entity.motionZ * 0.20000000298023224D) * 0.2F;
|
||||
|
||||
if (f > 1.0F)
|
||||
{
|
||||
f = 1.0F;
|
||||
}
|
||||
|
||||
entity.playSound("liquid.splash", f, 1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.4F);
|
||||
}
|
||||
world.spawnParticle("splash", entity.posX + ((double)world.rand.nextFloat() - 0.5D) * (double)entity.width, entity.boundingBox.minY + 0.1D, entity.posZ + ((double)world.rand.nextFloat() - 0.5D) * (double)entity.width, -entity.motionX, 0.6D, -entity.motionZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue