Silverkill95 Posted May 1, 2013 Posted May 1, 2013 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? Quote
Mazetar Posted May 1, 2013 Posted May 1, 2013 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? Quote If you guys dont get it.. then well ya.. try harder...
Silverkill95 Posted May 1, 2013 Author Posted May 1, 2013 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 Quote
Mazetar Posted May 1, 2013 Posted May 1, 2013 world.getBlockId(xPos, yPos, zPos) Quote If you guys dont get it.. then well ya.. try harder...
Silverkill95 Posted May 1, 2013 Author Posted May 1, 2013 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? Quote
Mazetar Posted May 1, 2013 Posted May 1, 2013 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 Quote If you guys dont get it.. then well ya.. try harder...
Draco18s Posted May 1, 2013 Posted May 1, 2013 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. Quote 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.
Reika Posted May 2, 2013 Posted May 2, 2013 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); } } Quote Follow my mod(s) here: http://www.minecraftforum.net/topic/1969694-
Mazetar Posted May 2, 2013 Posted May 2, 2013 Nice code Reika Quote If you guys dont get it.. then well ya.. try harder...
Reika Posted May 2, 2013 Posted May 2, 2013 Nice code Reika Thank you. 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). Quote Follow my mod(s) here: http://www.minecraftforum.net/topic/1969694-
Draco18s Posted May 2, 2013 Posted May 2, 2013 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. Quote 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.
Recommended Posts
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.