hogbits's Avatar
Member
Level 34 Artisan Pig
20

Forum Posts

1 - 15 of 15

    hogbits
    10/30/2021 11:45 pm
    Level 34 : Artisan Pig
    hogbits's Avatar
    So I manged to get this working a few days ago. I tried many different approaches, and none of them worked. Just in case anyone else stumbles on this thread looking for a solution. Here is what I did:

    I used a scoreboard set to detect the used_rod stat then execute on that to call a sub function for the player to tag the bobber.

    execute as @a[scores={use_rod=1..}] at @s if block ~ ~-1 ~ red_wool run function game:misc/red_cast
    Execute at the player and look for a bobber that is within 3 blocks and not already tagged by another player.



    execute as @s at @s as @e[type=fishing_bobber,distance=..3,limit=1] run tag @e[type=fishing_bobber,tag=!red_bobber,tag=!gold_bobber,tag=!green_bobber,tag=!purple_bobber,limit=1] add red_bobber
    Reset the use_rod stat to 0

    Since I use various game states to manage various aspects of the game, I have a function that runs on the tick and detects when the bobber is near the sheep then runs a sub function for handling the score keeping part.

    execute as @e[type=fishing_bobber,tag=red_bobber] at @s if entity @e[type=sheep,distance=..1.09] run function game:misc/caught_sheep_red

    I had to do it this way, because I needed to execute as the bobber first then pass it to the caught_sheep function so the bobber could be referenced with the @s selector.

    There is probably a better more elegant way to do it but this is how I got it working
    1
    hogbits
    10/23/2021 9:17 pm
    Level 34 : Artisan Pig
    history
    hogbits's Avatar
    I don't think the fishing_bobber counts as a projectile. At least it's not listed in the entity NBT when I do a /data get ...

    Snowball vs Bobber NBT
    1
    hogbits
    10/23/2021 7:43 pm
    Level 34 : Artisan Pig
    hogbits's Avatar
    Thanks HoboMaggot. I am unable to find any reference to the "LeftOwner" NBT tag. Where can I find out more about it?
    1
    hogbits
    10/23/2021 12:35 am
    Level 34 : Artisan Pig
    hogbits's Avatar
    I think I may have narrowed it down to the root issue. Essentially determining what player cast the rod is a little harder to figure out. The fishing_bobber entity is not tagged with the player that cast it. I wish Mojang would add that useful information.

    Anyway, Some very old threads that I found suggested using a scoreboard to track who cast a rod, but honestly I did that with my original fishing game and when many players were all spamming their rods, I notice that the scores were not calculated correctly.

    Do you think it's possible to write a command that detects the closest player to the bobber as soon as it's cast, then tag the bobber based on that players team? In other words, if I am on the "red" team, and I cast my rod, then the bobber nearest to me is tagged with "red_bobber" immediately? This could work for me as teams will be pretty far apart.

    Any ideas how to write a command like that? I know it's not easy.
    1
    hogbits
    10/22/2021 2:10 pm
    Level 34 : Artisan Pig
    hogbits's Avatar
    I see, makes sense. Basically the idea is to make it so that the bobber cannot be tagged if it's already been tagged by another player. I will work on adding this tonight after work. Thanks for the input fellas.
    1
    hogbits
    10/22/2021 12:03 pm
    Level 34 : Artisan Pig
    hogbits's Avatar
    Thank you, this is getting much closer! :D

    Okay so I have this challenge remaining. I need to tag the bobber with the team color that cast it. Below are two of my commands for tagging the bobber.

    Unfortunatly, the bobber is getting tagged with both teams e.g. red_bobber and orange_bobber. I thought the sort and limit option would have prevented that but apparently not.

    execute if entity @a[team=red] run execute as @e[type=fishing_bobber,limit=1,sort=nearest] run tag @s add red_bobber
    execute if entity @a[team=orange] run execute as @e[type=fishing_bobber,limit=1,sort=nearest] run tag @s add orange_bobber
    1
    hogbits
    10/21/2021 10:02 pm
    Level 34 : Artisan Pig
    hogbits's Avatar
    Thanks pleasenotme,
    This is similar to one of my previous failed attempts. I don't have all of the code anymore, but it was something like this:


    execute at @e[type=fishing_bobber,tag=red_bobber] as @e[type=sheep,distance=..1.04,limit=1] run tag @s add killed

    execute at @e[type=sheep,tag=killed,distance=..1.04,limit=1] as @e[type=fishing_bobber,tag=red_bobber] run tag @s add kill_bobber
    execute at @e[type=fishing_bobber,tag=red_bobber] as @e[type=sheep,distance=..1,limit=1.04] run kill @e[tag=red_bobber]

    Probably some "as" and "at" commands that are out of order now.

    If you have some idea how to rewrite the commands I would like to see what you come up with.
    1
    hogbits
    10/15/2021 6:23 pm
    Level 34 : Artisan Pig
    hogbits's Avatar
    Mindcraft - Brain training game where you, the witchy protagonist have to solve puzzles, brain teasers, and riddles.
    3
    hogbits
    10/14/2021 2:01 am
    Level 34 : Artisan Pig
    history
    hogbits's Avatar
    Yes I confirmed the mob has that tag two ways.
    1. using /tag <selector> list
    2. using /data get <selector>
    EDIT:
    I reloaded the world after taking a break and watching a show and what do you know the command is now working correctly. I guess I should have followed the golden rule. "When in doubt, power out"

    Thanks for the sanity check!
    2
    hogbits
    10/13/2021 1:22 pm
    Level 34 : Artisan Pig
    hogbits's Avatar
    Thanks for the additional examples and explanation. I haven't found the wiki for x_rotation and y_rotation yet. My google-fu must be horrible in my old age. I think your responses should be enough to help me figure out what I need to do.

    Basically I am trying to make utility commands to help setup a map with game pieces that require an armor stand to be tagged with a direction. Since there will be more than just a few armor stands to setup, I think a utility that automatically tags the stand when summoned will help quite a bit.

    Thank you
    1
    hogbits
    10/13/2021 1:57 am
    Level 34 : Artisan Pig
    history
    hogbits's Avatar
    Can you give an example? I read about <pos> values on the wiki but it makes no sense the code completion wasnt much help. Or at least I didn't understand it. Google searches reveal results for ray tracing or examples from 4-8 years ago not finding any current results.
    1
    hogbits
    10/08/2021 6:36 pm
    Level 34 : Artisan Pig
    hogbits's Avatar
    Thanks for the comments everyone. You have given me some ideas that may work. For example if I want to use zombies, I can summon an invisible villager and randomize it's teleported location and keep moving the villager before the zombie can get close enough to attack. and I believe I can do the same with skeletons and wolves.

    I was really hoping that you all would tell me that there was an NBT tag that could be added to mobs and/or players to make mobs run away. (wishful thinking)
    1
    hogbits
    10/05/2021 11:32 pm
    Level 34 : Artisan Pig
    hogbits's Avatar
    Thanks for the response! the /data command is new to me. I don't think it existed last time I wrote any commands (mc v1.11 ish) It looks really powerful and complex so I will need to do some "light" reading :D

    If I understand the general concept here it is that the data store holds an array of players, as each player finishes their turn they are cycled to the end of the array or removed as needed. If so It sounds pretty straight forward. At least it gives me a good place to start.

    Thank you!
    1
    hogbits
    09/24/2021 2:31 am
    Level 34 : Artisan Pig
    hogbits's Avatar
    Minecraft after the "Combat update" (1.9) just never felt the same. I'm old school and to this day I sill try to block with my sword.
    2
    hogbits
    04/14/2021 11:10 pm
    Level 34 : Artisan Pig
    hogbits's Avatar
    The Custom World Generation page appears to suggest otherwise. See also Caves and cliffs snapshot article where they provide a prototype data pack to add in the caves and cliffs world generation.
    2

1 - 15 of 15

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome