Jump to content

Targren

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by Targren

  1. So the skeleton class sets up its own instance for it's ArrowAttack AI //File: EntitySkeleton.java private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F); //File: EntitySkeleton.java ... public EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F); ... //File: NerfedAIArrowAttack.java public class NerfedEntityAIArrowAttack extends EntityAIArrowAttack { public NerfedEntityAIArrowAttack(IRangedAttackMob par1IRangedAttackMob,double par2, int par4, float par5) { this(par1IRangedAttackMob, par2, par4, par4, par5); } public NerfedEntityAIArrowAttack(IRangedAttackMob par1IRangedAttackMob,double par2, int par4, int par5, float par6) { super(par1IRangedAttackMob, par2, par4, par5, par6); } //This is the only difference from the old AI @Override public void updateTask() { //..snip..// this.rangedAttackTime = MathHelper.floor_float((float) (this.maxRangedAttackTime - this.field_96561_g)+ (float) this.field_96561_g); System.out.println("Skele Debug: Distance^2: " + d0+ " -- Time to next shot: " + this.rangedAttackTime); //..snip..// } } //And here's my event @ForgeSubscribe public void OnSpawnEntity(LivingSpawnEvent ev){ //When Skeletons spawn, (and if they're not withers), replace their Arrow AI with the nerfed AI, to slow down //The freakin' machinegun if (ev.entityLiving instanceof EntitySkeleton){ if (((EntitySkeleton)ev.entityLiving).getSkeletonType() != 1){ //It's not a wither. ((EntitySkeleton)ev.entityLiving).tasks.removeTask(((EntitySkeleton)ev.entityLiving).aiArrowAttack); //Get it out if there's one already there ((EntitySkeleton)ev.entityLiving).aiArrowAttack = new NerfedEntityAIArrowAttack((IRangedAttackMob)ev.entityLiving, 1.0D, 20, 60, 15.0F); } } } It seemed pretty simple and straightforward, but I'm obviously missing something. Hopefully it's something that's obvious to someone better at this than I am. This is what I want to change. Since there doesn't appear to be any event that I can trap in EntityAIArrowAttack, I figured it would probably be cleaner to just make a new AI and swap it out at spawntime. (I know I'll need an AT to make it accessible, but for the moment, I've just changed the "private" to "public" so that I know it's my code that's broken and not the access transformer). Everything below seems to work (no errors or warnings outside of the 5 "built in" warnings for the mcp output), and if I breadcrumb the reassignment, I get the spam I expect. But when a skeleton shoots me in the face, I don't get the output from the new breadcrumb, and it's evident that the AI replacement isn't taking effect. UPDATE: TIL. What do you know... Popping a skeleton out of a spawn egg doesn't seem to fire an OnLivingSpawn event, nor does populating a Skeleton which was already in the world when it was unloaded (tested by breadcrumbing the event and turning doMobSpawning to false), which explains why it didn't seem to be working. Popped to peaceful to clear everything out, turned mob spawning back on, and lo and behold, it works (sort of... now they don't attack at all... back to the drawing board). Any thoughts as to what might be a better event to use for this?
  2. That's another way to do it. OP didn't specify whether he wanted it to count as a sword hit on the wielder, or just have a "punishment" for swinging it (like a cursed sword). The other reason I went with directly damaging the entity was that it would beat down a zombie who managed to pick up the sword.
  3. If you're using this: public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) {...} Then you've got the swinging entity. From there, would something like "EntityLivingBase.attackEntityFrom(DamageSource.generic, (float)dmg)" do what you're trying to do?
  4. I'm not sure about the changing the color of the water (but probably), but I'm pretty sure that the rest of what you're looking to do is possible: Thaumcraft basically does that with crucibles.
  5. My latest mod idea involves giving players special powers/immunities/weaknesses based on drops from monsters (think monster meat from Final Fantasy Legend/SaGa). I think I've got the general concept down on how to implement it, but I'd like to be able to override the players' skins while they're under the effects of these changes. I've done googling and looking through tutorials, but I'm still not sure how, or even if it's possible to do this, or if what the launcher says goes. A pointer would be much appreciated. If it's not possible, I have a second fallback idea of using particle effects like potions have, but definitely like the original idea better. Besides being cooler, it would require less memorization of what each particle effect indicates which monster skillset.
  6. I don't have any useful input about the projectile rate yet (hopefully that changes when I get to the "Skeleton Machinegun" part of my "Ultrasoftcore" mod project), but after reading your second question, I took a look at the code for the soul sand block. It's not much, but it might give you a starting point.
  7. Why do you check for the various subclasses of recipes (shaped, shapeless, shapedore, shapeless ore)? I ran into a problem with that, in that some recipes are none of the above (swords and pickaxes, e.g.) public static void removeRecipe(ItemStack resultItem) { ItemStack recipeResult = null; ArrayList recipes = (ArrayList) CraftingManager.getInstance().getRecipeList(); for (int scan = 0; scan < recipes.size(); scan++) { IRecipe recipe = (IRecipe) recipes.get(scan); recipeResult = recipe.getRecipeOutput(); if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) { System.out.println("MODID Removed Recipe: " + recipes.get(scan) + " -> " + recipeResult); recipes.remove(scan); } } } Going at it from that angle hasn't caused me any issues so far, and let me replace pickaxe and sword recipes, where the if/else checks missed those cases. Is there something I'm missing that could cause a problem using the simpler approach?
  8. Can you check the player's equipped weapon/tool, and whether a hit is a crit? If so, you might be able to work something in a LivingHurtEvent. If [DamageSource is Player] if [Hit is a Crit] //Not sure if/how this can be checked. EntityPlayer.java line 1330 may be a start If [Player Equipping Proper Weapon] // If you only want the buffed criticals to apply to certain weapons/tools ammount = weapon.base + crit bonus //Yes. ammount is misspelled.
  9. Yeah, I was just coming back to post something to that effect. Using Minecraft.getMinecraft().theWorld will return a "Multiplayer" world, even if loaded single player. I'm pretty sure it's the same case for loading .thePlayer. What I've ended up doing was trapping WorldEvent.Load and saving the world and the seed into static values for the mod, and that worked nicely. I've now got my "Slime Chunk: Yes/No" line on the debug screen. Of course, I can't stop there. Now the wild hair has expanded so that I want a line of all spawnable monsters for the given location (I saw a let's play on YT with such a mod once, but it doesn't seem to exist for 1.5.2). Bouncing around the code suggests I'm looking for IChunkProvider.getPossibleCreatures() but I'm still having some trouble sussing that one out. I'm not sure if I'm using the wrong positioning or the wrong provider, but it just keeps returning EntityEnderman and that's it. It's closer than I was yesterday, though. Update: Or possibly I should take a look in WorldEvent.java which seems to obligingly provide a static PotentialSpawns class... Nerp... that seems to be for adding potential spawns...
  10. Glad you caught it. Making your sword level up as you kill things with it? Intriguing. Good luck!
  11. That, my friend, is exactly what I needed. Thank you! I still seem to have a glitch in my code somewhere, so I'm not done bughunting yet, but that was a big boost. Much obliged.
  12. Wiki Event Ref Assuming the Wiki's up to date, I'd probably start with LivingDeathEvent and check the damage source to see if it was the player that dealt the death blow. I haven't messed much with combat yet, though, so YMMV.
  13. My latest mini-mod practice project is to duplicate an old mod I saw in a let's play once, which would simply tell you on the Debug (F3) screen if you're standing in a slime chunk (I'll find this useful for my future slime-spawning mod since Rei's detection is wonky). I've sussed out how to add the text to the Debug screen, no problem. Where I'm getting caught up is getting my current position in order to do the calculations. Unlike the other events I've dealt with to date, world, position, and player don't seem to show up in the inheritance chain for RenderGameOverlayEvent. Please forgive me if I'm missing something obvious -- I've been working with a certain other language for several years that has sabotaged my brain's ability to properly map out scoping. I figure that, if the answer to my question is "no", then I can "scrape" the X and Z coords out of the debug text lines and use them, but if there's a way to get posX and posZ straight, it'll be that much cleaner.
  14. I've taken the liberty of trimming down some code based on Moritz's, just to eliminate some duplicated code and to handle the tools and whatnot. I'll leave it here in case it helps someone else. Thanks to Moritz for doing all the heavy lifting on it! public static void removeRecipe(ItemStack par1) { List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList(); for(int i=0;i<recipeList.size();i++) { ItemStack output; IRecipe currentRecipe = recipeList.get(i); if(currentRecipe instanceof ShapedRecipes) { ShapedRecipes shape = (ShapedRecipes)currentRecipe; output = shape.getRecipeOutput(); } else if(currentRecipe instanceof ShapelessRecipes) { ShapelessRecipes shapeless = (ShapelessRecipes)currentRecipe; output = shapeless.getRecipeOutput(); } else { output = currentRecipe.getRecipeOutput(); } if (ItemStack.areItemStacksEqual(output, par1)) { recipeList.remove(i); } } }
  15. Finally have the chance to play with the code. Still not having any luck, but I think I've nailed down the problem. Certain recipes, including the tools, weapons, bed, workbench, etc... seem to be instances of neither shaped nor shapeless. I modified the inner check of the code like this: if(currentRecipe instanceof ShapedRecipes) { ShapedRecipes shape = (ShapedRecipes)currentRecipe; ItemStack output = shape.getRecipeOutput(); if(ItemStack.areItemStacksEqual(par1, output)) { recipeList.remove(i); System.out.println("Removed recipe successfully"); } else { /*System.out.print(par1); System.out.print(" is not eq to "); System.out.println(output); */ } } else if(currentRecipe instanceof ShapelessRecipes) { ShapelessRecipes shapeless = (ShapelessRecipes)currentRecipe; ItemStack output = shapeless.getRecipeOutput(); if(ItemStack.areItemStacksEqual(par1, output)) { recipeList.remove(i); System.out.println("Removed recipe successfully"); } } else { ItemStack output = currentRecipe.getRecipeOutput(); System.out.print("DEBUG: "); System.out.print(output); System.out.println(" is neither shaped nor shapeless"); } And my output confirmed my suspicions: When I change the "debug" conditional at the end to } else { ItemStack output = currentRecipe.getRecipeOutput(); if (ItemStack.areItemStacksEqual(output, par1)){ recipeList.remove(i); } It works! So I guess the moral of the story is that there are recipes that are neither shaped nor shapeless (in terms of "instanceOf", at least).
  16. Hey, Moritz, not to nag, but I was just wondering if you got a chance to test that idea, and what happened?
  17. Older but valuable resources: Introduction to Programming Using Java, 6E - Written for Java 5, but still serves nicely to learn how Java works. - Free Thinking In Java, 3E - Even more dated but was a fantastic book when I took my first Java course back when. Might be worth a look. - Free The Java Tutorials - More up to date tutorials, but less organized like a textbook and more like a list of tutorials. Free, book form available for purchase.
  18. Found in Item /** * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and * update it's contents. */ public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {} Might, perhaps, be overkill...
  19. That you want to be invincible.
  20. That's the amount of damage the armor takes? I read it as that's the amount of damage it absorbs... damn obfuscation...
  21. It looks like damaging items is handled in the ItemStack class. I was apparently on the right track, but ItemStack.damageItem doesn't pay attention to isDamageable(), just isItemStackDamageable() Maybe an extension from ItemStack overriding isItemStackDamageable or damageItem(), that checks for a flag that your immortal armor has set before applying damage... Naw, that'll need overrides all the way up to the player to change the armor inventory type... I'm not well-versed in forge events, but I think Mazetar has the right idea. If there's an event you can trap when an item is damaged, you can have it self-heal...
  22. I'm poring over the code now (you've piqued my curiosity). The trick is to find out where damage is applied and override that method... I can say that it doesn't seem to be getDamage, or getItemDamage. Overriding both of those to return 0 doesn't seem to help. Update: It looks like damaging items is handled in the ItemStack class. I was apparently on the right track, but ItemStack.damageItem doesn't pay attention to isDamageable(), just isItemStackDamageable() Maybe an extension from ItemStack overriding isItemStackDamageable or damageItem(), that checks for a flag that your immortal armor has set before applying damage.
  23. What happens if you override isDamageable() in your new armor class with something like this? public boolean isDamageable() { return false; } I'm guessing that's checked before damage is applied to an item (though I could be way off, I'm still new at this). Nope, that don't work. I'll just go sit quietly now.
  24. I don't think your code is to blame, since the logic seems to be sound. If you find anything, though, I'll be grateful to hear about it.
×
×
  • Create New...

Important Information

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