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

so, my mod blows items npc's mobs and players into a certain direction

however, if you put a block inbetween it will still move you

 

my question is what method do i need to use in my TileEntity to make it so that i stop moving

aka, how do i check for a block in the distance?

 

 

Well if you can answer this, you should already have the answer in front of you:

 

How can you get a block at any given position? :)

If you guys dont get it.. then well ya.. try harder...

  • Author

Well if you can answer this, you should already have the answer in front of you:

 

How can you get a block at any given position? :)

 

ehhhhh.... not really,  i cant seem to figure out a way to check if a block is in front of the block  in a 0 - 20 block  line

 

  • Author

world.getBlockId(xPos, yPos, zPos)

couldnt make it work....

besides can you show me how id make it so that it checks for a block in xPos  1-20 for example?

 

 

If you got access to the world object somehow (Hint: your TileEntity has one) then you can call the below method upon it during whatever method you are invoking, like the update method.

 

world.getBlockId(xPos, yPos, zPos)

couldnt make it work....

besides can you show me how id make it so that it checks for a block in xPos  1-20 for example?

 

Sure, but you won't like my answer.

You may not like it nor believe me, but anyone would give you the same answer:

You need to go back and learn some more java basics :)

 

I recommend looking into these, they are nice and interesting:

http://see.stanford.edu/see/lecturelist.aspx?coll=824a47e1-135f-4508-a5aa-866adcae1111

 

All material available for free, basically the whole course including assignments and handouts/lecture notes

 

If you guys dont get it.. then well ya.. try harder...

world.getBlockId(xPos, yPos, zPos)

couldnt make it work....

besides can you show me how id make it so that it checks for a block in xPos  1-20 for example?

 

Loops.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

If you want to get really advanced you could use line-of-sight algorithms like this (do not simply copy-paste the code, as it will not work for you):

	for (float i = 0; i <= range; i += 0.25) {
Vec3 vec2 = ReikaVectorHelper.getVec2Pt(x+a, y+b, z+c, x0, y0, z0).normalize();
vec2.xCoord *= i;
vec2.yCoord *= i;
vec2.zCoord *= i;
vec2.xCoord += x0;
vec2.yCoord += y0;
vec2.zCoord += z0;
//ReikaGuiAPI.write(String.format("%f --> %.3f, %.3f, %.3f", i, vec2.xCoord, vec2.yCoord, vec2.zCoord));
int id = world.getBlockId((int)vec2.xCoord, (int)vec2.yCoord, (int)vec2.zCoord);
if ((int)vec2.xCoord == x && (int)vec2.yCoord == y && (int)vec2.zCoord == z) {
//ReikaGuiAPI.writeCoords(world, (int)vec2.xCoord, (int)vec2.yCoord, (int)vec2.zCoord);
return true;
}
else if (id != 0 && (isCollideable(world, (int)vec2.xCoord, (int)vec2.yCoord, (int)vec2.zCoord) && !softBlocks(id))) {
i = (float)(range + 1);
}
}

Nice code Reika :)

Thank you. :D

 

I am writing a (non-base-class-modifying) API that has a lot of such functions; you can certainly use it in your own mods as a dependency if you want. ;) It has no "mod class", so forge does not recognize it as a true mod, but it is accessible if referenced correctly. It also has functionality to use the old spritesheet system (which Optifine sadly breaks on blocks, though items work beautifully) and some file I/O (including PNG and MIDI files).

I am writing a (non-base-class-modifying) API that has a lot of such functions; you can certainly use it in your own mods as a dependency if you want. ;) It has no "mod class", so forge does not recognize it as a true mod, but it is accessible if referenced correctly. It also has functionality to use the old spritesheet system (which Optifine sadly breaks on blocks, though items work beautifully) and some file I/O (including PNG and MIDI files).

 

Wow, really cool.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.