Create item objects only if they're to be registered

This commit is contained in:
SD 2022-03-14 22:50:32 +05:30
parent 7255862de5
commit 1b62f6ff80
6 changed files with 25 additions and 27 deletions

View file

@ -115,9 +115,7 @@ public class DimensionalDoorsInitializer implements ModInitializer {
public void onInitialize() {
apiSubscribers = FabricLoader.getInstance().getEntrypoints("dimdoors:api", DimensionalDoorsApi.class);
dimDoorsMod = FabricLoader.getInstance().getModContainer("dimdoors").orElseThrow(RuntimeException::new);
ServerLifecycleEvents.SERVER_STARTING.register((minecraftServer) -> {
server = minecraftServer;
});
ServerLifecycleEvents.SERVER_STARTING.register(minecraftServer -> server = minecraftServer);
registerRegistries();

View file

@ -98,7 +98,7 @@ public class DimensionalDoorItemRegistrar {
return;
}
register(identifier, original, dimItemConstructor.apply(blocksAlreadyNotifiedAbout.get(originalBlock)));
register(identifier, original, blocksAlreadyNotifiedAbout.get(originalBlock), dimItemConstructor);
}
}
@ -108,17 +108,17 @@ public class DimensionalDoorItemRegistrar {
return;
}
Triple<Identifier, Item, Function<Block, BlockItem>> triple = toBeMapped.get(original);
register(triple.getLeft(), triple.getMiddle(), triple.getRight().apply(dimBlock));
register(triple.getLeft(), triple.getMiddle(), dimBlock, triple.getRight());
}
private void register(Identifier identifier, Item original, BlockItem dimItem) {
Identifier gennedId = new Identifier("dimdoors", PREFIX + identifier.getNamespace() + "_" + identifier.getPath());
private void register(Identifier identifier, Item original, Block block, Function<Block, BlockItem> dimItem) {
if (!DoorData.PARENT_ITEMS.contains(original)) {
Registry.register(registry, gennedId, dimItem);
}
placementFunctions.put(original, dimItem::place);
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
registerItemRenderer(dimItem);
Identifier gennedId = new Identifier("dimdoors", PREFIX + identifier.getNamespace() + "_" + identifier.getPath());
BlockItem item = Registry.register(registry, gennedId, dimItem.apply(block));
placementFunctions.put(original, item::place);
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
registerItemRenderer(item);
}
}
}

View file

@ -15,15 +15,15 @@ import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
@Mixin(BackgroundRenderer.class)
public class BackgroundRendererMixin {
@ModifyVariable(
method = "render",
at = @At(value = "STORE", ordinal = 0),
ordinal = 0
)
private static double modifyVoidColor(double scale) {
if(ModDimensions.isPrivatePocketDimension(MinecraftClient.getInstance().world)) {
scale = 1.0;
}
return scale;
}
// @ModifyVariable(
// method = "render",
// at = @At(value = "STORE", ordinal = 0),
// ordinal = 0
// )
// private static double modifyVoidColor(double scale) {
// if(ModDimensions.isPrivatePocketDimension(MinecraftClient.getInstance().world)) {
// scale = 1.0;
// }
// return scale;
// }
}

View file

@ -12,7 +12,7 @@
"min_y": 0,
"height": 256,
"logical_height": 256,
"infiniburn": "minecraft:infiniburn_overworld",
"infiniburn": "#minecraft:infiniburn_overworld",
"ambient_light": 0.1,
"effects": "dimdoors:limbo"
}

View file

@ -12,6 +12,6 @@
"min_y": -16,
"height": 256,
"logical_height" : 256,
"infiniburn": "minecraft:infiniburn_overworld",
"infiniburn": "#minecraft:infiniburn_overworld",
"ambient_light": 0
}

View file

@ -29,6 +29,7 @@
"accessor.StatsAccessor"
],
"client": [
"client.BackgroundRendererMixin",
"client.ClientPlayerInteractionManagerMixin",
"client.ClientPlayNetworkHandlerMixin",
"client.ExtendedClientPlayNetworkHandlerMixin",
@ -36,7 +37,6 @@
"client.InGameHudMixin",
"client.PostProcessShaderMixin",
"client.WorldRendererMixin",
"client.BackgroundRendererMixin",
"client.accessor.RenderLayerAccessor",
"client.accessor.WorldRendererAccessor"
],