Skip to content

Commit

Permalink
修正格洛克去掉时,女仆枪械图标崩溃的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
TartaricAcid committed Nov 11, 2024
1 parent cab7be5 commit 945145c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import com.github.tartaricacid.touhoulittlemaid.compat.tacz.utils.GunBehaviorUtils;
import com.github.tartaricacid.touhoulittlemaid.config.subconfig.MaidConfig;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.init.InitItems;
import com.github.tartaricacid.touhoulittlemaid.init.InitSounds;
import com.github.tartaricacid.touhoulittlemaid.util.SoundUtil;
import com.google.common.collect.Lists;
import com.mojang.datafixers.util.Pair;
import com.tacz.guns.GunMod;
import com.tacz.guns.api.TimelessAPI;
import com.tacz.guns.api.item.IGun;
import com.tacz.guns.api.item.builder.GunItemBuilder;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -30,6 +32,7 @@

public class TaskGunAttack implements IAttackTask {
public static final ResourceLocation UID = new ResourceLocation(TouhouLittleMaid.MOD_ID, "gun_attack");
private ItemStack icon;

@Override
public ResourceLocation getUid() {
Expand All @@ -38,7 +41,12 @@ public ResourceLocation getUid() {

@Override
public ItemStack getIcon() {
return GunItemBuilder.create().setId(new ResourceLocation(GunMod.MOD_ID, "glock_17")).build();
ResourceLocation gunId = new ResourceLocation(GunMod.MOD_ID, "glock_17");
if (icon == null) {
TimelessAPI.getCommonGunIndex(gunId).ifPresentOrElse(index -> this.icon = GunItemBuilder.create().setId(gunId).build(),
() -> this.icon = InitItems.TACZ_GUN_ICON.get().getDefaultInstance());
}
return this.icon;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ public final class InitItems {
public static RegistryObject<Item> ALL_NETHERITE_EQUIPMENT = ITEMS.register("all_netherite_equipment", ItemAdvancementIcon::new);
public static RegistryObject<Item> KILL_WITHER = ITEMS.register("kill_wither", ItemAdvancementIcon::new);
public static RegistryObject<Item> KILL_DRAGON = ITEMS.register("kill_dragon", ItemAdvancementIcon::new);
public static RegistryObject<Item> TACZ_GUN_ICON = ITEMS.register("tacz_gun_icon", ItemAdvancementIcon::new);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "touhou_little_maid:item/tacz_gun_icon"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 945145c

Please sign in to comment.