Jump to content

Recommended Posts

Posted

Hello everyone. Pardon my English.

 

I was looking at the BlockPistonBase class because I want to understand it's funcionality and there are 2 methods that are real mysteries to me:

 

/**
   * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the
   * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
*/
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB,
          List par6List, Entity par7Entity)
{
     this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
     super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}

 

the other one seems related to the first one:

 

/**
   * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
   * cleared to be reused)
   */
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
     this.setBlockBoundsBasedOnState(par1World, par2, par3, par4);
     return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4);
}

 

They are both about Bounding Boxes. I assume a Bounding Box is a Box of uncrossable space, and that any moving thing will collide with it and halt it's movement. If someone could explain them further and give me an insight on how Bounding Boxes and those 2 methods work I'd very much appreciate it.

 

Thanks!

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Posted

lets see... (not sure if im correct! ^^)

 

here's an example, if you create a table like this one

jwipbces.png

and now want to add it 2 the game and then test it.

So you save your classes, start minecraft and place your new table.

But whats this? you siddenly realise that you can walk trough one side of the table block.

You can also place other blocks inside the other side of your table.

that's because when you place blocks, they have a bounding box of 1 block.

there isnt any collision data there wich would stop you from walking trough the one side of the table.

 

Back to the pistons.

when you power one, the piston block occupies the space of the block next to it in it's direction.

so,

this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

the 1st 3 params are X1, Y1, Z1 and the last 3 X2, Y2, Z2.

X1,Y1,Z1 are the coordinates of the first angle of the block and X2,Y2,Z2 are the coordinates of the opposite angle of the block. These must be between 0 and 1.

now, the piston occupies the space of two blocks.

as the piston occupies only 1 block by default, it needs this Bounding box function, to add one more when powered, i believe.

 

But that's just a theory of mine. All this could be completely wrong but maybe not xD idk..

 

if you are trying to make a block wich is for example 4 blocks big, you can let your "structure" to be placed by an item.

Now you split your structure in 4 parts (as you need the space of 4 blocks), just like Mojang did with the bed, ya, the bed is a good example.

They split it up in 2 blocks.

Now back to the item. in the item's class (wich is placing the structure) you can make it place all the parts of your structure in the right section,

to make it look as one when its placed :)

there are a lot mroe tricks for making structures wich need more space, but i currently only know this one :)

 

yeah :) ended up writing, gettin' off topic a lil bit i guess... but maybe it helped u somehow  8)

 

ps: ya, i guess the bounding box function thingy is useful for blocks, wich are by default 1x1 and when powered (for example) bigger.

the bed didnt need such a thing, since it's never goin' 2 change when powered :P

 

 

Cheers,

-East

Posted

Thanks! That's a real good start! I'll resume studying now that I know a little more. If anyone has something more to add, though, it would help even more!

 

Thanks again :)

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Posted

It's impossible for me to understand BlockPistonBase  :'(

 

Due to it's inherent complexity, minecraft's extremely confusing and labyrinthine coding style (it must be hell inside Notch's head) and the lack of meaningful names on parameters and local variables. I quit trying to understand this class.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Posted

It's impossible for me to understand BlockPistonBase  :'(

 

Due to it's inherent complexity, minecraft's extremely confusing and labyrinthine coding style (it must be hell inside Notch's head) and the lack of meaningful names on parameters and local variables. I quit trying to understand this class.

 

The names are not those Mojang/Notch wrote inn their code, the functions are named whatever the decompile set it to( like func_24443a).

The methods which have real names are named based upon what they seemes to be doing by the Mcp/community after playing with the code.

 

Anyways, what other parts did you find confusing?

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

Posted
The names are not those Mojang/Notch wrote inn their code, the functions are named whatever the decompile set it to( like func_24443a).

The methods which have real names are named based upon what they seemes to be doing by the Mcp/community after playing with the code.

 

Which is why it's taken them four years to implement dynamic deobfuscation. :P

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.

Posted

oh I know about the names... It just adds up to the problem. It's complex stuff, written in a crazy obscure way (this is the part I blame Mojang for, haha) and without meaninful names (which is unavoidable, I suppose).

 

Anyway, I decided to focus on the parts regarding sides and orientation. I've implemented a multi-textured block (each of it's 6 sides has a texture: front, back, top, bot, left, right). I copy-pasted BlockPistonBase.determineOrientation and found out that it returns an integer from 0 to 5, each meaning a different side from where you placed the block.

 

So, I wrote my own registerIcon and getBlockTextureFromSideAndMetadata because 1) I couldn't understand how their implementation in BlockPistonBase class worked and 2) My block has 6 textures instead of only 3 (i think it's 3?) like pistons.

 

It all works fine when I place the block from any side other than "from above" and "from bellow". Because, the way I did, you always get each texture on a particular side, depending on from where you placed the block (the return of determineOrientation). The problem with this approach is that if I place the block from bellow or from above things like "left", "right", "top" and "bottom" should mean different things, unless you are DIRECTLY above or below the block you placed, you are always kinda at one of the 4 other positions.

 

So, how could I change the implementation of BlockPistonBase.determineOrientation to fix that? Because I don't really have any idea of how the method does what it does, I can't figure out what to change to make it work the way I mean to.

 

EDIT: If I knew of a way to know which direction a given entity is facing (the same info shown when you press f3 and you can read north or south or east or west there) then I think I would be able to do this. Does anyone know how to get the direction an entity is facing?

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Posted
EDIT: If I knew of a way to know which direction a given entity is facing (the same info shown when you press f3 and you can read north or south or east or west there) then I think I would be able to do this. Does anyone know how to get the direction an entity is facing?

 

You have access to the player as he places the block, if you look into player there are some fields you can access fields like:

 

-rotationYaw

-rotationPitch

-prevRotationYaw

 

and so on, I think you can use them to see which way the player is facing and the determine how to do the textures.

For the piston it's quite easy since it has the same texture on all sides,

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

Posted

I thought about those fields but I don't know what they mean. I don't know what's yaw or pitch etc. I don't even know what is the unity used to measure rotation. I got some Vec3 from a method called "getLook" but, again, I don't know what it means. This Vec3 has 3 really small float numbers (like 0,0000283... etc) that change in a seemingly random way as I move.

 

Has anyone already figured out how to determine the general direction an entity is facing (either north, south, east or west) who can explain it, please? Thanks

 

EDIT: I believe I maye have figured it out but for no use. I can't combine both informations (if facing Up, Down or neither and the general direction) in a 4 bit nibble :( This is probably the reason why minecraft itself doesn't have any block with 6 different textures, one for each face.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Posted

A block with 6 different textures? Why not :P

A block can have 6 different "positions" (each side can be the one facing up). You can store that in a nibble, a nibble has room for 16 states.

 

Yes. I think it is possible. In my sleep I realized I was counting from 2 to 5 instead of 0 to 3 to define the 4 basic directions (probably because they are counted like that in minecraft, 0 and 1 meaning down and up). So I was wasting a "whole bit". We can't afford that!

 

I'll try again after I come back from school today. Jesus, I'm dreaming of Java now. What's wrong with me!?!  :o

 

EDIT: It worked!

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

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.

Announcements



×
×
  • Create New...

Important Information

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