- 269
- 8
- 19
Дак у меня указан!Вместо name.of.YourHookLoader надо указать путь до твоего хук лоадера, который ты создал по гайду
Дак у меня указан!Вместо name.of.YourHookLoader надо указать путь до твоего хук лоадера, который ты создал по гайду
2) Положите methods.bin в папку src/main/resources.
Очень странно, но при запуске из eclipse всё отлично хукает, а после компиляции в graddle - как будто не видит класс с хуком... Вот содержимое файла MANIFEST.MF после компиляции в graddle
Код:Manifest-Version: 1.0 FMLCorePlugin: com.debugme.hooklib.example.ExampleHookLoader FMLCorePluginContainsFMLMod: true
Может я забыл ещё что то прикрутить? Или нужно както следить за очередью загрузки мода/класса? Если да, то как?
Это как? Скала или Котлин?Хук в метод, который находится внутри метода - сработает?
java -Это как? Скала или Котлин?
public static BlockColors init()
{
final BlockColors blockcolors = new BlockColors();
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)state.getValue(BlockDoublePlant.VARIANT);
return worldIn != null && pos != null && (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS || blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.FERN) ? BiomeColorHelper.getGrassColorAtPos(worldIn, state.getValue(BlockDoublePlant.HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? pos.down() : pos) : -1;
}
}, Blocks.DOUBLE_PLANT);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
if (worldIn != null && pos != null)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityFlowerPot)
{
Item item = ((TileEntityFlowerPot)tileentity).getFlowerPotItem();
IBlockState iblockstate = Block.getBlockFromItem(item).getDefaultState();
return blockcolors.colorMultiplier(iblockstate, worldIn, pos, tintIndex);
}
else
{
return -1;
}
}
else
{
return -1;
}
}
}, Blocks.FLOWER_POT);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
return worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D);
}
}, Blocks.GRASS);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
BlockPlanks.EnumType blockplanks$enumtype = (BlockPlanks.EnumType)state.getValue(BlockOldLeaf.VARIANT);
if (blockplanks$enumtype == BlockPlanks.EnumType.SPRUCE)
{
return ColorizerFoliage.getFoliageColorPine();
}
else if (blockplanks$enumtype == BlockPlanks.EnumType.BIRCH)
{
return ColorizerFoliage.getFoliageColorBirch();
}
else
{
return worldIn != null && pos != null ? BiomeColorHelper.getFoliageColorAtPos(worldIn, pos) : ColorizerFoliage.getFoliageColorBasic();
}
}
}, Blocks.LEAVES);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
return worldIn != null && pos != null ? BiomeColorHelper.getFoliageColorAtPos(worldIn, pos) : ColorizerFoliage.getFoliageColorBasic();
}
}, Blocks.LEAVES2);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
return worldIn != null && pos != null ? BiomeColorHelper.getWaterColorAtPos(worldIn, pos) : -1;
}
}, Blocks.WATER, Blocks.FLOWING_WATER);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
return BlockRedstoneWire.colorMultiplier(((Integer)state.getValue(BlockRedstoneWire.POWER)).intValue());
}
}, Blocks.REDSTONE_WIRE);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
return worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : -1;
}
}, Blocks.REEDS);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
int i = ((Integer)state.getValue(BlockStem.AGE)).intValue();
int j = i * 32;
int k = 255 - i * 8;
int l = i * 4;
return j << 16 | k << 8 | l;
}
}, Blocks.MELON_STEM, Blocks.PUMPKIN_STEM);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
if (worldIn != null && pos != null)
{
return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
else
{
return state.getValue(BlockTallGrass.TYPE) == BlockTallGrass.EnumType.DEAD_BUSH ? 16777215 : ColorizerGrass.getGrassColor(0.5D, 1.0D);
}
}
}, Blocks.TALLGRASS);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
return worldIn != null && pos != null ? BiomeColorHelper.getFoliageColorAtPos(worldIn, pos) : ColorizerFoliage.getFoliageColorBasic();
}
}, Blocks.VINE);
blockcolors.registerBlockColorHandler(new IBlockColor()
{
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
{
return worldIn != null && pos != null ? 2129968 : 7455580;
}
}, Blocks.WATERLILY);
net.minecraftforge.client.ForgeHooksClient.onBlockColorsInit(blockcolors);
return blockcolors;
}
public int getColor(IBlockState state, World p_189991_2_, BlockPos p_189991_3_)
{
IBlockColor iblockcolor = this.blockColorMap.get(state.getBlock().delegate);
if (iblockcolor != null)
{
return iblockcolor.colorMultiplier(state, (IBlockAccess)null, (BlockPos)null, 0);
}
else
{
MapColor mapcolor = state.getMapColor(p_189991_2_, p_189991_3_);
return mapcolor != null ? mapcolor.colorValue : -1;
}
}
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess blockAccess, @Nullable BlockPos pos, int renderPass)
{
IBlockColor iblockcolor = this.blockColorMap.get(state.getBlock().delegate);
return iblockcolor == null ? -1 : iblockcolor.colorMultiplier(state, blockAccess, pos, renderPass);
}
public void registerBlockColorHandler(IBlockColor blockColor, Block... blocksIn)
{
for (Block block : blocksIn)
{
if (block == null) throw new IllegalArgumentException("Block registered to block color handler cannot be null!");
if (block.getRegistryName() == null) throw new IllegalArgumentException("Block must be registered before assigning color handler.");
this.blockColorMap.put(block.delegate, blockColor);
}
}
}
При компиляции все равно анонимные классыЭто как? Скала или Котлин?
Can not find target method of hook AsmHook: net.minecraft.client.gui.inventory.GuiContainer#handleMouseClick(Lnet/minecraft/inventory/Slot;III) -> ua.agravaine.advancediteminfo.asm.AdvancedItemInfoHooks#handleMouseClick(Lnet/minecraft/client/gui/inventory/GuiContainer;Lnet/minecraft/inventory/Slot;III)Z, ReturnCondition=ON_TRUE, ReturnValue=HOOK_RETURN_VALUE, InjectorFactory: ua.agravaine.hooklib.asm.HookInjectorFactory$MethodEnter, CreateMethod = false
public class AdvancedItemInfoHooks {
@Hook(returnCondition = ReturnCondition.ON_TRUE)
public static boolean handleMouseClick(GuiContainer gui, Slot slot, int slotIndex, int mouseButton, int clickType) {
if (slot != null && mouseButton == 1 && !isSplitKeyDown()) {
ItemStack stack = slot.getStack();
ItemInfo info = AdvancedItemInfoMod.getInfoFromItem(stack);
if (stack != null && info != null && Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
ContextMenu menu = ContextMenu.getInstance();
int mouseX = Mouse.getEventX() * gui.width / gui.mc.displayWidth;
int mouseY = gui.height - Mouse.getEventY() * gui.height / gui.mc.displayHeight - 1;
menu.setX(mouseX);
menu.setY(mouseY);
menu.setTarget(slot);
MenuItem item = menu.getItem(ContextMenu.MENU_ITEM_INSURE_ID);
if (ArrayUtils.isEmpty(info.getInsure()) || AdvancedItemInfoMod.isItemHas(stack, AdvancedItemInfoMod.NBT_NO_DROP_KEY)) {
item.hide();
}
menu.show();
return true;
}
}
return false;
}
@Hook(returnCondition = ReturnCondition.ON_TRUE)
public static boolean mouseClicked(GuiContainer gui, int mouseX, int mouseY, int mouseButton) {
ContextMenu menu = ContextMenu.getInstance();
boolean clicked = menu.mouseClicked(mouseX, mouseY, mouseButton);
if (!clicked) {
menu.close();
}
return clicked;
}
@Hook(injectOnExit = true)
public static void drawScreen(GuiContainer gui, int mouseX, int mouseY, float ticks) {
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
ContextMenu menu = ContextMenu.getInstance();
menu.draw(mouseX, mouseY);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableStandardItemLighting();
}
@Hook
public static void onGuiClosed(GuiContainer gui) {
ContextMenu.getInstance().close();
}
public static boolean isSplitKeyDown() {
return Minecraft.isRunningOnMac ? Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220) : Keyboard.isKeyDown(Keyboard.KEY_Z) || Keyboard.isKeyDown(Keyboard.KEY_Z);
}
}
Код:Can not find target method of hook AsmHook: net.minecraft.client.gui.inventory.GuiContainer#handleMouseClick(Lnet/minecraft/inventory/Slot;III) -> ua.agravaine.advancediteminfo.asm.AdvancedItemInfoHooks#handleMouseClick(Lnet/minecraft/client/gui/inventory/GuiContainer;Lnet/minecraft/inventory/Slot;III)Z, ReturnCondition=ON_TRUE, ReturnValue=HOOK_RETURN_VALUE, InjectorFactory: ua.agravaine.hooklib.asm.HookInjectorFactory$MethodEnter, CreateMethod = false
А у меня вот такая вот ересь вылезает. Хотя и в моде и в хуклибе лежит методс.бин, который я генерировал с mcp 908, для 1.7.10.
Ну и сам класс, собственно.
Java:public class AdvancedItemInfoHooks { @Hook(returnCondition = ReturnCondition.ON_TRUE) public static boolean handleMouseClick(GuiContainer gui, Slot slot, int slotIndex, int mouseButton, int clickType) { if (slot != null && mouseButton == 1 && !isSplitKeyDown()) { ItemStack stack = slot.getStack(); ItemInfo info = AdvancedItemInfoMod.getInfoFromItem(stack); if (stack != null && info != null && Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { ContextMenu menu = ContextMenu.getInstance(); int mouseX = Mouse.getEventX() * gui.width / gui.mc.displayWidth; int mouseY = gui.height - Mouse.getEventY() * gui.height / gui.mc.displayHeight - 1; menu.setX(mouseX); menu.setY(mouseY); menu.setTarget(slot); MenuItem item = menu.getItem(ContextMenu.MENU_ITEM_INSURE_ID); if (ArrayUtils.isEmpty(info.getInsure()) || AdvancedItemInfoMod.isItemHas(stack, AdvancedItemInfoMod.NBT_NO_DROP_KEY)) { item.hide(); } menu.show(); return true; } } return false; } @Hook(returnCondition = ReturnCondition.ON_TRUE) public static boolean mouseClicked(GuiContainer gui, int mouseX, int mouseY, int mouseButton) { ContextMenu menu = ContextMenu.getInstance(); boolean clicked = menu.mouseClicked(mouseX, mouseY, mouseButton); if (!clicked) { menu.close(); } return clicked; } @Hook(injectOnExit = true) public static void drawScreen(GuiContainer gui, int mouseX, int mouseY, float ticks) { RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); ContextMenu menu = ContextMenu.getInstance(); menu.draw(mouseX, mouseY); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); RenderHelper.enableStandardItemLighting(); } @Hook public static void onGuiClosed(GuiContainer gui) { ContextMenu.getInstance().close(); } public static boolean isSplitKeyDown() { return Minecraft.isRunningOnMac ? Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220) : Keyboard.isKeyDown(Keyboard.KEY_Z) || Keyboard.isKeyDown(Keyboard.KEY_Z); } }
Чекнул mcp908. В methods.csv там нет метода handleMouseClick. Твой воркспейс сгенерирован на базе какого-то другого mcp. В качестве костыля можешь завести второй хук-метод с srg названием (вида func_12345_X), но лучше разберись, из чего сделан твой воркспейс.
[DEBUG] Injecting hooks into class net.minecraft.client.gui.inventory.GuiContainer
[DEBUG] Patching method net.minecraft.client.gui.inventory.GuiContainer#drawScreen(IIF)
[DEBUG] Patching method net.minecraft.client.gui.inventory.GuiContainer#mouseClicked(III)
[DEBUG] Patching method net.minecraft.client.gui.inventory.GuiContainer#func_146984_a(Lnet/minecraft/inventory/Slot;III)
[DEBUG] Patching method net.minecraft.client.gui.inventory.GuiContainer#handleMouseClick(Lnet/minecraft/inventory/Slot;III)
[DEBUG] Patching method net.minecraft.client.gui.inventory.GuiContainer#onGuiClosed()