Coder Social home page Coder Social logo

Explore Interactive Scenes about mcthings HOT 14 CLOSED

voxelers avatar voxelers commented on May 23, 2024
Explore Interactive Scenes

from mcthings.

Comments (14)

acs avatar acs commented on May 23, 2024

Taking a look to the API: https://www.stuffaboutcode.com/p/minecraft-api-reference.html

event.py
Class BlockEvent - definition of a block event, specifically what event, what block and what player

 Minecraft.events
.pollBlockHits()
"Block Hits (Only triggered by sword) => [BlockEvent]"
#get block event hits that have occured since the last time the function was run
blockEvents = mc.events.pollBlockHits()
for blockEvent in blockEvents:
    print blockEvent

.clearAll()
"Clear all old events"
#clear all events that have happened since the events where last got
mc.events.clearAll()

So the interactivity is easy: you need a sword? and when you hit a block, you get the block data that was hit. The block could be a button for example, or a lever.

The already interactive blocks in minecraft are: https://minecraft.fandom.com/wiki/Category:Interactive_blocks But we can do addiitonal things when collecting the events.

from mcthings.

acs avatar acs commented on May 23, 2024

Next steps:

  • Check the pollBlockHits data
  • Add interactivity to some basic scene

from mcthings.

acs avatar acs commented on May 23, 2024

In the extended API in the Rasperry Juice version, there is an API call to collect the chat messages. With it, you can implement a bot that read the chat messages and do things based on them. It could be pretty interesting also.

But I am not sure that this endpoint is implemented in the Forge mod or in Minetest:

.pollChatPosts()
"Chat posts => [ChatEvent]"
Available on RaspberryJuice
#get chat post events (messages) since the last time the function was run
chatEvents = mc.events.pollChatPosts()
for chatEvent in chatEvents:
    print chatEvents

https://github.com/arpruss/raspberryjammod ... it seems it takes the chat events also

And in Minetest: https://github.com/arpruss/raspberryjammod-minetest it is also implemented

from mcthings.

acs avatar acs commented on May 23, 2024

After thinking a bit about what can be done here. I have decided to build an interactive scene showing the capabilities of McThings:

  • An action will build the next Thing in a Scene
  • Other action will unbuilt it
  • Other action will change the block used
  • Other actions will let you make the Thing smaller or bigger
  • Other actionss will let you build the Things closer or further

This is just an stating point from which to evolve.

The basic scene will have two Things to play with them. Let's call the Scene the interactive scene.

Let's use two pyramids.

Let's take a look to the official blocks in the API: https://www.stuffaboutcode.com/p/minecraft-api-reference.html There are not interactive blocks. Ideally. I would like to have the lever and the button and *pressure plates.

https://minecraft.gamepedia.com/Button
https://minecraft.gamepedia.com/Lever
https://minecraft.gamepedia.com/Pressure_Plate

None of them are available in the API, but let's see if we can create them just using Block(block_id).

from mcthings.

acs avatar acs commented on May 23, 2024

Let's take a look to the available blocks using the BlockGallery Thing in 1.12.2 ....

https://www.minecraftinfo.com/idlist.htm

  • Lever: 69
  • Pressure plate: 70
  • Buttom: 77

Let's confirm we have all of them available.

Scene.server.setBlock(
  self.position.x, self.position.y, self.position.z+10, 
  mcpi.block.Block(69)
)
Scene.server.setBlock(
  self.position.x, self.position.y, self.position.z+10, 
  mcpi.block.Block(70)
)
Scene.server.setBlock(
  self.position.x, self.position.y, self.position.z+10, 
  mcpi.block.Block(77)
)

from mcthings.

acs avatar acs commented on May 23, 2024

Ok, to generate hits you need to have a sword and right click on a block (left click hits with the sword to do damage, right click is the one generating events).

And and event is something like:

BlockEvent(BlockEvent.HIT, 43, 1, 817, 5, 57)

Each hit generates 3 events (Up, down, up):

Screenshot from 2020-05-21 08-06-02

And if you leave the button pressed, you get lots of events:

Screenshot from 2020-05-21 08-08-01

from mcthings.

acs avatar acs commented on May 23, 2024

Ok, so the path is clear to start buiding interactive scenes. In my next session I will implement it!

from mcthings.

acs avatar acs commented on May 23, 2024

The idea is evolving. The scene will have a platform in the sky from which you can see the full scene. And from it, you can build and unbuild things, and change the block used in the construction. Let's see if it is possible to implement in a reasonable way.

from mcthings.

acs avatar acs commented on May 23, 2024

Mostly done:

Screenshot from 2020-05-22 08-31-24

Right hitting with the sword in the glass bar build the next item in the scene.

from mcthings.

acs avatar acs commented on May 23, 2024

For the future:

  • Create a specific SceneInteractive that can detect interactions with all the elements in a Scene. Or better, the current Scene could have a param to describe if it is interactive. In this case, an event loop is started.
  • When an interaction is detected a callback method is called: we can have a list of subscribers to be called upon events receiving. In the event we can include the Thing hit.

from mcthings.

acs avatar acs commented on May 23, 2024

Development completed!

Next step is to merge the branch and to create the video for showing it in action.

If you right click with the sword the blocks, this block will be used to build the Thing. If you right click in the glass the default block for the Thing will be used.

If you unbuilt a Thing, the next time the default block will be used if you right click the glass.

Screenshot from 2020-05-23 19-41-56

from mcthings.

acs avatar acs commented on May 23, 2024

I will add a new glass block at the center to hit it also. And move the tower further to see better the Scene. Little effort and much better result!

from mcthings.

acs avatar acs commented on May 23, 2024

All done including a video:

https://github.com/juntosdesdecasa/mcthings/releases/tag/v0.30.0
https://www.youtube.com/watch?v=TjHqt3WO-o0

Time to do the tweet!

from mcthings.

acs avatar acs commented on May 23, 2024

https://twitter.com/acstw/status/1264337652746260480

All done!

from mcthings.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.