Search in sources :

Example 56 with PhysicsWrapperEntity

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

the class CallRunner method onEntityMove.

public static void onEntityMove(Entity entity, double dx, double dy, double dz) {
    double movDistSq = (dx * dx) + (dy * dy) + (dz * dz);
    if (movDistSq > 1000000) {
        //Assume this will take us to Ship coordinates
        double newX = entity.posX + dx;
        double newY = entity.posY + dy;
        double newZ = entity.posZ + dz;
        BlockPos newPosInBlock = new BlockPos(newX, newY, newZ);
        PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(entity.worldObj, newPosInBlock);
        if (wrapper == null) {
            //				System.err.println("An entity just tried moving like a millions miles an hour. Probably VW's fault, sorry about that.");
            return;
        }
        Vector endPos = new Vector(newX, newY, newZ);
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform, endPos);
        dx = endPos.X - entity.posX;
        dy = endPos.Y - entity.posY;
        dz = endPos.Z - entity.posZ;
    }
    if (!EntityCollisionInjector.alterEntityMovement(entity, dx, dy, dz)) {
        entity.moveEntity(dx, dy, dz);
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) Vector(ValkyrienWarfareBase.API.Vector)

Example 57 with PhysicsWrapperEntity

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

the class EventsClient method onDrawBlockHighlightEventLast.

@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void onDrawBlockHighlightEventLast(DrawBlockHighlightEvent event) {
    BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos();
    if (pos != null) {
        PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(Minecraft.getMinecraft().theWorld, pos);
        if (wrapper != null && wrapper.wrapping != null && wrapper.wrapping.renderer != null && wrapper.wrapping.centerCoord != null) {
            float partialTicks = event.getPartialTicks();
            Entity player = Minecraft.getMinecraft().thePlayer;
            wrapper.wrapping.renderer.inverseTransform(partialTicks);
            Tessellator tessellator = Tessellator.getInstance();
            VertexBuffer vertexbuffer = tessellator.getBuffer();
            double xOff = (player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getX();
            double yOff = (player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getY();
            double zOff = (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getZ();
            vertexbuffer.xOffset -= xOff;
            vertexbuffer.yOffset -= yOff;
            vertexbuffer.zOffset -= zOff;
        //				GL11.glPopMatrix();
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 58 with PhysicsWrapperEntity

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

the class EntityDraggable method tickAddedVelocityForWorld.

public static void tickAddedVelocityForWorld(World world) {
    try {
        for (int i = 0; i < world.loadedEntityList.size(); i++) {
            Entity e = world.loadedEntityList.get(i);
            //TODO: Maybe add a check to prevent moving entities that are fixed onto a Ship, but I like the visual effect
            if (!(e instanceof PhysicsWrapperEntity) && !(e instanceof EntityCannonBall)) {
                EntityDraggable draggable = getDraggableFromEntity(e);
                draggable.tickAddedVelocity();
                if (draggable.worldBelowFeet == null) {
                    if (draggable.draggableAsEntity.onGround) {
                        draggable.velocityAddedToPlayer.zero();
                        draggable.yawDifVelocity = 0;
                    } else {
                        if (draggable.draggableAsEntity instanceof EntityPlayer) {
                            EntityPlayer player = (EntityPlayer) draggable.draggableAsEntity;
                            if (player.isCreative() && player.capabilities.isFlying) {
                                draggable.velocityAddedToPlayer.multiply(.99D * .95D);
                                draggable.yawDifVelocity *= .95D * .95D;
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Entity(net.minecraft.entity.Entity) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityCannonBall(ValkyrienWarfareCombat.Entity.EntityCannonBall) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 59 with PhysicsWrapperEntity

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

the class CustomNetHandlerPlayServer method processPlayerDigging.

@Override
public void processPlayerDigging(CPacketPlayerDigging packetIn) {
    BlockPos packetPos = packetIn.getPosition();
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(playerEntity.worldObj, packetPos);
    if (playerEntity.interactionManager.getBlockReachDistance() != dummyBlockReachDist) {
        lastGoodBlockReachDist = playerEntity.interactionManager.getBlockReachDistance();
    }
    if (wrapper != null) {
        playerEntity.interactionManager.setBlockReachDistance(dummyBlockReachDist);
        ticksSinceLastTry = 0;
    }
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    if (wrapper != null && wrapper.wrapping.coordTransform != null) {
        float playerYaw = playerEntity.rotationYaw;
        float playerPitch = playerEntity.rotationPitch;
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform, wrapper.wrapping.coordTransform.wToLRotation, playerEntity);
        super.processPlayerDigging(packetIn);
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, playerEntity);
        playerEntity.rotationYaw = playerYaw;
        playerEntity.rotationPitch = playerPitch;
    } else {
        super.processPlayerDigging(packetIn);
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 60 with PhysicsWrapperEntity

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

the class CallRunner method markBlockRangeForRenderUpdate.

public static void markBlockRangeForRenderUpdate(World world, int x1, int y1, int z1, int x2, int y2, int z2) {
    //Stupid OpenComputers fix, blame those assholes
    if (x2 == 1 && y1 == 0 && z2 == 1) {
        x2 = x1 + 1;
        x1--;
        y1 = y2 - 1;
        y2++;
        z2 = z1 + 1;
        z2--;
    }
    int midX = (x1 + x2) / 2;
    int midY = (y1 + y2) / 2;
    int midZ = (z1 + z2) / 2;
    BlockPos newPos = new BlockPos(midX, midY, midZ);
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, newPos);
    if (wrapper != null && wrapper.wrapping.renderer != null) {
        wrapper.wrapping.renderer.updateRange(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
    }
    if (wrapper == null) {
        world.markBlockRangeForRenderUpdate(x1, y1, z1, x2, y2, z2);
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos)

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