8 posts
Location
Overworld
Posted 12 March 2013 - 02:50 PM
Hi!
I create a peripheral and i need to get the username of who uses the computer. It's possible? If yes, how?
Sorry for my bad english :P/>
8543 posts
Posted 12 March 2013 - 04:27 PM
Split into new topic.
Which user? A computer can be interacted with by multiple people.
Perhaps this topic would be better suited to the peripheral help section. I think I shall move it in a while.
7508 posts
Location
Australia
Posted 12 March 2013 - 04:38 PM
You could poll Minecraft for the players within a 1 block radius of the peripheral block. But I am unaware of a method to find out what they are interacting with, so you wouldn't know if they were using the computer or just standing near it. Also another problem would be if they were interacting with a monitor as that can be done 3 blocks away from it.
1511 posts
Location
Pennsylvania
Posted 12 March 2013 - 04:51 PM
I was thinking about this the other day (Someone was screwing with my computer when I was coding), why not make private computers? However, i'm not entirely sure you can do this. What if two users click in at once? What if a user crafts a private computer but another user clicked into it first? Should it detect the owner upon crafting? Can you detect owners upon crafting? Like I said, i'm not even sure if you can detect who is using the computer at the current time. Maybe through a new event? Although that would call for serious background coding.
7508 posts
Location
Australia
Posted 12 March 2013 - 05:13 PM
You cannot get the owner on crafting. It would have to be done on first open like IC2 personal safe.
2005 posts
Posted 12 March 2013 - 06:26 PM
PDA's (whenever they arrive) will probably only be usable by the player holding the item. So that solves that problem. But not the OP's question.
1511 posts
Location
Pennsylvania
Posted 12 March 2013 - 06:30 PM
You cannot get the owner on crafting. It would have to be done on first open like IC2 personal safe.
There lies the problem…
7508 posts
Location
Australia
Posted 12 March 2013 - 06:50 PM
There lies the problem…
It's minecrafts fault.
the crafting container is what 'crafts' the item, not the player, the player supplies the items, the recipe manager for the crafting container checks the item and puts it in the output. so code base wise the player is never involved in the process. so if you could get the entity that crafted the item it would always be the 'crafting bench' entity.
98 posts
Posted 12 March 2013 - 09:35 PM
for the block you could ask RichardG how he did his player detector and for the crafting there might be a way because mystcraft uses the coords of the player surely you could get the name aswel.
7508 posts
Location
Australia
Posted 12 March 2013 - 11:15 PM
Mystcraft is different. On crafting it uses the crafting bench coord, or the player coord when using the internal crafting bench, which is different than getting the player name on crafting.
8 posts
Location
Overworld
Posted 12 March 2013 - 11:55 PM
Thanks!
Finally, i save the owner of my peripheral with onBlockPlacedBy()