添加插板上限
This commit is contained in:
parent
8176ee2633
commit
6f37245c3e
4 changed files with 20 additions and 6 deletions
|
@ -90,6 +90,8 @@ public class ModItemTagProvider extends ItemTagsProvider {
|
||||||
this.tag(ModTags.Items.IS_AUTO_WEAPON).add(ModItems.AA_12.get(), ModItems.AK_47.get(), ModItems.HK_416.get(), ModItems.AA_12.get(), ModItems.M_4.get(),
|
this.tag(ModTags.Items.IS_AUTO_WEAPON).add(ModItems.AA_12.get(), ModItems.AK_47.get(), ModItems.HK_416.get(), ModItems.AA_12.get(), ModItems.M_4.get(),
|
||||||
ModItems.QBZ_95.get(), ModItems.MK_14.get(), ModItems.AA_12.get(), ModItems.GLOCK_18.get(), ModItems.VECTOR.get(), ModItems.AA_12.get(), ModItems.MINIGUN.get(),
|
ModItems.QBZ_95.get(), ModItems.MK_14.get(), ModItems.AA_12.get(), ModItems.GLOCK_18.get(), ModItems.VECTOR.get(), ModItems.AA_12.get(), ModItems.MINIGUN.get(),
|
||||||
ModItems.DEVOTION.get(), ModItems.M_60.get(), ModItems.RPK.get());
|
ModItems.DEVOTION.get(), ModItems.M_60.get(), ModItems.RPK.get());
|
||||||
|
|
||||||
|
this.tag(ModTags.Items.MILITARY_ARMOR).add(ModItems.RU_CHEST_6B43.get(), ModItems.US_CHEST_IOTV.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TagKey<Item> forgeTag(String name) {
|
private static TagKey<Item> forgeTag(String name) {
|
||||||
|
|
|
@ -419,7 +419,7 @@ public class ClientEventHandler {
|
||||||
|
|
||||||
private static void handleWeaponZoom() {
|
private static void handleWeaponZoom() {
|
||||||
float times = 5 * Minecraft.getInstance().getDeltaFrameTime();
|
float times = 5 * Minecraft.getInstance().getDeltaFrameTime();
|
||||||
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS) {
|
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS && !notInGame()) {
|
||||||
zoomTime = Mth.clamp(zoomTime + 0.03 * times, 0, 1);
|
zoomTime = Mth.clamp(zoomTime + 0.03 * times, 0, 1);
|
||||||
} else {
|
} else {
|
||||||
zoomTime = Mth.clamp(zoomTime - 0.04 * times, 0, 1);
|
zoomTime = Mth.clamp(zoomTime - 0.04 * times, 0, 1);
|
||||||
|
|
|
@ -31,6 +31,8 @@ public class ModTags {
|
||||||
public static final TagKey<Item> CANNOT_RELOAD = tag("cannot_reload");
|
public static final TagKey<Item> CANNOT_RELOAD = tag("cannot_reload");
|
||||||
public static final TagKey<Item> IS_AUTO_WEAPON = tag("is_auto_weapon");
|
public static final TagKey<Item> IS_AUTO_WEAPON = tag("is_auto_weapon");
|
||||||
|
|
||||||
|
public static final TagKey<Item> MILITARY_ARMOR = tag("military_armor");
|
||||||
|
|
||||||
private static TagKey<Item> tag(String name) {
|
private static TagKey<Item> tag(String name) {
|
||||||
return ItemTags.create(new ResourceLocation(ModUtils.MODID, name));
|
return ItemTags.create(new ResourceLocation(ModUtils.MODID, name));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package net.mcreator.superbwarfare.item;
|
package net.mcreator.superbwarfare.item;
|
||||||
|
|
||||||
|
|
||||||
|
import net.mcreator.superbwarfare.init.ModTags;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
@ -23,12 +25,17 @@ public class ArmorPlate extends Item {
|
||||||
@Override
|
@Override
|
||||||
public @NotNull InteractionResultHolder<ItemStack> use(Level worldIn, Player playerIn, InteractionHand handIn) {
|
public @NotNull InteractionResultHolder<ItemStack> use(Level worldIn, Player playerIn, InteractionHand handIn) {
|
||||||
ItemStack stack = playerIn.getItemInHand(handIn);
|
ItemStack stack = playerIn.getItemInHand(handIn);
|
||||||
|
|
||||||
ItemStack armor = playerIn.getItemBySlot(EquipmentSlot.CHEST);
|
ItemStack armor = playerIn.getItemBySlot(EquipmentSlot.CHEST);
|
||||||
|
|
||||||
if (armor.getItem() != ItemStack.EMPTY.getItem() && armor.getOrCreateTag().getDouble("armorPlate") < 50) {
|
if (armor.getItem() == ItemStack.EMPTY.getItem()) return InteractionResultHolder.fail(stack);
|
||||||
|
|
||||||
|
int armorLevel = 1;
|
||||||
|
if (armor.is(ModTags.Items.MILITARY_ARMOR)) {
|
||||||
|
armorLevel = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (armor.getOrCreateTag().getDouble("armorPlate") < armorLevel * 30) {
|
||||||
playerIn.startUsingItem(handIn);
|
playerIn.startUsingItem(handIn);
|
||||||
return InteractionResultHolder.consume(stack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return InteractionResultHolder.fail(stack);
|
return InteractionResultHolder.fail(stack);
|
||||||
|
@ -45,10 +52,13 @@ public class ArmorPlate extends Item {
|
||||||
|
|
||||||
ItemStack armor = pLivingEntity.getItemBySlot(EquipmentSlot.CHEST);
|
ItemStack armor = pLivingEntity.getItemBySlot(EquipmentSlot.CHEST);
|
||||||
|
|
||||||
if (armor.getItem() != ItemStack.EMPTY.getItem()) {
|
int armorLevel = 1;
|
||||||
armor.getOrCreateTag().putDouble("ArmorPlate", armor.getOrCreateTag().getDouble("ArmorPlate") + 50);
|
if (armor.is(ModTags.Items.MILITARY_ARMOR)) {
|
||||||
|
armorLevel = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
armor.getOrCreateTag().putDouble("ArmorPlate", Mth.clamp(armor.getOrCreateTag().getDouble("ArmorPlate") + 30, 0, armorLevel * 30));
|
||||||
|
|
||||||
if (pLivingEntity instanceof ServerPlayer serverPlayer) {
|
if (pLivingEntity instanceof ServerPlayer serverPlayer) {
|
||||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), SoundEvents.ARMOR_EQUIP_IRON, SoundSource.PLAYERS, 0.5f, 1);
|
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), SoundEvents.ARMOR_EQUIP_IRON, SoundSource.PLAYERS, 0.5f, 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue