forked from SteamWar/SteamWar
Make it 1.8 compatible
This commit is contained in:
@@ -66,8 +66,8 @@ public class BlockIds14 implements BlockIds {
|
||||
return getBlock.invoke(null, material);
|
||||
}
|
||||
|
||||
private static final Reflection.Method getCombinedId = Reflection.getTypedMethod(TechHider.block, null, int.class, TechHider.iBlockData);
|
||||
private int getCombinedId(Object blockData) {
|
||||
@Override
|
||||
public int getCombinedId(Object blockData) {
|
||||
return (int) getCombinedId.invoke(null, blockData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,12 @@ import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class BlockIds8 implements BlockIds {
|
||||
@Override
|
||||
public int getCombinedId(Object iBlockData) {
|
||||
int id = (int) getCombinedId.invoke(null, iBlockData); // blockState << 12 | blockId
|
||||
return (id & 4095) | (id >> 12);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public int materialToId(Material material) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.techhider;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.VersionDependent;
|
||||
import org.bukkit.Material;
|
||||
@@ -28,6 +29,9 @@ import java.util.Set;
|
||||
public interface BlockIds {
|
||||
BlockIds impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||
|
||||
Reflection.Method getCombinedId = Reflection.getTypedMethod(TechHider.block, null, int.class, TechHider.iBlockData);
|
||||
|
||||
int getCombinedId(Object iBlockData);
|
||||
int materialToId(Material material);
|
||||
Set<Integer> materialToAllIds(Material material);
|
||||
}
|
||||
|
||||
@@ -49,9 +49,8 @@ public class TechHider {
|
||||
public static final Class<?> craftMagicNumbers = Reflection.getClass("org.bukkit.craftbukkit.util.CraftMagicNumbers");
|
||||
private static final Reflection.Method getBlockByMaterial = Reflection.getTypedMethod(craftMagicNumbers, "getBlock", block, Material.class);
|
||||
|
||||
private static final Reflection.Method getCombinedIdByIBlockData = Reflection.getTypedMethod(block, null, int.class, iBlockData);
|
||||
public boolean iBlockDataHidden(Object iBlockData) {
|
||||
return obfuscateIds.contains(getCombinedIdByIBlockData.invoke(null, iBlockData));
|
||||
return obfuscateIds.contains(BlockIds.impl.getCombinedId(iBlockData));
|
||||
}
|
||||
|
||||
public static final Object AIR = getBlockDataByBlock.invoke(getBlockByMaterial.invoke(null, Material.AIR));
|
||||
|
||||
Reference in New Issue
Block a user