Jump to content

Targren

Members
  • Posts

    34
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    Green as a creeper

Targren's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  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. That's not the code. It's just the code logic.
  9. 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.
  10. 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...
  11. Glad you caught it. Making your sword level up as you kill things with it? Intriguing. Good luck!
  12. 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.
  13. 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.
  14. 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.
  15. 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); } } }
×
×
  • Create New...

Important Information

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