Jump to content

Recommended Posts

Posted

Hello there. I have just taken up creating mods. I am working on my first mod and it is coming along very nicely. (Or at least I think so lol). I am running into a tiny issue that I can't seem to figure out. I have read multiple tutorials. Specifically I read this one (http://www.minecraftforge.net/wiki/Tutorials/Basic_Shooter_Item_-_Blaster_Rifle) and watched some tutorial videos to get my "Grenade" item working fine.

 

So my grenade does EXACTLY what it is supposed to do and I am very happy with it. However I am looking to add a cost to it. So, if the player doesnt have the "reagent" item in their inventory the event will fail and the item will not be used. Here is my class: http://pastebin.com/vGAMLzgY

 

So this works. Actually it subtracts the item requirement as well. I know what the issue is. In my if I simply am subtracting the itemstack provided you have the "reagent" item as well. So what the code does is subtract both the "reagent" item as well as the item stack. I am trying to make it so that if you do not have the "reagent" item in your inventory you cannot use the item. I know am sure it is really simple to do, but since I am a noobie coder/modder I am missing something so obvious.

 

Thank You in Advanced.

 

Posted

Only spawn the grenade entity and play the sound if you successfully consumed the reagent (in the

if (player.inventory.consumeItem(...))

block).

 

Item#setMaxStackSize

should only be called once (in the constructor or wherever you instantiate the class). There's no reason to call it every time the item is right clicked.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Outstanding, I knew it was probably a small oversight that I just wasn't aware of. And I also set the maxStack size in the appropriate location. Thank you for pointing that out to me. My last question with these grenades seems to be how I cast the entity. I cast it too Living base and it works, but I don't think Minecraft likes that. How should I alter the code? Here is the rather obvious error lol: http://pastebin.com/1H0wQyBV

 

And here is my entity class:

http://pastebin.com/Ve2f04vr

 

Once again I apologize for how noobish I sound and how obvious these errors are but I really am trying to learn and I would rather learn correctly, rather then let the errors sit there since the item works as is. Thank you again.

 

 

Posted

It looks like you've tried to add your grenade as a naturally spawning entity with

EntityRegistry.addSpawn

(like a mob or animal), but this doesn't work because it doesn't extend

EntityLiving

. You shouldn't have added it as a naturally spawning entity in the first place.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Perfect, once again it was a dumb oversight on my part. I had this being registered via my RegisterMonster function as opposed to my RegisterItemEntity function (both are identical but one doesn't add the spawn)

 

Thank you again for the help. The issue seems to have been corrected.

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...

×   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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • wait, i just did that. why didn't it work? also it's the same. help me!!!!
    • Culprit has been located! It was Tough As Nails + (plus) which was among one of the mods *added* before re-entering, in an attempt to improve compatibility. It, for some reason or another, did not want to work!
    • "You can either try to load it with only the vanilla data pack ("safe mode"), or go back to the title screen and fix it manually." Hello! I encountered this error just now while attempting to re-enter my world for the first time. Notably, no mods were removed before encountering this error and, while being able to find this error elsewhere on the internet, in my scenario it is seemingly caused by a specific mod, of which I cannot isolate. Things I have tried: - Enter "Safe Mode" (fails) - Remove datapacks (no change) - Reverted to old save data (no change) Here is the server log: https://mclo.gs/9vJQEfN I use Modrinth mod loader so please let me know how to share my mod list, and if it is needed.
    • So, i'm hosting (or attempting to host) a port-forwarded modded server for 1.12.2. There's quite a few mods in this pack, but they all run and have no compatibility issues (besides something causing the game to crash if you go fullscreen, a problem ive given up trying to identify or fix). It can run on 6gb of ram or less, and works fine in singleplayer. All of my friends that want to join have the exact same mod/config/game setup as I do (I personally helped them set everything up). Just to be safe, we've all allocated 12 gigabytes of RAM to the installation, and I've also allocated 12GB to the server itself. I am able to join with no issue and it runs fine. However, when they try to join, it gets stuck in the 'logging in' screen before their game becomes unresponsive. When they close it, it gives them the exit code 805306369, which usually means not enough RAM, but this cant be the case. On my screen, in the server, it shows them joining, and then disconnecting, so I dont think its a port-forwarding issue. They can all run it just fine in singleplayer as well. The annoying bit about this particular issue is that it generates no crash log. Does anyone have any suggestions? Thanks! Here is my debug log, and his, starting from the same place. MINE: [132647] [Netty Client IO #5INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132653.817 [132653] [Client threadINFO] [minecraftGuiConnecting] Connecting to 0, 25565 132654.682 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.common.core.transformer.ClassNodeTransformertransform29] Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 132654.684 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.map.core.transformer.ClassNodeTransformertransform29] Transforming class net.minecraft.client.network.NetHandlerPlayClient 132654.764 [132654] [Netty Client IO #9INFO] [FML] Server protocol version 2 132654.777 [132654] [Netty Client IO #9INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132656.193 [132656] [Client threadINFO] [FML] Injecting existing registry data into this client instance 132659.081 [132659] [Client threadINFO] [FML] Applying holder lookups 132659.082 [132659] [Client threadINFO] [FML] Holder lookups applied 132659.092 [132659] [Netty Client IO #9INFO] [FML] [Netty Client IO #9] Client side modded connection established HIS: [13:12:16] [Netty Client IO #0/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:25.597 [13:12:25] [Client thread/INFO] [minecraft/GuiConnecting]: Connecting to (my IP address and the server port 25565) 13:12:26.805 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.common.core.transformer.ClassNodeTransformer:transform:29]: Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 13:12:26.808 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.map.core.transformer.ClassNodeTransformer:transform:29]: Transforming class net.minecraft.client.network.NetHandlerPlayClient 13:12:26.936 [13:12:26] [Netty Client IO #1/INFO] [FML]: Server protocol version 2 13:12:27.114 [13:12:27] [Netty Client IO #1/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:27.480 [13:12:27] [Client thread/INFO] [FML]: Injecting existing registry data into this client instance 13:12:30.669 [13:12:30] [Client thread/INFO] [FML]: Applying holder lookups 13:12:30.671 [13:12:30] [Client thread/INFO] [FML]: Holder lookups applied 13:13:04.700 Process crashed with exit code -805306369 P.S - Both mods "CTM" and "FUSION" are present in both our folders so idk what that's about.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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