Jump to content

Kemuri Senpai

Members
  • Posts

    30
  • Joined

  • Last visited

Kemuri Senpai's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Damn, thank you! I was so focused on the code from github, assuming that he is doing it correctly... How can I upvote you?
  2. Ow, I see, so the second "0" i use, is only a placeholder? I could also use any other slot I want?... So I even could swap two slots without the three commands? Just with one: clickWindow( inventoryID, 36, 1, click, player )? I expect this to swap two first slots in hotbar.. Is it how it works?
  3. However, I still have a question 😅 pc.windowClick(0, 37, 0, click, player); pc.windowClick(0, 38, 0, click, player); pc.windowClick(0, 37, 0, click, player); works as I wanted. It swaps the second and the third item in my hotbar. But pc.windowClick(0, 36, 0, click, player); pc.windowClick(0, 37, 0, click, player); pc.windowClick(0, 36, 0, click, player); does not swap the first and the second... It actually does nothing
  4. Okay, currently no acces to my computer, I will check it Thank you, so far
  5. I still do not understand, as in https://stackoverflow.com/questions/60443432/using-minecrafts-playercontroller-windowclick it says, slot 0 is the crafting table Output, so how could the "parameter" be a slot ID? Cause then, the github example would be wrong
  6. Hmm... But the Method takes this arguments in my opinion: 1) Inventory ID, in code above it's 0 2) Slot ID to interact with 3) whether a right-click 4) Type of interaction 5) The player What do you mean by "taking in two slot IDs"?
  7. Did this windowClick method change since 1.12? I am actually using the same principe as in https://github.com/kulttuuri/quick-hotbar-mod/blob/1.12/src/main/java/com/kulttuuri/quickhotbar/QuickHotbarEventHandler.java#L472
  8. I am using PlayerController.windowClick to organize my Inventory. For testing purpose I have made a loop, that should swap the 9 slots of hotbar with 9 horizontal slots from inventory: Minecraft mc = Minecraft.getInstance(); if ( mc.player == null ) return; PlayerEntity player = mc.player; PlayerController pc = mc.playerController; ClickType click = ClickType.SWAP; for ( int i = 1; i < 4; i ++ ) { for ( int j = 0; j < 9; j ++ ) { int k = j + i * 9; pc.windowClick(0, k, 0, click, player); pc.windowClick(0, k + 9, 0, click, player); pc.windowClick(0, k, 0, click, player); } } It swaps the hotbar slots from 1 to 8 perfectly, but the hotbar slot 0 ( or in inventory it is 36 ) just does not react to windowClick with clickType.SWAP... I tested with clickType.THROW and it dropped the item successfully... What is going on?
  9. Ow... RotateTowards... I tried it out right now, and it looks smooth Now need to figure out, which arguments to pass
  10. Hmm, well, then 🤷‍♂️ I don't want to argue a lot, because, you're right.. Could you still please help me to find this out?
  11. I know the very basics.. I guess it is still not enough.. But I am here to get help I am sorry, but it won't help me, if you tell me, how bad I am
  12. Thank you for your advice, but after going through it, did not have any idea, how to use it ( as mentioned earlier, I was never programming before and was always using MCreator ) private void cursorPosCallback(long handle, double xpos, double ypos) { if (handle == Minecraft.getInstance().getMainWindow().getHandle()) { if (this.ignoreFirstMove) { this.mouseX = xpos; this.mouseY = ypos; this.ignoreFirstMove = false; } IGuiEventListener iguieventlistener = this.minecraft.currentScreen; if (iguieventlistener != null && this.minecraft.loadingGui == null) { double d0 = xpos * (double)this.minecraft.getMainWindow().getScaledWidth() / (double)this.minecraft.getMainWindow().getWidth(); double d1 = ypos * (double)this.minecraft.getMainWindow().getScaledHeight() / (double)this.minecraft.getMainWindow().getHeight(); Screen.wrapScreenError(() -> { iguieventlistener.mouseMoved(d0, d1); }, "mouseMoved event handler", iguieventlistener.getClass().getCanonicalName()); if (this.activeButton != -1 && this.eventTime > 0.0D) { double d2 = (xpos - this.mouseX) * (double)this.minecraft.getMainWindow().getScaledWidth() / (double)this.minecraft.getMainWindow().getWidth(); double d3 = (ypos - this.mouseY) * (double)this.minecraft.getMainWindow().getScaledHeight() / (double)this.minecraft.getMainWindow().getHeight(); Screen.wrapScreenError(() -> { if (net.minecraftforge.client.ForgeHooksClient.onGuiMouseDragPre(this.minecraft.currentScreen, d0, d1, this.activeButton, d2, d3)) return; if (iguieventlistener.mouseDragged(d0, d1, this.activeButton, d2, d3)) return; net.minecraftforge.client.ForgeHooksClient.onGuiMouseDragPost(this.minecraft.currentScreen, d0, d1, this.activeButton, d2, d3); }, "mouseDragged event handler", iguieventlistener.getClass().getCanonicalName()); } } this.minecraft.getProfiler().startSection("mouse"); if (this.isMouseGrabbed() && this.minecraft.isGameFocused()) { this.xVelocity += xpos - this.mouseX; this.yVelocity += ypos - this.mouseY; } this.updatePlayerLook(); this.mouseX = xpos; this.mouseY = ypos; this.minecraft.getProfiler().endSection(); } } public void updatePlayerLook() { double d0 = NativeUtil.getTime(); double d1 = d0 - this.lastLookTime; this.lastLookTime = d0; if (this.isMouseGrabbed() && this.minecraft.isGameFocused()) { double d4 = this.minecraft.gameSettings.mouseSensitivity * (double)0.6F + (double)0.2F; double d5 = d4 * d4 * d4 * 8.0D; double d2; double d3; if (this.minecraft.gameSettings.smoothCamera) { double d6 = this.xSmoother.smooth(this.xVelocity * d5, d1 * d5); double d7 = this.ySmoother.smooth(this.yVelocity * d5, d1 * d5); d2 = d6; d3 = d7; } else { this.xSmoother.reset(); this.ySmoother.reset(); d2 = this.xVelocity * d5; d3 = this.yVelocity * d5; } this.xVelocity = 0.0D; this.yVelocity = 0.0D; int i = 1; if (this.minecraft.gameSettings.invertMouse) { i = -1; } this.minecraft.getTutorial().onMouseMove(d2, d3); if (this.minecraft.player != null) { this.minecraft.player.rotateTowards(d2, d3 * (double)i); } } else { this.xVelocity = 0.0D; this.yVelocity = 0.0D; } } Only things to use in my opinion are "this.minecraft.getProfiler().startSection("mouse");" and "IGuiEventListener iguieventlistener = this.minecraft.currentScreen;", but I have no idea, how to use them as trigger for my function... 😵
  13. @SubscribeEvent public void aim (TickEvent.RenderTickEvent event) { if (event.phase == TickEvent.Phase.START) { if ( Minecraft.getInstance().player == null ) return; PlayerEntity entity = (PlayerEntity) Minecraft.getInstance().player; IWorld world = (IWorld) entity.world; boolean aiming = PlaceModVariables.WorldVariables.get(world).aiming; if ( aiming ) { double d = PlaceModVariables.WorldVariables.get(world).aim_distance; { List<Entity> _entfound = world .getEntitiesWithinAABB(Entity.class, new AxisAlignedBB((entity.getPosX()) - (d / 2d), (entity.getPosY()) - (d / 2d), (entity.getPosZ()) - (d / 2d), (entity.getPosX()) + (d / 2d), (entity.getPosY()) + (d / 2d), (entity.getPosZ()) + (d / 2d)), null) .stream().sorted(new Object() { Comparator<Entity> compareDistOf(double _x, double _y, double _z) { return Comparator.comparing((Function<Entity, Double>) (_entcnd -> _entcnd.getDistanceSq(_x, _y, _z))); } }.compareDistOf((entity.getPosX()), (entity.getPosY()), (entity.getPosZ()))).collect(Collectors.toList()); for (Entity entityiterator : _entfound) { if ((entityiterator != entity) && (entityiterator.getDisplayName().getString().equals( PlaceModVariables.WorldVariables.get(world).aim ) ) ) { double dX = (double) ((entity.getPosX()) - (entityiterator.getPosX())); double dY = (double) ((entity.getPosY() + entity.getHeight()) - (entityiterator.getPosY() + ((entityiterator.getHeight()) / 2 ))); double dZ = (double) ((entity.getPosZ()) - (entityiterator.getPosZ())); float yaw = (float) (Math.toDegrees((Math.atan2(dZ, dX))) + 90); float pitch = (float) ( 263 - (Math.toDegrees((Math.atan2(Math.sqrt(dZ * dZ + dX * dX), dY) + Math.PI )))); entity.rotationYaw = yaw; entity.rotationPitch = pitch; break; } } } } } } This code was partially generated by MCreator ( it's a Scratch-like programm to make mods for minecraft )
  14. public void onPlayerTick(TickEvent.RenderTickEvent event) { if (event.phase == TickEvent.Phase.START) { if (Minecraft.getInstance().player == null) return; PlayerEntity player = Minecraft.getInstance().player; execute ( player ); } } public void execute() { //set rotation of player } Can't post more because I'm on phone right now.
  15. in the method I am testing if player is available and then I call another procedure "aim", and in that I am setting the pitch and rotation
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.