zhuowei / MCPELauncher

Source code for BlockLauncher, a launcher that patches Minecraft for Android
Apache License 2.0
683 stars 189 forks source link

Finding the pixels of a block...hmm. #331

Closed thejaustin closed 8 years ago

thejaustin commented 8 years ago

I need a way to find the pixels of a block when I tap it. Top left, bottom left, etc. I have no idea how you would do this though. Maybe you could use the way that stairs find out where you've tapped on a block when being placed? If you would like to know why, this is for my Mini Blocks Mod. Thanks for ALL your help! :smiley:

Oh, and sorry for the run-on sentence :stuck_out_tongue_closed_eyes:

thejaustin commented 8 years ago

It's not a good post from me without emojis! Hahaha

thejaustin commented 8 years ago

Haha, labeling me.

aetriusgx commented 8 years ago

Your a tagger :P

zhuowei commented 8 years ago

I think (in split touch or controller mode at least) this might be doable just from the player's pitch and yaw and raycasting to find the block - and then the sub-block - that is hit (In https://github.com/zhuowei/ModPEScripts/blob/master/500ise_paintbrush.js I used http://gamedev.stackexchange.com/questions/47362/cast-ray-to-select-block-in-voxel-game, https://raw.github.com/Overv/MineAssemble/master/reference/src/mineassemble.c to do that - I don't quite understand how it works though) but that wouldn't be practical and would break in regular touch mode, which doesn't have a crosshair

For regular touch, Minecraft PE does know where its own ray cast lands, so you can use that to find out which small block it intersects - I'll expose that and see if that helps

zhuowei commented 8 years ago

I added Player.getPointedVecX(), Player.getPointedVecY() , Player.getPointedVecZ(), which allows ModPE scripts to access MCPE's "where on the block is the player touching" info - give that a try. it's in (x, y, z) in world coordinates. I'm not sure whether that's enough for this to work though.

(ps: for lols I used this to make a cow hover over the block my cursor's on:

        Entity.setPosition(cowfly, Player.getPointedVecX(), Player.getPointedVecY() + 2, Player.getPointedVecZ());
        Entity.setVelX(cowfly, 0);
        Entity.setVelY(cowfly, 0);
        Entity.setVelZ(cowfly, 0);

So even if this isn't enough for your use case, the floating cow certainly made me laugh)

thejaustin commented 8 years ago

Okay, so bringing up split touch...I forgot to mention that. Split touch needs to be enabled to do this efficiently. I will have it auto-enable split touch when you're holding a mini block. However, I've mentioned before that there's no ModPE code that lets you turn on crosshairs. If you could go ahead and add that it would help me alot. Thanks. :)

thejaustin commented 8 years ago

Hahaha

zhuowei commented 8 years ago

(stupid comment: why do you need split touch? just, like, zoom the FOV way in and both regular and split touch should be able to edit the blocks...)

thejaustin commented 8 years ago

Yes, but it would help players out a lot. I can promise you people will yell at me saying 'I can't place it directly on the corner of this block' IDK. Thanks for the help though. :)

zhuowei commented 8 years ago

ok, well, grab the latest beta (http://tinyw.in/bl) and see if that helps you. I'll look into split touch later, I guess.

thejaustin commented 8 years ago

Thanks man. :) Currently playing with code at 2 AM. DOES THIS MAKE ME A REAL PROGRAMMER? Hahaha

aetriusgx commented 8 years ago

Honestly yes it does, survive 2 more hours then your a pro

thejaustin commented 8 years ago

Haha, I've done so until 4 AM before, but I need some sleep now. Hopefully I can figure this out tomorrow. :) Thanks to Zhuowei I'll be working my butt off on mini blocks!

aetriusgx commented 8 years ago

I've done an all nighter once, only to find out I didn't have to spend all that time :/

ghost commented 8 years ago

@zhuowei maybe add a method that can change the options of minecraft pe, that will help a lot.

I have a suggestion for you all turn gfx_gamma:1 its value to 400 that way you can use Night Vision :)

zhuowei commented 8 years ago

@KairusDarkSeeker or just apply the night vision potion effect to the player ;)

So I guess this is resolved - closing issue.

thejaustin commented 8 years ago

I don't know if you'll respond @zhuowei, but I'm still trying to figure out how to use this feature to find the pixels of a block to place a mini block there... 😟

ghost commented 8 years ago

@zhuowei Player.getPointedVec isn't on BlockLauncher why???