添加防弹插板机制
This commit is contained in:
parent
08511d28ce
commit
8176ee2633
12 changed files with 129 additions and 2 deletions
|
@ -1,8 +1,9 @@
|
||||||
// 1.20.1 2024-09-30T20:14:30.9400448 Item Models: superbwarfare
|
// 1.20.1 2024-10-01T13:07:54.2773833 Item Models: superbwarfare
|
||||||
13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/aa_12_blueprint.json
|
13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/aa_12_blueprint.json
|
||||||
13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/ak_47_blueprint.json
|
13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/ak_47_blueprint.json
|
||||||
c993bddc0db9453ffbefa59f9ac9a74dba909038 assets/superbwarfare/models/item/ancient_cpu.json
|
c993bddc0db9453ffbefa59f9ac9a74dba909038 assets/superbwarfare/models/item/ancient_cpu.json
|
||||||
4b8fe8fbe5e64c3449ad539317254e4ed7188411 assets/superbwarfare/models/item/ap_head.json
|
4b8fe8fbe5e64c3449ad539317254e4ed7188411 assets/superbwarfare/models/item/ap_head.json
|
||||||
|
9a20bdee844ad4f2556250e0eca7a2575cafd712 assets/superbwarfare/models/item/armor_plate.json
|
||||||
984c08ca6f6893a15721a85e30118f9e32c65c7f assets/superbwarfare/models/item/barbed_wire.json
|
984c08ca6f6893a15721a85e30118f9e32c65c7f assets/superbwarfare/models/item/barbed_wire.json
|
||||||
13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/bocek_blueprint.json
|
13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/bocek_blueprint.json
|
||||||
1e5b4637c3787516305dd3d1598f401a5e78a954 assets/superbwarfare/models/item/cemented_carbide_action.json
|
1e5b4637c3787516305dd3d1598f401a5e78a954 assets/superbwarfare/models/item/cemented_carbide_action.json
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "minecraft:item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "superbwarfare:item/armor_plate"
|
||||||
|
}
|
||||||
|
}
|
|
@ -85,6 +85,8 @@ public class ModItemModelProvider extends ItemModelProvider {
|
||||||
simpleItem(ModItems.EPIC_MATERIAL_PACK);
|
simpleItem(ModItems.EPIC_MATERIAL_PACK);
|
||||||
simpleItem(ModItems.LEGENDARY_MATERIAL_PACK);
|
simpleItem(ModItems.LEGENDARY_MATERIAL_PACK);
|
||||||
|
|
||||||
|
simpleItem(ModItems.ARMOR_PLATE);
|
||||||
|
|
||||||
// armor
|
// armor
|
||||||
|
|
||||||
simpleItem(ModItems.RU_HELMET_6B47);
|
simpleItem(ModItems.RU_HELMET_6B47);
|
||||||
|
|
|
@ -103,7 +103,16 @@ public class LivingEventHandler {
|
||||||
damage *= 1 - 0.2 * Mth.clamp(entity.getAttributeValue(ModAttributes.BULLET_RESISTANCE.get()), 0, 1);
|
damage *= 1 - 0.2 * Mth.clamp(entity.getAttributeValue(ModAttributes.BULLET_RESISTANCE.get()), 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setAmount((float) damage);
|
ItemStack armor = entity.getItemBySlot(EquipmentSlot.CHEST);
|
||||||
|
|
||||||
|
double armorValue = 0;
|
||||||
|
|
||||||
|
if (armor.getItem() != ItemStack.EMPTY.getItem()) {
|
||||||
|
armorValue = armor.getOrCreateTag().getDouble("ArmorPlate");
|
||||||
|
armor.getOrCreateTag().putDouble("ArmorPlate", Math.max(armor.getOrCreateTag().getDouble("ArmorPlate") - damage, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setAmount((float)(Math.max(damage - armorValue, 0)));
|
||||||
|
|
||||||
if (entity instanceof TargetEntity && sourceEntity instanceof Player player) {
|
if (entity instanceof TargetEntity && sourceEntity instanceof Player player) {
|
||||||
player.displayClientMessage(Component.literal("Damage:" + new DecimalFormat("##.#").format(damage) +
|
player.displayClientMessage(Component.literal("Damage:" + new DecimalFormat("##.#").format(damage) +
|
||||||
|
|
|
@ -125,6 +125,7 @@ public class ModItems {
|
||||||
public static final RegistryObject<Item> KNIFE = ITEMS.register("knife", Knife::new);
|
public static final RegistryObject<Item> KNIFE = ITEMS.register("knife", Knife::new);
|
||||||
public static final RegistryObject<Item> HAMMER = ITEMS.register("hammer", Hammer::new);
|
public static final RegistryObject<Item> HAMMER = ITEMS.register("hammer", Hammer::new);
|
||||||
public static final RegistryObject<Item> CROWBAR = ITEMS.register("crowbar", Crowbar::new);
|
public static final RegistryObject<Item> CROWBAR = ITEMS.register("crowbar", Crowbar::new);
|
||||||
|
public static final RegistryObject<Item> ARMOR_PLATE = ITEMS.register("armor_plate", ArmorPlate::new);
|
||||||
public static final RegistryObject<Item> RU_HELMET_6B47 = ITEMS.register("ru_helmet_6b47", RuHelmet6b47::new);
|
public static final RegistryObject<Item> RU_HELMET_6B47 = ITEMS.register("ru_helmet_6b47", RuHelmet6b47::new);
|
||||||
public static final RegistryObject<Item> RU_CHEST_6B43 = ITEMS.register("ru_chest_6b43", RuChest6b43::new);
|
public static final RegistryObject<Item> RU_CHEST_6B43 = ITEMS.register("ru_chest_6b43", RuChest6b43::new);
|
||||||
public static final RegistryObject<Item> US_HELMET_PASTG = ITEMS.register("us_helmet_pastg", UsHelmetPastg::new);
|
public static final RegistryObject<Item> US_HELMET_PASTG = ITEMS.register("us_helmet_pastg", UsHelmetPastg::new);
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
package net.mcreator.superbwarfare.item;
|
||||||
|
|
||||||
|
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.UseAnim;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class ArmorPlate extends Item {
|
||||||
|
public ArmorPlate() {
|
||||||
|
super(new Item.Properties());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull InteractionResultHolder<ItemStack> use(Level worldIn, Player playerIn, InteractionHand handIn) {
|
||||||
|
ItemStack stack = playerIn.getItemInHand(handIn);
|
||||||
|
|
||||||
|
ItemStack armor = playerIn.getItemBySlot(EquipmentSlot.CHEST);
|
||||||
|
|
||||||
|
if (armor.getItem() != ItemStack.EMPTY.getItem() && armor.getOrCreateTag().getDouble("armorPlate") < 50) {
|
||||||
|
playerIn.startUsingItem(handIn);
|
||||||
|
return InteractionResultHolder.consume(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
return InteractionResultHolder.fail(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull UseAnim getUseAnimation(@NotNull ItemStack stack) {
|
||||||
|
return UseAnim.BOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack finishUsingItem(ItemStack pStack, Level pLevel, LivingEntity pLivingEntity) {
|
||||||
|
if (!pLevel.isClientSide) {
|
||||||
|
|
||||||
|
ItemStack armor = pLivingEntity.getItemBySlot(EquipmentSlot.CHEST);
|
||||||
|
|
||||||
|
if (armor.getItem() != ItemStack.EMPTY.getItem()) {
|
||||||
|
armor.getOrCreateTag().putDouble("ArmorPlate", armor.getOrCreateTag().getDouble("ArmorPlate") + 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pLivingEntity instanceof ServerPlayer serverPlayer) {
|
||||||
|
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), SoundEvents.ARMOR_EQUIP_IRON, SoundSource.PLAYERS, 0.5f, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pLivingEntity instanceof Player player && !player.isCreative()) {
|
||||||
|
pStack.shrink(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.finishUsingItem(pStack, pLevel, pLivingEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getUseDuration(ItemStack stack) {
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -79,6 +79,10 @@ public class HandGrenade extends Item {
|
||||||
if (pLivingEntity instanceof Player player) {
|
if (pLivingEntity instanceof Player player) {
|
||||||
player.getCooldowns().addCooldown(pStack.getItem(), 25);
|
player.getCooldowns().addCooldown(pStack.getItem(), 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pLivingEntity instanceof Player player && !player.isCreative()) {
|
||||||
|
pStack.shrink(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.finishUsingItem(pStack, pLevel, pLivingEntity);
|
return super.finishUsingItem(pStack, pLevel, pLivingEntity);
|
||||||
|
|
|
@ -79,6 +79,10 @@ public class RgoGrenade extends Item {
|
||||||
if (pLivingEntity instanceof Player player) {
|
if (pLivingEntity instanceof Player player) {
|
||||||
player.getCooldowns().addCooldown(pStack.getItem(), 20);
|
player.getCooldowns().addCooldown(pStack.getItem(), 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pLivingEntity instanceof Player player && !player.isCreative()) {
|
||||||
|
pStack.shrink(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.finishUsingItem(pStack, pLevel, pLivingEntity);
|
return super.finishUsingItem(pStack, pLevel, pLivingEntity);
|
||||||
|
|
|
@ -202,6 +202,8 @@
|
||||||
"item.superbwarfare.scheelite": "Raw Galena",
|
"item.superbwarfare.scheelite": "Raw Galena",
|
||||||
"item.superbwarfare.raw_silver": "Raw Silver",
|
"item.superbwarfare.raw_silver": "Raw Silver",
|
||||||
|
|
||||||
|
"item.superbwarfare.armor_plate": "Armor Plate",
|
||||||
|
|
||||||
"item.superbwarfare.ru_helmet_6b47": "Russia 6b47 Helmet",
|
"item.superbwarfare.ru_helmet_6b47": "Russia 6b47 Helmet",
|
||||||
"item.superbwarfare.ru_chest_6b43": "Russia 6b43 Chest",
|
"item.superbwarfare.ru_chest_6b43": "Russia 6b43 Chest",
|
||||||
"item.superbwarfare.us_helmet_pastg": "US PASTG Helmet",
|
"item.superbwarfare.us_helmet_pastg": "US PASTG Helmet",
|
||||||
|
|
|
@ -202,6 +202,8 @@
|
||||||
"item.superbwarfare.scheelite": "白钨矿",
|
"item.superbwarfare.scheelite": "白钨矿",
|
||||||
"item.superbwarfare.raw_silver": "粗银",
|
"item.superbwarfare.raw_silver": "粗银",
|
||||||
|
|
||||||
|
"item.superbwarfare.armor_plate": "防弹插板",
|
||||||
|
|
||||||
"item.superbwarfare.ru_helmet_6b47": "俄罗斯6B47头盔",
|
"item.superbwarfare.ru_helmet_6b47": "俄罗斯6B47头盔",
|
||||||
"item.superbwarfare.ru_chest_6b43": "俄罗斯6B43防弹胸甲",
|
"item.superbwarfare.ru_chest_6b43": "俄罗斯6B43防弹胸甲",
|
||||||
"item.superbwarfare.us_helmet_pastg": "美制PASTG头盔",
|
"item.superbwarfare.us_helmet_pastg": "美制PASTG头盔",
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 334 B |
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"category": "misc",
|
||||||
|
"pattern": [
|
||||||
|
"aba",
|
||||||
|
"ccc",
|
||||||
|
"ada"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"a": {
|
||||||
|
"item": "minecraft:string"
|
||||||
|
},
|
||||||
|
"b": {
|
||||||
|
"tag": "minecraft:terracotta"
|
||||||
|
},
|
||||||
|
"c": {
|
||||||
|
"tag":"forge:ingots/steel"
|
||||||
|
},
|
||||||
|
"d": {
|
||||||
|
"tag": "minecraft:wool"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "superbwarfare:armor_plate",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue