Jump to content

Anvil durability


mobeonsa

Recommended Posts

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.

  • Thanks 1

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).

  • Thanks 1

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.

Link to comment
Share on other sites

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;
Link to comment
Share on other sites

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.

  • Thanks 1

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.

Link to comment
Share on other sites

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;
Link to comment
Share on other sites

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 by mobeonsa
Link to comment
Share on other sites

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/

Link to comment
Share on other sites

  • 2 months later...
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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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%.

  • Thanks 1

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

  • Thanks 1
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Slot Bank BNI adalah pilihan tergacor untuk memulai bermain slot judi Online dimuka bumi saat ini. Jika anda mempunyai Bank BNI, Anda berkesempatan mendapatkan Akun Pro atau ID pro untuk bermain slot. Tunggu apa lagi? Segera daftarkan diri anda sekarang dan dapatkan kemewahan menang maxwin di Museumbola.
    • Halo para penggemar slot online! Apakah Anda mencari pengalaman bermain slot yang seru dan menguntungkan? Apakah Anda ingin menikmati slot gacor dari server Thailand sambil melakukan deposit melalui Mandiri dengan kesempatan meraih kemenangan besar? Anda telah sampai di tempat yang tepat! Kami di WINNING303 siap memberikan Anda pengalaman bermain yang mengasyikkan dan menguntungkan. Mengapa Memilih WINNING303? WINNING303 telah dikenal sebagai salah satu platform terbaik untuk bermain slot dengan berbagai keunggulan yang kami tawarkan kepada para pemain kami. Berikut adalah beberapa alasan mengapa Anda harus memilih WINNING303: Slot Gacor dari Server Thailand Kami menyajikan koleksi slot gacor terbaik dari server Thailand yang pastinya akan memberikan Anda pengalaman bermain yang menarik dan menguntungkan. Nikmati berbagai jenis permainan slot dengan tingkat kemenangan yang tinggi dan jackpot yang menarik. Deposit Mudah Melalui Mandiri Kami memahami pentingnya kemudahan dalam bertransaksi bagi para pemain kami. Oleh karena itu, kami menyediakan layanan deposit melalui bank Mandiri, salah satu bank terbesar di Indonesia. Proses depositnya cepat, mudah, dan aman, sehingga Anda dapat langsung memulai petualangan bermain tanpa hambatan. Peluang Maxwin Besar Di WINNING303, kami selalu memberikan peluang untuk meraih kemenangan besar. Dengan berbagai promosi dan bonus menarik yang kami sediakan, Anda memiliki kesempatan untuk memenangkan hadiah-hadiah yang fantastis dan meraih maxwin dalam bermain slot.  
    • SLOT Ratubet77 adalah bocoran slot gacor rekomendasi dari Ratubet77 yang bisa anda temukan di SLOT Ratubet77. Situs SLOT Ratubet77 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ratubet77 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ratubet77 merupakan SLOT Ratubet77 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ratubet77. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ratubet77 hari ini yang telah disediakan SLOT Ratubet77. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ratubet77 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ratubet77 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ratubet77 di link SLOT Ratubet77. DAFTAR SEKARANG DAFTAR SEKARANG DAFTAR SEKARANG
    • I am currently running the 1.20.1 Occultcraft modpack in Curseforge and am having numerous troubles making a mob farm with the apotheosis mod. When trying to modify the stats of the spawners specific stats such as the range, spawn count, and max entities reset to default after every spawn. When the spawners spawn boss mobs with certain attributes, that I'm not sure of, the building it is in explode even with mob griefing turned off. This has happened multiple times with varying sizes for the explosions. I was wonder if there is any way to disable these explosions from happening or disable boss abilities with something in the game. I also wanted to know a fix for the resetting stats on spawners and why this is happening.
    • SLOT Bank BSI adalah pilihan terbaik untuk Anda yang ingin merasakan sensasi bermain slot dengan layanan dari Bank BSI. Dengan keamanan terjamin, beragam pilihan permainan, kemudahan deposit via Bank BSI, dan berbagai bonus menarik, kami siap memberikan Anda pengalaman bermain yang tak terlupakan. Bergabunglah dengan kami sekarang dan mulailah petualangan seru Anda!    
  • Topics

×
×
  • Create New...

Important Information

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