Skip to content

Commit 8d3572d

Browse files
Merge pull request #388 from ut7/1.13-drone-fix
Minimal fix for Drone in 1.13
2 parents 0a6fe18 + fdeb7c6 commit 8d3572d

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

src/main/js/modules/drone/index.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,33 @@ function getDirFromRotation(location) {
326326
if (r > 225 && r <= 315) return 0; // east
327327
return 1; // south
328328
}
329+
330+
var setTypeIdAndData = makeTypeIdAndDataSetter();
331+
332+
function makeTypeIdAndDataSetter() {
333+
if (!__plugin.bukkit) {
334+
return null;
335+
}
336+
337+
var Block = Java.type('org.bukkit.block.Block');
338+
if (
339+
Java.from(Block.class.methods).some(function(m) {
340+
return m.name == 'setTypeIdAndData';
341+
})
342+
) {
343+
console.log('Drone using Block.setTypeIdAndData method');
344+
return function(block, typeId, data, applyPhysics) {
345+
block.setTypeIdAndData(typeId, data, applyPhysics);
346+
};
347+
} else {
348+
console.log('Drone using CraftEvil.setTypeIdAndData method');
349+
var CraftEvil = Java.type(server.class.package.name + '.util.CraftEvil');
350+
return function(block, typeId, data, applyPhysics) {
351+
CraftEvil.setTypeIdAndData(block, typeId, data, applyPhysics);
352+
};
353+
}
354+
}
355+
329356
/*
330357
low-level function to place a block in the world - all drone methods which
331358
place blocks ultimately invoke this function.
@@ -349,8 +376,7 @@ function putBlock(x, y, z, blockId, metadata, world, update) {
349376
}
350377
}
351378
if (__plugin.bukkit) {
352-
block.setTypeIdAndData(blockId, metadata, false);
353-
block.data = metadata;
379+
setTypeIdAndData(block, blockId, metadata, update);
354380
}
355381
return block;
356382
}

0 commit comments

Comments
 (0)