Skip to content

Commit

Permalink
Finally fixed block model rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
shurik204 committed Jan 27, 2024
1 parent f6a6e32 commit 82523cc
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 61 deletions.
24 changes: 13 additions & 11 deletions src/main/java/sonar/fluxnetworks/register/ClientRegistration.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
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;
import net.minecraft.client.color.block.BlockColors;
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;
Expand All @@ -26,6 +28,8 @@

import javax.annotation.Nonnull;

import static sonar.fluxnetworks.register.RegistryBlocks.*;

@Environment(EnvType.CLIENT)
public class ClientRegistration {
public static void init() {
Expand All @@ -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));
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"parent": "block/cube_all",
"render_type": "cutout",
"textures": {
"base": "fluxnetworks:block/base_color",
"texture": "fluxnetworks:block/storage/tier/basic",
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"parent": "block/cube_all",
"render_type": "cutout",
"textures": {
"0": "fluxnetworks:block/controller/bottom",
"1": "fluxnetworks:block/controller/texture",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"parent": "block/cube_all",
"render_type": "cutout",
"textures": {
"0":"fluxnetworks:block/plug/on",
"colour": "fluxnetworks:block/plug/color",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"parent": "block/cube_all",
"render_type": "cutout",
"textures": {
"0":"fluxnetworks:block/point/on",
"colour":"fluxnetworks:block/point/color",
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 82523cc

Please sign in to comment.