Skip to content

Commit 5b85d20

Browse files
committed
-licence update
1 parent 3e39625 commit 5b85d20

File tree

17 files changed

+143
-32
lines changed

17 files changed

+143
-32
lines changed

.licence

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
Binary file not shown.

common/src/main/java/smartin/miapi/modules/properties/AttributeProperty.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ public static Multimap<EntityAttribute, EntityAttributeModifier> getAttributeMod
149149
}
150150
}
151151
startValue = startValue - key.getDefaultValue();
152-
EntityAttributeModifier entityAttributeModifier = new EntityAttributeModifier(uuid, "generic.miapi." + key.getTranslationKey(), startValue, EntityAttributeModifier.Operation.ADDITION);
153-
toAdding.put(key, entityAttributeModifier);
152+
if (startValue != 0) {
153+
EntityAttributeModifier entityAttributeModifier = new EntityAttributeModifier(uuid, "generic.miapi." + key.getTranslationKey(), startValue, EntityAttributeModifier.Operation.ADDITION);
154+
toAdding.put(key, entityAttributeModifier);
155+
}
154156
});
155157
});
156158

@@ -187,7 +189,7 @@ private static void sortMultimap(Multimap<EntityAttribute, EntityAttributeModifi
187189
multimap.putAll(sortedMultimap);
188190
}
189191

190-
public static double getActualValue(ItemStack stack, EquipmentSlot slot, EntityAttribute entityAttribute) {
192+
public static double getActualValue(ItemStack stack, EquipmentSlot slot, EntityAttribute entityAttribute, double fallback) {
191193
Collection<EntityAttributeModifier> attributes = stack.getAttributeModifiers(slot).get(entityAttribute);
192194
Multimap<EntityAttribute, EntityAttributeModifier> map = HashMultimap.create();
193195
attributes.forEach(attribute -> {
@@ -199,8 +201,15 @@ public static double getActualValue(ItemStack stack, EquipmentSlot slot, EntityA
199201
AttributeContainer container1 = new AttributeContainer(container);
200202

201203
container1.addTemporaryModifiers(map);
204+
if (container1.hasAttribute(entityAttribute)) {
205+
return container1.getValue(entityAttribute);
206+
} else {
207+
return fallback;
208+
}
209+
}
202210

203-
return container1.getValue(entityAttribute);
211+
public static double getActualValue(ItemStack stack, EquipmentSlot slot, EntityAttribute entityAttribute) {
212+
return getActualValue(stack, slot, entityAttribute, entityAttribute.getDefaultValue());
204213
}
205214

206215
private static Multimap<EntityAttribute, EntityAttributeModifierHolder> createAttributeCache(ItemStack itemStack) {

common/src/main/java/smartin/miapi/modules/properties/MiningLevelProperty.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,28 @@ public static boolean IsSuitable(ItemStack stack, BlockState state) {
7878

7979
public static boolean canMine(BlockState state, World world, BlockPos pos, PlayerEntity miner) {
8080
ItemStack stack = miner.getActiveItem();
81-
if(ToolOrWeaponProperty.isWeapon(stack)){
81+
if (ToolOrWeaponProperty.isWeapon(stack)) {
8282
return !miner.isCreative();
8383
}
8484
return true;
8585
}
8686

8787
public static float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
8888
if (state.isIn(BlockTags.PICKAXE_MINEABLE)) {
89-
double value = AttributeProperty.getActualValue(stack, EquipmentSlot.MAINHAND, AttributeRegistry.MINING_SPEED_PICKAXE);
90-
return (float) value;
89+
double value = AttributeProperty.getActualValue(stack, EquipmentSlot.MAINHAND, AttributeRegistry.MINING_SPEED_PICKAXE, 1);
90+
return (value == 0) ? 1.0f : (float) value;
9191
}
9292
if (state.isIn(BlockTags.AXE_MINEABLE)) {
93-
double value = AttributeProperty.getActualValue(stack, EquipmentSlot.MAINHAND, AttributeRegistry.MINING_SPEED_AXE);
94-
return (float) value;
93+
double value = AttributeProperty.getActualValue(stack, EquipmentSlot.MAINHAND, AttributeRegistry.MINING_SPEED_AXE, 1);
94+
return (value == 0) ? 1.0f : (float) value;
9595
}
9696
if (state.isIn(BlockTags.SHOVEL_MINEABLE)) {
97-
double value = AttributeProperty.getActualValue(stack, EquipmentSlot.MAINHAND, AttributeRegistry.MINING_SPEED_SHOVEL);
98-
return (float) value;
97+
double value = AttributeProperty.getActualValue(stack, EquipmentSlot.MAINHAND, AttributeRegistry.MINING_SPEED_SHOVEL, 1);
98+
return (value == 0) ? 1.0f : (float) value;
9999
}
100100
if (state.isIn(BlockTags.HOE_MINEABLE)) {
101-
double value = AttributeProperty.getActualValue(stack, EquipmentSlot.MAINHAND, AttributeRegistry.MINING_SPEED_HOE);
102-
return (float) value;
101+
double value = AttributeProperty.getActualValue(stack, EquipmentSlot.MAINHAND, AttributeRegistry.MINING_SPEED_HOE, 1);
102+
return (value == 0) ? 1.0f : (float) value;
103103
}
104104
return 1.0f;
105105
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,16 @@ public static void setup() {
187187

188188
// mining
189189
registerAtt("generic.mining_speed.pickaxe", false, () ->
190-
new ClampedEntityAttribute("miapi.attribute.name.mining_speed.pickaxe", 1.0, 1.0, 1024.0).setTracked(true),
190+
new ClampedEntityAttribute("miapi.attribute.name.mining_speed.pickaxe", 0.0, 0.0, 1024.0).setTracked(true),
191191
att -> MINING_SPEED_PICKAXE = att);
192192
registerAtt("generic.mining_speed.axe", false, () ->
193-
new ClampedEntityAttribute("miapi.attribute.name.mining_speed.axe", 1.0, 1.0, 1024.0).setTracked(true),
193+
new ClampedEntityAttribute("miapi.attribute.name.mining_speed.axe", 0.0, 0.0, 1024.0).setTracked(true),
194194
att -> MINING_SPEED_AXE = att);
195195
registerAtt("generic.mining_speed.shovel", false, () ->
196-
new ClampedEntityAttribute("miapi.attribute.name.mining_speed.shovel", 1.0, 1.0, 1024.0).setTracked(true),
196+
new ClampedEntityAttribute("miapi.attribute.name.mining_speed.shovel", 0.0, 0.0, 1024.0).setTracked(true),
197197
att -> MINING_SPEED_SHOVEL = att);
198198
registerAtt("generic.mining_speed.hoe", false, () ->
199-
new ClampedEntityAttribute("miapi.attribute.name.mining_speed.hoe", 1.0, 1.0, 1024.0).setTracked(true),
199+
new ClampedEntityAttribute("miapi.attribute.name.mining_speed.hoe", 0.0, 0.0, 1024.0).setTracked(true),
200200
att -> MINING_SPEED_HOE = att);
201201

202202
// entity attached
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"parent": "item/generated",
3+
"textures": {
4+
"layer0": "miapi:item/sword/blade/blade_voe"
5+
}
6+
}
Loading
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"name": "blade_voe",
3+
"texture": {
4+
"path": "miapi:models/item/sword/blade/voe/[material.texture].json",
5+
"transform": {
6+
"rotation": {
7+
"x": 0.0,
8+
"y": 0.0,
9+
"z": 0.0
10+
},
11+
"translation": {
12+
"x": -20.0,
13+
"y": -20.0,
14+
"z": 0.0
15+
},
16+
"scale": {
17+
"x": 2,
18+
"y": 2,
19+
"z": 1
20+
}
21+
}
22+
},
23+
"allowedInSlots": [
24+
"polearm_blade"
25+
],
26+
"allowedMaterial": {
27+
"allowedMaterials": [
28+
"wood",
29+
"stone",
30+
"metal",
31+
"crystal"
32+
],
33+
"cost": 1
34+
},
35+
"attributes": [
36+
{
37+
"attribute": "generic.attack_speed",
38+
"value": "-0.75",
39+
"operation": "+",
40+
"slot": "mainhand",
41+
"uuid": "FA233E1C-4180-4865-B01B-BCCE9785ACA3"
42+
},
43+
{
44+
"attribute": "generic.attack_damage",
45+
"value": "[material.hardness]*1.15",
46+
"operation": "+",
47+
"slot": "mainhand",
48+
"uuid": "CB3F55D3-645C-4F38-A497-9C13A33DB5CF"
49+
},
50+
{
51+
"attribute": "miapi:generic.shield_break",
52+
"value": "2",
53+
"operation": "+",
54+
"slot": "mainhand",
55+
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"
56+
},
57+
{
58+
"attribute": "miapi:generic.durability",
59+
"value": "[material.durability]* 0.25",
60+
"operation": "+",
61+
"slot": "mainhand",
62+
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"
63+
}
64+
],
65+
"guiOffset": {
66+
"sizeX": 3,
67+
"sizeY": 3
68+
},
69+
"displayName": "miapi.module.blade_greatsword.name",
70+
"itemId": "miapi:modular_greatsword"
71+
}

common/src/main/resources/data/miapi/modules/tool/head/axe_front.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,24 @@
7676
},
7777
{
7878
"attribute": "miapi:generic.durability",
79-
"value": "[material.durability]* 0.25",
79+
"value": "[material.durability]* 0.5",
8080
"operation": "+",
8181
"slot": "mainhand",
8282
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"
83+
},
84+
{
85+
"attribute": "generic.attack_damage",
86+
"value": "8",
87+
"operation": "+",
88+
"slot": "mainhand",
89+
"uuid": "CB3F55D3-645C-4F38-A497-9C13A33DB5CF"
90+
},
91+
{
92+
"attribute": "generic.attack_speed",
93+
"value": "+0.5",
94+
"operation": "+",
95+
"slot": "mainhand",
96+
"uuid": "FA233E1C-4180-4865-B01B-BCCE9785ACA3"
8397
}
8498
],
8599
"displayName": "miapi.module.axe_front.name",

common/src/main/resources/data/miapi/modules/tool/head/hoe_front.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
},
6161
{
6262
"attribute": "miapi:generic.durability",
63-
"value": "[material.durability]* 0.25",
63+
"value": "[material.durability]* 0.5",
6464
"operation": "+",
6565
"slot": "mainhand",
6666
"uuid": "AAAAAAAA-4180-4865-B01B-BCCE9785ACA3"

0 commit comments

Comments
 (0)