Fixed: исправлена ошибка об отсувии runtime id
This commit is contained in:
@@ -8,6 +8,7 @@ import cn.nukkit.item.RuntimeItems;
|
|||||||
import com.reider745.api.ReflectHelper;
|
import com.reider745.api.ReflectHelper;
|
||||||
import com.reider745.api.hooks.HookClass;
|
import com.reider745.api.hooks.HookClass;
|
||||||
import com.reider745.api.hooks.annotation.Hooks;
|
import com.reider745.api.hooks.annotation.Hooks;
|
||||||
|
import com.reider745.api.hooks.annotation.Inject;
|
||||||
import com.reider745.block.CustomBlock;
|
import com.reider745.block.CustomBlock;
|
||||||
import com.reider745.item.CustomItem;
|
import com.reider745.item.CustomItem;
|
||||||
import com.reider745.item.ItemMethod;
|
import com.reider745.item.ItemMethod;
|
||||||
@@ -20,6 +21,12 @@ import java.util.*;
|
|||||||
|
|
||||||
@Hooks(className = "cn.nukkit.item.RuntimeItemMapping")
|
@Hooks(className = "cn.nukkit.item.RuntimeItemMapping")
|
||||||
public class RuntimeItemsHooks implements HookClass {
|
public class RuntimeItemsHooks implements HookClass {
|
||||||
|
private static HashMap<Integer, Boolean> protocols = new HashMap<>();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public static void generatePalette(RuntimeItemMapping self){
|
||||||
|
protocols.put(self.getProtocolId(), true);
|
||||||
|
}
|
||||||
|
|
||||||
public static void register(int protocolId) {
|
public static void register(int protocolId) {
|
||||||
final Map<String, Integer> legacyString2LegacyInt = ReflectHelper.getField(RuntimeItems.class,
|
final Map<String, Integer> legacyString2LegacyInt = ReflectHelper.getField(RuntimeItems.class,
|
||||||
@@ -84,29 +91,13 @@ public class RuntimeItemsHooks implements HookClass {
|
|||||||
Method generatePalette = RuntimeItemMapping.class.getDeclaredMethod("generatePalette", new Class[0]);
|
Method generatePalette = RuntimeItemMapping.class.getDeclaredMethod("generatePalette", new Class[0]);
|
||||||
generatePalette.setAccessible(true);
|
generatePalette.setAccessible(true);
|
||||||
generatePalette.invoke(mapping, new Object[0]);
|
generatePalette.invoke(mapping, new Object[0]);
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
|
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
| SecurityException e) {
|
|
||||||
throw new UnsupportedOperationException(e);
|
throw new UnsupportedOperationException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
register(361);
|
for(Integer id : protocols.keySet())
|
||||||
register(419);
|
register(id);
|
||||||
register(440);
|
|
||||||
register(448);
|
|
||||||
register(475);
|
|
||||||
register(486);
|
|
||||||
register(503);
|
|
||||||
register(527);
|
|
||||||
register(534);
|
|
||||||
register(560);
|
|
||||||
register(567);
|
|
||||||
register(575);
|
|
||||||
register(582);
|
|
||||||
register(589);
|
|
||||||
register(594);
|
|
||||||
register(618);
|
|
||||||
register(630);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user