use of ValkyrienWarfareCombat.Entity.EntityMountingWeaponBase in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsWrapperEntity method updatePassenger.
@Override
public void updatePassenger(Entity passenger) {
Vector inLocal = wrapping.getLocalPositionForEntity(passenger);
if (inLocal != null) {
Vector newEntityPosition = new Vector(inLocal);
float f = passenger.width / 2.0F;
float f1 = passenger.height;
AxisAlignedBB inLocalAABB = new AxisAlignedBB(newEntityPosition.X - (double) f, newEntityPosition.Y, newEntityPosition.Z - (double) f, newEntityPosition.X + (double) f, newEntityPosition.Y + (double) f1, newEntityPosition.Z + (double) f);
wrapping.coordTransform.fromLocalToGlobal(newEntityPosition);
passenger.setPosition(newEntityPosition.X, newEntityPosition.Y, newEntityPosition.Z);
Polygon entityBBPoly = new Polygon(inLocalAABB, wrapping.coordTransform.lToWTransform);
AxisAlignedBB newEntityBB = entityBBPoly.getEnclosedAABB();
passenger.setEntityBoundingBox(newEntityBB);
if (passenger instanceof EntityMountingWeaponBase) {
passenger.onUpdate();
for (Entity e : passenger.riddenByEntities) {
if (wrapping.isEntityFixed(e)) {
Vector inLocalAgain = wrapping.getLocalPositionForEntity(e);
if (inLocalAgain != null) {
Vector newEntityPositionAgain = new Vector(inLocalAgain);
wrapping.coordTransform.fromLocalToGlobal(newEntityPositionAgain);
e.setPosition(newEntityPositionAgain.X, newEntityPositionAgain.Y, newEntityPositionAgain.Z);
}
}
}
}
}
}
use of ValkyrienWarfareCombat.Entity.EntityMountingWeaponBase in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ValkyrienWarfareWorldEventListener method onEntityAdded.
@Override
public void onEntityAdded(Entity entityIn) {
int oldChunkX = MathHelper.floor_double(entityIn.posX / 16.0D);
int oldChunkZ = MathHelper.floor_double(entityIn.posZ / 16.0D);
BlockPos posAt = new BlockPos(entityIn);
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldObj, posAt);
if (!(entityIn instanceof EntityFallingBlock) && wrapper != null && wrapper.wrapping.coordTransform != null) {
if (entityIn instanceof EntityMountingWeaponBase || entityIn instanceof EntityArmorStand || entityIn instanceof EntityPig || entityIn instanceof EntityBoat) {
// entity.startRiding(wrapper);
wrapper.wrapping.fixEntity(entityIn, new Vector(entityIn));
wrapper.wrapping.queueEntityForMounting(entityIn);
}
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, entityIn);
int newChunkX = MathHelper.floor_double(entityIn.posX / 16.0D);
int newChunkZ = MathHelper.floor_double(entityIn.posZ / 16.0D);
worldObj.getChunkFromChunkCoords(oldChunkX, oldChunkZ).removeEntity(entityIn);
worldObj.getChunkFromChunkCoords(newChunkX, newChunkZ).addEntity(entityIn);
}
if (entityIn instanceof PhysicsWrapperEntity) {
ValkyrienWarfareMod.physicsManager.onShipLoad((PhysicsWrapperEntity) entityIn);
}
if (entityIn.getEntityWorld().isRemote) {
PhysicsWrapperEntity shipFixOnto = ValkyrienWarfareMod.physicsManager.getManagerForWorld(entityIn.worldObj).getShipFixedOnto(entityIn, true);
if (shipFixOnto != null) {
// System.out.println("Ye");
entityIn.startRiding(shipFixOnto, true);
}
}
}
Aggregations