From 54b4e75bc299e8014ca1b925c9a2935cb5ddb227 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Wed, 8 Jan 2014 07:31:17 -0500 Subject: [PATCH] Start work on balloon entity base raytrace --- .../mekanism/common/entity/EntityBalloon.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/mekanism/common/entity/EntityBalloon.java b/common/mekanism/common/entity/EntityBalloon.java index 77b788c7f..6b76aca9c 100644 --- a/common/mekanism/common/entity/EntityBalloon.java +++ b/common/mekanism/common/entity/EntityBalloon.java @@ -11,6 +11,7 @@ import net.minecraft.client.particle.EntityReddustFX; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.World; @@ -196,10 +197,28 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData } else if(latchedEntity != null && latchedEntity.getHealth() > 0) { + int floor = getFloor(latchedEntity); setPosition(posX = latchedEntity.posX, posY = latchedEntity.posY + 3F, posZ = latchedEntity.posZ); } } + private int getFloor(EntityLivingBase entity) + { + int xPos = MathHelper.floor_double(entity.posX); + int yPos = MathHelper.floor_double(entity.posY); + int zPos = MathHelper.floor_double(entity.posZ); + + for(int i = yPos; i > 0; i--) + { + if(!worldObj.isAirBlock(xPos, i, zPos)) + { + return i; + } + } + + return -1; + } + private void findCachedEntity() { for(Object obj : worldObj.loadedEntityList)