Skip to content

Commit

Permalink
fixed registration of tools and armor
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Jan 6, 2025
1 parent 48cbc6a commit cad446c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static void onRegister(final String domain) {
Registry.register(Registry.ITEM, new ResourceLocation(d, id), i);
AntimatterAPIImpl.registerItemTransferAPI(i);
});
if (domain.equals(Ref.SHARED_ID)) registerTools(domain);
registerTools(domain);
AntimatterAPI.all(BlockEntityType.class, domain, (t, d, i) -> {
Registry.register(Registry.BLOCK_ENTITY_TYPE, new ResourceLocation(d, i), t);
});
Expand Down Expand Up @@ -112,16 +112,16 @@ public Ingredient fromJson(JsonObject object) {
}

public static void registerTools(String domain) {
AntimatterAPI.all(AntimatterToolType.class, t -> {
AntimatterAPI.all(AntimatterToolType.class, domain, t -> {
List<IAntimatterTool> tools = t.isPowered() ? t.instantiatePoweredTools(domain) : t.instantiateTools(domain);
for (IAntimatterTool i : tools) {
Registry.register(Registry.ITEM, new ResourceLocation(domain, i.getId()), i.getItem());
}
});
AntimatterAPI.all(AntimatterArmorType.class, t -> {
AntimatterAPI.all(AntimatterArmorType.class, domain, t -> {
List<IAntimatterArmor> i = t.instantiateTools();
i.forEach(a -> {
Registry.register(Registry.ITEM, new ResourceLocation(Ref.SHARED_ID, a.getId()), a.getItem());
Registry.register(Registry.ITEM, new ResourceLocation(domain, a.getId()), a.getItem());
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static void onRegister(final String domain, final RegistryEvent.Register<
i.setRegistryName(d, id);
((IForgeRegistry) e.getRegistry()).register(i);
});
if (domain.equals(Ref.SHARED_ID)) registerTools(domain, e.getRegistry());
registerTools(domain, e.getRegistry());
} else if (e.getRegistry() == ForgeRegistries.BLOCK_ENTITIES) {
AntimatterAPI.all(BlockEntityType.class, domain, (t, d, i) -> {
if (t.getRegistryName() == null) t.setRegistryName(d, i);
Expand Down Expand Up @@ -171,17 +171,17 @@ public void write(FriendlyByteBuf arg, Ingredient arg2) {

@SuppressWarnings({"unchecked", "rawtypes"})
public static void registerTools(String domain, IForgeRegistry registry) {
AntimatterAPI.all(AntimatterToolType.class, t -> {
AntimatterAPI.all(AntimatterToolType.class, domain, t -> {
List<IAntimatterTool> tools = t.isPowered() ? t.instantiatePoweredTools(domain) : t.instantiateTools(domain);
for (IAntimatterTool i : tools) {
if (i.getItem().getRegistryName() == null) i.getItem().setRegistryName(domain, i.getId());
registry.register(i.getItem());
}
});
AntimatterAPI.all(AntimatterArmorType.class, t -> {
AntimatterAPI.all(AntimatterArmorType.class, domain, t -> {
List<IAntimatterArmor> i = t.instantiateTools();
i.forEach(a -> {
if (a.getItem().getRegistryName() == null) a.getItem().setRegistryName(Ref.SHARED_ID, a.getId());
if (a.getItem().getRegistryName() == null) a.getItem().setRegistryName(domain, a.getId());
registry.register(a.getItem());
});

Expand Down

0 comments on commit cad446c

Please sign in to comment.