Jump to content

get coordinates of the block the player looking at


DoctorG_Mystery

Recommended Posts

here:

package drgmystery.darklight.events;

import net.minecraft.item.Item;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class DarklightPlaceTest extends Item{

    }

    @Override
        public ActionResult<ItemStack> useOn(PlayerEntity player, World world, Hand hand, BlockPos Pos){
            if(!world.isClientSide){
                 ;
                double x = player.position().x();
                double y = player.position().y();
                double z = player.position().z(); 
                BlockPos blockPos = new BlockPos(x, y, z);
                world.setBlockAndUpdate(blockPos, Blocks.DIAMOND_BLOCK.defaultBlockState());
            }
            return ActionResult.pass(null);
        }

    @Override
    public ActionResultType useOn(ItemUseContext p_195939_1_) {
        // TODO Auto-generated method stub
        return super.useOn(p_195939_1_);
    }

}

edit: sorry I only read: what has been generated the error?

Edited by DoctorG_Mystery
Link to comment
Share on other sites

errors at this points:

            if(!world.isClientSide){
                double x = player.position().x();
                double y = player.position().y();
                double z = player.position().z(); 
                BlockPos blockPos = new BlockPos(x, y, z);
                world.setBlockAndUpdate(blockPos, Blocks.DIAMOND_BLOCK.defaultBlockState());
            }

Link to comment
Share on other sites

look better so?

        PlayerEntity player = null;
        World world = null;
        Hand hand = null;
        if(!world.isClientSide){
             ;
           double x = player.position().x();
           double y = player.position().y();
           double z = player.position().z(); 
           BlockPos blockPos = new BlockPos(x, y, z);
            world.setBlockAndUpdate(blockPos, Blocks.DIAMOND_BLOCK.defaultBlockState());
        }

Link to comment
Share on other sites

no errors more

        PlayerEntity player;
        World world;
        Hand hand;
        
    @Override
    public ActionResultType useOn(ItemUseContext p_195939_1_) {

        if(!world.isClientSide){
             ;
           double x = player.position().x();
           double y = player.position().y();
           double z = player.position().z(); 
           BlockPos blockPos = new BlockPos(x, y, z);
            world.setBlockAndUpdate(blockPos, Blocks.DIAMOND_BLOCK.defaultBlockState());
        }
        return super.useOn(p_195939_1_);
    }

Link to comment
Share on other sites

I wanted to add that I am doing "learning by doing" and not only understand Forge mobing but also Java as well as the IDE Eclipse, so when I look very stupid (and I feel stupid to myself because I sometimes don't check it what you mean) so sorry for that and thank you for your time for my problem with Probgarmmiren ^^

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello! I have recently purchased a new computer and cannot download Optifine or Forge. The issue I am having is that the Java program 'javaw.exe' does not seem to open .jar files for me. As far as I can tell, I cannot open .jar files at all. The trouble-shooting I have tried so far is that I have un-downloaded and re-downloaded Java and that has not fixed it. I have followed the pathway to 'open with->choose another app->choose an app on your pc->Program Files (x86)->Java->jre-1.8->bin. and from inside bin I have tried opening these programs with each and every java application in there assuming I may have been wrong about which one I need to use. Still no luck. From there I checked to make sure that Java was allowed through my firewall and have seen no instances of any application with Java in the name anywhere in the list of apps to let through fire wall. I'm unsure of what to try next, so I would absolutely love help figuring out why my computer is not letting me open .jar files. Specifically these ones that I know are meant to open as installers. Any ideas are appreciated. Thanks in advance!
    • Thanks again for your anwsers, I tested without practical_plushies_mobs, practical_plushies_animals and dark-waters and now red forge loading screen appears however few seconds later it crashed again.  How I could put my file codes in my minecraft folder? log crash report
    • I have a modded mob that when I try to spawn it, it won't spawn and a crash happens (doesn't crash whole game though) and it says "Duplicate id value for 16!" and points to the mob's defineSynchedData method. Anyone know what's going on? Here's the method it was pointing to: @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(MY_BOOLEAN_DATA, false); }  
    • Click Here -- Official Website -- Order Now ➡️● For Order Official Website - https://sale365day.com/get-restore-cbd-gummies ➡️● Item Name: — Restore CBD Gummies ➡️● Ingredients: — All Natural ➡️● Incidental Effects: — NA ➡️● Accessibility: — Online ✅HUGE DISCOUNT ! HURRY UP! ORDER NOW!✅ ✅HUGE DISCOUNT ! HURRY UP! ORDER NOW!✅ ✅HUGE DISCOUNT ! HURRY UP! ORDER NOW!✅   Restore CBD Gummies is a strong contender for the top gummy of the year. Due to its strong concentration of CBD and purity, you will achieve excellent results while using it if you stick with this solution. Most people who suffer from constant pain, anxiety, depression, and insomnia are currently solving these problems, and you can be the next one. All you need to do is give Restore CBD Gummies a chance and let this fantastic product change your life. Visit the official website to order your Restore CBD Gummies today! After reading Restore CBD Gummies reviews, we now know that knee replacement surgeries are not the only option to treat knee pain, inflammation, joint discomfort, and stiffness. These CBD gummies can heal your joints and provide you relief from pain and stress so that you can lead a happy life. Prosper Wellness Restore CBD Gummies can improve joint mobility and improve knee health so that you can remain healthy. Exclusive Details: *Restore CBD Gummies* Read More Details on Official Website #USA! https://www.facebook.com/claritox.pro.unitedstates https://www.facebook.com/illudermaUCAAU https://www.facebook.com/awakenxtusa https://groups.google.com/a/chromium.org/g/chromium-reviews/c/8NMUVKgd-FA https://groups.google.com/g/microsoft.public.project/c/0UZQQKOZF58 https://groups.google.com/g/comp.editors/c/r_BcRRrvGhs https://medium.com/@illuderma/illuderma-reviews-fda-approved-breakthrough-or-clever-skincare-scam-36088ae82c3e https://medium.com/@claritoxpros/claritox-pro-reviews-legitimate-or-deceptive-dr-warns-of-potential-dangers-d5ff3867b34d https://medium.com/@thedetoxall17/detoxall-17-reviews-scam-alert-or-legit-detox-solution-customer-report-inside-1fd4c6920c9e https://groups.google.com/a/chromium.org/g/chromium-reviews/c/RONgLAl6vwM https://groups.google.com/g/microsoft.public.project/c/TgtOMRFt6nQ https://groups.google.com/g/comp.editors/c/fUfg0L2YfzU https://crediblehealths.blogspot.com/2023/12/revitalize-with-restore-cbd-gummies.html https://community.weddingwire.in/forum/restore-cbd-gummies-uncovered-fda-approved-breakthrough-or-deceptive-wellness-scam--t206896 https://restorecbdgummies.bandcamp.com/album/restore-cbd-gummies-uncovered-fda-approved https://my-restore-cb.clubeo.com/page/restore-cbd-gummies-reviews-customer-alert-drs-warning-genuine-or-wellness-hoax.html https://my-restore-cb.clubeo.com/page/restore-cbd-gummies-reviews-scam-alert-or-legit-relief-solution-customer-report-inside.html https://medium.com/@restorecbdgum/restore-cbd-gummies-reviews-warning-2023-update-real-or-a-powerful-relief-hoax-caution-350b61472a3f https://devfolio.co/@restorecbdgum https://restore-cbd-gummies-9.jimdosite.com/ https://devfolio.co/project/new/restore-cbd-gummies-reviews-scam-or-legit-custo-7bd6 https://groups.google.com/a/chromium.org/g/chromium-reviews/c/R0enUCvfs8s https://groups.google.com/g/microsoft.public.project/c/miJma2yOMDQ https://groups.google.com/g/comp.os.vms/c/S_HG94aaKFo https://groups.google.com/g/mozilla.dev.platform/c/qb6WpMUYLu0 https://hellobiz.in/restore-cbd-gummies-reviews-warning-2023-update-genuine-wellness-or-another-hoax-caution-211948390 https://pdfhost.io/v/ir5l.cseV_Restore_CBD_Gummies_Reviews_WARNING_2023_Update_Genuine_Wellness_or_Another_Hoax_Caution https://odoe.powerappsportals.us/en-US/forums/general-discussion/7c8b3f62-6d96-ee11-a81c-001dd8066f2b https://gamma.app/public/Restore-CBD-Gummies-ssh57nprs2l6xgq https://restorecbdgummies.quora.com/ https://www.facebook.com/RestoreCBDGummiesUS https://groups.google.com/g/restorecbdgum/c/9KHVNp3oy3E https://sites.google.com/view/restorecbdgummiesreviewsfdaapp/home https://experiment.com/projects/pjyhtzvpcvllopsglcph/methods https://lookerstudio.google.com/reporting/e5e9f52d-ae52-4c84-96c6-96b97932215f/page/XtkkD https://restore-cbd-gummies-reviews-is-it-a-sca.webflow.io/ https://colab.research.google.com/drive/1xZoc6E2H-jliBSZRVl0vnVqrkc3ix4YU https://soundcloud.com/restore-cbd-gummies-821066674/restore-cbd-gummies https://www.eventcreate.com/e/restore-cbd-gummies-reviews https://restorecbdgummies.godaddysites.com/ https://sketchfab.com/3d-models/restore-cbd-gummies-reviews-fda-approved-7cfe1fb8b003481c81689dd9489d2812 https://www.scoop.it/topic/restore-cbd-gummies-by-restore-cbd-gummies-9 https://events.humanitix.com/restore-cbd-gummies https://communityforums.atmeta.com/t5/General-Development/Restore-CBD-Gummies/m-p/1113602
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.