Posted August 2, 20205 yr 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!
August 2, 20205 yr 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 August 2, 20205 yr 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.