Posted July 24, 201510 yr Hello, I'm trying to override the current vanilla mobs with slight adjustments (like them dealing more damage for example). For example, I created a class called AdjustedSkeleton which just extends EntitySkeleton and adjusts the damage it deals when attacking. To register this mob, I had to first remove the standard skeleton to be able to override it. Here's what I did: private static Map stringToClassMapping = EntityList.stringToClassMapping; private static Map classToStringMapping = EntityList.classToStringMapping; private static Map idToClassMapping = EntityList.idToClassMapping; public static void init() { removeEntity(EntitySkeleton.class, "Skeleton", 51); } private static void removeEntity(Class entity, String name, int id) { stringToClassMapping.remove(name); classToStringMapping.remove(entity); idToClassMapping.remove(id); } However, there are still two Maps from which the skeleton needs to be removed in order for the new skeleton to be able to be registered on the exact same name as the vanilla "Skeleton". These two Maps are located in the EntityList class and are private: private static final Map classToIDMapping = Maps.newHashMap(); private static final Map stringToIDMapping = Maps.newHashMap(); As you can see, I was able to simply remove the Skeleton from the other three maps, but for some reason, these two are private and I cannot edit them from my mod classes. I also don't want to modify the .class files. What do you suggest I do at this point? Maybe you have a better approach to this? ~Cheers, Krikke
July 24, 201510 yr You could also use EntityJoinWorldEvent to add AttributeModifiers to attack damage, health, or whatever else you want. http://i.imgur.com/NdrFdld.png[/img]
July 24, 201510 yr Author Could you give a more detailed expanation and/or example for me to start with as I have no clue how Events and Modifiers work. I'm very new to modding, so my appologies if this is some basic stuff. Thanks in advance, ~Krikke
July 24, 201510 yr CoolAlias's EventHandler tutorial: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-forge-1-6-4-1-8-eventhandler-and SanAndreasP's entity attribute tutorial(scroll to modifying an attribute) http://www.minecraftforge.net/forum/index.php/topic,30137.0.html
July 24, 201510 yr Author What am I doing wrong here? As far as I understood, this should multiply the attack damage of all mobs by 10, right? @SubscribeEvent public void addMobDamage(LivingAttackEvent e) { if(e.entityLiving instanceof EntityMob) { EntityMob mob = (EntityMob)e.entityLiving; mob.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(mob.getEntityAttribute(SharedMonsterAttributes.attackDamage).getBaseValue()*10.0); } }
July 24, 201510 yr AttackEntityEvent is called when the mob attacks, LivingAttackEvent is called when the mob IS attacked. In either case, you probably want to do your code in EntityJoinWorld, otherwise you'll end up with the mob's damaged being multiplied by 10 every time it hits something, which could cause some problems
July 25, 201510 yr Also, you should not set the base value of the attribute; instead, add an attribute modifier. http://i.imgur.com/NdrFdld.png[/img]
July 25, 201510 yr Author I seem to be missing something, because this doesn't seem to work either: @SubscribeEvent public void addMobDamage(EntityJoinWorldEvent e) { if(e.entity instanceof EntityMob) { EntityMob mob = (EntityMob)e.entity; AttributeModifier modifier = new AttributeModifier(UUID.fromString("82611fdd-7e53-4b74-86c0-8413b1def591"), "allMobDamagex10", 10.0, 1); if(mob.getEntityAttribute(SharedMonsterAttributes.attackDamage).getModifier(UUID.fromString("82611fdd-7e53-4b74-86c0-8413b1def591")) == null) { mob.getEntityAttribute(SharedMonsterAttributes.attackDamage).applyModifier(modifier); } } } -I used EntityJoinWorldEvent -I used an attribute modifier -I've tried changing the operation to 0, 1 and 2. Neither of them change anything. -The second if-statement is there to make sure the game doesn't crash when re-entering a world. It would give an error the entity already has this modifier. Again, what am I doing wrong? I'm sorry I can't seem to get this right Thanks in advance, ~Krikke
July 25, 201510 yr That looks correct... and you are sure the method is getting called, i.e. you registered the event listener to the Forge EVENT_BUS ? Have you been printing out the damage inflicted from LivingHurtEvent? Best to do so only for players, otherwise your console will get spammed, but that will let you verify whether the damage is increasing or not. If not, how do you know it's not working? Just for reference, attribute modifier operations are: 0: simply adds a flat amount to the total 1: adds (amount * current total) to the total 2: multiplies current total * (1 + amount) http://i.imgur.com/NdrFdld.png[/img]
July 25, 201510 yr Author and you are sure the method is getting called, i.e. you registered the event listener to the Forge EVENT_BUS ? Have you been printing out the damage inflicted from LivingHurtEvent? Best to do so only for players, otherwise your console will get spammed, but that will let you verify whether the damage is increasing or not. If not, how do you know it's not working? -Normally it should, not 100% sure though -No, I checked the damage I take by spawning a skeleton in survival mode. (they should be able to kill me in 1-2 shots with a multiplier of x10) I will try printing out the damage when I get back home though, that will let me know if the method is being called and how many damage the entity is doing. Thanks for your help so far, really appreciated
July 25, 201510 yr The Skeleton's ranged attack doesn't use the attribute system: entityarrow.setDamage((double)(p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.getDifficulty().getDifficultyId() * 0.11F)); Way to make the code consistent, Mojang -.- So yeah, all (?) melee mobs should work fine, but ranged ones you may have to use the LivingHurtEvent, and that could get messy. http://i.imgur.com/NdrFdld.png[/img]
July 26, 201510 yr Author Thank you very much for your help. It indeed only affects melee damage by Mobs.
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.