Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/main/js/modules/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -223,6 +227,7 @@ var blocks = {
},
trapdoor: 96,
monster_egg: 97,
stone_bricks: 98,
brick: {
stone: 98,
mossy: '98:1',
Expand Down Expand Up @@ -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;
14 changes: 12 additions & 2 deletions src/main/js/modules/drone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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!");
};
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/js/modules/testmaterial.js
Original file line number Diff line number Diff line change
@@ -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));