Search in sources :

Example 1 with ItemFishingRod

use of net.minecraft.item.ItemFishingRod in project Wurst-MC-1.12 by Wurst-Imperium.

the class AutoFishMod method onUpdate.

@Override
public void onUpdate() {
    // check if inventory is full
    if (!overfillInventory.isChecked() && WMinecraft.getPlayer().inventory.getFirstEmptyStack() == -1) {
        ChatUtils.message("Inventory is full.");
        setEnabled(false);
        return;
    }
    // search fishing rod in hotbar
    int rodInHotbar = -1;
    for (int i = 0; i < 9; i++) {
        // skip non-rod items
        ItemStack stack = WMinecraft.getPlayer().inventory.getStackInSlot(i);
        if (WItem.isNullOrEmpty(stack) || !(stack.getItem() instanceof ItemFishingRod))
            continue;
        rodInHotbar = i;
        break;
    }
    // check if any rod was found
    if (rodInHotbar != -1) {
        // select fishing rod
        if (WMinecraft.getPlayer().inventory.currentItem != rodInHotbar) {
            WMinecraft.getPlayer().inventory.currentItem = rodInHotbar;
            return;
        }
        // wait for timer
        if (timer > 0) {
            timer--;
            return;
        }
        // check bobber
        if (WMinecraft.getPlayer().fishEntity != null)
            return;
        // cast rod
        rightClick();
        return;
    }
    // search fishing rod in inventory
    int rodInInventory = -1;
    for (int i = 9; i < 36; i++) {
        // skip non-rod items
        ItemStack stack = WMinecraft.getPlayer().inventory.getStackInSlot(i);
        if (WItem.isNullOrEmpty(stack) || !(stack.getItem() instanceof ItemFishingRod))
            continue;
        rodInInventory = i;
        break;
    }
    // check if completely out of rods
    if (rodInInventory == -1) {
        ChatUtils.message("Out of fishing rods.");
        setEnabled(false);
        return;
    }
    // find empty hotbar slot
    int hotbarSlot = -1;
    for (int i = 0; i < 9; i++) {
        // skip non-empty slots
        if (!InventoryUtils.isSlotEmpty(i))
            continue;
        hotbarSlot = i;
        break;
    }
    // check if hotbar is full
    boolean swap = false;
    if (hotbarSlot == -1) {
        hotbarSlot = WMinecraft.getPlayer().inventory.currentItem;
        swap = true;
    }
    // place rod in hotbar slot
    WPlayerController.windowClick_PICKUP(rodInInventory);
    WPlayerController.windowClick_PICKUP(36 + hotbarSlot);
    // swap old hotbar item with rod
    if (swap)
        WPlayerController.windowClick_PICKUP(rodInInventory);
}
Also used : ItemFishingRod(net.minecraft.item.ItemFishingRod) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemFishingRod

use of net.minecraft.item.ItemFishingRod in project Wurst-MC-1.12 by Wurst-Imperium.

the class AutoFishMod method rightClick.

private void rightClick() {
    // check held item
    ItemStack stack = WMinecraft.getPlayer().inventory.getCurrentItem();
    if (WItem.isNullOrEmpty(stack) || !(stack.getItem() instanceof ItemFishingRod))
        return;
    // right click
    mc.rightClickMouse();
    // reset timer
    timer = 15;
}
Also used : ItemFishingRod(net.minecraft.item.ItemFishingRod) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ItemFishingRod

use of net.minecraft.item.ItemFishingRod in project SilentGems by SilentChaos512.

the class EquipmentTooltips method onRenderTooltip.

@SubscribeEvent
public void onRenderTooltip(RenderTooltipEvent.PostText event) {
    ItemStack stack = event.getStack();
    Item item = stack.getItem();
    boolean isTinkersHarvestTool = isTinkersLoaded && item instanceof slimeknights.tconstruct.library.tools.AoeToolCore;
    boolean isTinkersWeapon = isTinkersLoaded && item instanceof slimeknights.tconstruct.library.tools.SwordCore;
    boolean isTinkersBow = isTinkersLoaded && item instanceof slimeknights.tconstruct.library.tools.ranged.BowCore;
    // Tools (pickaxes, shovels, axes, and more)
    if (item instanceof ItemTool || item instanceof ItemHoe || item instanceof ItemShears || item instanceof ItemFishingRod || isTinkersHarvestTool) {
        renderBackground(event);
        renderForTool(event, stack);
    } else // Swords
    if (item instanceof ItemSword || isTinkersWeapon) {
        boolean isCaster = item instanceof ITool && ToolHelper.getToolTier(stack).ordinal() >= EnumMaterialTier.SUPER.ordinal();
        renderBackground(event);
        renderForWeapon(event, stack);
    } else // Bows
    if (item instanceof ItemBow || isTinkersBow) {
        renderBackground(event);
        renderForBow(event, stack);
    } else // Shields
    if (item instanceof ItemShield) {
        renderBackground(event);
        renderForShield(event, stack);
    } else // Armor
    if (item instanceof ItemArmor) {
        renderBackground(event);
        renderForArmor(event, stack);
    }
// Unknown
}
Also used : ItemSword(net.minecraft.item.ItemSword) ItemTool(net.minecraft.item.ItemTool) ItemShield(net.minecraft.item.ItemShield) ItemFishingRod(net.minecraft.item.ItemFishingRod) ItemArmor(net.minecraft.item.ItemArmor) ITool(net.silentchaos512.gems.api.ITool) ItemBow(net.minecraft.item.ItemBow) Item(net.minecraft.item.Item) ItemHoe(net.minecraft.item.ItemHoe) ItemShears(net.minecraft.item.ItemShears) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with ItemFishingRod

use of net.minecraft.item.ItemFishingRod in project SilentGems by SilentChaos512.

the class EquipmentTooltips method renderForTool.

private void renderForTool(RenderTooltipEvent.PostText event, ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    FontRenderer fontRenderer = event.getFontRenderer();
    ItemStack currentEquip = mc.player.getHeldItemMainhand();
    boolean isAxe = stack.getItem() instanceof ItemAxe;
    boolean isDurabilityOnly = !(stack.getItem() instanceof ItemTool);
    // boolean isHoe = stack.getItem() instanceof ItemHoe;
    // boolean isSickle = stack.getItem() instanceof ItemGemSickle;
    // boolean isShears = stack.getItem() instanceof ItemShears;
    // boolean isFishingRod = stack.getItem() instanceof ItemFishingRod;
    double scale = 0.75;
    int x = (int) (event.getX() / scale);
    int y = (int) ((event.getY() - 16) / scale);
    int durability = getDurability(stack, 0);
    int equippedDurability = getDurability(currentEquip, durability);
    int harvestLevel = getHarvestLevel(stack, 0);
    int equippedHarvestLevel = getHarvestLevel(currentEquip, harvestLevel);
    float harvestSpeed = getHarvestSpeed(stack, 0);
    float equippedHarvestSpeed = getHarvestSpeed(currentEquip, harvestSpeed);
    float meleeDamage = getMeleeDamage(stack, 0);
    float equippedMeleeDamage = getMeleeDamage(currentEquip, meleeDamage);
    float meleeSpeed = getMeleeSpeed(stack, 0);
    float equippedMeleeSpeed = getMeleeSpeed(currentEquip, meleeSpeed);
    GlStateManager.pushMatrix();
    GlStateManager.color(1f, 1f, 1f, 1f);
    GlStateManager.scale(scale, scale, scale);
    mc.renderEngine.bindTexture(TEXTURE);
    boolean currentIsDurabilityOnly = currentEquip.getItem() instanceof ItemHoe || currentEquip.getItem() instanceof ItemGemSickle || currentEquip.getItem() instanceof ItemFishingRod;
    boolean bothWeapons = (isWeapon(stack) || stack.getItem() instanceof ItemTool) && (isWeapon(currentEquip) || currentEquip.getItem() instanceof ItemTool);
    // Durability
    x = renderStat(mc, fontRenderer, 0, x, y, durability, equippedDurability, StackHelper.isValid(currentEquip));
    // Harvest Level
    if (!isAxe && !isDurabilityOnly && harvestLevel > -1) {
        x = renderStat(mc, fontRenderer, 1, x, y, harvestLevel, equippedHarvestLevel, !currentIsDurabilityOnly && currentEquip.getItem() instanceof ItemTool);
    }
    // Harvest Speed
    if (!isDurabilityOnly && harvestSpeed > 0)
        x = renderStat(mc, fontRenderer, 2, x, y, harvestSpeed, equippedHarvestSpeed, !currentIsDurabilityOnly && currentEquip.getItem() instanceof ItemTool);
    // Melee Damage and Speed
    if (isAxe) {
        x = renderStat(mc, fontRenderer, 3, x, y, meleeDamage, equippedMeleeDamage, bothWeapons);
        x = renderStat(mc, fontRenderer, 5, x, y, meleeSpeed, equippedMeleeSpeed, bothWeapons);
    }
    lastWidth = (int) (x * scale - event.getX());
    GlStateManager.popMatrix();
}
Also used : ItemAxe(net.minecraft.item.ItemAxe) ItemHoe(net.minecraft.item.ItemHoe) ItemTool(net.minecraft.item.ItemTool) ItemFishingRod(net.minecraft.item.ItemFishingRod) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) ItemGemSickle(net.silentchaos512.gems.item.tool.ItemGemSickle)

Example 5 with ItemFishingRod

use of net.minecraft.item.ItemFishingRod in project Wurst-MC-1.12 by Wurst-Imperium.

the class TrajectoriesMod method onRender.

@Override
public void onRender(float partialTicks) {
    EntityPlayerSP player = WMinecraft.getPlayer();
    // check if player is holding item
    ItemStack stack = player.inventory.getCurrentItem();
    if (stack == null)
        return;
    // check if item is throwable
    if (!WItem.isThrowable(stack))
        return;
    boolean usingBow = stack.getItem() instanceof ItemBow;
    // calculate starting position
    double arrowPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * mc.timer.renderPartialTicks - WMath.cos((float) Math.toRadians(player.rotationYaw)) * 0.16F;
    double arrowPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().timer.renderPartialTicks + player.getEyeHeight() - 0.1;
    double arrowPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().timer.renderPartialTicks - WMath.sin((float) Math.toRadians(player.rotationYaw)) * 0.16F;
    // calculate starting motion
    float arrowMotionFactor = usingBow ? 1F : 0.4F;
    float yaw = (float) Math.toRadians(player.rotationYaw);
    float pitch = (float) Math.toRadians(player.rotationPitch);
    float arrowMotionX = -WMath.sin(yaw) * WMath.cos(pitch) * arrowMotionFactor;
    float arrowMotionY = -WMath.sin(pitch) * arrowMotionFactor;
    float arrowMotionZ = WMath.cos(yaw) * WMath.cos(pitch) * arrowMotionFactor;
    double arrowMotion = Math.sqrt(arrowMotionX * arrowMotionX + arrowMotionY * arrowMotionY + arrowMotionZ * arrowMotionZ);
    arrowMotionX /= arrowMotion;
    arrowMotionY /= arrowMotion;
    arrowMotionZ /= arrowMotion;
    if (usingBow) {
        float bowPower = (72000 - player.getItemInUseCount()) / 20F;
        bowPower = (bowPower * bowPower + bowPower * 2F) / 3F;
        if (bowPower > 1F || bowPower <= 0.1F)
            bowPower = 1F;
        bowPower *= 3F;
        arrowMotionX *= bowPower;
        arrowMotionY *= bowPower;
        arrowMotionZ *= bowPower;
    } else {
        arrowMotionX *= 1.5D;
        arrowMotionY *= 1.5D;
        arrowMotionZ *= 1.5D;
    }
    // GL settings
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glLineWidth(2);
    RenderManager renderManager = mc.getRenderManager();
    // draw trajectory line
    double gravity = usingBow ? 0.05D : stack.getItem() instanceof ItemPotion ? 0.4D : stack.getItem() instanceof ItemFishingRod ? 0.15D : 0.03D;
    Vec3d playerVector = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
    GL11.glColor4f(0, 1, 0, 0.75F);
    GL11.glBegin(GL11.GL_LINE_STRIP);
    for (int i = 0; i < 1000; i++) {
        GL11.glVertex3d(arrowPosX - renderManager.renderPosX, arrowPosY - renderManager.renderPosY, arrowPosZ - renderManager.renderPosZ);
        arrowPosX += arrowMotionX * 0.1;
        arrowPosY += arrowMotionY * 0.1;
        arrowPosZ += arrowMotionZ * 0.1;
        arrowMotionX *= 0.999D;
        arrowMotionY *= 0.999D;
        arrowMotionZ *= 0.999D;
        arrowMotionY -= gravity * 0.1;
        if (WMinecraft.getWorld().rayTraceBlocks(playerVector, new Vec3d(arrowPosX, arrowPosY, arrowPosZ)) != null)
            break;
    }
    GL11.glEnd();
    // draw end of trajectory line
    double renderX = arrowPosX - renderManager.renderPosX;
    double renderY = arrowPosY - renderManager.renderPosY;
    double renderZ = arrowPosZ - renderManager.renderPosZ;
    GL11.glPushMatrix();
    GL11.glTranslated(renderX - 0.5, renderY - 0.5, renderZ - 0.5);
    GL11.glColor4f(0F, 1F, 0F, 0.25F);
    RenderUtils.drawSolidBox();
    GL11.glColor4f(0, 1, 0, 0.75F);
    RenderUtils.drawOutlinedBox();
    GL11.glPopMatrix();
    // GL resets
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glPopMatrix();
}
Also used : ItemPotion(net.minecraft.item.ItemPotion) ItemFishingRod(net.minecraft.item.ItemFishingRod) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ItemStack(net.minecraft.item.ItemStack) ItemBow(net.minecraft.item.ItemBow) RenderManager(net.minecraft.client.renderer.entity.RenderManager) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

ItemFishingRod (net.minecraft.item.ItemFishingRod)5 ItemStack (net.minecraft.item.ItemStack)5 ItemBow (net.minecraft.item.ItemBow)2 ItemHoe (net.minecraft.item.ItemHoe)2 ItemTool (net.minecraft.item.ItemTool)2 Minecraft (net.minecraft.client.Minecraft)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 RenderManager (net.minecraft.client.renderer.entity.RenderManager)1 Item (net.minecraft.item.Item)1 ItemArmor (net.minecraft.item.ItemArmor)1 ItemAxe (net.minecraft.item.ItemAxe)1 ItemPotion (net.minecraft.item.ItemPotion)1 ItemShears (net.minecraft.item.ItemShears)1 ItemShield (net.minecraft.item.ItemShield)1 ItemSword (net.minecraft.item.ItemSword)1 Vec3d (net.minecraft.util.math.Vec3d)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 ITool (net.silentchaos512.gems.api.ITool)1 ItemGemSickle (net.silentchaos512.gems.item.tool.ItemGemSickle)1