Jump to content

Tim_

Members
  • Posts

    15
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Tim_'s Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hi is there a way to get the block the player is looking at if i only have the player?
  2. how do i use the ForgeEventFactory ?
  3. @SubscribeEvent public static void ChiselMine(TickEvent.PlayerTickEvent mine) { Player player = mine.player; Item itemInHand = player.getMainHandItem().getItem(); Level pLevel = player.level; BlockState eyeBlockstate = pLevel.getBlockState(player.eyeBlockPosition()); Block eyeBlock = eyeBlockstate.getBlock(); BlockPos eyeBlockPos = player.eyeBlockPosition(); if (itemInHand.equals(ModItems.CHISEL.get())) { if (Minecraft.getInstance().options.keyUse.isDown()) { System.out.println("Use is down! Time is: " + pLevel.getGameTime()); if (player.distanceToSqr(eyeBlockPos.getX(), eyeBlockPos.getY(), eyeBlockPos.getZ()) <= 5) { System.out.println("BlockPos comparing succeeded! Time is: " + pLevel.getGameTime()); if (checkForBlock(eyeBlock)) { System.out.println("Block comparing succeeded! Time is: " + pLevel.getGameTime()); } } } } } public static boolean checkForBlock(Block clickedBlock) { System.out.println("Block comparing!"); if (clickedBlock == ModBlocks.IRON_ORE_SMALL.get()){ dropItem = ModItems.IRON_CHUNK.get(); return true; }else if (clickedBlock == ModBlocks.LEAD_ORE_SMALL.get()){ dropItem = ModItems.LEAD_CHUNK.get(); return true; }else { return false; } } thats my code i know now that eyeblockpos isnt the block the player is looking at just ignore that but u might understand what im trying to achieve it would be way easier if i could fire a playerUseOnBlock event instead in the tickevent
  4. Hi is there a way to fire an event if another event happens?
  5. can u pls explain a bit how a tickevent works?
  6. So i want to check if a player is still looking at a specific block. Can i do it like an event so the event fires if the player stops looking at a specific block and if so how i haven't found an event that does this.
  7. Okay i think i understand a bit more now and will try it in a few days when I have time thx very much for ur help
  8. I just wanted to explain it better and i dont want to do a custom loot drop cause the block has to stay there
  9. Hello i want to give a player an item(reward) after the player was right-clicking a block(targetBlock) with an item(useItem) for an amount of time(t) how do i do that? I tried with a player interaction event but it fires every few ticks and doesn't stop when the player stops interacting so that doesn't work. Does anyone have an idea or a solution? If so i would be happy if u can show me. Thx
  10. i can also do left click
  11. and how am i doing it with breaking?
  12. and how am i doing it with breaking?
  13. so i want to check if a player right clicks a block for a specific tickduration and then want to give an output is that possible? and if so how?
  14. Thank you the documentation helped me a lot!!!
  15. I made a chisel item and an ore item and everytime i use the chisel on the block i want to play an animation in firstperson and then get an item how is that possible? Im on 1.18.2
×
×
  • Create New...

Important Information

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