Posted July 14, 20187 yr Is there a way to change the durability of an anvil? Or change a chance of damaging the anvil. And also can i do it separately for in world interaction(fall) and in GUI interaction(repair) Edited July 14, 20187 yr by mobeonsa
July 15, 20187 yr You can use AnvilRepairEvent to control the chance of the anvil damaging when it is used to repair/combine items.
July 15, 20187 yr Author Thank you! Does AnvilRepairEvent work with in world interaction(then anvil fall)?
July 15, 20187 yr No. That is hardcoded at EntityFallingBlock#fall and there are currently no forge hooks into it as far as I can tell.
July 15, 20187 yr Author 'Anvil' -> 'Slightly Damaged Anvil' -> 'Very Damaged Anvil' But can i change 'Slightly Damaged Anvil' properties so it will be equal to 'Anvil'? (And same for 'Very Damaged Anvil') Sorry for bad English(
July 15, 20187 yr 9 minutes ago, mobeonsa said: But can i change 'Slightly Damaged Anvil' properties so it will be equal to 'Anvil'? (And same for 'Very Damaged Anvil') Sorry for bad English( If you use the EntityJoinWorldEvent to remove the EntityFallingBlock when it is an anvil and replace it with your own entity that does the same thing, but modifies the chance for breaking. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
July 15, 20187 yr 11 minutes ago, mobeonsa said: But can i change 'Slightly Damaged Anvil' properties so it will be equal to 'Anvil'? (And same for 'Very Damaged Anvil') Sorry for bad English( If you use the EntityJoinWorldEvent to remove the EntityFallingBlock when it is an anvil and replace it with your own entity that does the same thing, but modifies the chance for breaking. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
July 15, 20187 yr 2 hours ago, mobeonsa said: But can i change 'Slightly Damaged Anvil' properties so it will be equal to 'Anvil'? (And same for 'Very Damaged Anvil') Sorry for bad English( What do you mean, "change its properties"? Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
July 15, 20187 yr Author I'm new in modding, but i think every block has some set of "properties", like: texture, gravity, tool level...
July 15, 20187 yr Well if you want a damaged anvil to look like an undamaged anvil (but is still damaged) I would not like that as a player: I would never know when my anvil might just poof out of existence. If you want to change the anvil back to a less-damaged state, just change its state. (Other properties: sure, these exist, but none of them are "different" for the different stages of anvils, this is why I asked). Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
July 15, 20187 yr It should be an anvil that's always an undamaged one, and he does his own damaging in metadata, of course this anvil needs to be another one, extended from the original. My idea is what if you replace the damaged anvil with an undamaged one when the player opens the gui, but with keeping the metadata itself, so if you make it like that, you can make the anvil a custom "durability", and change it whenever you want, like increasing the metadata's value by one per use, and when it's idk, 48, then you break the block. (Sorry for this crappy sentence, I'm Hungarian) procedure WakeMeUp(Integer plusTime); var I: Integer; begin for I := 0 to plusTime do begin println('One more minute!'); Sleep(1000); end; println('Okay, nothing to worry, I''m alive!'); println('So... somebody can give me a coffee?'); println('I know it''s Pascal, and not Java, but I love it :D.'); end;
July 15, 20187 yr 9 minutes ago, Legenes said: increasing the metadata's value by one per use, and when it's idk, 48 Metadata is limited to 16. Also metadata is an implementation detail. Use IBlockState properties. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
July 15, 20187 yr But he can do it like that way with BlockState? (Sorry for that, I always mix them up) procedure WakeMeUp(Integer plusTime); var I: Integer; begin for I := 0 to plusTime do begin println('One more minute!'); Sleep(1000); end; println('Okay, nothing to worry, I''m alive!'); println('So... somebody can give me a coffee?'); println('I know it''s Pascal, and not Java, but I love it :D.'); end;
July 17, 20187 yr Author After some searching i found this: Quote: "Subscribe to "EntityJoinWorldEvent", check if entity is EntityFallingBlock, then check if EntityFallingBlock.fallTile is Anvil. Extend EntityFallingBlock with your MyEntityFallingBlock and override onUpdate() method adding a subtle change that will instead of placing anvil on ground-hit ..." And then i place undamaged version of anvil. Is it right? Or there are better way to do it? Edited July 17, 20187 yr by mobeonsa
July 17, 20187 yr Pretty much. In MyEntityFallingBlock you'll just want to get rid of part of the fall() method where it updates damage to the anvil. I think you can pretty much just delete this part: if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D) { int j = ((Integer)this.fallTile.getValue(BlockAnvil.DAMAGE)).intValue(); ++j; if (j > 2) { this.dontSetBlock = true; } else { this.fallTile = this.fallTile.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j)); } } Check out my tutorials here: http://jabelarminecraft.blogspot.com/
September 25, 20186 yr On 7/17/2018 at 1:40 AM, mobeonsa said: After some searching i found this: Quote: "Subscribe to "EntityJoinWorldEvent", check if entity is EntityFallingBlock, then check if EntityFallingBlock.fallTile is Anvil. Extend EntityFallingBlock with your MyEntityFallingBlock and override onUpdate() method adding a subtle change that will instead of placing anvil on ground-hit ..." And then i place undamaged version of anvil. Is it right? Or there are better way to do it? I'm interested in altering the durability of the anvil as well but am struggling to get my head around where/what to do here. Am I right that EntityJoinWorldEvent and EntityFallingBlock events only occur when you first create/place the anvil the first time? Or does this fire every time you use the anvil? GitHub Profile | MinecraftForum.net Profile
September 25, 20186 yr EntityJoinWorldEvent happens every time any entity joins a world. As in every time World#spawnEntity is called. EntityFallingBlock is not an event. It's an entity.
September 25, 20186 yr 23 minutes ago, V0idWa1k3r said: EntityJoinWorldEvent happens every time any entity joins a world. As in every time World#spawnEntity is called. EntityFallingBlock is not an event. It's an entity. Thanks, @V0idWa1k3r. So would overriding those events/entity only affect new anvils or all (existing) anvils? GitHub Profile | MinecraftForum.net Profile
September 25, 20186 yr It would override any falling block. It doesn't matter whether the anvil is "new" or "old". It should also affect even the falling blocks currently in the process of falling.
September 25, 20186 yr Also note that anvils don't have durability the way items have durability. They have a probabilistic chance of going from "newly made" to "worn" to "damaged" to "gone." The falling action is also probabilistic: Number of blocks fallen * 5%. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
September 25, 20186 yr Yeah I'm struggling to hook into EntityJoinWorldEvent for Anvil. Admittedly I am not a MC mod/java pro so I could be doing it wrong but seems to only triggers when I place it on the ground. Ideally I'd like to find what event fires when the Anvil is "USED" to repair/upgrade something. Forge has that onAnvilUpdate() in the ForeHooks but that SEEMS to have zero information about the Anvil being used (only has cost, item left, item right etc) @Draco18s when does that falling action/chance moment fire? Is that happening inside an EntityJoinWorldEvent or another, more specific event? GitHub Profile | MinecraftForum.net Profile
September 25, 20186 yr 7 minutes ago, EM3R50N said: Ideally I'd like to find what event fires when the Anvil is "USED" to repair/upgrade something. AnvilRepairEvent. You can get the "current anvil" from the opened container(event.getEntityPlayer().openContainer). It is likely an instance of ContainerRepair(although it might not be in case of modded anvils so you have to account for that). ContainerRepair has a selfPosition field you can use to get the position of the anvil. Although none of that is needed if you simply want to modify the break chance for the anvil. Just use AnvilRepairEvent#setBreakChance. 7 minutes ago, EM3R50N said: when does that falling action/chance moment fire? There is no event for that. If you wish for one you can submit a PR. This is why you are using a EntityJoinWorldEvent in the first place - to replace the falling anvil entity provided by vanilla with your own wrapper/version that has the necessary hook.
September 25, 20186 yr Thank you @V0idWa1k3r and @Draco18s. Much appreciated! All sorted out now. Sorry if I semi-hijacked this thread btw - I did come here trying to avoid a dup post. Again - thank you both. GitHub Profile | MinecraftForum.net Profile
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.