File Details
projectiles-strengthen-1.0.0_a.jar
- B
- Apr 13, 2025
- 47.14 KB
- 6
- 1.21.1
- Fabric
File Name
projectiles-strengthen-1.0.0_a.jar
Supported Versions
- 1.21.1
Curse Maven Snippet
reporter:To avoid potential discrepancies with the intended meaning, no English changelog is provided here. Please translate it yourself.
MOD名称Projectiles Strengthen
MOD_ID:projectiles-strengthen
开发者:J_pc(中国大陆,PRC)
MOD内容:
新增物品:
projectiles-strengthen:nylon_rope
projectiles-strengthen:compound_bow
projectiles-strengthen:long_range_crossbow
projectiles-strengthen:triple_shot_bow
新增方块:NONE
新增生物实体:NONE
新增弹射物实体:NONE
新增命令:NONE
新增结构:NONE
新增地物:NONE
新增维度:NONE
新增生物群系:NONE
projectiles-strengthen:nylon_rope
最大堆叠数量:64
获取方式:合成
用途:NONE
相关代码:
{
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"X": {
"item": "minecraft:string"
}
},
"pattern": [
" XX",
" XX",
" XX"
],
"result": {
"count": 1,
"id": "projectiles-strengthen:nylon_rope"
}
}
projectiles-strengthen:compound_bow
耐久:768
获取方式:合成
用途:发射箭矢
相关代码:
{
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"*": {
"item": "minecraft:string"
},
"#": {
"item": "minecraft:stick"
},
"X": {
"item": "projectiles-strengthen:nylon_rope"
}
},
"pattern": [
"*#X",
"# X",
"*#X"
],
"result": {
"count": 1,
"id": "projectiles-strengthen:compound_bow"
}
}
--
package com.example.items.custom;
import java.util.List;
import java.util.function.Predicate;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.RangedWeaponItem;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.Stats;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
public class Compound_Bow extends RangedWeaponItem {
public static final int TICKS_PER_SECOND = 20;
public static final int RANGE = 15;
public Compound_Bow(Settings settings) {
super(settings);
}
@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
if (user instanceof PlayerEntity playerEntity) {
ItemStack itemStack = playerEntity.getProjectileType(stack);
if (!itemStack.isEmpty()) {
int i = this.getMaxUseTime(stack, user) - remainingUseTicks;
float f = getPullProgress(i);
if (!((double)f < 0.1)) {
List<ItemStack> list = load(stack, itemStack, playerEntity);
if (world instanceof ServerWorld serverWorld && !list.isEmpty()) {
this.shootAll(serverWorld, playerEntity, playerEntity.getActiveHand(), stack, list, f * 6.0F, 0.1F, f == 1.0F, null);
}
world.playSound(
null,
playerEntity.getX(),
playerEntity.getY(),
playerEntity.getZ(),
SoundEvents.ENTITY_ARROW_SHOOT,
SoundCategory.PLAYERS,
1.0F,
1.0F / (world.getRandom().nextFloat() * 0.4F + 1.2F) + f * 0.5F
);
playerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
}
}
}
}
@Override
protected void shoot(LivingEntity shooter, ProjectileEntity projectile, int index, float speed, float divergence, float yaw, @Nullable LivingEntity target) {
projectile.setVelocity(shooter, shooter.getPitch(), shooter.getYaw() + yaw, 0.0F, speed, divergence);
}
public static float getPullProgress(int useTicks) {
float f = (float)useTicks / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if (f > 1.0F) {
f = 1.0F;
}
return f;
}
@Override
public int getMaxUseTime(ItemStack stack, LivingEntity user) {
return 72000;
}
@Override
public UseAction getUseAction(ItemStack stack) {
return UseAction.BOW;
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
ItemStack itemStack = user.getStackInHand(hand);
boolean bl = !user.getProjectileType(itemStack).isEmpty();
if (!user.isInCreativeMode() && !bl) {
return TypedActionResult.fail(itemStack);
} else {
user.setCurrentHand(hand);
return TypedActionResult.consume(itemStack);
}
}
@Override
public Predicate<ItemStack> getProjectiles() {
return BOW_PROJECTILES;
}
@Override
public int getRange() {
return 15;
}
}
projectiles-strengthen:long_range_crossbow
耐久:465
获取方式:合成
用途:发射箭矢
相关代码:
{
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"#": {
"item": "minecraft:stick"
},
"$": {
"item": "minecraft:tripwire_hook"
},
"&": {
"item": "minecraft:iron_ingot"
},
"~": {
"item": "projectiles-strengthen:nylon_rope"
},
"*": {
"item": "minecraft:iron_nugget"
}
},
"pattern": [
"#&#",
"~$~",
"*#*"
],
"result": {
"count": 1,
"id": "projectiles-strengthen:long_range_crossbow"
}
}
--
package com.example.items.custom;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.ChargedProjectilesComponent;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.CrossbowItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import java.util.function.Predicate;
public class Long_range_crossbow extends CrossbowItem {
public Long_range_crossbow(Settings settings) {
super(settings);
}
private boolean charged = false;
private boolean loaded = false;
private static final float DEFAULT_PULL_TIME = 1.5F;
public static final int RANGE = 8;
private static final float CHARGE_PROGRESS = 0.2F;
private static final float LOAD_PROGRESS = 0.5F;
private static final float DEFAULT_SPEED = 16F;
private static final float FIREWORK_ROCKET_SPEED = 3.2F;
public static final float field_49258 = 1.6F;
@Override
public Predicate<ItemStack> getHeldProjectiles() {
return CROSSBOW_HELD_PROJECTILES;
}
@Override
public Predicate<ItemStack> getProjectiles() {
return BOW_PROJECTILES;
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand){
ItemStack itemStack = user.getStackInHand(hand);
ChargedProjectilesComponent chargedProjectilesComponent = itemStack.get(DataComponentTypes.CHARGED_PROJECTILES);
if (chargedProjectilesComponent != null && !chargedProjectilesComponent.isEmpty()) {
this.shootAll(world, user, hand, itemStack, getSpeed(chargedProjectilesComponent), 0.35F, null);
return TypedActionResult.consume(itemStack);
} else if (!user.getProjectileType(itemStack).isEmpty()) {
this.charged = false;
this.loaded = false;
user.setCurrentHand(hand);
return TypedActionResult.consume(itemStack);
} else {
return TypedActionResult.fail(itemStack);
}
}
private static float getSpeed(ChargedProjectilesComponent stack) {
return stack.contains(Items.FIREWORK_ROCKET) ? 6.4F : 16F;
}
}
projectiles-strengthen:triple_shot_bow
耐久:1152
获取方式:合成
用途:发射箭矢
相关代码:
{
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"*": {
"item": "minecraft:iron_ingot"
},
"#": {
"item": "minecraft:stick"
},
"X": {
"item": "minecraft:string"
}
},
"pattern": [
" #X",
"* X",
" #X"
],
"result": {
"count": 1,
"id": "projectiles-strengthen:compound_bow"
}
}
--
package com.example.items.custom;
import java.util.List;
import java.util.function.Predicate;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.RangedWeaponItem;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.Stats;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
public class Triple_Shot_Bow extends RangedWeaponItem {
public static final int TICKS_PER_SECOND = 20;
public static final int RANGE = 15;
public Triple_Shot_Bow(Item.Settings settings) {
super(settings);
}
@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
if (user instanceof PlayerEntity playerEntity) {
ItemStack itemStack = playerEntity.getProjectileType(stack);
for (int j = 0; j < 3; j++) {
if (!itemStack.isEmpty()) {
int i = this.getMaxUseTime(stack, user) - remainingUseTicks;
float f = getPullProgress(i);
if (!((double)f < 0.1)) {
List<ItemStack> list = load(stack, itemStack, playerEntity);
if (world instanceof ServerWorld serverWorld && !list.isEmpty()) {
this.shootAll(serverWorld, playerEntity, playerEntity.getActiveHand(), stack, list, f * 3.0F, 3.5F, f == 1.0F, null);
}
world.playSound(
null,
playerEntity.getX(),
playerEntity.getY(),
playerEntity.getZ(),
SoundEvents.ENTITY_ARROW_SHOOT,
SoundCategory.PLAYERS,
1.0F,
1.0F / (world.getRandom().nextFloat() * 0.4F + 1.2F) + f * 0.5F
);
playerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
}
} else {
break;
}
}
}
}
@Override
protected void shoot(LivingEntity shooter, ProjectileEntity projectile, int index, float speed, float divergence, float yaw, @Nullable LivingEntity target) {
projectile.setVelocity(shooter, shooter.getPitch(), shooter.getYaw() + yaw, 0.0F, speed, divergence);
}
public static float getPullProgress(int useTicks) {
float f = (float)useTicks / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if (f > 1.0F) {
f = 1.0F;
}
return f;
}
@Override
public int getMaxUseTime(ItemStack stack, LivingEntity user) {
return 72000;
}
@Override
public UseAction getUseAction(ItemStack stack) {
return UseAction.BOW;
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
ItemStack itemStack = user.getStackInHand(hand);
boolean bl = !user.getProjectileType(itemStack).isEmpty();
if (!user.isInCreativeMode() && !bl) {
return TypedActionResult.fail(itemStack);
} else {
user.setCurrentHand(hand);
return TypedActionResult.consume(itemStack);
}
}
@Override
public Predicate<ItemStack> getProjectiles() {
return BOW_PROJECTILES;
}
@Override
public int getRange() {
return 15;
}
}
--
package com.example.items;
import com.example.ProjectilesStrengthen;
import com.example.items.custom.Compound_Bow;
import com.example.items.custom.Long_range_crossbow;
import com.example.items.custom.Triple_Shot_Bow;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.ChargedProjectilesComponent;
import net.minecraft.item.CrossbowItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
public class ModItems {
public static final Item NYLON_ROPE = registerItems("nylon_rope", new Item(new Item.Settings()));
public static final Item COMPOUND_BOW = registerItems("compound_bow", new Compound_Bow(new Item.Settings().maxDamage(768)));
public static final Item LONG_RANGE_CROSSBOW = registerItems("long_range_crossbow", new Long_range_crossbow(new CrossbowItem.Settings().maxDamage(465).component(DataComponentTypes.CHARGED_PROJECTILES, ChargedProjectilesComponent.DEFAULT)));
public static final Item TRIPLE_SHOT_BOW = registerItems("triple_shot_bow", new Triple_Shot_Bow(new Item.Settings().maxDamage(1152)));
public static void addItemsToItemGroup_COMBAT(FabricItemGroupEntries fabricItemGroupEntries) {
fabricItemGroupEntries.add(LONG_RANGE_CROSSBOW);
fabricItemGroupEntries.add(COMPOUND_BOW);
fabricItemGroupEntries.add(TRIPLE_SHOT_BOW);
}public static void addItemsToItemGroup_INGREDIENTS(FabricItemGroupEntries fabricItemGroupEntries) {
fabricItemGroupEntries.add(NYLON_ROPE);
}
public static Item registerItems(String id, Item item) {
return Registry.register(Registries.ITEM, Identifier.of(ProjectilesStrengthen.MOD_ID, id), item);
}
public static void registerModItems() {
ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register(ModItems::addItemsToItemGroup_COMBAT);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(ModItems::addItemsToItemGroup_INGREDIENTS);
}
}
经测试,此版本目前未发现异常
报告人:J_pc(中国大陆,PRC)
报告时间:2025/3/2/20:48(东八区)
MOD创建时期:2025/2/12/19:50(东八区)
MOD版本:1.0.0_a
MOD编写时的联网状态:个人网
MOD适用的Minecraft版本:《Minecraft JAVA 1.21.1-Fabric 0.16.10-Fabric API 0.115.1 Edition》
MOD适用的模组加载器版本:Fabric 0.16.10+ &Fabric API 0.97.8+
MOD当前版本完成时期:2025/2/2/13:07(东八区)
MOD当前版本测试完成时期:2025/2/2/13:07(东八区)
MOD编写时使用的操作系统:Windows10.0.19042.746
MOD编写时使用的中央处理器:Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz 2.40 GHz
MOD编写时使用的显卡:集成显卡
MOD编写时使用的JAVA解释器:JDK 21.0.5
MOD编写时使用的JAVA虚拟机:
MOD编写时使用的映射:yarn映射
MOD测试时使用的启动器:Fabric Launcher
MOD测试时的联网状态:个人网
MOD测试时的登录方式:离线登录
MOD测试时使用的JAVA解释器:JDK 21.0.5
MOD测试时使用的Minecraft源:镜像源
MOD测试时的版本隔离:隔离所有版本
MOD测试时的JAVA虚拟机参数头:-XX:+UseG1GC -XX:-UseAdaptiveSizePolicy -XX:-OmitStackTraceInFastThrow -Dfml.ignoreInvalidMinecraftCertificates=True -Dfml.ignorePatchDiscrepancies=True -Dlog4j2.formatMsgNoLookups=true
JAVA虚拟机参数尾:
MOD测试时使用的Minecraft版本:《Minecraft JAVA 1.21.1-Fabric 0.16.10-Fabric API 0.115.1 Edition》