Search in sources :

Example 11 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunnerClient method getRenderBoundingBox.

public static AxisAlignedBB getRenderBoundingBox(TileEntity tile) {
    AxisAlignedBB toReturn = tile.getRenderBoundingBox();
    //    	System.out.println("running");
    BlockPos pos = tile.getPos();
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(Minecraft.getMinecraft().theWorld, pos);
    if (wrapper != null) {
        Polygon inWorldPoly = new Polygon(toReturn, wrapper.wrapping.coordTransform.lToWTransform);
        return inWorldPoly.getEnclosedAABB();
    }
    return toReturn;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) Polygon(ValkyrienWarfareBase.Collision.Polygon)

Example 12 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunner method getDistanceSq.

public static double getDistanceSq(double ret, TileEntity ent, double x, double y, double z) {
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(ent.getWorld(), ent.getPos());
    if (wrapper != null) {
        Vector vec = new Vector(x, y, z);
        wrapper.wrapping.coordTransform.fromGlobalToLocal(vec);
        double d0 = ent.getPos().getX() - vec.X;
        double d1 = ent.getPos().getY() - vec.Y;
        double d2 = ent.getPos().getZ() - vec.Z;
        return d0 * d0 + d1 * d1 + d2 * d2;
    }
    return ret;
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Vector(ValkyrienWarfareBase.API.Vector)

Example 13 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunner method onSendToAllNearExcept.

/*	public static boolean onSpawnEntityInWorld(World world, Entity entity) {
		BlockPos posAt = new BlockPos(entity);
		PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, posAt);
		if (!(entity instanceof EntityFallingBlock) && wrapper != null && wrapper.wrapping.coordTransform != null) {
			if (entity instanceof EntityMountingWeaponBase || entity instanceof EntityArmorStand || entity instanceof EntityPig || entity instanceof EntityBoat) {
//				entity.startRiding(wrapper);
				wrapper.wrapping.fixEntity(entity, new Vector(entity));
				wrapper.wrapping.queueEntityForMounting(entity);
			}
			RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, entity);
		}
		return world.spawnEntityInWorld(entity);
	}*/
public static void onSendToAllNearExcept(PlayerList list, @Nullable EntityPlayer except, double x, double y, double z, double radius, int dimension, Packet<?> packetIn) {
    BlockPos pos = new BlockPos(x, y, z);
    World worldIn = null;
    if (except == null) {
        worldIn = DimensionManager.getWorld(dimension);
    } else {
        worldIn = except.worldObj;
    }
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
    Vector packetPosition = new Vector(x, y, z);
    if (wrapper != null && wrapper.wrapping.coordTransform != null) {
        wrapper.wrapping.coordTransform.fromLocalToGlobal(packetPosition);
        if (packetIn instanceof SPacketSoundEffect) {
            SPacketSoundEffect soundEffect = (SPacketSoundEffect) packetIn;
            packetIn = new SPacketSoundEffect(soundEffect.sound, soundEffect.category, packetPosition.X, packetPosition.Y, packetPosition.Z, soundEffect.soundVolume, soundEffect.soundPitch);
        }
        //
        if (packetIn instanceof SPacketEffect) {
            SPacketEffect effect = (SPacketEffect) packetIn;
            BlockPos blockpos = new BlockPos(packetPosition.X, packetPosition.Y, packetPosition.Z);
            packetIn = new SPacketEffect(effect.soundType, blockpos, effect.soundData, effect.serverWide);
        }
    }
    x = packetPosition.X;
    y = packetPosition.Y;
    z = packetPosition.Z;
    for (int i = 0; i < list.playerEntityList.size(); ++i) {
        EntityPlayerMP entityplayermp = (EntityPlayerMP) list.playerEntityList.get(i);
        if (entityplayermp != except && entityplayermp.dimension == dimension) {
            // NOTE: These are set to use the last variables for a good reason; dont change them
            double d0 = x - entityplayermp.posX;
            double d1 = y - entityplayermp.posY;
            double d2 = z - entityplayermp.posZ;
            if (d0 * d0 + d1 * d1 + d2 * d2 < radius * radius) {
                entityplayermp.connection.sendPacket(packetIn);
            } else {
                d0 = x - entityplayermp.lastTickPosX;
                d1 = y - entityplayermp.lastTickPosY;
                d2 = z - entityplayermp.lastTickPosZ;
                if (d0 * d0 + d1 * d1 + d2 * d2 < radius * radius) {
                    entityplayermp.connection.sendPacket(packetIn);
                }
            }
        }
    }
}
Also used : SPacketSoundEffect(net.minecraft.network.play.server.SPacketSoundEffect) SPacketEffect(net.minecraft.network.play.server.SPacketEffect) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) Vector(ValkyrienWarfareBase.API.Vector)

Example 14 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunner method onGetEntitiesInAABBexcluding.

public static List<Entity> onGetEntitiesInAABBexcluding(World world, @Nullable Entity entityIn, AxisAlignedBB boundingBox, @Nullable Predicate<? super Entity> predicate) {
    if ((boundingBox.maxX - boundingBox.minX) * (boundingBox.maxZ - boundingBox.minZ) > 1000000D) {
        return new ArrayList();
    }
    //Prevents the players item pickup AABB from merging with a PhysicsWrapperEntity AABB
    if (entityIn instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entityIn;
        if (player.isRiding() && !player.getRidingEntity().isDead && player.getRidingEntity() instanceof PhysicsWrapperEntity) {
            AxisAlignedBB axisalignedbb = player.getEntityBoundingBox().union(player.getRidingEntity().getEntityBoundingBox()).expand(1.0D, 0.0D, 1.0D);
            if (boundingBox.equals(axisalignedbb)) {
                boundingBox = player.getEntityBoundingBox().expand(1.0D, 0.5D, 1.0D);
            }
        }
    }
    List toReturn = world.getEntitiesInAABBexcluding(entityIn, boundingBox, predicate);
    BlockPos pos = new BlockPos((boundingBox.minX + boundingBox.maxX) / 2D, (boundingBox.minY + boundingBox.maxY) / 2D, (boundingBox.minZ + boundingBox.maxZ) / 2D);
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, pos);
    if (wrapper != null) {
        Polygon poly = new Polygon(boundingBox, wrapper.wrapping.coordTransform.lToWTransform);
        boundingBox = poly.getEnclosedAABB().contract(.3D);
        toReturn.addAll(world.getEntitiesInAABBexcluding(entityIn, boundingBox, predicate));
    }
    return toReturn;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ArrayList(java.util.ArrayList) PlayerList(net.minecraft.server.management.PlayerList) List(java.util.List) BlockPos(net.minecraft.util.math.BlockPos) Polygon(ValkyrienWarfareBase.Collision.Polygon) EntityPolygon(ValkyrienWarfareBase.Collision.EntityPolygon)

Example 15 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunner method onPlaySound.

public static void onPlaySound(World world, double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch, boolean distanceDelay) {
    BlockPos pos = new BlockPos(x, y, z);
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, pos);
    if (wrapper != null) {
        Vector posVec = new Vector(x, y, z);
        wrapper.wrapping.coordTransform.fromLocalToGlobal(posVec);
        x = posVec.X;
        y = posVec.Y;
        z = posVec.Z;
    }
    world.playSound(x, y, z, soundIn, category, volume, pitch, distanceDelay);
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) Vector(ValkyrienWarfareBase.API.Vector)

Aggregations

PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)69 BlockPos (net.minecraft.util.math.BlockPos)29 Vector (ValkyrienWarfareBase.API.Vector)28 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 IBlockState (net.minecraft.block.state.IBlockState)9 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)9 TextComponentString (net.minecraft.util.text.TextComponentString)9 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)8 Vec3d (net.minecraft.util.math.Vec3d)7 WorldPhysObjectManager (ValkyrienWarfareBase.PhysicsManagement.WorldPhysObjectManager)6 Block (net.minecraft.block.Block)6 Entity (net.minecraft.entity.Entity)6 TileEntity (net.minecraft.tileentity.TileEntity)6 IThreadListener (net.minecraft.util.IThreadListener)5 World (net.minecraft.world.World)5 Quaternion (ValkyrienWarfareBase.Math.Quaternion)4 ArrayList (java.util.ArrayList)4 RayTraceResult (net.minecraft.util.math.RayTraceResult)4 EntityPolygon (ValkyrienWarfareBase.Collision.EntityPolygon)3 Polygon (ValkyrienWarfareBase.Collision.Polygon)3