From 82523ccc9a2ac42155c5ab6d72173dc79b126705 Mon Sep 17 00:00:00 2001 From: shurik204 Date: Sat, 27 Jan 2024 18:26:05 +0200 Subject: [PATCH] Finally fixed block model rendering --- .../register/ClientRegistration.java | 24 +++--- .../models/block/basic_flux_storage.json | 1 - .../models/block/flux_connection.json | 74 ++++++++----------- .../models/block/flux_controller.json | 1 - .../fluxnetworks/models/block/flux_plug.json | 1 - .../fluxnetworks/models/block/flux_point.json | 1 - .../models/block/gargantuan_flux_storage.json | 1 - .../models/block/herculean_flux_storage.json | 1 - 8 files changed, 43 insertions(+), 61 deletions(-) diff --git a/src/main/java/sonar/fluxnetworks/register/ClientRegistration.java b/src/main/java/sonar/fluxnetworks/register/ClientRegistration.java index 7d25409..7309b58 100644 --- a/src/main/java/sonar/fluxnetworks/register/ClientRegistration.java +++ b/src/main/java/sonar/fluxnetworks/register/ClientRegistration.java @@ -3,6 +3,7 @@ import io.github.fabricators_of_create.porting_lib.event.client.ColorHandlersCallback; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.event.client.player.ClientPickBlockGatherCallback; import net.minecraft.client.Minecraft; @@ -10,6 +11,7 @@ import net.minecraft.client.color.item.ItemColors; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.ItemStack; @@ -26,6 +28,8 @@ import javax.annotation.Nonnull; +import static sonar.fluxnetworks.register.RegistryBlocks.*; + @Environment(EnvType.CLIENT) public class ClientRegistration { public static void init() { @@ -35,6 +39,12 @@ public static void init() { ); registerEntityRenderers(); ColorHandlersCallback.ITEM.register(ClientRegistration::registerColorHandlers); + BlockRenderLayerMap.INSTANCE.putBlocks(RenderType.cutout(), FLUX_PLUG, + FLUX_POINT, + FLUX_CONTROLLER, + BASIC_FLUX_STORAGE, + HERCULEAN_FLUX_STORAGE, + GARGANTUAN_FLUX_STORAGE); ClientPlayNetworking.registerGlobalReceiver(Channel.CHANNEL_NAME, (client, handler, buf, responseSender) -> ClientMessages.msg(buf.readShort(), buf, () -> Minecraft.getInstance().player)); @@ -79,20 +89,12 @@ public static void registerEntityRenderers() { public static void registerColorHandlers(ItemColors itemColors, BlockColors blockColors) { // Items - itemColors.register(FluxColorHandler.INSTANCE, - RegistryBlocks.FLUX_CONTROLLER, - RegistryBlocks.FLUX_POINT, - RegistryBlocks.FLUX_PLUG); + itemColors.register(FluxColorHandler.INSTANCE, FLUX_CONTROLLER, FLUX_POINT, FLUX_PLUG); itemColors.register(FluxColorHandler::colorMultiplierForConfigurator, RegistryItems.FLUX_CONFIGURATOR); // Blocks - blockColors.register(FluxColorHandler.INSTANCE, - RegistryBlocks.FLUX_CONTROLLER, - RegistryBlocks.FLUX_POINT, - RegistryBlocks.FLUX_PLUG, - RegistryBlocks.BASIC_FLUX_STORAGE, - RegistryBlocks.HERCULEAN_FLUX_STORAGE, - RegistryBlocks.GARGANTUAN_FLUX_STORAGE); + blockColors.register(FluxColorHandler.INSTANCE, FLUX_CONTROLLER, FLUX_POINT, FLUX_PLUG, + BASIC_FLUX_STORAGE, HERCULEAN_FLUX_STORAGE, GARGANTUAN_FLUX_STORAGE); } } \ No newline at end of file diff --git a/src/main/resources/assets/fluxnetworks/models/block/basic_flux_storage.json b/src/main/resources/assets/fluxnetworks/models/block/basic_flux_storage.json index ef1074e..38439f8 100644 --- a/src/main/resources/assets/fluxnetworks/models/block/basic_flux_storage.json +++ b/src/main/resources/assets/fluxnetworks/models/block/basic_flux_storage.json @@ -1,6 +1,5 @@ { "parent": "block/cube_all", - "render_type": "cutout", "textures": { "base": "fluxnetworks:block/base_color", "texture": "fluxnetworks:block/storage/tier/basic", diff --git a/src/main/resources/assets/fluxnetworks/models/block/flux_connection.json b/src/main/resources/assets/fluxnetworks/models/block/flux_connection.json index 7d9295e..3a14f8a 100644 --- a/src/main/resources/assets/fluxnetworks/models/block/flux_connection.json +++ b/src/main/resources/assets/fluxnetworks/models/block/flux_connection.json @@ -1,62 +1,48 @@ { "parent": "block/cube_all", - "render_type": "cutout", "textures": { - "0":"fluxnetworks:block/plug/on", - "colour": "fluxnetworks:block/plug/color", - "particle":"fluxnetworks:block/plug/on" + "0": "fluxnetworks:block/plug/on", + "color": "fluxnetworks:block/plug/color", + "particle": "fluxnetworks:block/plug/on" }, "elements": [ { - "name":"Connection1", - "from": [ 7.0, 1.0, 7.0 ], - "to": [ 9.0, 6.0, 9.0 ], + "name": "connection_shaft", + "from": [7, 1, 7], + "to": [9, 6, 9], "faces": { - "north": { "texture":"#0", "uv": [ 0.0, 0.0, 2.0, 5.0 ] }, - "east": { "texture":"#0", "uv": [ 0.0, 0.0, 2.0, 5.0 ] }, - "south": { "texture":"#0", "uv": [ 0.0, 0.0, 2.0, 5.0 ] }, - "west": { "texture":"#0", "uv": [ 0.0, 0.0, 2.0, 5.0 ] }, - "up": { "texture":"#0", "uv": [ 0.0, 0.0, 2.0, 2.0 ] }, - "down": { "texture":"#0", "uv": [ 0.0, 0.0, 2.0, 2.0 ] } + "north": {"uv": [0, 0, 2, 5], "texture": "#0"}, + "east": {"uv": [0, 0, 2, 5], "texture": "#0"}, + "south": {"uv": [0, 0, 2, 5], "texture": "#0"}, + "west": {"uv": [0, 0, 2, 5], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 2], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 2], "texture": "#0"} } }, { - "name":"Connection2", - "from": [ 5.0, 0.0, 5.0 ], - "to": [ 11.0, 1.0, 11.0 ], + "name": "connection_plane", + "from": [5, 0, 5], + "to": [11, 1, 11], "faces": { - "north": { "texture":"#0", "uv": [ 0.0, 0.0, 6.0, 1.0 ] }, - "east": { "texture":"#0", "uv": [ 0.0, 0.0, 6.0, 1.0 ] }, - "south": { "texture":"#0", "uv": [ 0.0, 0.0, 6.0, 1.0 ] }, - "west": { "texture":"#0", "uv": [ 0.0, 0.0, 6.0, 1.0 ] }, - "up": { "texture":"#0", "uv": [ 10.0, 10.0, 16.0, 16.0 ] }, - "down": { "texture":"#0", "uv": [ 10.0, 10.0, 16.0, 16.0 ] } + "north": {"uv": [0, 0, 6, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 6, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 6, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 6, 1], "texture": "#0"}, + "up": {"uv": [10, 10, 16, 16], "texture": "#0"}, + "down": {"uv": [10, 10, 16, 16], "texture": "#0"} } }, { - "name":"Colour1", - "from": [ 7.0, 1.0, 7.0 ], - "to": [ 9.0, 6.0, 9.0 ], + "name": "Color", + "from": [7, 0, 7], + "to": [9, 0, 9], "faces": { - "north": { "texture":"#colour", "uv": [ 0.0, 0.0, 2.0, 5.0 ], "tintindex": 1 }, - "east": { "texture":"#colour", "uv": [ 0.0, 0.0, 2.0, 5.0 ], "tintindex": 1 }, - "south": { "texture":"#colour", "uv": [ 0.0, 0.0, 2.0, 5.0 ], "tintindex": 1 }, - "west": { "texture":"#colour", "uv": [ 0.0, 0.0, 2.0, 5.0 ], "tintindex": 1 }, - "up": { "texture":"#colour", "uv": [ 0.0, 0.0, 2.0, 2.0 ], "tintindex": 1 }, - "down": { "texture":"#colour", "uv": [ 0.0, 0.0, 2.0, 2.0 ], "tintindex": 1 } - } - }, - { - "name":"Colour2", - "from": [ 5.0, 0.0, 5.0 ], - "to": [ 11.0, 1.0, 11.0 ], - "faces": { - "north": { "texture":"#colour", "uv": [ 0.0, 0.0, 6.0, 1.0 ], "tintindex": 1 }, - "east": { "texture":"#colour", "uv": [ 0.0, 0.0, 6.0, 1.0 ], "tintindex": 1 }, - "south": { "texture":"#colour", "uv": [ 0.0, 0.0, 6.0, 1.0 ], "tintindex": 1 }, - "west": { "texture":"#colour", "uv": [ 0.0, 0.0, 6.0, 1.0 ], "tintindex": 1 }, - "up": { "texture":"#colour", "uv": [ 10.0, 10.0, 16.0, 16.0 ], "tintindex": 1 }, - "down": { "texture":"#colour", "uv": [ 10.0, 10.0, 16.0, 16.0 ], "tintindex": 1 } + "north": {"uv": [0, 0, 6, 1], "texture": "#color", "tintindex": 1}, + "east": {"uv": [0, 0, 6, 1], "texture": "#color", "tintindex": 1}, + "south": {"uv": [0, 0, 6, 1], "texture": "#color", "tintindex": 1}, + "west": {"uv": [0, 0, 6, 1], "texture": "#color", "tintindex": 1}, + "up": {"uv": [10, 10, 16, 16], "texture": "#color", "tintindex": 1}, + "down": {"uv": [12, 12, 14, 14], "texture": "#color", "tintindex": 1} } } ] diff --git a/src/main/resources/assets/fluxnetworks/models/block/flux_controller.json b/src/main/resources/assets/fluxnetworks/models/block/flux_controller.json index c1ffd22..4cd6266 100644 --- a/src/main/resources/assets/fluxnetworks/models/block/flux_controller.json +++ b/src/main/resources/assets/fluxnetworks/models/block/flux_controller.json @@ -1,6 +1,5 @@ { "parent": "block/cube_all", - "render_type": "cutout", "textures": { "0": "fluxnetworks:block/controller/bottom", "1": "fluxnetworks:block/controller/texture", diff --git a/src/main/resources/assets/fluxnetworks/models/block/flux_plug.json b/src/main/resources/assets/fluxnetworks/models/block/flux_plug.json index f83b933..087052a 100644 --- a/src/main/resources/assets/fluxnetworks/models/block/flux_plug.json +++ b/src/main/resources/assets/fluxnetworks/models/block/flux_plug.json @@ -1,6 +1,5 @@ { "parent": "block/cube_all", - "render_type": "cutout", "textures": { "0":"fluxnetworks:block/plug/on", "colour": "fluxnetworks:block/plug/color", diff --git a/src/main/resources/assets/fluxnetworks/models/block/flux_point.json b/src/main/resources/assets/fluxnetworks/models/block/flux_point.json index 214536d..370b5f2 100644 --- a/src/main/resources/assets/fluxnetworks/models/block/flux_point.json +++ b/src/main/resources/assets/fluxnetworks/models/block/flux_point.json @@ -1,6 +1,5 @@ { "parent": "block/cube_all", - "render_type": "cutout", "textures": { "0":"fluxnetworks:block/point/on", "colour":"fluxnetworks:block/point/color", diff --git a/src/main/resources/assets/fluxnetworks/models/block/gargantuan_flux_storage.json b/src/main/resources/assets/fluxnetworks/models/block/gargantuan_flux_storage.json index 46f72ca..4a4e4b5 100644 --- a/src/main/resources/assets/fluxnetworks/models/block/gargantuan_flux_storage.json +++ b/src/main/resources/assets/fluxnetworks/models/block/gargantuan_flux_storage.json @@ -1,6 +1,5 @@ { "parent": "fluxnetworks:block/basic_flux_storage", - "render_type": "cutout", "textures": { "base": "fluxnetworks:block/base_color", "texture": "fluxnetworks:block/storage/tier/gargantuan", diff --git a/src/main/resources/assets/fluxnetworks/models/block/herculean_flux_storage.json b/src/main/resources/assets/fluxnetworks/models/block/herculean_flux_storage.json index 0b2e67e..7a120ef 100644 --- a/src/main/resources/assets/fluxnetworks/models/block/herculean_flux_storage.json +++ b/src/main/resources/assets/fluxnetworks/models/block/herculean_flux_storage.json @@ -1,6 +1,5 @@ { "parent": "fluxnetworks:block/basic_flux_storage", - "render_type": "cutout", "textures": { "base": "fluxnetworks:block/base_color", "texture": "fluxnetworks:block/storage/tier/herculean",