Skip to content

Commit c9463ed

Browse files
authored
Merge pull request #5 from misakajialin/dev
Dev
2 parents 92c8593 + 5259be1 commit c9463ed

20 files changed

+288
-40
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package xyz.lisbammisakait;
22

33
import net.fabricmc.api.ModInitializer;
4-
54
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
65
import net.minecraft.entity.effect.StatusEffectInstance;
76
import net.minecraft.entity.effect.StatusEffects;
@@ -36,6 +35,10 @@ public void onInitialize() {
3635
// 为玩家添加加速效果
3736
player.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 2, 1));
3837
}
38+
// 如果玩家的主手或副手拿着神威虎头湛金枪
39+
if(mainHandStack.getItem() == ModItems.SHENWEIHUTOUZHANJINQIANG || offHandStack.getItem() == ModItems.SHENWEIHUTOUZHANJINQIANG){
40+
player.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 2, 2));
41+
}
3942
}
4043
});
4144
LOGGER.info("Hello Fabric world!");

src/main/java/xyz/lisbammisakait/RelightTheThreePointStrategyClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
66
import net.minecraft.client.option.KeyBinding;
77
import net.minecraft.client.util.InputUtil;
8-
import net.minecraft.text.Text;
98
import org.lwjgl.glfw.GLFW;
109

1110
public class RelightTheThreePointStrategyClient implements ClientModInitializer {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package xyz.lisbammisakait.Skill;
2+
3+
import net.minecraft.item.Item;
4+
import net.minecraft.item.ItemStack;
5+
import net.minecraft.item.tooltip.TooltipType;
6+
import net.minecraft.text.Text;
7+
import net.minecraft.util.Formatting;
8+
9+
import java.util.List;
10+
11+
public class TieJiTaChuanSkill extends Item {
12+
public TieJiTaChuanSkill(Settings settings) {
13+
super(settings);
14+
}
15+
16+
@Override
17+
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
18+
tooltip.add(Text.translatable("skill.relight-the-three-point-strategy.tiejitachuan").formatted(Formatting.GOLD));
19+
}
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package xyz.lisbammisakait.Skill;
2+
3+
import net.minecraft.item.Item;
4+
import net.minecraft.item.ItemStack;
5+
import net.minecraft.item.tooltip.TooltipType;
6+
import net.minecraft.text.Text;
7+
import net.minecraft.util.Formatting;
8+
import xyz.lisbammisakait.item.FeilongduofengItem;
9+
10+
import java.util.List;
11+
12+
public class YinFengLaiXiangSkill extends Item {
13+
public YinFengLaiXiangSkill(Settings settings) {
14+
super(settings);
15+
}
16+
17+
@Override
18+
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
19+
tooltip.add(Text.translatable("skill.relight-the-three-point-strategy.yinfenglaixiang", FeilongduofengItem.PROBABILITY,FeilongduofengItem.FIRETIME).formatted(Formatting.GOLD));
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package xyz.lisbammisakait.compoennt;
2+
3+
import com.mojang.serialization.Codec;
4+
import net.minecraft.component.ComponentType;
5+
import net.minecraft.registry.Registries;
6+
import net.minecraft.registry.Registry;
7+
import net.minecraft.util.Identifier;
8+
import xyz.lisbammisakait.RelightTheThreePointStrategy;
9+
10+
public class RtTPSComponents {
11+
protected static void initialize() {
12+
RelightTheThreePointStrategy.LOGGER.info("Registering {} components", RelightTheThreePointStrategy.MOD_ID);
13+
// Technically this method can stay empty, but some developers like to notify
14+
// the console, that certain parts of the mod have been successfully initialized
15+
}
16+
public static final ComponentType<Integer> COOLDOWN_TYPE = Registry.register(
17+
Registries.DATA_COMPONENT_TYPE,
18+
Identifier.of(RelightTheThreePointStrategy.MOD_ID, "cooldown"),
19+
ComponentType.<Integer>builder().codec(Codec.INT).build()
20+
);
21+
}

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
package xyz.lisbammisakait.item;
22

33

4-
import net.minecraft.entity.EquipmentSlot;
5-
import net.minecraft.entity.LivingEntity;
6-
import net.minecraft.item.ItemStack;
74
import net.minecraft.item.SwordItem;
85
import net.minecraft.item.ToolMaterial;
9-
import net.minecraft.util.ActionResult;
10-
import net.minecraft.util.Hand;
11-
import net.minecraft.world.World;
12-
import xyz.lisbammisakait.RelightTheThreePointStrategy;
136

147
import java.util.Random;
158

169
public class FeilongduofengItem extends SwordItem {
10+
public static final int PROBABILITY = 20;
11+
public static final int FIRETIME = 2;
1712
public FeilongduofengItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
1813
super(material, attackDamage, attackSpeed, settings);
1914
}
@@ -22,10 +17,10 @@ public boolean postHit(net.minecraft.item.ItemStack stack, net.minecraft.entity.
2217
Random random = new Random();
2318
// 生成一个 0 到 9 之间的随机整数
2419
int randomNumber = random.nextInt(10);
25-
// 判断随机数是否为 0
26-
if (randomNumber<10) {
20+
// 判断随机数是否为 0或1
21+
if (randomNumber<(PROBABILITY/10)) {
2722
// 给目标添加火焰效果
28-
target.setFireTicks(60);
23+
target.setFireTicks(FIRETIME*20);
2924
double motionX = attacker.getRotationVector().x;
3025
double motionZ = attacker.getRotationVector().z;
3126
// 计算击退强度,这里假设一个简单的强度值

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

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
package xyz.lisbammisakait.item;
22

3-
import net.minecraft.block.Blocks;
4-
import net.minecraft.block.enums.BlockHalf;
53
import net.minecraft.entity.LivingEntity;
4+
import net.minecraft.entity.player.PlayerEntity;
65
import net.minecraft.item.ItemStack;
76
import net.minecraft.item.SwordItem;
87
import net.minecraft.item.ToolMaterial;
8+
import net.minecraft.item.tooltip.TooltipType;
99
import net.minecraft.network.packet.s2c.play.PositionFlag;
1010
import net.minecraft.server.world.ServerWorld;
11+
import net.minecraft.text.Text;
12+
import net.minecraft.util.Formatting;
1113
import net.minecraft.util.math.BlockPos;
14+
import net.minecraft.text.Text;
15+
import net.minecraft.util.ActionResult;
16+
import net.minecraft.util.Formatting;
17+
import net.minecraft.util.Hand;
1218
import net.minecraft.util.math.Vec3d;
13-
import net.minecraft.world.BlockView;
1419
import net.minecraft.world.World;
1520
import xyz.lisbammisakait.RelightTheThreePointStrategy;
21+
import xyz.lisbammisakait.compoennt.RtTPSComponents;
1622
import xyz.lisbammisakait.tools.SafeTp;
1723

1824
import java.util.Collections;
1925
import java.util.EnumSet;
26+
import java.util.List;
27+
import java.util.List;
2028
import java.util.Set;
2129

2230

2331

2432
public class HutouzhanjinqiangItem extends SwordItem {
33+
public static final int COOLDOWN = 30;
2534
public HutouzhanjinqiangItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
2635
super(material, attackDamage, attackSpeed, settings);
2736
}
2837
@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.hutouzhanjinqiang",COOLDOWN).formatted(Formatting.GOLD));
40+
}
41+
@Override
2942
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
3043
// 计算从攻击者指向被攻击者的方向向量
3144
Vec3d direction = target.getPos().subtract(attacker.getPos());
@@ -62,17 +75,35 @@ public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attack
6275
RelightTheThreePointStrategy.LOGGER.info("攻击者传送到目标位置");
6376
return super.postHit(stack, target, attacker);
6477
}
65-
// private boolean isSafeLocation(BlockView world, BlockPos pos) {
66-
// if (world.getBlockState(pos).isAir() && world.getBlockState(pos.up()).isAir()) {
67-
// return true;
78+
// @Override
79+
// public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
80+
// if (stack.contains(RtTPSComponents.COOLDOWN_TYPE)) {
81+
// //int rct = stack.get(RtTPSComponents.COOLDOWN_TYPE);
82+
// int rct = stack.getOrDefault(RtTPSComponents.COOLDOWN_TYPE, COOLDOWN);
83+
// tooltip.add(Text.translatable("item.relight-the-three-point-strategy.hutouzhanjinqiang.remaining-cooldown-time", rct).formatted(Formatting.GOLD));
6884
// }
69-
// if(world.getBlockState(pos).getBlock() == Blocks.LIGHT && world.getBlockState(pos.up()).getBlock() == Blocks.LIGHT){
70-
// return true;
71-
// }
72-
// return false;
7385
// }
7486

75-
76-
77-
87+
@Override
88+
public ActionResult use(World world, PlayerEntity user, Hand hand) {
89+
// ItemStack stack = user.getStackInHand(hand);
90+
// // Don't do anything on the client
91+
if (world.isClient()) {
92+
return ActionResult.SUCCESS;
93+
}
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;
108+
}
78109
}
Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
package xyz.lisbammisakait.item;
22

3-
import xyz.lisbammisakait.RelightTheThreePointStrategy;
3+
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
44
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
55
import net.minecraft.item.Item;
6-
import net.minecraft.item.ItemGroups;
7-
import net.minecraft.item.Items;
6+
import net.minecraft.item.ItemGroup;
7+
import net.minecraft.item.ItemStack;
88
import net.minecraft.item.ToolMaterial;
99
import net.minecraft.registry.Registries;
1010
import net.minecraft.registry.Registry;
1111
import net.minecraft.registry.RegistryKey;
1212
import net.minecraft.registry.RegistryKeys;
13+
import net.minecraft.text.Text;
1314
import net.minecraft.util.Identifier;
14-
15-
import java.util.function.Function;
15+
import xyz.lisbammisakait.Skill.TieJiTaChuanSkill;
16+
import xyz.lisbammisakait.RelightTheThreePointStrategy;
17+
import xyz.lisbammisakait.Skill.YinFengLaiXiangSkill;
18+
import xyz.lisbammisakait.compoennt.RtTPSComponents;
1619

1720
public class ModItems {
21+
//创建技能物品组
22+
public static final RegistryKey<ItemGroup> SKILL_GROUP_KEY = RegistryKey.of(Registries.ITEM_GROUP.getKey(), Identifier.of(RelightTheThreePointStrategy.MOD_ID, "skill_group"));
23+
public static final ItemGroup SKILL_GROUP = FabricItemGroup.builder()
24+
.icon(() -> new ItemStack(ModItems.HUTOUZHANJINQIANG))
25+
.displayName(Text.translatable("skillGroup.RelightTheThreePointStrategy"))
26+
.build();
27+
//创建武器物品组
28+
public static final RegistryKey<ItemGroup> RTTPS_ITEM_GROUP_KEY = RegistryKey.of(Registries.ITEM_GROUP.getKey(), Identifier.of(RelightTheThreePointStrategy.MOD_ID, "rttps_group"));
29+
public static final ItemGroup RTTPS_GROUP = FabricItemGroup.builder()
30+
.icon(() -> new ItemStack(ModItems.FEILONGDUOFENG))
31+
.displayName(Text.translatable("rttpsGroup.RelightTheThreePointStrategy"))
32+
.build();
33+
1834
// public static final Item FEILONGDUOFENG = register("feilongduofeng", Item::new, new Item.Settings());
1935
// public static final Item FEILONGDUOFENG = register();
2036
// public static Item register(String path, Function<Item.Settings, Item> factory, Item.Settings settings) {
@@ -23,10 +39,21 @@ public class ModItems {
2339
// }
2440
//注册飞龙夺凤
2541
public static final RegistryKey<Item> FEILONGDUOFENG_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(RelightTheThreePointStrategy.MOD_ID, "feilongduofeng"));
26-
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);
2743
//注册虎头湛金枪
2844
public static final RegistryKey<Item> HUTOUZHANJINQIANG_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(RelightTheThreePointStrategy.MOD_ID, "hutouzhanjinqiang"));
29-
public static final Item HUTOUZHANJINQIANG = register(new HutouzhanjinqiangItem(ToolMaterial.GOLD, 6f, 1f, new Item.Settings().registryKey(HUTOUZHANJINQIANG_KEY)), 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);
49+
//-----------------------------------------------------------------------------------------------
50+
//-----------------------------------------------------------------------------------------------
51+
//注册引凤来翔
52+
public static final RegistryKey<Item> YINFENGLAIXIANG_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(RelightTheThreePointStrategy.MOD_ID, "yinfenglaixiang"));
53+
public static final Item YINFENGLAIXIANG = register(new YinFengLaiXiangSkill( new Item.Settings().registryKey(YINFENGLAIXIANG_KEY)), YINFENGLAIXIANG_KEY);
54+
//注册铁骑踏川
55+
public static final RegistryKey<Item> TIEJITACHUAN_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(RelightTheThreePointStrategy.MOD_ID, "tiejitachuan"));
56+
public static final Item TIEJITACHUAN = register(new TieJiTaChuanSkill( new Item.Settings().registryKey(TIEJITACHUAN_KEY)), TIEJITACHUAN_KEY);
3057

3158
public static Item register(Item item, RegistryKey<Item> registryKey) {
3259
// Register the item.
@@ -36,13 +63,32 @@ public static Item register(Item item, RegistryKey<Item> registryKey) {
3663
}
3764

3865

39-
public static void registerToVanillaItemGroups() {
66+
/*public static void registerToVanillaItemGroups() {
4067
ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register(content -> {
4168
content.add(FEILONGDUOFENG);
4269
content.add(HUTOUZHANJINQIANG);
4370
});
71+
}*/
72+
//注册技能
73+
public static void registerToSkillGroups() {
74+
Registry.register(Registries.ITEM_GROUP, SKILL_GROUP_KEY, SKILL_GROUP);
75+
ItemGroupEvents.modifyEntriesEvent(SKILL_GROUP_KEY).register(itemGroup -> {
76+
itemGroup.add(ModItems.YINFENGLAIXIANG);
77+
itemGroup.add(ModItems.TIEJITACHUAN);
78+
});
79+
}
80+
//注册武器
81+
public static void registerToRtTPSGroups() {
82+
Registry.register(Registries.ITEM_GROUP, RTTPS_ITEM_GROUP_KEY, RTTPS_GROUP);
83+
ItemGroupEvents.modifyEntriesEvent(RTTPS_ITEM_GROUP_KEY).register(itemGroup -> {
84+
itemGroup.add(ModItems.FEILONGDUOFENG);
85+
itemGroup.add(ModItems.HUTOUZHANJINQIANG);
86+
itemGroup.add(ModItems.SHENWEIHUTOUZHANJINQIANG);
87+
});
4488
}
4589
public static void initialize() {
46-
registerToVanillaItemGroups();
90+
registerToSkillGroups();
91+
registerToRtTPSGroups();
92+
//registerToVanillaItemGroups();
4793
}
4894
}
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"model": {
3+
"type": "minecraft:model",
4+
"model": "relight-the-three-point-strategy:item/shenweihutouzhanjinqiang"
5+
}
6+
}

0 commit comments

Comments
 (0)