重写弹药补给
This commit is contained in:
parent
bd716ecdeb
commit
afc495eda6
36 changed files with 161 additions and 536 deletions
|
@ -0,0 +1,54 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.mcreator.target.init.TargetModSounds;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public abstract class AmmoSupplierItem extends Item {
|
||||
|
||||
public final GunInfo.Type type;
|
||||
public final int ammoToAdd;
|
||||
|
||||
public AmmoSupplierItem(GunInfo.Type type, int ammoToAdd, Properties properties) {
|
||||
super(properties);
|
||||
this.type = type;
|
||||
this.ammoToAdd = ammoToAdd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
player.getCooldowns().addCooldown(this, 20);
|
||||
stack.shrink(1);
|
||||
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
var newAmmoCount = player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> switch (this.type) {
|
||||
case HANDGUN -> c.handgunAmmo;
|
||||
case RIFLE -> c.rifleAmmo;
|
||||
case SHOTGUN -> c.shotgunAmmo;
|
||||
case SNIPER -> c.sniperAmmo;
|
||||
}).orElse(0d) + ammoToAdd;
|
||||
switch (this.type) {
|
||||
case HANDGUN -> capability.handgunAmmo = newAmmoCount;
|
||||
case RIFLE -> capability.rifleAmmo = newAmmoCount;
|
||||
case SHOTGUN -> capability.shotgunAmmo = newAmmoCount;
|
||||
case SNIPER -> capability.sniperAmmo = newAmmoCount;
|
||||
}
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
|
||||
if (!level.isClientSide()) {
|
||||
player.displayClientMessage(Component.literal(this.type.name + " Ammo +" + ammoToAdd), false);
|
||||
level.playSound(null, player.blockPosition(), TargetModSounds.BULLETSUPPLY.get(), SoundSource.PLAYERS, 1, 1);
|
||||
}
|
||||
return InteractionResultHolder.consume(stack);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.mcreator.target.procedures.CreativeAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure;
|
||||
import net.mcreator.target.init.TargetModSounds;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -40,9 +42,23 @@ public class CreativeAmmoBox extends Item {
|
|||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player entity, InteractionHand hand) {
|
||||
InteractionResultHolder<ItemStack> ar = super.use(world, entity, hand);
|
||||
CreativeAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure.execute(entity, ar.getObject());
|
||||
return ar;
|
||||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
player.getCooldowns().addCooldown(this, 20);
|
||||
stack.shrink(1);
|
||||
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.handgunAmmo = 2147483647;
|
||||
capability.rifleAmmo = 2147483647;
|
||||
capability.shotgunAmmo = 2147483647;
|
||||
capability.sniperAmmo = 2147483647;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
|
||||
if (!level.isClientSide()) {
|
||||
player.displayClientMessage(Component.literal("All Ammo +2147483647"), false);
|
||||
level.playSound(null, player.blockPosition(), TargetModSounds.BULLETSUPPLY.get(), SoundSource.VOICE, 1, 1);
|
||||
}
|
||||
return InteractionResultHolder.consume(stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.mcreator.target.procedures.HandgunAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure;
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
|
@ -13,20 +10,13 @@ import net.minecraft.world.level.Level;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class HandgunAmmo extends Item {
|
||||
public class HandgunAmmo extends AmmoSupplierItem {
|
||||
public HandgunAmmo() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
super(GunInfo.Type.HANDGUN, 5, new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
super.appendHoverText(itemstack, world, list, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player entity, InteractionHand hand) {
|
||||
InteractionResultHolder<ItemStack> ar = super.use(world, entity, hand);
|
||||
HandgunAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure.execute(entity, ar.getObject());
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.mcreator.target.procedures.HandgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure;
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HandgunAmmoBox extends Item {
|
||||
public class HandgunAmmoBox extends AmmoSupplierItem {
|
||||
public HandgunAmmoBox() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
super(GunInfo.Type.HANDGUN, 30, new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,11 +27,4 @@ public class HandgunAmmoBox extends Item {
|
|||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
list.add(Component.translatable("des.target.handgun_ammo_box").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player entity, InteractionHand hand) {
|
||||
InteractionResultHolder<ItemStack> ar = super.use(world, entity, hand);
|
||||
HandgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure.execute(entity, ar.getObject());
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.mcreator.target.procedures.RifleAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure;
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
|
@ -13,20 +10,13 @@ import net.minecraft.world.level.Level;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class RifleAmmo extends Item {
|
||||
public class RifleAmmo extends AmmoSupplierItem {
|
||||
public RifleAmmo() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
super(GunInfo.Type.RIFLE, 5, new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
super.appendHoverText(itemstack, world, list, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player entity, InteractionHand hand) {
|
||||
InteractionResultHolder<ItemStack> ar = super.use(world, entity, hand);
|
||||
RifleAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure.execute(entity, ar.getObject());
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.mcreator.target.procedures.RifleAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure;
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RifleAmmoBox extends Item {
|
||||
public class RifleAmmoBox extends AmmoSupplierItem {
|
||||
public RifleAmmoBox() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
super(GunInfo.Type.RIFLE, 30, new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,11 +27,4 @@ public class RifleAmmoBox extends Item {
|
|||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
list.add(Component.translatable("des.target.rifle_ammo_box").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player entity, InteractionHand hand) {
|
||||
InteractionResultHolder<ItemStack> ar = super.use(world, entity, hand);
|
||||
RifleAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure.execute(entity, ar.getObject());
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.mcreator.target.procedures.ShotgunAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure;
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
|
@ -13,20 +10,13 @@ import net.minecraft.world.level.Level;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class ShotgunAmmo extends Item {
|
||||
public class ShotgunAmmo extends AmmoSupplierItem {
|
||||
public ShotgunAmmo() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
super(GunInfo.Type.SHOTGUN, 2, new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
super.appendHoverText(itemstack, world, list, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player entity, InteractionHand hand) {
|
||||
InteractionResultHolder<ItemStack> ar = super.use(world, entity, hand);
|
||||
ShotgunAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure.execute(entity, ar.getObject());
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.mcreator.target.procedures.ShotgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure;
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ShotgunAmmoBox extends Item {
|
||||
public class ShotgunAmmoBox extends AmmoSupplierItem {
|
||||
public ShotgunAmmoBox() {
|
||||
super(new Item.Properties().stacksTo(8).rarity(Rarity.COMMON));
|
||||
super(GunInfo.Type.SHOTGUN, 12, new Item.Properties().stacksTo(8).rarity(Rarity.COMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,11 +27,4 @@ public class ShotgunAmmoBox extends Item {
|
|||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
list.add(Component.translatable("des.target.shotgun_ammo_box").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player entity, InteractionHand hand) {
|
||||
InteractionResultHolder<ItemStack> ar = super.use(world, entity, hand);
|
||||
ShotgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure.execute(entity, ar.getObject());
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.mcreator.target.procedures.SniperAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure;
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
|
@ -13,20 +10,13 @@ import net.minecraft.world.level.Level;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class SniperAmmo extends Item {
|
||||
public class SniperAmmo extends AmmoSupplierItem {
|
||||
public SniperAmmo() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
super(GunInfo.Type.SNIPER, 2, new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
super.appendHoverText(itemstack, world, list, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player entity, InteractionHand hand) {
|
||||
InteractionResultHolder<ItemStack> ar = super.use(world, entity, hand);
|
||||
SniperAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure.execute(entity, ar.getObject());
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
package net.mcreator.target.item.common.ammo;
|
||||
|
||||
import net.mcreator.target.init.TargetModSounds;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SniperAmmoBox extends Item {
|
||||
public class SniperAmmoBox extends AmmoSupplierItem {
|
||||
public SniperAmmoBox() {
|
||||
super(new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
super(GunInfo.Type.SNIPER, 12, new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,24 +27,4 @@ public class SniperAmmoBox extends Item {
|
|||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
||||
list.add(Component.translatable("des.target.sniper_ammo_box").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
player.getCooldowns().addCooldown(this, 20);
|
||||
stack.shrink(1);
|
||||
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.sniperAmmo = (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo + 12;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
|
||||
if (!level.isClientSide()) {
|
||||
level.playSound(player, player.getOnPos(), TargetModSounds.BULLETSUPPLY.get(), SoundSource.VOICE, 1f, 1f);
|
||||
|
||||
player.displayClientMessage(Component.translatable("des.target.sniper_ammo_box.use"), false);
|
||||
}
|
||||
|
||||
return InteractionResultHolder.consume(stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.mcreator.target.init.TargetModSounds;
|
|||
import net.mcreator.target.init.TargetModTags;
|
||||
import net.mcreator.target.item.AnimatedItem;
|
||||
import net.mcreator.target.procedures.WeaponDrawLightProcedure;
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.mcreator.target.tools.GunsTool;
|
||||
import net.mcreator.target.tools.TooltipTool;
|
||||
|
@ -179,7 +180,7 @@ public class VectorItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
tag.putDouble("reloadtime", 0);
|
||||
}
|
||||
if (tag.getDouble("reloadtime") == 1 && mainHandItem.getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.HANDGUN);
|
||||
GunReload.reload(entity, GunInfo.Type.HANDGUN);
|
||||
}
|
||||
} else if (tag.getDouble("reloading") == 1 && tag.getDouble("ammo") > 0) {
|
||||
if (tag.getDouble("reloadtime") == 47) {
|
||||
|
@ -196,7 +197,7 @@ public class VectorItem extends GunItem implements GeoItem, AnimatedItem {
|
|||
tag.putDouble("reloadtime", 0);
|
||||
}
|
||||
if (tag.getDouble("reloadtime") == 1 && mainHandItem.getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.HANDGUN, true);
|
||||
GunReload.reload(entity, GunInfo.Type.HANDGUN, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -40,7 +41,7 @@ public class AK47WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
|
||||
|
@ -63,7 +64,7 @@ public class AK47WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE, true);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -37,7 +38,7 @@ public class Aa12WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SHOTGUN);
|
||||
GunReload.reload(entity, GunInfo.Type.SHOTGUN);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
|
||||
|
@ -60,7 +61,7 @@ public class Aa12WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SHOTGUN, true);
|
||||
GunReload.reload(entity, GunInfo.Type.SHOTGUN, true);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class CreativeAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
|
||||
public static void execute(Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (entity instanceof Player _player)
|
||||
_player.getCooldowns().addCooldown(itemstack.getItem(), 20);
|
||||
if (entity instanceof LivingEntity _entity)
|
||||
_entity.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (entity instanceof Player _player) {
|
||||
ItemStack _stktoremove = new ItemStack(TargetModItems.CREATIVE_AMMO_BOX.get());
|
||||
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
{
|
||||
double _setval = 2147483647;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.rifleAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
{
|
||||
double _setval = 2147483647;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.handgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
{
|
||||
double _setval = 2147483647;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
{
|
||||
double _setval = 2147483647;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.sniperAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Rifle Ammo +2147483647"), false);
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Handgun Ammo +2147483647"), false);
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Shotgun Ammo +2147483647"), false);
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Sniper Ammo +2147483647"), false);
|
||||
{
|
||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:bulletsupply voice @a ~ ~ ~ 1 1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -40,7 +41,7 @@ public class DevotionWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 51) {
|
||||
|
@ -64,7 +65,7 @@ public class DevotionWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE, true);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class HandgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
|
||||
public static void execute(Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (entity instanceof Player _player)
|
||||
_player.getCooldowns().addCooldown(itemstack.getItem(), 20);
|
||||
if (entity instanceof LivingEntity _entity)
|
||||
_entity.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (entity instanceof Player _player) {
|
||||
ItemStack _stktoremove = new ItemStack(TargetModItems.HANDGUN_AMMO_BOX.get());
|
||||
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
{
|
||||
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo + 30;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.handgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Handgun Ammo +30"), false);
|
||||
{
|
||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:bulletsupply voice @a ~ ~ ~ 1 1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class HandgunAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
|
||||
public static void execute(Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
{
|
||||
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo + 5;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.handgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Handgun Ammo +5"), false);
|
||||
{
|
||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:bulletsupply voice @a ~ ~ ~ 1 1");
|
||||
}
|
||||
}
|
||||
if (entity instanceof Player _player) {
|
||||
ItemStack _stktoremove = new ItemStack(TargetModItems.HANDGUN_AMMO.get());
|
||||
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
if (entity instanceof Player _player)
|
||||
_player.getCooldowns().addCooldown(itemstack.getItem(), 10);
|
||||
if (entity instanceof LivingEntity _entity)
|
||||
_entity.swing(InteractionHand.MAIN_HAND, true);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -40,7 +41,7 @@ public class Hk416WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
|
||||
|
@ -63,7 +64,7 @@ public class Hk416WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE, true);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -42,7 +43,7 @@ public class HrrelodingProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SNIPER);
|
||||
GunReload.reload(entity, GunInfo.Type.SNIPER);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -40,7 +41,7 @@ public class KraberWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SNIPER);
|
||||
GunReload.reload(entity, GunInfo.Type.SNIPER);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 65) {
|
||||
|
@ -63,7 +64,7 @@ public class KraberWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SNIPER, true);
|
||||
GunReload.reload(entity, GunInfo.Type.SNIPER, true);
|
||||
}
|
||||
}
|
||||
WeapondrawhaveyProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -40,7 +41,7 @@ public class M4WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
|
||||
|
@ -63,7 +64,7 @@ public class M4WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE, true);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -43,7 +44,7 @@ public class M60WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 111) {
|
||||
|
@ -66,7 +67,7 @@ public class M60WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
||||
}
|
||||
}
|
||||
WeapondrawhaveyProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -44,7 +45,7 @@ public class M98bWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SNIPER);
|
||||
GunReload.reload(entity, GunInfo.Type.SNIPER);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 57) {
|
||||
|
@ -67,7 +68,7 @@ public class M98bWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SNIPER, true);
|
||||
GunReload.reload(entity, GunInfo.Type.SNIPER, true);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -43,7 +44,7 @@ public class Mk14WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("gj", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 45) {
|
||||
|
@ -66,7 +67,7 @@ public class Mk14WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE, true);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -42,7 +43,7 @@ public class ReloadingProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.HANDGUN);
|
||||
GunReload.reload(entity, GunInfo.Type.HANDGUN);
|
||||
}
|
||||
}
|
||||
WeaponDrawLightProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class RifleAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
|
||||
public static void execute(Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (entity instanceof Player _player)
|
||||
_player.getCooldowns().addCooldown(itemstack.getItem(), 20);
|
||||
if (entity instanceof LivingEntity _entity)
|
||||
_entity.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (entity instanceof Player _player) {
|
||||
ItemStack _stktoremove = new ItemStack(TargetModItems.RIFLE_AMMO_BOX.get());
|
||||
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
{
|
||||
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo + 30;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.rifleAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Rifle Ammo +30"), false);
|
||||
{
|
||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:bulletsupply voice @a ~ ~ ~ 1 1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class RifleAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
|
||||
public static void execute(Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
{
|
||||
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo + 5;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.rifleAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Rifle Ammo +5"), false);
|
||||
{
|
||||
Entity _ent = entity;
|
||||
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
|
||||
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
|
||||
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:bulletsupply voice @a ~ ~ ~ 1 1");
|
||||
}
|
||||
}
|
||||
if (entity instanceof Player _player) {
|
||||
ItemStack _stktoremove = new ItemStack(TargetModItems.RIFLE_AMMO.get());
|
||||
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
if (entity instanceof Player _player)
|
||||
_player.getCooldowns().addCooldown(itemstack.getItem(), 10);
|
||||
if (entity instanceof LivingEntity _entity)
|
||||
_entity.swing(InteractionHand.MAIN_HAND, true);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -36,7 +37,7 @@ public class RpkWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
|
||||
|
@ -57,7 +58,7 @@ public class RpkWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE, true);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -42,7 +43,7 @@ public class SentinelWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SNIPER);
|
||||
GunReload.reload(entity, GunInfo.Type.SNIPER);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 53) {
|
||||
|
@ -66,7 +67,7 @@ public class SentinelWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SNIPER, true);
|
||||
GunReload.reload(entity, GunInfo.Type.SNIPER, true);
|
||||
}
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("firing") > 0) {
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class ShotgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure {
|
||||
public static void execute(Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (entity instanceof Player _player)
|
||||
_player.getCooldowns().addCooldown(itemstack.getItem(), 20);
|
||||
if (entity instanceof LivingEntity _entity)
|
||||
_entity.swing(InteractionHand.MAIN_HAND, true);
|
||||
if (entity instanceof Player _player) {
|
||||
ItemStack _stktoremove = new ItemStack(TargetModItems.SHOTGUN_AMMO_BOX.get());
|
||||
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
{
|
||||
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo + 12;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Shotgun Ammo +12"), false);
|
||||
{
|
||||
Entity _ent = entity;
|
||||
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
|
||||
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
|
||||
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:bulletsupply voice @a ~ ~ ~ 1 1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class ShotgunAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
|
||||
public static void execute(Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
{
|
||||
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo + 2;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.shotgunAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Shotgun Ammo +2"), false);
|
||||
{
|
||||
Entity _ent = entity;
|
||||
if (!_ent.level().isClientSide() && _ent.getServer() != null) {
|
||||
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
|
||||
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:bulletsupply voice @a ~ ~ ~ 1 1");
|
||||
}
|
||||
}
|
||||
if (entity instanceof Player _player) {
|
||||
ItemStack _stktoremove = new ItemStack(TargetModItems.SHOTGUN_AMMO.get());
|
||||
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
if (entity instanceof Player _player)
|
||||
_player.getCooldowns().addCooldown(itemstack.getItem(), 10);
|
||||
if (entity instanceof LivingEntity _entity)
|
||||
_entity.swing(InteractionHand.MAIN_HAND, true);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -44,7 +45,7 @@ public class SksWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("gj", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
|
||||
|
@ -68,7 +69,7 @@ public class SksWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
|
||||
GunReload.reload(entity, GunInfo.Type.RIFLE, true);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class SniperAmmoYouJiKongQiShiShiTiDeWeiZhiProcedure {
|
||||
public static void execute(Entity entity, ItemStack itemstack) {
|
||||
if (entity == null)
|
||||
return;
|
||||
{
|
||||
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo + 2;
|
||||
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.sniperAmmo = _setval;
|
||||
capability.syncPlayerVariables(entity);
|
||||
});
|
||||
}
|
||||
if (entity instanceof Player _player && !_player.level().isClientSide())
|
||||
_player.displayClientMessage(Component.literal("Sniper Ammo +2"), false);
|
||||
{
|
||||
if (!entity.level().isClientSide() && entity.getServer() != null) {
|
||||
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
|
||||
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:bulletsupply voice @a ~ ~ ~ 1 1");
|
||||
}
|
||||
}
|
||||
if (entity instanceof Player _player) {
|
||||
ItemStack _stktoremove = new ItemStack(TargetModItems.SNIPER_AMMO.get());
|
||||
_player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots());
|
||||
}
|
||||
if (entity instanceof Player _player)
|
||||
_player.getCooldowns().addCooldown(itemstack.getItem(), 10);
|
||||
if (entity instanceof LivingEntity _entity)
|
||||
_entity.swing(InteractionHand.MAIN_HAND, true);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.tools.GunInfo;
|
||||
import net.mcreator.target.tools.GunReload;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
@ -44,7 +45,7 @@ public class SvdWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("gj", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SNIPER);
|
||||
GunReload.reload(entity, GunInfo.Type.SNIPER);
|
||||
}
|
||||
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
|
||||
|
@ -68,7 +69,7 @@ public class SvdWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
|
|||
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
|
||||
}
|
||||
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
|
||||
GunReload.reload(entity, GunReload.GunType.SNIPER, true);
|
||||
GunReload.reload(entity, GunInfo.Type.SNIPER, true);
|
||||
}
|
||||
}
|
||||
WeaponDrawProcedure.execute(entity, itemstack);
|
||||
|
|
12
src/main/java/net/mcreator/target/tools/GunInfo.java
Normal file
12
src/main/java/net/mcreator/target/tools/GunInfo.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package net.mcreator.target.tools;
|
||||
|
||||
public class GunInfo {
|
||||
public enum Type {
|
||||
HANDGUN("Handgun"), RIFLE("Rifle"), SHOTGUN("Shotgun"), SNIPER("Sniper");
|
||||
public final String name;
|
||||
|
||||
Type(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,11 +6,11 @@ import net.minecraft.world.entity.Entity;
|
|||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
||||
public class GunReload {
|
||||
public static void reload(Entity entity, GunType gunType) {
|
||||
reload(entity, gunType, false);
|
||||
public static void reload(Entity entity, GunInfo.Type type) {
|
||||
reload(entity, type, false);
|
||||
}
|
||||
|
||||
public static void reload(Entity entity, GunType gunType, boolean extraOne) {
|
||||
public static void reload(Entity entity, GunInfo.Type type, boolean extraOne) {
|
||||
if (!(entity instanceof LivingEntity living)) return;
|
||||
|
||||
CompoundTag tag = living.getMainHandItem().getOrCreateTag();
|
||||
|
@ -19,7 +19,7 @@ public class GunReload {
|
|||
double ammo = tag.getDouble("ammo");
|
||||
double ammoToAdd = mag - ammo + (extraOne ? 1 : 0);
|
||||
|
||||
double playerAmmo = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> switch (gunType) {
|
||||
double playerAmmo = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> switch (type) {
|
||||
case RIFLE -> c.rifleAmmo;
|
||||
case HANDGUN -> c.handgunAmmo;
|
||||
case SHOTGUN -> c.shotgunAmmo;
|
||||
|
@ -35,8 +35,4 @@ public class GunReload {
|
|||
tag.putDouble("reloading", 0);
|
||||
tag.putDouble("emptyreload", 0);
|
||||
}
|
||||
|
||||
public enum GunType {
|
||||
HANDGUN, RIFLE, SHOTGUN, SNIPER
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue