Jump to content

Recommended Posts

Posted (edited)

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 by mobeonsa
Posted

'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(

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

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

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

Posted

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.

Posted

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;
Posted
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.

Posted

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;
Posted (edited)

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
Posted

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/

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

Posted

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.

Posted

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?

Posted
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

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



×
×
  • Create New...

Important Information

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