Skip to content

Commit a081d28

Browse files
committed
- bugfix update
1 parent f1ca7c6 commit a081d28

File tree

7 files changed

+43
-20
lines changed

7 files changed

+43
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
## v1.1.11 (1.20.1)
22
- fixed bug were wood tag wasnt picked up correctly
3-
- added config option for max generated materials to prevent crashes with default of 200 per type (generated,wood,stone)
3+
- fixed crash related to block ability
4+
- added config option for max generated materials to prevent crashes with default of 200 per type (generated,wood,stone)
5+
- minor fixes for generated Materials
6+
- fixed issues were woods were listed as stones and vice versa

common/src/main/java/smartin/miapi/client/atlas/MaterialSpriteManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class MaterialSpriteManager {
3232
})
3333
.build(new CacheLoader<>() {
3434
@Override
35-
public Identifier load(Holder key) throws Exception {
35+
public Identifier load(Holder key) {
3636
return getMaterialSprite(key);
3737
}
3838
});

common/src/main/java/smartin/miapi/item/modular/items/ModularCrossbow.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.fabricmc.api.EnvType;
55
import net.fabricmc.api.Environment;
66
import net.minecraft.advancement.criterion.Criteria;
7+
import net.minecraft.client.item.TooltipContext;
78
import net.minecraft.enchantment.EnchantmentHelper;
89
import net.minecraft.enchantment.Enchantments;
910
import net.minecraft.entity.CrossbowUser;
@@ -16,19 +17,18 @@
1617
import net.minecraft.item.*;
1718
import net.minecraft.nbt.NbtCompound;
1819
import net.minecraft.nbt.NbtList;
20+
import net.minecraft.screen.ScreenTexts;
1921
import net.minecraft.server.network.ServerPlayerEntity;
2022
import net.minecraft.sound.SoundCategory;
2123
import net.minecraft.sound.SoundEvents;
2224
import net.minecraft.stat.Stats;
2325
import net.minecraft.text.Text;
24-
import net.minecraft.util.Hand;
25-
import net.minecraft.util.Identifier;
26-
import net.minecraft.util.Rarity;
27-
import net.minecraft.util.TypedActionResult;
26+
import net.minecraft.util.*;
2827
import net.minecraft.util.math.MathHelper;
2928
import net.minecraft.util.math.Vec3d;
3029
import net.minecraft.util.math.random.Random;
3130
import net.minecraft.world.World;
31+
import org.jetbrains.annotations.Nullable;
3232
import org.joml.Quaternionf;
3333
import org.joml.Vector3f;
3434
import smartin.miapi.Miapi;
@@ -295,7 +295,7 @@ private static void clearProjectiles(ItemStack crossbow) {
295295
nbtList.clear();
296296
nbtCompound.put("ChargedProjectiles", nbtList);
297297
}
298-
298+
crossbow.setNbt(nbtCompound);
299299
}
300300

301301
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
@@ -345,6 +345,26 @@ public static List<ItemStack> getProjectiles(ItemStack crossbow) {
345345
return list;
346346
}
347347

348+
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
349+
List<ItemStack> list = getProjectiles(stack);
350+
if (isCharged(stack) && !list.isEmpty()) {
351+
ItemStack itemStack = (ItemStack) list.get(0);
352+
tooltip.add(Text.translatable("item.minecraft.crossbow.projectile").append(ScreenTexts.SPACE).append(itemStack.toHoverableText()));
353+
if (context.isAdvanced() && itemStack.isOf(Items.FIREWORK_ROCKET)) {
354+
List<Text> list2 = Lists.newArrayList();
355+
Items.FIREWORK_ROCKET.appendTooltip(itemStack, world, list2, context);
356+
if (!list2.isEmpty()) {
357+
for (int i = 0; i < list2.size(); ++i) {
358+
list2.set(i, Text.literal(" ").append((Text) list2.get(i)).formatted(Formatting.GRAY));
359+
}
360+
361+
tooltip.addAll(list2);
362+
}
363+
}
364+
365+
}
366+
}
367+
348368
public Predicate<ItemStack> getProjectiles() {
349369
return itemStack -> projectile.test(itemStack) || IsCrossbowShootAble.canCrossbowShoot(itemStack);
350370
}

common/src/main/java/smartin/miapi/modules/abilities/util/ItemAbilityManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import net.minecraft.util.UseAction;
1313
import net.minecraft.world.World;
1414
import org.jetbrains.annotations.Nullable;
15-
import smartin.miapi.Miapi;
1615
import smartin.miapi.modules.cache.ModularItemCache;
1716
import smartin.miapi.modules.properties.AbilityMangerProperty;
1817
import smartin.miapi.modules.properties.AbilityProperty;
@@ -68,12 +67,8 @@ private static ItemUseAbility getAbility(ItemStack itemStack) {
6867
}
6968

7069
private static ItemUseAbility getAbility(ItemStack itemStack, World world, PlayerEntity player, Hand hand, AbilityHitContext abilityHitContext) {
71-
Miapi.LOGGER.info("searching for ability " + itemStack.getTranslationKey());
7270
for (ItemUseAbility ability : AbilityMangerProperty.get(itemStack)) {
73-
Miapi.LOGGER.info("checking ability " + useAbilityRegistry.findKey(ability));
7471
if (ability.allowedOnItem(itemStack, world, player, hand, abilityHitContext)) {
75-
Miapi.LOGGER.info("Found ability" + useAbilityRegistry.findKey(ability));
76-
Miapi.LOGGER.info("for Item " + itemStack.getTranslationKey());
7772
return ability;
7873
}
7974
}

common/src/main/java/smartin/miapi/modules/material/GeneratedMaterial.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ public void interpretDataClient(PacketByteBuf buf) {
100100
genMaterials = buf.readInt();
101101
for (int i = 0; i < genMaterials; i++) {
102102
Item item = buf.readItemStack().getItem();
103-
stoneMaterials.add(item);
103+
woodMaterials.add(item);
104104
}
105105
genMaterials = buf.readInt();
106106
for (int i = 0; i < genMaterials; i++) {
107107
Item item = buf.readItemStack().getItem();
108-
woodMaterials.add(item);
108+
stoneMaterials.add(item);
109109
}
110110
synchronized (generatedItems) {
111111
generatedItems.clear();
@@ -210,8 +210,11 @@ public static void onReloadServer() {
210210
if (isValidItem(item)) {
211211
woodItems.add(item);
212212
GeneratedMaterial generatedMaterial = new GeneratedMaterial(ToolMaterials.WOOD, item.getDefaultStack(), false);
213-
materials.put(generatedMaterial.getKey(), generatedMaterial);
214-
generatedMaterial.copyStatsFrom(materials.get("wood"));
213+
if (MaterialProperty.getMaterialFromIngredient(item.getDefaultStack()) != materials.get("wood")) {
214+
materials.put(generatedMaterial.getKey(), generatedMaterial);
215+
generatedMaterial.copyStatsFrom(materials.get("wood"));
216+
217+
}
215218
}
216219
});
217220
}
@@ -225,8 +228,10 @@ public static void onReloadServer() {
225228
if (isValidItem(item)) {
226229
stoneItems.add(item);
227230
GeneratedMaterial generatedMaterial = new GeneratedMaterial(ToolMaterials.STONE, item.getDefaultStack(), false);
228-
materials.put(generatedMaterial.getKey(), generatedMaterial);
229-
generatedMaterial.copyStatsFrom(materials.get("stone"));
231+
if (MaterialProperty.getMaterialFromIngredient(item.getDefaultStack()) != materials.get("stone")) {
232+
materials.put(generatedMaterial.getKey(), generatedMaterial);
233+
generatedMaterial.copyStatsFrom(materials.get("stone"));
234+
}
230235
}
231236
});
232237
}

common/src/main/java/smartin/miapi/modules/material/JsonMaterial.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public Double getPriorityOfIngredientItem(ItemStack itemStack) {
248248
String tagId = itemObj.get("tag").getAsString();
249249
TagKey<Item> tag = TagKey.of(Registries.ITEM.getKey(), new Identifier(tagId));
250250
if (tag != null && itemStack.isIn(tag)) {
251-
return 1.0;
251+
return 10.0;
252252
}
253253
}
254254
}

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=Truly-Modular-miapi
6-
mod_version=1.1.10
6+
mod_version=1.1.11
77
maven_group=smartin
88
github=Truly-Modular.Modular-Item-API
99

0 commit comments

Comments
 (0)