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;
}
Aggregations