Skip to content

Commit 1e6e862

Browse files
committed
- minor fixes
1 parent 46a708a commit 1e6e862

File tree

8 files changed

+63
-19
lines changed

8 files changed

+63
-19
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package smartin.miapi.entity.arrowhitbehaviours;
22

33
import net.minecraft.entity.Entity;
4+
import net.minecraft.entity.LivingEntity;
5+
import net.minecraft.entity.projectile.ArrowEntity;
46
import net.minecraft.util.hit.EntityHitResult;
57
import smartin.miapi.entity.ItemProjectileEntity;
68

79
public class EntityStickBehaviour implements ProjectileHitBehaviour {
810
@Override
911
public void onHit(ItemProjectileEntity projectile, Entity hit, EntityHitResult hitResult) {
12+
ArrowEntity arrowEntity;
13+
LivingEntity livingEntity;
1014
projectile.discard();
1115
}
1216
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package smartin.miapi.modules.properties;
2+
3+
import com.google.gson.JsonElement;
4+
import dev.architectury.event.EventResult;
5+
import net.minecraft.enchantment.EnchantmentHelper;
6+
import net.minecraft.entity.LivingEntity;
7+
import smartin.miapi.entity.arrowhitbehaviours.EntityStickBehaviour;
8+
import smartin.miapi.events.MiapiProjectileEvents;
9+
import smartin.miapi.modules.ItemModule;
10+
import smartin.miapi.modules.properties.util.ModuleProperty;
11+
12+
/**
13+
* This property is responsible for teleporting a hit target of projectiles
14+
*/
15+
public class ArrowProperty implements ModuleProperty {
16+
public static final String KEY = "is_arrow";
17+
public static ArrowProperty property;
18+
public static EntityStickBehaviour entityStickBehaviour = new EntityStickBehaviour();
19+
20+
public ArrowProperty() {
21+
property = this;
22+
MiapiProjectileEvents.MODULAR_PROJECTILE_ENTITY_HIT.register(event -> {
23+
JsonElement element = ItemModule.getMergedProperty(event.projectile.asItemStack(), property);
24+
if (element != null && element.getAsBoolean() && event.entityHitResult.getEntity() instanceof LivingEntity livingEntity) {
25+
if (EnchantmentHelper.getLoyalty(event.projectile.asItemStack()) < 1) {
26+
event.projectile.projectileHitBehaviour = entityStickBehaviour;
27+
}
28+
}
29+
return EventResult.pass();
30+
});
31+
}
32+
33+
@Override
34+
public boolean load(String moduleKey, JsonElement data) throws Exception {
35+
data.getAsBoolean();
36+
return true;
37+
}
38+
}

common/src/main/java/smartin/miapi/registries/RegistryInventory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ public static void setup() {
400400
registerMiapi(moduleProperties, ChannelingProperty.KEY, new ChannelingProperty());
401401
registerMiapi(moduleProperties, AirDragProperty.KEY, new AirDragProperty());
402402
registerMiapi(moduleProperties, WaterDragProperty.KEY, new WaterDragProperty());
403+
registerMiapi(moduleProperties, ArrowProperty.KEY, new ArrowProperty());
403404

404405
//compat
405406
registerMiapi(moduleProperties, BetterCombatProperty.KEY, new BetterCombatProperty());

common/src/main/resources/data/miapi/modules/arrow/shaft/arrow_shaft.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"arrow_shaft",
2525
"melee"
2626
],
27+
"is_arrow": true,
2728
"allowedMaterial": {
2829
"allowedMaterials": [
2930
"wood",

common/src/main/resources/data/miapi/modules/sword/blade/blade_rapier.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@
2727
]
2828
},
2929
"allowedInSlots": [
30-
"wood",
31-
"metal",
32-
"flint",
33-
"bone",
34-
"stone",
35-
"crystal",
36-
"glass"
30+
"sword_blade"
3731
],
3832
"tag": [
3933
"blade",
@@ -44,7 +38,13 @@
4438
},
4539
"allowedMaterial": {
4640
"allowedMaterials": [
47-
"wood","stone","metal","crystal"
41+
"wood",
42+
"metal",
43+
"flint",
44+
"bone",
45+
"stone",
46+
"crystal",
47+
"glass"
4848
],
4949
"cost": 1
5050
},

common/src/main/resources/data/miapi/modules/sword/blade/blade_spear.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
},
7777
{
7878
"attribute": "miapi:generic.projectile_speed",
79-
"value": "2.5",
79+
"value": "1.5",
8080
"operation": "+",
8181
"slot": "mainhand",
8282
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"

common/src/main/resources/data/miapi/modules/sword/blade/blade_throwing_knife.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@
2828
]
2929
},
3030
"allowedInSlots": [
31-
"wood",
32-
"metal",
33-
"flint",
34-
"bone",
35-
"stone",
36-
"crystal",
37-
"glass"
31+
"sword_blade_small"
3832
],
3933
"better_combat_config": {
4034
"parent": "bettercombat:dagger"
@@ -45,7 +39,13 @@
4539
],
4640
"allowedMaterial": {
4741
"allowedMaterials": [
48-
"wood","stone","metal","crystal"
42+
"wood",
43+
"metal",
44+
"flint",
45+
"bone",
46+
"stone",
47+
"crystal",
48+
"glass"
4949
],
5050
"cost": 1
5151
},
@@ -87,7 +87,7 @@
8787
},
8888
{
8989
"attribute": "miapi:generic.projectile_speed",
90-
"value": "2.0",
90+
"value": "1.3",
9191
"operation": "+",
9292
"slot": "mainhand",
9393
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3G
33
minecraft_version=1.20.1
44

55
archives_base_name=miapi
6-
mod_version=0.5.6-SNAPSHOT
6+
mod_version=0.6.2-SNAPSHOT
77
maven_group=smartin
88

99
architectury_version=9.0.8

0 commit comments

Comments
 (0)