Multi-file support as well, please. I dont want to make a 2000 line server mod, thanks.
Last active
October 27, 2018 12:25
-
-
Save lukeeey/fee381de5b1d4696e595e51446360773 to your computer and use it in GitHub Desktop.
An example of what i would like to see in the Minecraft: Bedrock scripting api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PLEASE add this. I love OOP and it will encourage more developers to accept the defeat of not using C# and instead using javascript. | |
// I dont know if theres currently a way to create a new block, but i would encourage you, Mojang, to make it **this** way. | |
class CustomBlock extends minecraft.Block { | |
constructor() { | |
super('minecraft:custom_block'); | |
} | |
getName() { | |
return 'Custom Block'; | |
} | |
onInteract(world, pos, player) { | |
if(world.name == 'LuckyBlockArena') { | |
player.sendChat(`You clicked the block at ${pos.x}, ${pos.y}, ${pos.z}!`); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomEntity extends minecraft.Entity { | |
constructor() { | |
super('minecraft:custom_entity'); | |
} | |
getName() { | |
return 'Custom Entity'; | |
} | |
onDeath(world, pos, entity) { | |
if(world.name == 'LuckyBlockArena') { | |
world.broadcastChat(entity.name + ' died!'); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here are some examples of what the world and player objects (passed to onInteract() in CustomBlock.js) could look like. | |
// Maybe some of this could be replaced with the component system or by allowing us to read the NBT instead. | |
// I'm just a fan of a nice API so i thought i'd give an example | |
world { | |
name: 'LuckyBlockArena', | |
dimension: 'overworld', | |
gamerules: { | |
doDaylightCycle: true, | |
commandBlockOutput: false | |
}, | |
spawnpoint: { | |
x: 9, y: 9, z: 9 | |
}, | |
difficulty: 'peaceful', | |
defaultGamemode: 'survival' | |
} | |
// And the player stuff | |
player { | |
sendChat(string): function, | |
setPosition(x, y, z): function, | |
position: { | |
x: 9, y: 9, z: 9 | |
}, | |
name: string, | |
uuid: string | |
} | |
// I know this will probably never make its way into the API, but it was worth a try. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var system = client.registerSystem(0, 0); | |
system.initialize = function() { // cant this be onInitialize, to clarify the fact its an event? | |
this.registerBlock(new CustomBlock()); | |
this.registerEntity(new CustomEntity()); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment