Posted August 27, 201312 yr can i set the critical hit damage on a sword/tool? somthing like: this.setCriticalDamage(+10) //so it does +10 damage if you critical strike a mob Only code when your having fun doing it.
August 29, 201312 yr 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.
August 29, 201312 yr Author i cant copy paste that code plz help ima noob (just tell me how i need to put this in my code) Only code when your having fun doing it.
August 29, 201312 yr you do: [.code]YOUR TEXT[/.code] (remove the dots) Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
August 29, 201312 yr i cant copy paste that code plz help ima noob (just tell me how i need to put this in my code) That's not the code. It's just the code logic.
August 29, 201312 yr maybe this works: @ForgeSubscribe public void onEntityHit(LivingHurtEvent event) { if (!(event.source instanceof EntityDamageSource)) { return; } EntityDamageSource dmgSource = (EntityDamageSource) event.source; Entity ent = dmgSource.getEntity(); if (!(ent instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) ent; ItemStack weapon = player.getCurrentEquippedItem(); if (!(weapon.getItem() instanceof *PUT_YOUR_SWORD_CLASS_HERE*)) //EDIT: forgot the .getItem() { return null; } /** * Copied from {@link EntityPlayer#1345} */ boolean flag = player.fallDistance > 0.0f && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && !player.isRiding(); if (flag) { event.ammount += *PUT_CRIT_AMOUNT_HERE*; } } If I was any help please hit that "Thank You" button.
September 1, 201312 yr Author maybe this works: @ForgeSubscribe public void onEntityHit(LivingHurtEvent event) { if (!(event.source instanceof EntityDamageSource)) { return; } EntityDamageSource dmgSource = (EntityDamageSource) event.source; Entity ent = dmgSource.getEntity(); if (!(ent instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) ent; ItemStack weapon = player.getCurrentEquippedItem(); if (!(weapon.getItem() instanceof *PUT_YOUR_SWORD_CLASS_HERE*)) //EDIT: forgot the .getItem() { return null; } /** * Copied from {@link EntityPlayer#1345} */ boolean flag = player.fallDistance > 0.0f && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && !player.isRiding(); if (flag) { event.ammount += *PUT_CRIT_AMOUNT_HERE*; } } do i need to put this code in a eventhandler class or somthing? Only code when your having fun doing it.
September 4, 201312 yr ok so i modified your code to eliminate errors but i cant seem to make it work this is funny coincidence i was trying to do this before i cam on here so yeah. @EventHandler public void onEntityHit(LivingHurtEvent event) { if (!(event.source instanceof EntityDamageSource)) { return; } EntityDamageSource dmgSource = (EntityDamageSource) event.source; Entity ent = dmgSource.getEntity(); if (!(ent instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) ent; ItemStack weapon = player.getCurrentEquippedItem(); if (!(weapon.getItem() instanceof LightSteelRapier)) { return; } Random random1Generator = new Random(); int ran1 = random1Generator.nextInt(25);{ if (ran1 == 10) { event.ammount += 10000000; }} } Use examples, i have aspergers. Examples make sense to me.
September 5, 201312 yr got it last night lol nice code btw &thnx Use examples, i have aspergers. Examples make sense to me.
September 6, 201312 yr i found a problem with you code? a bug or somthing? if (!(weapon.getItem() instanceof *PUT_YOUR_SWORD_CLASS_HERE*)) //EDIT: forgot the .getItem() { return null; } on this part, the return null is an error, it suggests you remove the "null" but if you do when you hit something with your hand it crashed the game saying ee al one method not closed or something like that and it says that this line is the problem? anyone got any ideas? Use examples, i have aspergers. Examples make sense to me.
September 6, 201312 yr Well your method has a "void" as return type. So you can't return null (which is an object). The other issue is you didn't check if "weapon" isn't null before calling getItem().
September 6, 201312 yr i figured out the void bit, i was questioning the code, i didnt write it if you read the above parts of the post. Also would the null check be something like this? @ForgeSubscribe public void onEntityHit1(LivingHurtEvent event) { if (!(event.source instanceof EntityDamageSource)) { return; } EntityDamageSource dmgSource = (EntityDamageSource) event.source; Entity ent = dmgSource.getEntity(); if (!(ent instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) ent; ItemStack weapon = player.getCurrentEquippedItem(); if (!(weapon.getItem() == null)){ if (weapon.getItem() instanceof ImmortalTheSkewer) { Random random1Generator = new Random(); int ran1 = random1Generator.nextInt(100);{ if (ran1 < 2){ event.ammount += 100; }}}} } Use examples, i have aspergers. Examples make sense to me.
September 6, 201312 yr but if the weapon = null i dont want it do do anything this works with my old version of the event, but when i attack with the hand it crashes and says AL lib: (EE) alc_cleanup: 1 device not closed. any other tool or item works fine, so i understand what your saying but isnt it if whats in my hand isn't the specified item it should not do anything? and surly hand does not equal weapon of choice so why the crash??? maybe because they hand isnt an item at all... so, i put if weapon item doesnt equal nothing (hand) then check if its the specified item, so why does this not worl? ((!(weapon.getItem() == null)){ Use examples, i have aspergers. Examples make sense to me.
September 6, 201312 yr Read again, or learn how to use booleans. This is the null class: public class null { //Really, just void } Do you see a getItem() method here ?
September 6, 201312 yr my bad i understand you i just missed that, oops lol and thanks btw Use examples, i have aspergers. Examples make sense to me.
September 6, 201312 yr and finally just for luck, can you see any errors or modifications that would make the code better? @ForgeSubscribe public void onEntityHit1(LivingHurtEvent event) { if (!(event.source instanceof EntityDamageSource)) { return; } EntityDamageSource dmgSource = (EntityDamageSource) event.source; Entity ent = dmgSource.getEntity(); if (!(ent instanceof EntityPlayer)) {return;} Random random1Generator = new Random(); int ran1 = random1Generator.nextInt(100); EntityPlayer player = (EntityPlayer) ent; ItemStack weapon = player.getCurrentEquippedItem(); if (!(weapon == null)){ if (weapon.getItem() instanceof MythicalVampiricBlade) {if (ran1 < 13){ player.addPotionEffect(new PotionEffect(Potion.field_76444_x.getId(), 600, 4));}} if (weapon.getItem() instanceof ImmortalTheSkewer) {if (ran1 < 2){ event.ammount += 100;}} if (!(weapon.getItem() instanceof MythicalSteelRapier)) {if (ran1 < 80) {event.ammount += 10;}} if (!(weapon.getItem() instanceof SharpWoodSword) || (weapon.getItem() instanceof SharpStoneSword) || (weapon.getItem() instanceof SharpIronSword )|| (weapon.getItem() instanceof SharpSteelSword) || (weapon.getItem() instanceof SharpDiamondSword) || (weapon.getItem() instanceof SharpGoldSword)) {if (ran1 < 2){ event.ammount += 100; }}}} btw please don't steal my ideas D: -EDIT i just found a misplaced construct have changed the code above, and again Use examples, i have aspergers. Examples make sense to me.
September 6, 201312 yr ok wtf i keep critting 100 with random items which means that som part of the above code is fucked up and i have no idea WHYYYYYY ... GODDAAAAAMITTTTTTT im going to sleep any help would be great, ill read it in the morn. Use examples, i have aspergers. Examples make sense to me.
September 6, 201312 yr if (!(weapon.getItem() instanceof MythicalSteelRapier)) {if (ran1 < 80) {event.ammount += 10;}} Any item not a MythicalSteelRapier gets a 80% chance of having 10 more damage.
September 7, 201312 yr thanks i am such a dumbass somtimes... Use examples, i have aspergers. Examples make sense to me.
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.