Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Does anyone have an idea how i can get the distance from player to a specific block like placed torches?

 

i tried "ModLoader.getMinecraftInstance().theWorld.getEntitiesWithinAABB" but it only works with entities like the name says xP...

 

anyone knowing a good way?

 

edit: on second page is a working solution

  AxisAlignedBB var4 = AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1)).expand(var1, var1, var1);

         

List var5 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, var4);

            Iterator var6 = var5.iterator();

            EntityPlayer var7;

 

            while (var6.hasNext())

            {

                var7 = (EntityPlayer)var6.next();

                do stuff

}

  • Author

thanks! but i have a few questions..

 

...this.xCoord... should this be the player position? or from the toch?

 

is var1 the radius of the detection?

 

Edit: and i dont want to use it in a new block i want to detect things that are already in the game..

oh i forgot this methods only works if the block has tile entity(because this must go in tile entity)

also var1 is

double var1 = (double)(4* 8 + 8);

this is from TileEntityBeacon

  • Author

my problem is that i dont want to use it with new blocks i want to detect torches and things in vanilla...

  • Author

hey like u can use world.setBlockTileEntity

 

how do you mean that?

 

i need the coordinates for the world.setBlockTileEntity...

this will return a list of colliding boxes

AxisAlignedBB var4 = AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)player.posX + how blocks u want(double)player.posY + how blocks u want(double)player.posZ + how blocks u want(double)(player.posX + 1), (double)(player.posY + 1), (double)(player.posZ + 1));

    List list = Minecraft.getMinecraft().theWorld.getAllCollidingBoundingBoxes(var4);

  • Author

but how do i use that to compare if its a specific block like a torch etc...?

sry for the many questions...^^

  • Author

list.equals(string)

 

ok i tried this:

 

			AxisAlignedBB var4 = AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)plX + 10,(double)plY + 10,(double)plZ + 10,(double)(plX + 1), (double)(plY + 1), (double)(plZ + 1));
	       List list = Minecraft.getMinecraft().theWorld.getAllCollidingBoundingBoxes(var4);

            Iterator var6 = list.iterator();
            EntityPlayer var7;
            
            if(list.equals("50"))
            while (var6.hasNext())
            {
            	System.out.println("got one torch!");
                var7 = (EntityPlayer)var6.next();
            }

 

but the list is empty xP

  • Author

System.out.println(list);

see what u get on console

 

ok now i got the coordinates in the list like:

[iNFO] [sTDOUT] [box[-295.0, 68.0, 277.0 -> -294.0, 69.0, 278.0], box[-295.0, 69.0, 277.0 -> -294.0, 70.0, 278.0], box[-295.0, 70.0, 277.0 -> -294.0, 71.0, 278.0], box[-295.0, 68.0, 278.0 -> -294.0, 69.0, 279.0],...]

 

but how do i go through this with a block specific comparison? ^^

 

complete code:

[hide]

			AxisAlignedBB var4 = AxisAlignedBB.getBoundingBox(plX, plY, plZ, plX + 1.0D, plY + 1.0D, plZ + 1.0D).expand(4D, 2D, 4D);
	       List list = Minecraft.getMinecraft().theWorld.getAllCollidingBoundingBoxes(var4);

            Iterator var6 = list.iterator();
            EntityPlayer var7;
            
            if(list.equals("50"))
            while (var6.hasNext())
            {
            	System.out.println("got one torch!");
                var7 = (EntityPlayer)var6.next();
            }
            System.out.println(list);

[/hide]

  • Author

String ing =  list.toString();

System.out.println(ing);

 

do you mean i have to write a function which goes through the string; takes the specific coordinates; compares them if they are torches; and gives a return statement?

because the " System.out.println(ing);" output is the same...

 

  • Author

do you have skype or something?, to talk better

 

yes but i cant talk anymore girlfriend is asleep... ;)

 

i mean this comparison if the torch block is in the list is the last thing i have to find out...^^

sorry, torch dosent have aabb so change

                      if(list.equals("50"))

              to

if(!list)

  • Author

sorry, torch dosent have aabb so change

                      if(list.equals("50"))

              to

if(!list)

 

if(!list) is red underlined i took if(list != null)...

 

but the game crashes in the while at:

var7 = (EntityPlayer)var6.next();

 

edit: nevermind saw my bug^^

 

 

			AxisAlignedBB var4 = AxisAlignedBB.getBoundingBox(plX, plY, plZ, plX + 1.0D, plY + 1.0D, plZ + 1.0D).expand(4D, 2D, 4D);
	       List list = Minecraft.getMinecraft().theWorld.getAllCollidingBoundingBoxes(var4);

            Iterator var6 = list.iterator();
            EntityPlayer var7;
            
            if(list != null)
            while (var6.hasNext())
            {
            	
                var7 = (EntityPlayer)var6.next();
            }
            
            String ing =     list.toString();
            System.out.println(ing);   

 

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.