Search in sources :

Example 1 with PhysicsWrapperEntity

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

the class CallRunnerClient method renderTileEntity.

public static void renderTileEntity(TileEntityRendererDispatcher dispatch, TileEntity tileentityIn, float partialTicks, int destroyStage) {
    BlockPos pos = tileentityIn.getPos();
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(tileentityIn.getWorld(), pos);
    if (wrapper != null && wrapper.wrapping != null && wrapper.wrapping.renderer != null) {
        try {
            boolean drawingBatchOrig = drawingBatchName.getBoolean(dispatch);
            if (drawingBatchOrig) {
                dispatch.drawBatch(MinecraftForgeClient.getRenderPass());
                dispatch.preDrawBatch();
            }
            wrapper.wrapping.renderer.setupTranslation(partialTicks);
            double playerX = TileEntityRendererDispatcher.instance.staticPlayerX;
            double playerY = TileEntityRendererDispatcher.instance.staticPlayerY;
            double playerZ = TileEntityRendererDispatcher.instance.staticPlayerZ;
            TileEntityRendererDispatcher.instance.staticPlayerX = wrapper.wrapping.renderer.offsetPos.getX();
            TileEntityRendererDispatcher.instance.staticPlayerY = wrapper.wrapping.renderer.offsetPos.getY();
            TileEntityRendererDispatcher.instance.staticPlayerZ = wrapper.wrapping.renderer.offsetPos.getZ();
            if (drawingBatchOrig) {
                dispatch.renderTileEntity(tileentityIn, partialTicks, destroyStage);
                dispatch.drawBatch(MinecraftForgeClient.getRenderPass());
                dispatch.preDrawBatch();
            } else {
                dispatch.renderTileEntity(tileentityIn, partialTicks, destroyStage);
            }
            TileEntityRendererDispatcher.instance.staticPlayerX = playerX;
            TileEntityRendererDispatcher.instance.staticPlayerY = playerY;
            TileEntityRendererDispatcher.instance.staticPlayerZ = playerZ;
            wrapper.wrapping.renderer.inverseTransform(partialTicks);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        dispatch.renderTileEntity(tileentityIn, partialTicks, destroyStage);
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) IOException(java.io.IOException)

Example 2 with PhysicsWrapperEntity

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

the class CallRunnerClient method onGetPositionEyes.

public static Vec3d onGetPositionEyes(Entity entityFor, float partialTicks) {
    Vec3d defaultOutput = entityFor.getPositionEyes(partialTicks);
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getShipFixedOnto(entityFor);
    if (wrapper != null) {
        Vector playerPosition = new Vector(wrapper.wrapping.getLocalPositionForEntity(entityFor));
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.RlToWTransform, playerPosition);
        Vector playerEyes = new Vector(0, entityFor.getEyeHeight(), 0);
        //Remove the original position added for the player's eyes
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWRotation, playerEyes);
        //Add the new rotate player eyes to the position
        playerPosition.add(playerEyes);
        //			System.out.println("test");
        return playerPosition.toVec3d();
    }
    return defaultOutput;
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Vector(ValkyrienWarfareBase.API.Vector) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with PhysicsWrapperEntity

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

the class EventsClient method onDrawBlockHighlightEventFirst.

@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
public void onDrawBlockHighlightEventFirst(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) {
            //				GL11.glPushMatrix();
            float partialTicks = event.getPartialTicks();
            Entity player = Minecraft.getMinecraft().thePlayer;
            wrapper.wrapping.renderer.setupTranslation(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;
        }
    }
}
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 4 with PhysicsWrapperEntity

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

the class EventsCommon method onRightClick.

@SubscribeEvent
public void onRightClick(PlayerInteractEvent.RightClickBlock event) {
    if (!event.getWorld().isRemote) {
        PhysicsWrapperEntity physObj = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(event.getWorld(), event.getPos());
        if (physObj != null) {
            //Bucket fix, probably not that important
            if (event.getEntityPlayer().getHeldItem(event.getHand()) != null && event.getEntityPlayer().getHeldItem(event.getHand()).getItem() instanceof ItemBucket) {
                event.setResult(Result.ALLOW);
                event.setCanceled(false);
            }
            if (ValkyrienWarfareMod.runAirshipPermissions && !(physObj.wrapping.creator.equals(event.getEntityPlayer().entityUniqueID.toString()) || physObj.wrapping.allowedUsers.contains(event.getEntityPlayer().entityUniqueID.toString()))) {
                event.getEntityPlayer().addChatMessage(new TextComponentString("You need to be added to the airship to do that!" + (physObj.wrapping.creator == null || physObj.wrapping.creator.trim().isEmpty() ? " Try using \"/airshipSettings claim\"!" : "")));
                event.setCanceled(true);
                return;
            }
        }
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) ItemBucket(net.minecraft.item.ItemBucket) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with PhysicsWrapperEntity

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

the class EventsCommon method onRightClickBlock.

@SubscribeEvent()
public void onRightClickBlock(RightClickBlock event) {
    if (!event.getWorld().isRemote) {
        ItemStack stack = event.getItemStack();
        if (stack != null && stack.getItem() instanceof ItemNameTag) {
            BlockPos posAt = event.getPos();
            EntityPlayer player = event.getEntityPlayer();
            World world = event.getWorld();
            PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, posAt);
            if (wrapper != null) {
                wrapper.setCustomNameTag(stack.getDisplayName());
                --stack.stackSize;
                event.setCanceled(true);
            }
        }
    }
}
Also used : ItemNameTag(net.minecraft.item.ItemNameTag) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

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