TwIxToR_TiTaN Posted August 27, 2013 Posted August 27, 2013 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 Quote Only code when your having fun doing it.
Targren Posted August 29, 2013 Posted August 29, 2013 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. Quote
TwIxToR_TiTaN Posted August 29, 2013 Author Posted August 29, 2013 i cant copy paste that code plz help ima noob (just tell me how i need to put this in my code) Quote Only code when your having fun doing it.
larsgerrits Posted August 29, 2013 Posted August 29, 2013 you do: [.code]YOUR TEXT[/.code] (remove the dots) Quote 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/
Targren Posted August 29, 2013 Posted August 29, 2013 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. Quote
big_Xplosion Posted August 29, 2013 Posted August 29, 2013 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*; } } Quote If I was any help please hit that "Thank You" button.
TwIxToR_TiTaN Posted September 1, 2013 Author Posted September 1, 2013 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? Quote Only code when your having fun doing it.
GotoLink Posted September 1, 2013 Posted September 1, 2013 Man, if you don't understand how to use the code... learn Java, seriously. Quote
ashtonr12 Posted September 4, 2013 Posted September 4, 2013 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; }} } Quote Use examples, i have aspergers. Examples make sense to me.
ashtonr12 Posted September 5, 2013 Posted September 5, 2013 got it last night lol nice code btw &thnx Quote Use examples, i have aspergers. Examples make sense to me.
ashtonr12 Posted September 6, 2013 Posted September 6, 2013 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? Quote Use examples, i have aspergers. Examples make sense to me.
GotoLink Posted September 6, 2013 Posted September 6, 2013 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(). Quote
ashtonr12 Posted September 6, 2013 Posted September 6, 2013 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; }}}} } Quote Use examples, i have aspergers. Examples make sense to me.
ashtonr12 Posted September 6, 2013 Posted September 6, 2013 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)){ Quote Use examples, i have aspergers. Examples make sense to me.
GotoLink Posted September 6, 2013 Posted September 6, 2013 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 ? Quote
ashtonr12 Posted September 6, 2013 Posted September 6, 2013 my bad i understand you i just missed that, oops lol and thanks btw Quote Use examples, i have aspergers. Examples make sense to me.
ashtonr12 Posted September 6, 2013 Posted September 6, 2013 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 Quote Use examples, i have aspergers. Examples make sense to me.
ashtonr12 Posted September 6, 2013 Posted September 6, 2013 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. Quote Use examples, i have aspergers. Examples make sense to me.
GotoLink Posted September 6, 2013 Posted September 6, 2013 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. Quote
ashtonr12 Posted September 7, 2013 Posted September 7, 2013 thanks i am such a dumbass somtimes... Quote Use examples, i have aspergers. Examples make sense to me.
Recommended Posts
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.