MCPcopy Create free account
hub / github.com/MCModderAnchor/TACZ / TimelessAPI

Class TimelessAPI

src/main/java/com/tacz/guns/api/TimelessAPI.java:28–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26import java.util.Set;
27
28public final class TimelessAPI {
29 @OnlyIn(Dist.CLIENT)
30 public static Optional<GunDisplayInstance> getGunDisplay(ItemStack stack) {
31 if (stack.getItem() instanceof IGun iGun) {
32 ResourceLocation gunId = iGun.getGunId(stack);
33 if (getCommonGunIndex(gunId).isEmpty()) {
34 return Optional.empty();
35 }
36 ResourceLocation displayId = iGun.getGunDisplayId(stack);
37 if (displayId.equals(DefaultAssets.DEFAULT_GUN_DISPLAY_ID)) {
38 return getClientGunIndex(gunId).map(ClientGunIndex::getDefaultDisplay);
39 } else {
40 return getGunDisplay(displayId, gunId);
41 }
42 }
43 return Optional.empty();
44 }
45
46 @OnlyIn(Dist.CLIENT)
47 public static Optional<ClientGunIndex> getClientGunIndex(ResourceLocation gunId) {
48 return Optional.ofNullable(ClientIndexManager.GUN_INDEX.get(gunId));
49 }
50
51 @OnlyIn(Dist.CLIENT)
52 public static Optional<GunDisplayInstance> getGunDisplay(ResourceLocation displayId, ResourceLocation fallbackGunId) {
53 if (displayId == null || displayId.equals(DefaultAssets.DEFAULT_GUN_DISPLAY_ID)) {
54 return getClientGunIndex(fallbackGunId).map(ClientGunIndex::getDefaultDisplay);
55 }
56
57 GunDisplayInstance instance = ClientIndexManager.getOrCreateGunDisplay(displayId);
58 if (instance == null) {
59 return getClientGunIndex(fallbackGunId).map(ClientGunIndex::getDefaultDisplay);
60 }
61 return Optional.of(instance);
62 }
63
64 @OnlyIn(Dist.CLIENT)
65 public static Optional<ClientAttachmentIndex> getClientAttachmentIndex(ResourceLocation attachmentId) {
66 return Optional.ofNullable(ClientIndexManager.ATTACHMENT_INDEX.get(attachmentId));
67 }
68
69 @OnlyIn(Dist.CLIENT)
70 public static Optional<ClientAmmoIndex> getClientAmmoIndex(ResourceLocation ammoId) {
71 return Optional.ofNullable(ClientIndexManager.AMMO_INDEX.get(ammoId));
72 }
73
74 @OnlyIn(Dist.CLIENT)
75 public static Optional<ClientBlockIndex> getClientBlockIndex(ResourceLocation blockId) {
76 return Optional.ofNullable(ClientIndexManager.BLOCK_INDEX.get(blockId));
77 }
78
79 @OnlyIn(Dist.CLIENT)
80 public static Set<Map.Entry<ResourceLocation, ClientGunIndex>> getAllClientGunIndex() {
81 return ClientIndexManager.getAllGuns();
82 }
83
84 @OnlyIn(Dist.CLIENT)
85 public static Set<Map.Entry<ResourceLocation, ClientAmmoIndex>> getAllClientAmmoIndex() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected