Search in sources :

Example 1 with EntityPolygon

use of ValkyrienWarfareBase.Collision.EntityPolygon in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunner method onIsOnLadder.

public static boolean onIsOnLadder(EntityLivingBase base) {
    boolean vanilla = base.isOnLadder();
    if (vanilla) {
        return true;
    }
    if (base instanceof EntityPlayer && ((EntityPlayer) base).isSpectator()) {
        return false;
    }
    List<PhysicsWrapperEntity> nearbyPhys = ValkyrienWarfareMod.physicsManager.getManagerForWorld(base.worldObj).getNearbyPhysObjects(base.getEntityBoundingBox());
    for (PhysicsWrapperEntity physWrapper : nearbyPhys) {
        Vector playerPos = new Vector(base);
        physWrapper.wrapping.coordTransform.fromGlobalToLocal(playerPos);
        int i = MathHelper.floor_double(playerPos.X);
        int j = MathHelper.floor_double(playerPos.Y);
        int k = MathHelper.floor_double(playerPos.Z);
        BlockPos blockpos = new BlockPos(i, j, k);
        IBlockState iblockstate = base.worldObj.getBlockState(blockpos);
        Block block = iblockstate.getBlock();
        boolean isSpectator = (base instanceof EntityPlayer && ((EntityPlayer) base).isSpectator());
        if (isSpectator)
            return false;
        EntityPolygon playerPoly = new EntityPolygon(base.getEntityBoundingBox(), physWrapper.wrapping.coordTransform.wToLTransform, base);
        AxisAlignedBB bb = playerPoly.getEnclosedAABB();
        for (int x = MathHelper.floor_double(bb.minX); x < bb.maxX; x++) {
            for (int y = MathHelper.floor_double(bb.minY); y < bb.maxY; y++) {
                for (int z = MathHelper.floor_double(bb.minZ); z < bb.maxZ; z++) {
                    BlockPos pos = new BlockPos(x, y, z);
                    IBlockState checkState = base.worldObj.getBlockState(pos);
                    if (checkState.getBlock().isLadder(checkState, base.worldObj, pos, base)) {
                        return true;
                    // AxisAlignedBB ladderBB = checkState.getBlock().getBoundingBox(checkState, base.worldObj, pos).offset(pos).expandXyz(.1D);
                    // Polygon checkBlock = new Polygon(ladderBB);
                    // EntityPolygonCollider collider = new EntityPolygonCollider(playerPoly, checkBlock, physWrapper.wrapping.coordTransform.normals, new Vector(base.motionX,base.motionY,base.motionZ));
                    //// System.out.println(!collider.seperated);
                    // if(!collider.seperated){
                    // return true;
                    // }
                    }
                }
            }
        }
    // return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(iblockstate, base.worldObj, new BlockPos(i, j, k), base);
    }
    return false;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IBlockState(net.minecraft.block.state.IBlockState) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) EntityPolygon(ValkyrienWarfareBase.Collision.EntityPolygon) Vector(ValkyrienWarfareBase.API.Vector)

Aggregations

Vector (ValkyrienWarfareBase.API.Vector)1 EntityPolygon (ValkyrienWarfareBase.Collision.EntityPolygon)1 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1