Skip to content

Commit

Permalink
add tag to define items that should not get damaged
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckscor3 committed Feb 21, 2023
1 parent da9829b commit c51bfd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/me/juancarloscp52/entropy/EntropyTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static class ItemTags {
public static final TagKey<Item> DOES_NOT_DROP_RANDOMLY = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "does_not_drop_randomly"));
public static final TagKey<Item> DOES_NOT_RAIN = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "does_not_rain"));
public static final TagKey<Item> DO_NOT_CURSE = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "do_not_curse"));
public static final TagKey<Item> DO_NOT_DAMAGE = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "do_not_damage"));
public static final TagKey<Item> UNFIXABLE = TagKey.of(Registries.ITEM.getKey(), new Identifier("entropy", "unfixable"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package me.juancarloscp52.entropy.events.db;

import me.juancarloscp52.entropy.Entropy;
import me.juancarloscp52.entropy.EntropyTags.ItemTags;
import me.juancarloscp52.entropy.events.AbstractInstantEvent;
import net.minecraft.util.math.MathHelper;

Expand All @@ -27,17 +28,17 @@ public class DamageItemsEvent extends AbstractInstantEvent {
public void init() {
Entropy.getInstance().eventHandler.getActivePlayers().forEach(serverPlayerEntity -> {
serverPlayerEntity.getInventory().main.forEach(itemStack -> {
if(itemStack.isDamageable()){
if(itemStack.isDamageable() && !itemStack.isIn(ItemTags.DO_NOT_DAMAGE)){
itemStack.damage(MathHelper.ceil((itemStack.getMaxDamage()-itemStack.getDamage())*serverPlayerEntity.getRandom().nextFloat()),serverPlayerEntity,serverPlayerEntity1 -> {});
}
});
serverPlayerEntity.getInventory().armor.forEach(itemStack -> {
if(itemStack.isDamageable()){
if(itemStack.isDamageable() && !itemStack.isIn(ItemTags.DO_NOT_DAMAGE)){
itemStack.damage(MathHelper.ceil((itemStack.getMaxDamage()-itemStack.getDamage())*serverPlayerEntity.getRandom().nextFloat()),serverPlayerEntity,serverPlayerEntity1 -> {});
}
});
serverPlayerEntity.getInventory().offHand.forEach(itemStack -> {
if(itemStack.isDamageable()){
if(itemStack.isDamageable() && !itemStack.isIn(ItemTags.DO_NOT_DAMAGE)){
itemStack.damage(MathHelper.ceil((itemStack.getMaxDamage()-itemStack.getDamage())*serverPlayerEntity.getRandom().nextFloat()),serverPlayerEntity,serverPlayerEntity1 -> {});
}
});
Expand Down

0 comments on commit c51bfd2

Please sign in to comment.