Add blockdata as a valid falling block thing, requires setblockdata

This commit is contained in:
libraryaddict
2020-08-12 09:36:13 +12:00
parent f322a80b69
commit 4f0290218b
36 changed files with 268 additions and 139 deletions

View File

@@ -16,6 +16,8 @@ import me.libraryaddict.disguise.utilities.sounds.SoundGroup;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.*;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.SimpleCommandMap;
@@ -131,7 +133,7 @@ public class ReflectionManager {
NmsAddedIn added = obj.getAnnotation(NmsAddedIn.class);
// If it was added after this version
if (!added.val().isSupported()) {
if (!added.value().isSupported()) {
return false;
}
}
@@ -1463,6 +1465,19 @@ public class ReflectionManager {
return new WrappedWatchableObject(watcherItem);
}
public static int getCombinedIdByBlockData(BlockData data) {
try {
Object iBlockData = getCraftMethod("block.data.type.CraftBlockData", "getState").invoke(data);
return (int) getNmsMethod("Block", "getCombinedId", getNmsClass("IBlockData")).invoke(null, iBlockData);
}
catch (Exception ex) {
ex.printStackTrace();
}
return 0;
}
public static int getCombinedIdByItemStack(ItemStack itemStack) {
try {
Object nmsBlock;