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

Hello all, for my mod I want to have an ore that is smelt-able when you throw it into the end gateway so I have set up a simple item toss event with ray tracing. The tracing works with any block that I'm looking at but for some reason it doesn't even fire for the end gateway (it doesn't recognize it as a block even) Here is my code:

 

@SubscribeEvent
    public static void onItemDrop(ItemTossEvent event) {
        if(event.getEntityItem().getItem().getItem().equals(ModItems.FIN_ORE_ITEM.get().getItem())) {
            PlayerEntity player = event.getPlayer();
            Vector3d eyePos = player.getEyePosition(1.0F);
            BlockRayTraceResult result = player.getEntityWorld().rayTraceBlocks(new RayTraceContext(eyePos, player.getLookVec().mul(5,5,5).add(eyePos), RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, player));
            if(result.getType() == RayTraceResult.Type.BLOCK) {
                MajCraft.LOGGER.info("result location: " + result.getPos().toString());
                if(player.getEntityWorld().getBlockState(result.getPos()).equals(Blocks.END_GATEWAY.getDefaultState())) {
                    MajCraft.LOGGER.info("Yes it is the end gateway!");
                }
                if(player.getEntityWorld().getBlockState(result.getPos()).equals(Blocks.END_STONE.getDefaultState())) {
                    MajCraft.LOGGER.info("it is end stone");
                }
            }
        }
    }

When I look at end stone, the log will print the location of the end stone say "it is end stone" (as expected). However, when I look at the end portal gate, it doesn't even print a "result location: " which means it doesn't recognize it as a block. What's even weirder is when I look at a block through the end gateway, it will print out the result location of that block (not the gateway). How can I make sure the player is looking at the end gateway so I can 'smelt' the ore when they throw it in? Thank you!

This is my guess...your RayTraceContext specifies the BlockMode.COLLIDER. If you look at the implementation, this calls getCollisionShape. If you look at getCollisionShape you see it returns a VoxelShapes.Empty if it find the variable canCollide to be false. canCollide takes the value of Material.blocksMovement, which the Material.PORTAL(which end gateway is build of) sets to be false. Basically the End gateway block is not even taken into account in the raytracing process which is what is happening to you. I do not know if there is a way around this by using ray trace, but maybe you can make it work like that: when you throw your ore, check the position the ItemEntity lands on, and get the Block that contains that position. Then you can just check if the Block is an END_GATEWAY block. If it is do the stuff you want to do

Edited by Beethoven92

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

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.