Non résolu Problème curseur
-
Bonjour j’essayé de trouver un moyen de changer mon curseur inGame sauf que cele ne fonctionne pas. Je suis sur d’avoir fait une erreur quelque part mais je ne sais pas ou.
Pouvez vous m’aider s’il vous plait, je vous serait trés reconnaissant.
Voici mon code actuel de mon client Proxy:
public class ClientProxy extends CommonProxy { public static KeyBinding key; public static KeyBinding key2; @Override public void preInit() { super.preInit(); } @SubscribeEvent public void onInitGuiEvent(InitGuiEvent.Post event) { for (Object b : event.getButtonList()) { if (((GuiButton) b).id == 14) { ((GuiButton) b).visible = false; } } } public ClientProxy() { MinecraftForge.EVENT_BUS.register(this); FMLCommonHandler.instance().bus().register(this); key = new KeyBinding(".keytuto", org.lwjgl.input.Keyboard.KEY_G, "key.categories.gameplay"); ClientRegistry.registerKeyBinding(key); key2 = new KeyBinding(".keytuto", org.lwjgl.input.Keyboard.KEY_F, "key.categories.gameplay"); ClientRegistry.registerKeyBinding(key2); Display.setTitle("Winds Isle"); } @SubscribeEvent public void onEvent(KeyInputEvent event) { if(key.isPressed()) { keyPressed(); } if(key2.isPressed()) { keyPressed2(); } } private void keyPressed() { Minecraft.getMinecraft().displayGuiScreen(new Guitest()); } private void keyPressed2() { } @Override public void registerRender() { this.setCursor(Reference.MOD_ID, "/textures/misc/cursor.png", 32, 32, 3.1415926536); } private void setCursor(String modid, String path, int width, int height, double rotation) { AffineTransform transform = new AffineTransform(); try { BufferedImage cursorTexture = ImageIO.read(getClass().getResource("/assets/" + modid + path)); transform.rotate(rotation, cursorTexture.getWidth()/2, cursorTexture.getHeight()/2); AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); cursorTexture = op.filter(cursorTexture, null); int[] rgbs = new int[cursorTexture.getWidth() * cursorTexture.getHeight()]; IntBuffer buffer = IntBuffer.wrap(cursorTexture.getRGB(0, 0, cursorTexture.getWidth(), cursorTexture.getHeight(), rgbs, 0, cursorTexture.getHeight())); buffer.rewind(); Cursor newCursor = new Cursor(width, height, 1, cursorTexture.getHeight() - 1, 1, buffer, null); Mouse.setNativeCursor(newCursor); } catch (LWJGLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }