Jump to content

[1.16.1] Custom Entity holding an Item


BunnYx

Recommended Posts

Managed to make a hostile entity, however the item's, well let's just say, no dice. Found pretty much code that led me nowhere, searched through ZombieEntity, PillagerEntity and AbstractSkeletonEntity Classes.
*Entity Class:* https://pastebin.com/Kc03YVt7
*Entity Renderer:* https://pastebin.com/FTP9G3kn

Tried using this in my entity class:
`@Override
    protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) {
        this.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(Items.DIAMOND_SWORD));
`    }

And this in my entity render class:
 ` this.addLayer(new HeldItemLayer(this));`

Hope i can get pointed at what im supposed to be looking at, otherwise i will waste probably hours looking like i have already blindly, thank you in advance. (1.16.1)

Link to comment
Share on other sites

2 hours ago, diesieben07 said:
  1. You don't own bunny.com.
  2. Please update to 1.16.4.
  3. This is not visible in the code you posted.

I have updated to 1.16.4 like you said and the latest mappings, for your 1. I have no idea what you mean, since this is my very own mod package under my username. Also for 3. I have taken the code out because it was doing nothing and not giving me any errors anyways but thought id specify the closest thing I probably got to with my issue.  ` this.addLayer(new HeldItemLayer(this));`  <-- This was under in my builder super().

Link to comment
Share on other sites

 

1 hour ago, diesieben07 said:

Java package names are reverse domain names. If you use "com.bunny" that implies you own bunny.com. This is used to prevent name collisions, since obviously a domain cannot be own by multiple entities. If you don't own a domain name, use something that cannot be a domain name, e.g. "mod.<mod id here>". "mod" is not a valid TLD, so it is safe to use.

 

Please post the actual code you were trying to use to achieve this effect.

 

Alright i hope this fixed the issue, i will upload the classes once more with the code that i tried to use in order to get my original question to work.

Entity Renderer : https://pastebin.com/pVqqugcn

Entity Class : https://pastebin.com/sZyu0xex

If anything else is needed please let me know, although for holding an item I'm pretty sure that these two classes are all that you need in order to do so. Sorry for any inconveniences as I am ned to modding and thank you for your time.

Edited by BunnYx
Link to comment
Share on other sites

3 hours ago, diesieben07 said:

setEquipmentBasedOnDifficulty is not called by default. Look at where vanilla entities call it.

Yeah but without actually doing the difficulty setting I have no idea how to do any of the item setting if I'm being completely honest. setEquipmentBasedOnDifficulty is called from MobEntity , and by looking through that I do not see anything that I should be using. I can't paste any of the original code here but I'm very sure you know exactly what it looks like. I tried many discord forge modding servers and nobody was able to help. This is pretty much my last resort 🤷‍♂️ Wasted my whole day today playing around with Minecraft's original code to no avail.

Edited by BunnYx
Link to comment
Share on other sites

1 hour ago, diesieben07 said:

No, it is not. It is defined in MobEntity, but it is not called from there.

Once again: Look at where vanilla entities call this method.

From looking more onInitialSpawn seems to be the case, although whenever I try to override it alongside the renders of the item the game simply crashes upon loading in the world with this log. (Doing by summoning the entity only)

Updated Entity Class : https://pastebin.com/D1kZCm6H
lastest.log : https://pastebin.com/CfhZ39yS
Render Class : No changes
 

Edited by BunnYx
Link to comment
Share on other sites

Update, well i managed to actually add the item to the entities hand, as poopoodice mentioned the model i did more digging and it turns out i needed a few lines of code there, i am now able to add items to the mainhand as well as the offhand, however for the others aka Armor i assume i would need something else in the model class. Implemented

IHasArm

for the hands though. Not sure how i'd go about the armor, but regardless with the armor i will most likely just model all my entities in blockbench with the armor already on there since some models will be different sizes so i think that would be a good practice for me. Thank you to the both of you for the individual help. Big or small. Will focus on making animations and what-not in the far future since im only wanting to test all the features i need, which this was one of those :) 

2020-11-21_01.53.43.png

Edited by BunnYx
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.
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

    • https://pastebin.com/VwpAW6PX My game crashes upon launch when trying to implement the Oculus mod to this mod compilation, above is the crash report, I do not know where to begin to attempt to fix this issue and require assistance.
    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. 📈 Skills: RPG-style skill system that enhances your gaming experience! 🎮 Leaderboards: Compete and shine! Top players are rewarded weekly! 🏆 Random Teleporter: Travel instantly across different worlds with a click! 🌐 Custom World Generation: Beautifully generated world. 🌍 Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. 🏰 Kits: Unlock ranks and gain access to various kits. 🛠️ Fishing Tournament: Compete in a friendly fishing tournament! 🎣 Chat Games: Enjoy games right within the chat! 🎲 Minions: Get some help from your loyal minions. 👥 Piñata Party: Enjoy a festive party with Piñatas! 🎉 Quests: Over 1000 quests that you can complete! 📜 Bounty Hunter: Set a bounty on a player's head. 💰 Tags: Displayed on nametags, in the tab list, and in chat. 🏷️ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! 🟢 Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. 🔲✨[ Player Warp: Set your own warp points for other players to teleport to. 🌟 Display Shop: Create your own shop and sell to other players! 🛒 Item Skins: Customize your items with unique skins. 🎨 Pets: Your cute loyal companion to follow you wherever you go! 🐾 Cosmetics: Enhance the look of your character with beautiful cosmetics! 💄 XP-Bottle: Store your exp safely in a bottle for later use! 🍶 Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! 📦 Glowing: Stand out from other players with a colorful glow! ✨ Player Particles: Over 100 unique particle effects to show off. 🎇 Portable Inventories: Over virtual inventories with ease. 🧳 And a lot more! Become part of our growing community today! Discord: https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working   I am not familiar with Linux - check for similar/related issues  
  • Topics

×
×
  • Create New...

Important Information

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