From 1b62f6ff801f315ea21b3b819a44a3dcd7c63dcc Mon Sep 17 00:00:00 2001 From: SD Date: Mon, 14 Mar 2022 22:50:32 +0530 Subject: [PATCH] Create item objects only if they're to be registered --- .../dimdoors/DimensionalDoorsInitializer.java | 4 +--- .../item/DimensionalDoorItemRegistrar.java | 18 +++++++------- .../mixin/client/BackgroundRendererMixin.java | 24 +++++++++---------- .../data/dimdoors/dimension_type/limbo.json | 2 +- .../data/dimdoors/dimension_type/pocket.json | 2 +- src/main/resources/dimdoors.mixins.json | 2 +- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java index 309dc72b..02e08513 100644 --- a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java +++ b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java @@ -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(); diff --git a/src/main/java/org/dimdev/dimdoors/item/DimensionalDoorItemRegistrar.java b/src/main/java/org/dimdev/dimdoors/item/DimensionalDoorItemRegistrar.java index 008b0a45..527b14ac 100644 --- a/src/main/java/org/dimdev/dimdoors/item/DimensionalDoorItemRegistrar.java +++ b/src/main/java/org/dimdev/dimdoors/item/DimensionalDoorItemRegistrar.java @@ -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> 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 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); + } } } diff --git a/src/main/java/org/dimdev/dimdoors/mixin/client/BackgroundRendererMixin.java b/src/main/java/org/dimdev/dimdoors/mixin/client/BackgroundRendererMixin.java index dd958400..6018af3e 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/client/BackgroundRendererMixin.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/client/BackgroundRendererMixin.java @@ -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; - } -} \ No newline at end of file +// @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; +// } +} diff --git a/src/main/resources/data/dimdoors/dimension_type/limbo.json b/src/main/resources/data/dimdoors/dimension_type/limbo.json index eb0ecd2e..59249cc7 100644 --- a/src/main/resources/data/dimdoors/dimension_type/limbo.json +++ b/src/main/resources/data/dimdoors/dimension_type/limbo.json @@ -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" } diff --git a/src/main/resources/data/dimdoors/dimension_type/pocket.json b/src/main/resources/data/dimdoors/dimension_type/pocket.json index d54ee29e..c0a47eab 100644 --- a/src/main/resources/data/dimdoors/dimension_type/pocket.json +++ b/src/main/resources/data/dimdoors/dimension_type/pocket.json @@ -12,6 +12,6 @@ "min_y": -16, "height": 256, "logical_height" : 256, - "infiniburn": "minecraft:infiniburn_overworld", + "infiniburn": "#minecraft:infiniburn_overworld", "ambient_light": 0 } diff --git a/src/main/resources/dimdoors.mixins.json b/src/main/resources/dimdoors.mixins.json index 2f2c0832..5271ae5c 100644 --- a/src/main/resources/dimdoors.mixins.json +++ b/src/main/resources/dimdoors.mixins.json @@ -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" ],