use of org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MixinWorld method postCheckBlockCollision.
/**
* This mixin fixes players getting kicked for flying when they're standing on the ground.
*/
@Inject(method = "checkBlockCollision", at = @At("HEAD"), cancellable = true)
public void postCheckBlockCollision(final AxisAlignedBB axisAlignedBB, final CallbackInfoReturnable<Boolean> callbackInfoReturnable) {
// If there wasn't a collision in the world, then check if there is a collision in ships
final List<PhysicsObject> physObjectsInAABB = getManager().getPhysObjectsInAABB(axisAlignedBB);
for (final PhysicsObject physicsObject : physObjectsInAABB) {
final ShipTransform shipTransform = physicsObject.getShipTransform();
final AxisAlignedBB aabbInShipSpace = new Polygon(axisAlignedBB, shipTransform.getGlobalToSubspace()).getEnclosedAABB();
final boolean collisionInShip = this.checkBlockCollision(aabbInShipSpace);
if (collisionInShip) {
callbackInfoReturnable.setReturnValue(true);
return;
}
}
}
use of org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MixinEntity method getDistanceSq.
/**
* This is easier to have as an overwrite because there's less laggy hackery to be done then :P
*
* @author DaPorkchop_
*/
@Overwrite
public double getDistanceSq(BlockPos pos) {
double vanilla = pos.getDistance((int) posX, (int) posY, (int) posZ);
if (vanilla < 64.0D) {
return vanilla;
} else {
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, pos);
if (physicsObject.isPresent()) {
Vector3d posVec = new Vector3d(pos.getX() + .5D, pos.getY() + .5D, pos.getZ() + .5D);
physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(posVec, TransformType.SUBSPACE_TO_GLOBAL);
posVec.x -= this.posX;
posVec.y -= this.posY;
posVec.z -= this.posZ;
if (vanilla > posVec.lengthSquared()) {
return posVec.lengthSquared();
}
}
}
return vanilla;
}
use of org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MixinEntity method getDistanceSq.
/**
* This is easier to have as an overwrite because there's less laggy hackery to be done then :P
*
* @author DaPorkchop_
*/
@Overwrite
public double getDistanceSq(double x, double y, double z) {
double d0 = this.posX - x;
double d1 = this.posY - y;
double d2 = this.posZ - z;
double vanilla = d0 * d0 + d1 * d1 + d2 * d2;
if (vanilla < 64.0D) {
return vanilla;
} else {
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, new BlockPos(x, y, z));
if (physicsObject.isPresent()) {
Vector3d posVec = new Vector3d(x, y, z);
physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(posVec, TransformType.SUBSPACE_TO_GLOBAL);
posVec.x -= this.posX;
posVec.y -= this.posY;
posVec.z -= this.posZ;
if (vanilla > posVec.lengthSquared()) {
return posVec.lengthSquared();
}
}
}
return vanilla;
}
use of org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MixinRenderGlobal method preRenderBlockLayer.
@Inject(method = "renderBlockLayer(Lnet/minecraft/util/BlockRenderLayer;DILnet/minecraft/entity/Entity;)I", at = @At("HEAD"))
private void preRenderBlockLayer(BlockRenderLayer blockLayerIn, double partialTicks, int pass, Entity entityIn, CallbackInfoReturnable callbackInfo) {
RenderHelper.disableStandardItemLighting();
// This probably won't work with strange mods, but I'm too lazy to do it better
ICamera icamera = new Frustum();
Entity entity = this.mc.getRenderViewEntity();
double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
icamera.setPosition(d0, d1, d2);
for (PhysicsObject physicsObject : ValkyrienUtils.getPhysObjWorld(world).getAllLoadedPhysObj()) {
GL11.glPushMatrix();
if (physicsObject.getShipRenderer().shouldRender(icamera)) {
physicsObject.getShipRenderer().renderBlockLayer(blockLayerIn, partialTicks, pass, icamera);
}
GL11.glPopMatrix();
}
GlStateManager.resetColor();
}
use of org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MixinRenderGlobal method preMarkBlocksForUpdate.
@Inject(method = "markBlocksForUpdate", at = @At("HEAD"))
private void preMarkBlocksForUpdate(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, boolean updateImmediately, CallbackInfo ci) {
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, new BlockPos(minX, minY, minZ));
if (!physicsObject.isPresent()) {
// Try again
physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, new BlockPos(minX, maxY, maxZ));
}
if (!physicsObject.isPresent()) {
// Try again
physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, new BlockPos(maxX, maxY, minZ));
}
if (!physicsObject.isPresent()) {
// Try again
physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, new BlockPos(maxX, maxY, maxZ));
}
physicsObject.ifPresent(p -> p.getShipRenderer().updateRange(minX, minY, minZ, maxX, maxY, maxZ, updateImmediately));
}
Aggregations