优化自动插板
This commit is contained in:
parent
632ba1ea46
commit
b1acd37a59
1 changed files with 11 additions and 2 deletions
|
@ -14,6 +14,7 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
|
@ -358,6 +359,13 @@ public class PlayerEventHandler {
|
||||||
if (armorPlate < armorLevel * 30) {
|
if (armorPlate < armorLevel * 30) {
|
||||||
for (var stack : player.getInventory().items) {
|
for (var stack : player.getInventory().items) {
|
||||||
if (stack.is(ModItems.ARMOR_PLATE.get())) {
|
if (stack.is(ModItems.ARMOR_PLATE.get())) {
|
||||||
|
if (stack.getTag() != null && stack.getTag().getBoolean("Infinite")) {
|
||||||
|
armor.getOrCreateTag().putDouble("ArmorPlate", armorLevel * 30);
|
||||||
|
|
||||||
|
if (player instanceof ServerPlayer serverPlayer) {
|
||||||
|
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), SoundEvents.ARMOR_EQUIP_IRON, SoundSource.PLAYERS, 0.5f, 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (int index0 = 0; index0 < Math.ceil(((armorLevel * 30) - armorPlate) / 30); index0++) {
|
for (int index0 = 0; index0 < Math.ceil(((armorLevel * 30) - armorPlate) / 30); index0++) {
|
||||||
stack.finishUsingItem(player.level(), player);
|
stack.finishUsingItem(player.level(), player);
|
||||||
}
|
}
|
||||||
|
@ -365,6 +373,7 @@ public class PlayerEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
Loading…
Add table
Reference in a new issue