Jump to content

Recommended Posts

Posted

Hi everyone,

 

I am working on a  tameable mob that uses a stats container class and a stats calculation class to determine its stats. Currently I have the tameable bit down I use a custom system and the stats are generated and stored per world where each instance of my mob has a unique version of the stats due to my implementation of a "genes" factor.

 

Given this structure, I was wondering how could I use it to alter the entities properties. If you look at the read/write EntityFromNBT methods contained in my entity class I want to use the stats that have been saved for each instance of my mob to alter the mobs movement speed, armour value, hp, exp, and also want to implement custom stuff like stamina bars for my mob (I already know how to add a stamina bar to a player using IExtendedPlayerProperties). Is there a way to use my stats system to affect the mobs "minecraft stats" so that movement speed, armour value, hp, exp etc are set to my values? To start off I am just trying to make my calculated HP be the actual mobs HP at the moment. Do I have to use IExtendedEntityProperties or is there another way I could implement this since my stats are already being saved to NBT per each instance of the mob?

 

My Entity Class

 

  Reveal hidden contents

 

 

My Stats Container class

 

  Reveal hidden contents

 

 

Posted

I wouldn't call few fields packed into object a "system".

Just to make sure you know:

IExtendedEntityProperies is for actual EXTENDED properties, not basic properties. Unless you want to have all mobs have stats (or you just want to have neat code) you wont be using IEEP to code your OWN mobs.

 

As long as mob is your class you can put all stuff in there.

 

As to how vanilla handles attributes:

SharedMonsterAttributes is a value assigned to each Entity.class (living) and defines ALL basic stuff for all mobs of this type.

Then there are AttributeModifiers.

With those you can pretty much do something like this:

Use update() method, get entity.stats.extraHp and add Modifier for current tick for hp to be BaseHP+YourExtraHp.

 

Mobs don't have stamina, you would have to make your new AI that will use it.

Everything that vanilla has can be manipulated with modifiers.

 

I'd go even further and nuse WorlTickEvent.PRE to make calculations in pre-tick. But that is a wider-look at topic.

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted

Do you recommend then to create my own way to determine each of my mobs actual stats for example Spd by altering fields in the Entity class such as motionX, motionY, motionZ. Atm this value is just a calculated value that is stored in NBT data for each entity and when a player tames the mob the item used to tame the mob stores the instance of the mob and lets the player release and recapture the mob at a whim where the stats are saved preserved throughout this process. I guess my question is how would I alter the actual HP of the mob that was assigned by vanilla to equal the value that I calculated (to replace the default HP value that vanilla gives my mob (i think it is 20 but i am not sure). Currently my stats.hp doesnt link with the vanilla hp so all instances of my mob have the same hp when I hit them they die with the same number of hits and Im not sure how this works in Vanilla

 

 

Posted

The entity classes have writeEntityToNBT() and readEntityToNBT() methods.  So for your own custom entities you can use those to store custom per-entity information.

 

IExtendedEntityProperties works similarly, but is really more useful for adding properties to vanilla enitities since you already have the above methods available in your own custom entities.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

I just literally told you :P

 

Base value of health is defined FOR ALL mobs that are using given class by SharedMonsterAttribute.maxHealth (might not be exact name).

 

You could actually change it, but I don't recommend it (using modifiers to add +x value is better since it auto-synchronizes)

 

    public void setEntityHealthPastMax(EntityLivingBase entity, float amount)
    {
        entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(amount);
        entity.setHealth(amount);
        instance.sendHealthPacket(entity, amount);
    }

 

sendHealthPacket is my method to update client-side data about entitys health.

 

Note that this custom health needs to be stored SEPARATELY and saved as other value than vanilla health and then loaded after mob is constructed. Basically you need to get your health value and set vanilla to yours everytime you want your entity to have not-basic one defined by parent class. That also requres you to send packet to client (every damn time).

 

I am not saying that this is too hard for you, but certainly coding advanced tracking systems is hard.

  Quote

1.7.10 is no longer supported by forge, you are on your own.

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



  • Create New...

Important Information

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