Skip to content

Commit 5259be1

Browse files
committed
完善马超武器
1 parent 793eab7 commit 5259be1

File tree

5 files changed

+80
-9
lines changed

5 files changed

+80
-9
lines changed

src/main/java/xyz/lisbammisakait/RelightTheThreePointStrategy.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public void onInitialize() {
3535
// 为玩家添加加速效果
3636
player.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 2, 1));
3737
}
38+
// 如果玩家的主手或副手拿着神威虎头湛金枪
39+
if(mainHandStack.getItem() == ModItems.SHENWEIHUTOUZHANJINQIANG || offHandStack.getItem() == ModItems.SHENWEIHUTOUZHANJINQIANG){
40+
player.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 2, 2));
41+
}
3842
}
3943
});
4044
LOGGER.info("Hello Fabric world!");

src/main/java/xyz/lisbammisakait/item/HutouzhanjinqiangItem.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,24 @@ public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attack
8686

8787
@Override
8888
public ActionResult use(World world, PlayerEntity user, Hand hand) {
89-
ItemStack stack = user.getStackInHand(hand);
90-
// Don't do anything on the client
89+
// ItemStack stack = user.getStackInHand(hand);
90+
// // Don't do anything on the client
9191
if (world.isClient()) {
9292
return ActionResult.SUCCESS;
9393
}
94-
// Read the current count and increase it by one
95-
int count = stack.getOrDefault(RtTPSComponents.COOLDOWN_TYPE, 0);
96-
stack.set(RtTPSComponents.COOLDOWN_TYPE, ++count);
97-
return ActionResult.SUCCESS;
94+
//
95+
// // Read the current count and increase it by one
96+
// int count = stack.getOrDefault(RtTPSComponents.COOLDOWN_TYPE, 0);
97+
// stack.set(RtTPSComponents.COOLDOWN_TYPE, ++count);
98+
// return ActionResult.SUCCESS;
99+
100+
if (user != null) {
101+
// 创建一个新的物品栈,这里以钻石为例
102+
ItemStack newItemStack = new ItemStack(ModItems.SHENWEIHUTOUZHANJINQIANG, 1);
103+
// 将主手物品更换为新的物品栈
104+
user.getInventory().main.set(user.getInventory().selectedSlot, newItemStack);
105+
return ActionResult.SUCCESS;
106+
}
107+
return ActionResult.FAIL;
98108
}
99109
}

src/main/java/xyz/lisbammisakait/item/ModItems.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ public class ModItems {
3939
// }
4040
//注册飞龙夺凤
4141
public static final RegistryKey<Item> FEILONGDUOFENG_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(RelightTheThreePointStrategy.MOD_ID, "feilongduofeng"));
42-
public static final Item FEILONGDUOFENG = register(new FeilongduofengItem(ToolMaterial.GOLD, 4f, 1f, new Item.Settings().registryKey(FEILONGDUOFENG_KEY)), FEILONGDUOFENG_KEY);
42+
public static final Item FEILONGDUOFENG = register(new FeilongduofengItem(ToolMaterial.GOLD, 4f, 20f, new Item.Settings().registryKey(FEILONGDUOFENG_KEY)), FEILONGDUOFENG_KEY);
4343
//注册虎头湛金枪
4444
public static final RegistryKey<Item> HUTOUZHANJINQIANG_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(RelightTheThreePointStrategy.MOD_ID, "hutouzhanjinqiang"));
45-
public static final Item HUTOUZHANJINQIANG = register(new HutouzhanjinqiangItem(ToolMaterial.GOLD, 6f, 1f, new Item.Settings().registryKey(HUTOUZHANJINQIANG_KEY).component(RtTPSComponents.COOLDOWN_TYPE,HutouzhanjinqiangItem.COOLDOWN)), HUTOUZHANJINQIANG_KEY);
45+
public static final Item HUTOUZHANJINQIANG = register(new HutouzhanjinqiangItem(ToolMaterial.GOLD, 6f, 20f, new Item.Settings().registryKey(HUTOUZHANJINQIANG_KEY).component(RtTPSComponents.COOLDOWN_TYPE,HutouzhanjinqiangItem.COOLDOWN)), HUTOUZHANJINQIANG_KEY);
46+
//注册神威虎头湛金枪
47+
public static final RegistryKey<Item> SHENWEIHUTOUZHANJINQIANG_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(RelightTheThreePointStrategy.MOD_ID, "shenweihutouzhanjinqiang"));
48+
public static final Item SHENWEIHUTOUZHANJINQIANG = register(new ShenweihutouzhanjianjinqiangItem(ToolMaterial.GOLD, 8f, 20f, new Item.Settings().registryKey(SHENWEIHUTOUZHANJINQIANG_KEY)), SHENWEIHUTOUZHANJINQIANG_KEY);
4649
//-----------------------------------------------------------------------------------------------
4750
//-----------------------------------------------------------------------------------------------
4851
//注册引凤来翔
@@ -80,6 +83,7 @@ public static void registerToRtTPSGroups() {
8083
ItemGroupEvents.modifyEntriesEvent(RTTPS_ITEM_GROUP_KEY).register(itemGroup -> {
8184
itemGroup.add(ModItems.FEILONGDUOFENG);
8285
itemGroup.add(ModItems.HUTOUZHANJINQIANG);
86+
itemGroup.add(ModItems.SHENWEIHUTOUZHANJINQIANG);
8387
});
8488
}
8589
public static void initialize() {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package xyz.lisbammisakait.item;
2+
3+
import net.minecraft.entity.LivingEntity;
4+
import net.minecraft.entity.player.PlayerEntity;
5+
import net.minecraft.item.ItemStack;
6+
import net.minecraft.item.ToolMaterial;
7+
import net.minecraft.item.tooltip.TooltipType;
8+
import net.minecraft.text.Text;
9+
import net.minecraft.util.ActionResult;
10+
import net.minecraft.util.Formatting;
11+
import net.minecraft.util.Hand;
12+
import net.minecraft.world.World;
13+
14+
import java.util.List;
15+
16+
public class ShenweihutouzhanjianjinqiangItem extends HutouzhanjinqiangItem {
17+
public ShenweihutouzhanjianjinqiangItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
18+
super(material, attackDamage, attackSpeed, settings);
19+
}
20+
@Override
21+
public ActionResult use(World world, PlayerEntity user, Hand hand) {
22+
return ActionResult.SUCCESS;
23+
}
24+
@Override
25+
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
26+
if (attacker.getWorld().isClient()) {
27+
return true;
28+
}
29+
PlayerEntity user = (PlayerEntity) attacker;
30+
// 创建一个新的物品栈,这里以钻石为例
31+
ItemStack newItemStack = new ItemStack(ModItems.HUTOUZHANJINQIANG, 1);
32+
// 将主手物品更换为新的物品栈
33+
user.getInventory().main.set(user.getInventory().selectedSlot, newItemStack);
34+
35+
return super.postHit(stack, target, attacker);
36+
}
37+
@Override
38+
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
39+
tooltip.add(Text.translatable("itemskill.relight-the-three-point-strategy.shenweihutouzhanjinqiang").formatted(Formatting.GOLD));
40+
}
41+
}
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
{
22
"item.relight-the-three-point-strategy.feilongduofeng": "FeiLongDuoFeng",
33
"item.relight-the-three-point-strategy.hutouzhanjinqiang": "HuTouZhanJinQiang",
4+
"item.relight-the-three-point-strategy.tiejitachuan":"TieJiTachuan",
5+
"item.relight-the-three-point-strategy.yinfenglaixiang": "YinFengLaiXiang",
6+
"item.relight-the-three-point-strategy.shenweihutouzhanjinqiang": "ShenWeiHuTouZhanJinQiang",
47
"key.RelightTheThreePointStrategy.SkillA": "SkillA",
58
"key.RelightTheThreePointStrategy.SkillB": "SkillB",
69
"category.RelightTheThreePointStrategy.SkillGroup": "Skill Group",
7-
"item.relight-the-three-point-strategy.hutouzhanjinqiang.remaining-cooldown-time": "Remaining Cooldown Time: %1$s s"
10+
"item.relight-the-three-point-strategy.hutouzhanjinqiang.remaining-cooldown-time": "Remaining Cooldown Time: %1$s s",
11+
"itemskill.relight-the-three-point-strategy.shenweihutouzhanjinqiang": "ShenWeiHuTouZhanJinQiang",
12+
"skillGroup.RelightTheThreePointStrategy": "Skill",
13+
"rttpsGroup.RelightTheThreePointStrategy": "Weapon",
14+
"key.RelightTheThreePointStrategy.SkillA": "SkillA",
15+
"key.RelightTheThreePointStrategy.SkillB": "SkillB",
16+
"category.RelightTheThreePointStrategy.SkillGroup": "Skill Group",
17+
"skill.relight-the-three-point-strategy.tiejitachuan": "§a[Passive] §fWhen you hold a weapon, you gain a speed - up effect. When you perform a basic attack, you dash 3 blocks towards the target.",
18+
"skill.relight-the-three-point-strategy.yinfenglaixiang": "§a[Passive] §fEach of your basic attacks has a %1$s%% chance to apply a knockback effect and a %2$s - second burn effect.",
19+
"itemskill.relight-the-three-point-strategy.hutouzhanjinqiang": "§6[Active][%1$ss] §fRight - click to strengthen the weapon, increasing its damage and speed - up effect until the next basic attack."
820
}

0 commit comments

Comments
 (0)