#shears damage

1 messages · Page 1 of 1 (latest)

dense snow
lethal forge
#

Hi

#

What happening

#

Explain your problem and send code on ?paste

dense snow
#

I set the meta back to usedShears but now the damage is reset after looping through all of the nearby sheep

#

?paste

lethal forge
#

Wait i dont why not work the command

dense snow
lethal forge
#

Allrigh

#

I will check it

#

What are you trying to do

#

I didnt understand

#

Sorry but im not native speaker and sometimes its really difficult to me to understand what you want

dense snow
#

The plugin shears all sheep in a 3 block radius of the sheared sheep

#

it works except for giving the shears damage

lethal forge
#

Please try to send full code

#

If not it more difficult to help

dense snow
lethal forge
#

Allright

#

A recommendation

#

Dont have listeners on main class

#

do it on another class

dense snow
#

yeah I thought this was going to be more simple, I'll refactor it

#

the issue in the paste is specifically between lines 73 and 82

#

setting the itemMeta didn't keep the damage at the end

lavish wasp
#

fixed ?

dense snow
#

no I'm still trying to figure it out

#

I changed up the code though so I'll make a new paste of it

#

now it's saying the shears are broken everytime

#

simple operator error

#

hang on

#
[13:58:31] [Server thread/INFO]: Collected list of nearby entities
[13:58:31] [Server thread/INFO]: Found 26
[13:58:31] [Server thread/INFO]: Looping through entities
[13:58:31] [Server thread/INFO]:
[13:58:31] [Server thread/INFO]: shearing sheep
[13:58:31] [Server thread/INFO]: Shears damaged. Current Damage: 56
[13:58:31] [Server thread/INFO]:
[13:58:31] [Server thread/INFO]: shearing sheep
[13:58:31] [Server thread/INFO]: Shears damaged. Current Damage: 57
[13:58:31] [Server thread/INFO]:
[13:58:31] [Server thread/INFO]: shearing sheep
[13:58:31] [Server thread/INFO]: Shears damaged. Current Damage: 58
[13:58:31] [Server thread/INFO]:
[13:58:31] [Server thread/INFO]: shearing sheep
[13:58:31] [Server thread/INFO]: Shears damaged. Current Damage: 59
[13:58:31] [Server thread/INFO]:
[13:58:31] [Server thread/INFO]: shearing sheep
[13:58:31] [Server thread/INFO]: Shears damaged. Current Damage: 60```
#

this goes all the way to 80 damage

#
[14:00:39] [Server thread/INFO]: Collected list of nearby entities
[14:00:39] [Server thread/INFO]: Found 2
[14:00:39] [Server thread/INFO]: Looping through entities
[14:00:39] [Server thread/INFO]: PLAYER is not a sheep, continuing
[14:00:39] [Server thread/INFO]: Original sheep, continuing
[14:00:39] [Server thread/INFO]:
[14:00:39] [Server thread/INFO]: shearing sheep
[14:00:39] [Server thread/INFO]: Shears damaged. Current Damage: 56```
#

when I shear sheep again, damage is reset

#
[14:01:23] [Server thread/INFO]: Collected list of nearby entities
[14:01:23] [Server thread/INFO]: Found 4
[14:01:23] [Server thread/INFO]: Looping through entities
[14:01:23] [Server thread/INFO]: PLAYER is not a sheep, continuing
[14:01:23] [Server thread/INFO]:
[14:01:23] [Server thread/INFO]: shearing sheep
[14:01:23] [Server thread/INFO]: Shears damaged. Current Damage: 56
[14:01:23] [Server thread/INFO]:
[14:01:23] [Server thread/INFO]: shearing sheep
[14:01:23] [Server thread/INFO]: Shears damaged. Current Damage: 57
[14:01:23] [Server thread/INFO]:
[14:01:23] [Server thread/INFO]: shearing sheep
[14:01:23] [Server thread/INFO]: Shears damaged. Current Damage: 58
[14:01:23] [Server thread/INFO]: Original sheep, continuing```
#

and this is with 4 sheep

lethal forge
#

Hum

#

I think that every entity has a unique id

#

Like players

#

If not i dont find the cause

dense snow
#

yeah, it's weird

#

line 52 should work

#

in the paste

#

usedShears.setItemMeta(usedShearsMeta);

lethal forge
#

Its not working?

dense snow
#

no the damage is reset

lethal forge
#

Hu

#

Let me read the new link

dense snow
#

everything works except for durability

lethal forge
dense snow
#

because the player is always grabbed in the list

lethal forge
#

Ah allright

dense snow
#

so length excluding player

lethal forge
#

Yeah

#

Wait

#

This

#

Damageable usedShearsMeta = (Damageable) usedShears.getItemMeta();

#

doesnt convince mee

dense snow
#

that's what I was told to do

#

cast it

lethal forge
#

wait let me check sth

#

Which version?

dense snow
#

opensource jdk 17

lethal forge
#

cuz i only do plugins on 1.8x

dense snow
#

language level 17

lethal forge
dense snow
#

oh uh

#

1.18.1-R0.1-SNAPSHOT

lethal forge
#

Ah allright

#

I think getItemMeta() return ItemMeta object

dense snow
#

it's cast to the Damageable interface used for dealing with item damage

lethal forge
#

Ah allright

lethal forge
#

Yeah on 1.8 it doesnt

#

No no, its has it

#

Yes

#

🤡

dense snow
#

because ItemStack item.getDurability and item.setDurability is deprecated

lethal forge
#

Im really clown

dense snow
#

oh

#

I'll try adding up all the damage taken and at the end, add the damage

#

does not work

#

hang on I didn't set the meta again