From 7fe1fdd4baaa756ccb0cce0d8f2886601901e341 Mon Sep 17 00:00:00 2001 From: fredo wang Date: Wed, 1 Jul 2020 09:41:38 -0400 Subject: [PATCH] minor workable fix for drone on 1.15.x and 1.16.x so we could have castle and cottage in the summer. --- src/main/js/modules/blocks.js | 22 +++++++++++++++++++++- src/main/js/modules/drone/index.js | 14 ++++++++++++-- src/main/js/modules/testmaterial.js | 11 +++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/main/js/modules/testmaterial.js diff --git a/src/main/js/modules/blocks.js b/src/main/js/modules/blocks.js index 8b2f13bdc..9255eb2f9 100644 --- a/src/main/js/modules/blocks.js +++ b/src/main/js/modules/blocks.js @@ -30,6 +30,7 @@ var blocks = { coarse_dirt: '3:1', podzol: '3:2', cobblestone: 4, + oak_wood: 5, oak: 5, spruce: '5:1', birch: '5:2', @@ -85,7 +86,7 @@ var blocks = { piston: 33, piston_extn: 34, piston_head: 34, - wool: { white: 35 /* All other colors added below */ }, + wool: { white: 35, /* All other colors added below */ }, piston_extended: 36, dandelion: 37, flower_yellow: 37, @@ -159,6 +160,7 @@ var blocks = { // see brick.red 45 tnt: 46, bookshelf: 47, + mossy_stone_bricks: 48, moss_stone: 48, obsidian: 49, torch: 50, @@ -190,9 +192,11 @@ var blocks = { furnace: 61, furnace_burning: 62, sign_post: 63, + dark_oak_door: 64, door_wood: 64, ladder: 65, rail: 66, + oak_sign: 68, sign: 68, lever: 69, pressure_plate_stone: 70, @@ -223,6 +227,7 @@ var blocks = { }, trapdoor: 96, monster_egg: 97, + stone_bricks: 98, brick: { stone: 98, mossy: '98:1', @@ -397,4 +402,19 @@ blocks.isStair = function(id) { } return false; }; +blocks.material = function(id) { + if (id == 35 || id == 95 || id == 159 || id == 160 || id == 171) id = id+":0"; + for (var p in blocks ) { + if (typeof blocks[p] == 'object') { + for (var e in blocks[p]) { + if (typeof blocks[p][e] == 'object') { + for (var i in blocks[p][e]) { + if (blocks[p][e][i] == id) return (i+'_'+e).toUpperCase(); + } + } else if (blocks[p][e] == id) return (e+'_'+p).toUpperCase(); + } + } else if (blocks[p] == id) return (p).toUpperCase(); + } + return false; +} module.exports = blocks; diff --git a/src/main/js/modules/drone/index.js b/src/main/js/modules/drone/index.js index 369f7a696..77460c846 100644 --- a/src/main/js/modules/drone/index.js +++ b/src/main/js/modules/drone/index.js @@ -335,6 +335,7 @@ function makeTypeIdAndDataSetter() { } var Block = Java.type('org.bukkit.block.Block'); + var Material = Java.type('org.bukkit.Material'); if ( Java.from(Block.class.methods).some(function(m) { return m.name == 'setTypeIdAndData'; @@ -356,8 +357,17 @@ function makeTypeIdAndDataSetter() { 'Drone support is experimental on 1.15.2 and above, and may be broken...' ); return function(block, typeId, data, applyPhysics) { - block.setBlockData(data, applyPhysics); - block.setType(typeId); + //block.setBlockData(data, applyPhysics); + // https://minecraft-ids.grahamedgecombe.com/ + var mstr = blocks.material(typeId); + if (mstr ) { + var mid = Material.getMaterial(mstr); + if (mid) block.setType(mid); + else { + console.log(typeId + " Material: " + mstr + " Not Found!"); + block.setType(Material.getMaterial('OAK_PLANKS')); + } + } else console.log("BlockId: "+typeId+" Not Found!"); }; } } diff --git a/src/main/js/modules/testmaterial.js b/src/main/js/modules/testmaterial.js new file mode 100644 index 000000000..1ad4f4d9e --- /dev/null +++ b/src/main/js/modules/testmaterial.js @@ -0,0 +1,11 @@ +var blocks=require('./blocks.js'); +console.log(blocks.oak); + +console.log(blocks.material(5)); +console.log(blocks.material('6:3')); +console.log(blocks.material('125:5')); +console.log(blocks.material('5')); +console.log(blocks.material(98)); +console.log(blocks.material('35:0'), blocks.wool.white); +console.log(blocks.material('35:15'), blocks.wool.black); +console.log(blocks.material(64));