Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi is there a way to fire an event if another event happens?

  • Author
@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

Regardless I guess, if you want to fire an event. forge has a ForgeEventFactory class you can create events from.

  • Author
3 minutes ago, MistaOmega said:

Regardless I guess, if you want to fire an event. forge has a ForgeEventFactory class you can create events from.

how do i use the ForgeEventFactory ?

1 minute ago, Tim_ said:

how do i use the ForgeEventFactory ?

Have a look in ForgeEventFactory, and look at usages, ItemBow for example will give you some guidance

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.