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