Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.14.4] Getting a Block Model's Element Clicked by the Player


Ommina
 Share

Recommended Posts

I have a Block.  So far, so good.

 

The block has a Boolean property: FORMED.

 

When false: the block's model is 1x1 (one full cube).

When true: the block's model is 3x3

 

The property switches from false to try when 26 other blocks are placed in the 3x3 area, in a typical multi-block fashion.

 

This is not my problem.

 

My problem is that I really want to know when the player clicks on a particular element of the 3x3 model.  I can't help but feel there is some ray tracing going on here, but none of my attempts of the past too-many-hours have yielded any success.

 

So far I've tried two approaches.  First, a "does this vector intersect with a square" solution found over yonder on StackOverflow.  It has given me mixed results.  As I don't really get the math going on behind it, all I've been able to do is try different inputs and see what happens.

 

Second, I've been fussing with VoxelShapes.  While they appeared promising, they only seem to be considered if the centre block is being targeted in some fashion.  I've tried to change the blocks getRaytraceShape to return the 3x3 area, but it didn't care.

 

Any suggestions?  I've been working with onBlockActivated, so I do have the Player and BlockRayTraceResult with which to play.

 

Thanks for reading.

Link to comment
Share on other sites

Multiple blocks are indeed being placed, there are 26 other blocks surrounding my centre block.

 

My "does the vector intersect with this square" tests happen in these shell blocks, since they are the blocks actually being activated.

 

Which does reinforce the notion that the VoxelShapes path, however attractive, simply isn't going to fly.  So it's back to the math.

Link to comment
Share on other sites

Well, it took me a couple of days, a handful of hours on 'mathisfun', and at least on instance of the problem intruding its way into dreams -- which is a sad commentary on my life.

 

The model elements are in block co-ordinates.  The hit vector is in world co-ordinates.  I was mixing units and simply took ages to make the connection.

 

So, yes, it is totally enough.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I think that is the problem. I changed to using ResourceKeys instead and haven't seen the log since. 
    • That's how, thanks a lot! (≧ ▽ ≦)
    • Sorry if this is something that is solved but i cant find anything. So when I am getting hurt or about to die the game crashes.   ---- Minecraft Crash Report ---- WARNING: coremods are present:   Plugin (NotEnoughIDs-1.5.4.4.jar)   llibrary (llibrary-core-1.0.11-1.12.2.jar)   EnderCorePlugin (EnderCore-1.12.2-0.5.76-core.jar)   LucraftCoreCoreMod (LucraftCore-1.12.2-2.4.16.jar)   ForgelinPlugin (Forgelin-1.8.4.jar)   MicdoodlePlugin (MicdoodleCore-1.12.2-4.0.2.280.jar)   JustEnoughIDs Extension Plugin (JustEnoughIDs-1.0.3-55.jar)   OpenModsCorePlugin (OpenModsLib-1.12.2-0.12.2.jar)   pymtech (PymTech-1.12.2-1.0.2.jar)   SteveKunGLibPlugin (SteveKunG's-Lib-1.12.2-1.1.10.jar)   ObfuscatePlugin (obfuscate-0.4.2-1.12.2.jar)   iceandfire (iceandfire-1.9.1-1.12.2.jar) Contact their authors BEFORE contacting forge // Uh... Did I do that? Time: 9/18/21 6:11 PM Description: Ticking entity java.lang.NoClassDefFoundError: c4/conarm/lib/capabilities/ArmorAbilityHandler     at landmaster.plustic.traits.DeathSaveTrait.timing(DeathSaveTrait.java:70)     at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_1306_DeathSaveTrait_timing_LivingHurtEvent.invoke(.dynamic)     at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)     at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)     at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:604)     at net.minecraft.entity.player.EntityPlayer.func_70665_d(EntityPlayer.java:1120)     at net.minecraft.entity.EntityLivingBase.func_70097_a(EntityLivingBase.java:918)     at net.minecraft.entity.player.EntityPlayer.func_70097_a(EntityPlayer.java:1038)     at net.minecraft.entity.player.EntityPlayerMP.func_70097_a(EntityPlayerMP.java:645)     at micdoodle8.mods.galacticraft.core.entities.player.GCEntityPlayerMP.func_70097_a(GCEntityPlayerMP.java:68)     at com.github.alexthe666.iceandfire.entity.EntityMyrmexSoldier.func_70636_d(EntityMyrmexSoldier.java:54)     at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:2179)     at net.minecraft.entity.EntityLiving.func_70071_h_(EntityLiving.java:295)     at com.github.alexthe666.iceandfire.entity.EntityMyrmexBase.func_70071_h_(EntityMyrmexBase.java:240)     at net.minecraft.world.World.func_72866_a(World.java:1996)     at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:832)     at net.minecraft.world.World.func_72870_g(World.java:1958)     at net.minecraft.world.World.func_72939_s(World.java:1762)     at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:613)     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:767)     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)     at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:185)     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)     at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: c4.conarm.lib.capabilities.ArmorAbilityHandler     at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191)     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)     ... 24 more Caused by: java.lang.NullPointerException A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace:     at landmaster.plustic.traits.DeathSaveTrait.timing(DeathSaveTrait.java:70)     at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_1306_DeathSaveTrait_timing_LivingHurtEvent.invoke(.dynamic)     at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)     at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)     at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:604)     at net.minecraft.entity.player.EntityPlayer.func_70665_d(EntityPlayer.java:1120)     at net.minecraft.entity.EntityLivingBase.func_70097_a(EntityLivingBase.java:918)     at net.minecraft.entity.player.EntityPlayer.func_70097_a(EntityPlayer.java:1038)     at net.minecraft.entity.player.EntityPlayerMP.func_70097_a(EntityPlayerMP.java:645)     at micdoodle8.mods.galacticraft.core.entities.player.GCEntityPlayerMP.func_70097_a(GCEntityPlayerMP.java:68)     at com.github.alexthe666.iceandfire.entity.EntityMyrmexSoldier.func_70636_d(EntityMyrmexSoldier.java:54)     at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:2179)     at net.minecraft.entity.EntityLiving.func_70071_h_(EntityLiving.java:295)     at com.github.alexthe666.iceandfire.entity.EntityMyrmexBase.func_70071_h_(EntityMyrmexBase.java:240)     at net.minecraft.world.World.func_72866_a(World.java:1996)     at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:832)     at net.minecraft.world.World.func_72870_g(World.java:1958) -- Entity being ticked -- Details:     Entity Type: iceandfire:myrmex_soldier (com.github.alexthe666.iceandfire.entity.EntityMyrmexSoldier)     Entity ID: 15     Entity Name: Myrmex Soldier     Entity's Exact location: -183.34, 61.00, -11.63     Entity's Block location: World: (-184,61,-12), Chunk: (at 8,3,4 in -12,-1; contains blocks -192,0,-16 to -177,255,-1), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)     Entity's Momentum: -0.04, -0.08, -0.14     Entity's Passengers: []     Entity's Vehicle: ~~ERROR~~ NullPointerException: null Stacktrace:     at net.minecraft.world.World.func_72939_s(World.java:1762)     at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:613) -- Affected level -- Details:     Level name: New World     All players: 1 total; [GCEntityPlayerMP['Altutium'/390, l='New World', x=-183.77, y=61.00, z=-12.57]]     Chunk stats: ServerChunkCache: 769 Drop: 0     Level seed: 2105410062015924141     Level generator: ID 00 - default, ver 1. Features enabled: true     Level generator options:      Level spawn location: World: (8,64,8), Chunk: (at 8,4,8 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)     Level time: 10758 game time, 10758 day time     Level dimension: 0     Level storage version: 0x04ABD - Anvil     Level weather: Rain time: 5018 (now: false), thunder time: 119120 (now: false)     Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false Stacktrace:     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:767)     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)     at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:185)     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)     at java.lang.Thread.run(Thread.java:745) -- System Details -- Details:     Minecraft Version: 1.12.2     Operating System: Windows 10 (amd64) version 10.0     Java Version: 1.8.0_51, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 2523489512 bytes (2406 MB) / 5603590144 bytes (5344 MB) up to 6442450944 bytes (6144 MB)     JVM Flags: 8 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx6G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94     FML: MCP 9.42 Powered by Forge 14.23.5.2855 95 mods loaded, 95 mods active     States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored  
    • Found a way to fix it! I went to the gradle folder on the right side of the project and press "Reload All Gradle Project" and now I can runClient without the errors showing up!
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.