Skip to content

Commit 8c2ecbe

Browse files
authored
Merge pull request #1 from misakajialin/dev
Dev
2 parents 2911530 + a21fe39 commit 8c2ecbe

File tree

10 files changed

+88
-6
lines changed

10 files changed

+88
-6
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
import net.fabricmc.api.ModInitializer;
44

5+
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
6+
import net.minecraft.entity.effect.StatusEffectInstance;
7+
import net.minecraft.entity.effect.StatusEffects;
8+
import net.minecraft.entity.player.PlayerEntity;
9+
import net.minecraft.item.ItemStack;
510
import org.slf4j.Logger;
611
import org.slf4j.LoggerFactory;
712
import xyz.lisbammisakait.item.ModItems;
@@ -20,6 +25,19 @@ public void onInitialize() {
2025
// However, some things (like resources) may still be uninitialized.
2126
// Proceed with mild caution.
2227
ModItems.initialize();
28+
29+
// 注册服务器tick事件
30+
ServerTickEvents.END_SERVER_TICK.register(server -> {
31+
for (PlayerEntity player : server.getPlayerManager().getPlayerList()) {
32+
ItemStack mainHandStack = player.getMainHandStack();
33+
ItemStack offHandStack = player.getOffHandStack();
34+
// 如果玩家的主手或副手拿着虎头湛金枪
35+
if (mainHandStack.getItem() == ModItems.HUTOUZHANJINQIANG || offHandStack.getItem() == ModItems.HUTOUZHANJINQIANG) {
36+
// 为玩家添加加速效果
37+
player.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 2, 1));
38+
}
39+
}
40+
});
2341
LOGGER.info("Hello Fabric world!");
2442
}
2543
}
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,38 @@
11
package xyz.lisbammisakait.item;
22

3+
34
import net.minecraft.item.SwordItem;
45
import net.minecraft.item.ToolMaterial;
6+
import net.minecraft.util.ActionResult;
7+
import net.minecraft.util.Hand;
8+
import net.minecraft.world.World;
9+
import xyz.lisbammisakait.RelightTheThreePointStrategy;
10+
11+
import java.util.Random;
512

613
public class FeilongduofengItem extends SwordItem {
714
public FeilongduofengItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
815
super(material, attackDamage, attackSpeed, settings);
916
}
1017
@Override
1118
public boolean postHit(net.minecraft.item.ItemStack stack, net.minecraft.entity.LivingEntity target, net.minecraft.entity.LivingEntity attacker) {
12-
target.setFireTicks(100);
19+
Random random = new Random();
20+
// 生成一个 0 到 9 之间的随机整数
21+
int randomNumber = random.nextInt(10);
22+
// 判断随机数是否为 0
23+
if (randomNumber<10) {
24+
// 给目标添加火焰效果
25+
target.setFireTicks(60);
26+
double motionX = attacker.getRotationVector().x;
27+
double motionZ = attacker.getRotationVector().z;
28+
// 计算击退强度,这里假设一个简单的强度值
29+
double knockbackStrength = 1;
30+
// 给目标添加击退效果
31+
//target.addVelocity(motionX * knockbackStrength, 0.5, motionZ * knockbackStrength);
32+
target.takeKnockback(knockbackStrength, -motionX, -motionZ);
33+
}
34+
1335
return super.postHit(stack, target, attacker);
1436
}
37+
1538
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package xyz.lisbammisakait.item;
2+
3+
import net.minecraft.entity.LivingEntity;
4+
import net.minecraft.item.ItemStack;
5+
import net.minecraft.item.SwordItem;
6+
import net.minecraft.item.ToolMaterial;
7+
import net.minecraft.world.World;
8+
import xyz.lisbammisakait.RelightTheThreePointStrategy;
9+
10+
public class HutouzhanjinqiangItem extends SwordItem {
11+
public HutouzhanjinqiangItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
12+
super(material, attackDamage, attackSpeed, settings);
13+
14+
}
15+
16+
17+
18+
19+
20+
21+
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,25 @@ public class ModItems {
2121
// final RegistryKey<Item> registryKey = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(RelightTheThreePointStrategy.MOD_ID, path));
2222
// return Items.register(registryKey, factory, settings);
2323
// }
24-
public static final RegistryKey<Item> FEILONGDUOFENG_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(RelightTheThreePointStrategy.MOD_ID, "feilongduofeng"));
24+
//注册飞龙夺凤
25+
public static final RegistryKey<Item> FEILONGDUOFENG_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(RelightTheThreePointStrategy.MOD_ID, "feilongduofeng"));
2526
public static final Item FEILONGDUOFENG = register(new FeilongduofengItem(ToolMaterial.GOLD, 1f, 1f, new Item.Settings().registryKey(FEILONGDUOFENG_KEY)), FEILONGDUOFENG_KEY);
27+
//注册虎头湛金枪
28+
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, 1f, 1f, new Item.Settings().registryKey(HUTOUZHANJINQIANG_KEY)), HUTOUZHANJINQIANG_KEY);
30+
2631
public static Item register(Item item, RegistryKey<Item> registryKey) {
2732
// Register the item.
2833
Item registeredItem = Registry.register(Registries.ITEM, registryKey.getValue(), item);
29-
3034
// Return the registered item!
3135
return registeredItem;
3236
}
3337

38+
3439
public static void registerToVanillaItemGroups() {
3540
ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register(content -> {
3641
content.add(FEILONGDUOFENG);
42+
content.add(HUTOUZHANJINQIANG);
3743
});
3844
}
3945
public static void initialize() {
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/hutouzhanjinqiang"
5+
}
6+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"item.relight-the-three-point-strategy.feilongduofeng": "feilongduofeng"
2+
"item.relight-the-three-point-strategy.feilongduofeng": "feilongduofeng",
3+
"item.relight-the-three-point-strategy.hutouzhanjinqiang": "hutouzhanjinqiang"
34
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"item.relight-the-three-point-strategy.feilongduofeng": "飞龙夺凤"
2+
"item.relight-the-three-point-strategy.feilongduofeng": "飞龙夺凤",
3+
"item.relight-the-three-point-strategy.hutouzhanjinqiang": "虎头湛金枪"
34
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parent": "item/handheld",
3+
"textures": {
4+
"layer0": "relight-the-three-point-strategy:item/hutouzhanjinqiang"
5+
}
6+
}
461 Bytes
Loading

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Relight-The-Three-Point-Strategy",
66
"description": "This is an example description! Tell everyone what your mod is about!",
77
"authors": [
8-
"Me!"
8+
"LisBam&Misakait"
99
],
1010
"contact": {
1111
"homepage": "https://fabricmc.net/",

0 commit comments

Comments
 (0)