Skip to content

Commit f5996cb

Browse files
committed
Itemstack damage
1 parent f2670ec commit f5996cb

16 files changed

Lines changed: 23 additions & 20 deletions

src/main/java/de/dafuqs/spectrum/blocks/deeper_down/flora/SawbladeHollyBushBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public ItemActionResult onUseWithItem(ItemStack handStack, BlockState state, Wor
109109
for (ItemStack stack : JadeVinePlantBlock.getHarvestedStacks(state, (ServerWorld) world, pos, world.getBlockEntity(pos), player, player.getMainHandStack(), SpectrumLootTables.SAWBLADE_HOLLY_SHEARING)) {
110110
dropStack(world, pos, stack);
111111
}
112-
handStack.damage(1, player, (p) -> p.sendToolBreakStatus(hand));
112+
handStack.damage(1, player, LivingEntity.getSlotForHand(hand));
113113
}
114114

115115
BlockState newState = state.with(AGE, state.get(AGE) - 1);

src/main/java/de/dafuqs/spectrum/blocks/deeper_down/flora/TriStateVineBlock.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import de.dafuqs.spectrum.registries.*;
66
import net.fabricmc.fabric.api.tag.convention.v1.*;
77
import net.minecraft.block.*;
8+
import net.minecraft.entity.LivingEntity;
89
import net.minecraft.entity.player.*;
910
import net.minecraft.item.*;
1011
import net.minecraft.server.world.*;
@@ -51,7 +52,7 @@ public ItemActionResult onUseWithItem(ItemStack handStack, BlockState state, Wor
5152
return ItemActionResult.FAIL;
5253

5354
if (!creative)
54-
handStack.damage(1, player, p -> p.sendToolBreakStatus(hand));
55+
handStack.damage(1, player, LivingEntity.getSlotForHand(hand));
5556

5657
reference.setProperty(LIFE_STAGE, LifeStage.MATURE);
5758
reference.update(world);
@@ -262,4 +263,4 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po
262263
Vec3d vec3d = state.getModelOffset(world, pos);
263264
return super.getOutlineShape(state, world, pos, context).offset(vec3d.x, vec3d.y, vec3d.z);
264265
}
265-
}
266+
}

src/main/java/de/dafuqs/spectrum/blocks/jade_vines/JadeiteLotusStemBlock.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import de.dafuqs.spectrum.registries.*;
55
import net.fabricmc.fabric.api.tag.convention.v1.*;
66
import net.minecraft.block.*;
7+
import net.minecraft.entity.LivingEntity;
78
import net.minecraft.entity.player.*;
89
import net.minecraft.item.*;
910
import net.minecraft.server.world.*;
@@ -50,7 +51,7 @@ public ItemActionResult onUseWithItem(ItemStack handStack, BlockState state, Wor
5051
BlockState newState = state.with(STEM_PART, StemComponent.STEM);
5152
world.setBlockState(pos, newState);
5253
player.playSoundToPlayer(SoundEvents.ENTITY_MOOSHROOM_SHEAR, SoundCategory.BLOCKS, 1, 0.9F + player.getRandom().nextFloat() * 0.2F);
53-
handStack.damage(1, player, (p) -> p.sendToolBreakStatus(hand));
54+
handStack.damage(1, player, LivingEntity.getSlotForHand(hand));
5455
world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(newState));
5556

5657
return ItemActionResult.success(world.isClient());

src/main/java/de/dafuqs/spectrum/blocks/jade_vines/NephriteBlossomStemBlock.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import de.dafuqs.spectrum.registries.*;
55
import net.fabricmc.fabric.api.tag.convention.v1.*;
66
import net.minecraft.block.*;
7+
import net.minecraft.entity.LivingEntity;
78
import net.minecraft.entity.player.*;
89
import net.minecraft.item.*;
910
import net.minecraft.server.world.*;
@@ -49,7 +50,7 @@ public ItemActionResult onUseWithItem(ItemStack handStack, BlockState state, Wor
4950
BlockState newState = state.with(STEM_PART, StemComponent.STEM);
5051
world.setBlockState(pos, newState);
5152
player.playSoundToPlayer(SoundEvents.ENTITY_MOOSHROOM_SHEAR, SoundCategory.BLOCKS, 1, 0.9F + player.getRandom().nextFloat() * 0.2F);
52-
handStack.damage(1, player, (p) -> p.sendToolBreakStatus(hand));
53+
handStack.damage(1, player, LivingEntity.getSlotForHand(hand));
5354
world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(newState));
5455

5556
return ItemActionResult.success(world.isClient());

src/main/java/de/dafuqs/spectrum/entity/entity/EggLayingWoolyPigEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public ActionResult interactMob(PlayerEntity player, Hand hand) {
7171
if (!world.isClient() && this.isShearable()) {
7272
this.sheared(SoundCategory.PLAYERS);
7373
this.emitGameEvent(GameEvent.SHEAR, player);
74-
handStack.damage(1, player, (p) -> p.sendToolBreakStatus(hand));
74+
handStack.damage(1, player, LivingEntity.getSlotForHand(hand)));
7575
return ActionResult.SUCCESS;
7676
} else {
7777
return ActionResult.CONSUME;

src/main/java/de/dafuqs/spectrum/entity/entity/KindlingEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ public ActionResult interactMob(PlayerEntity player, Hand hand) {
509509
this.sheared(SoundCategory.PLAYERS);
510510
this.emitGameEvent(GameEvent.SHEAR, player);
511511
if (!this.getWorld().isClient) {
512-
handStack.damage(1, player, (p) -> p.sendToolBreakStatus(hand));
512+
handStack.damage(1, player, LivingEntity.getSlotForHand(hand));
513513
}
514514
}
515515

src/main/java/de/dafuqs/spectrum/items/armor/GemstoneArmorItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void onHit(ItemStack itemStack, DamageSource source, LivingEntity targetE
3030
targetEntity.getWorld().playSound(null, targetEntity.getBlockPos(), SoundEvents.BLOCK_AMETHYST_BLOCK_HIT, SoundCategory.PLAYERS, 1.0F, 1.0F);
3131
targetEntity.getWorld().playSound(null, targetEntity.getBlockPos(), SoundEvents.ENTITY_SPLASH_POTION_BREAK, SoundCategory.PLAYERS, 1.0F, 1.0F);
3232

33-
itemStack.damage(2, targetEntity, (e) -> e.sendEquipmentBreakStatus(type.getEquipmentSlot()));
33+
itemStack.damage(2, targetEntity, type.getEquipmentSlot());
3434
}
3535

3636
@Override

src/main/java/de/dafuqs/spectrum/items/tools/DraconicTwinswordItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int
6767
nbt.putUuid("lastTwinsword", twinsword.getUuid());
6868

6969
if (!world.isClient())
70-
stack.damage(1, user, (p) -> p.sendToolBreakStatus(user.getActiveHand()));
70+
stack.damage(1, user, LivingEntity.getSlotForHand(user.getActiveHand()));
7171

7272

7373
super.onStoppedUsing(stack, world, user, remainingUseTicks);

src/main/java/de/dafuqs/spectrum/items/tools/FerociousBidentItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void usageTick(World world, LivingEntity user, ItemStack stack, int remai
4848
int useTime = this.getMaxUseTime(stack, user) - remainingUseTicks;
4949
if (useTime % 10 == 0) {
5050
if (InkPowered.tryDrainEnergy(player, RIPTIDE_COST)) {
51-
stack.damage(1, user, (p) -> p.sendToolBreakStatus(user.getActiveHand()));
51+
stack.damage(1, user, LivingEntity.getSlotForHand(user.getActiveHand()));
5252
} else {
5353
user.stopUsingItem();
5454
return;

src/main/java/de/dafuqs/spectrum/items/tools/GlassCrestGreatswordItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
8686
int groundSlamStrength = getGroundSlamStrength(stack);
8787
if (groundSlamStrength > 0) {
8888
performGroundSlam(world, user.getPos(), user, groundSlamStrength);
89-
stack.damage(1, user, (p) -> p.sendToolBreakStatus(user.getActiveHand()));
89+
stack.damage(1, user, LivingEntity.getSlotForHand(user.getActiveHand()));
9090
}
9191
}
9292

0 commit comments

Comments
 (0)