Comments (14)
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.
Next steps:
- Check the pollBlockHits data
- Add interactivity to some basic scene
from mcthings.
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.
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.
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.
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):
And if you leave the button pressed, you get lots of events:
from mcthings.
Ok, so the path is clear to start buiding interactive scenes. In my next session I will implement it!
from mcthings.
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.
Mostly done:
Right hitting with the sword in the glass bar build the next item in the scene.
from mcthings.
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.
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.
from mcthings.
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.
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.
https://twitter.com/acstw/status/1264337652746260480
All done!
from mcthings.
Related Issues (20)
- Learn Vulcan API HOT 3
- Research Open Source Physics engines HOT 5
- Learn Computer Graphics HOT 1
- Research Ray Tracing HOT 11
- Explore the Cyrille Rossant Python Ray Tracer HOT 4
- Implement a Ray Cast renderer for McThings
- Test that McThings works with MC 1.16.1 HOT 2
- Create a Blender renderer for McThings
- Remove McDrawing reimplementing the Sphere
- Research resources pack in Minecraft HOT 4
- Research shaders in Minecraft HOT 1
- Research the use of textures inside Blender
- Research the use of shaders inside Blender
- Implement voxels collisions in Godot physics testbed HOT 14
- Create a Godot renderer for McThings
- vox2schematic - TypeError: to_nbt() takes 3 positional arguments but 4 were given HOT 1
- Test McThings with the last version of Minecraft HOT 2
- Research the migration from TravisCI to GitHub Actions HOT 1
- vox2schematic not working
- Implement McThings over Godot
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mcthings.