diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppersClient.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppersClient.kt index 1002e28..0868b7c 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppersClient.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppersClient.kt @@ -1,18 +1,23 @@ package net.shadowfacts.extrahoppers import net.fabricmc.api.ClientModInitializer +import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap import net.fabricmc.fabric.api.client.screen.ContainerScreenFactory import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry +import net.minecraft.client.render.RenderLayer import net.shadowfacts.extrahoppers.block.gold.GoldHopperContainer import net.shadowfacts.extrahoppers.block.gold.GoldHopperScreen import net.shadowfacts.extrahoppers.block.wood.WoodHopperContainer import net.shadowfacts.extrahoppers.block.wood.WoodHopperScreen +import net.shadowfacts.extrahoppers.init.EHBlocks object ExtraHoppersClient: ClientModInitializer { override fun onInitializeClient() { ScreenProviderRegistry.INSTANCE.registerFactory(WoodHopperContainer.ID, ContainerScreenFactory(WoodHopperScreen.Companion::create)) ScreenProviderRegistry.INSTANCE.registerFactory(GoldHopperContainer.ID, ContainerScreenFactory(GoldHopperScreen.Companion::create)) + + BlockRenderLayerMap.INSTANCE.putBlock(EHBlocks.GRATE, RenderLayer.getCutout()) } } diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/grate/GrateBlock.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/grate/GrateBlock.kt index 1c65188..9cb7b23 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/block/grate/GrateBlock.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/grate/GrateBlock.kt @@ -4,6 +4,7 @@ import net.fabricmc.fabric.api.block.FabricBlockSettings import net.minecraft.block.* import net.minecraft.block.enums.BlockHalf import net.minecraft.entity.EntityContext +import net.minecraft.entity.EntityType import net.minecraft.fluid.Fluid import net.minecraft.fluid.FluidState import net.minecraft.fluid.Fluids @@ -37,8 +38,8 @@ class GrateBlock: BlockWithEntity( val HALF = Properties.BLOCK_HALF - val TOP_SHAPE = createCuboidShape(0.0, 15.0, 0.0, 16.0, 16.0, 16.0) - val BOTTOM_SHAPE = createCuboidShape(0.0, 0.0, 0.0, 16.0, 1.0, 16.0) + val TOP_SHAPE = createCuboidShape(0.0, 14.0, 0.0, 16.0, 16.0, 16.0) + val BOTTOM_SHAPE = createCuboidShape(0.0, 0.0, 0.0, 16.0, 2.0, 16.0) } init { @@ -75,6 +76,18 @@ class GrateBlock: BlockWithEntity( override fun createBlockEntity(world: BlockView) = GrateBlockEntity() + override fun isTranslucent(state: BlockState, world: BlockView, pos: BlockPos): Boolean { + return true + } + + override fun isSimpleFullBlock(state: BlockState, world: BlockView, pos: BlockPos): Boolean { + return false + } + + override fun allowsSpawning(state: BlockState, world: BlockView, pos: BlockPos, entityType: EntityType<*>): Boolean { + return false + } + override fun getFluidState(state: BlockState, world: BlockView, pos: BlockPos): FluidState { return getBlockEntity(world, pos)?.fluidState ?: Fluids.EMPTY.defaultState } diff --git a/src/main/resources/assets/extrahoppers/models/block/grate.json b/src/main/resources/assets/extrahoppers/models/block/grate.json index c1596c1..9862a7f 100644 --- a/src/main/resources/assets/extrahoppers/models/block/grate.json +++ b/src/main/resources/assets/extrahoppers/models/block/grate.json @@ -1,20 +1,124 @@ { "ambientocclusion": false, "textures": { - "face": "extrahoppers:block/grate/face", - "edge": "extrahoppers:block/grate/edge" + "face": "extrahoppers:block/grate", + "edge": "extrahoppers:block/grate_edge", + "internal": "extrahoppers:block/grate_internal", + "particle": "#face" }, "elements": [ { - "from": [0, 15, 0], + "from": [0, 14, 0], + "to": [1, 16, 16], + "faces": { + "down": {"texture": "#face"}, + "up": {"texture": "#face", "cullface": "up"}, + "west": {"texture": "#edge", "cullface": "west"}, + "east": {"texture": "#edge"}, + "north": {"texture": "#edge", "cullface": "north"}, + "south": {"texture": "#edge", "cullface": "south"} + } + }, + { + "from": [15, 14, 0], "to": [16, 16, 16], "faces": { "down": {"texture": "#face"}, "up": {"texture": "#face", "cullface": "up"}, + "west": {"texture": "#edge"}, + "east": {"texture": "#edge", "cullface": "east"}, "north": {"texture": "#edge", "cullface": "north"}, - "south": {"texture": "#edge", "cullface": "south"}, - "west": {"texture": "#edge", "cullface": "west"}, - "east": {"texture": "#edge", "cullface": "east"} + "south": {"texture": "#edge", "cullface": "south"} + } + }, + { + "from": [1, 14, 0], + "to": [15, 16, 1], + "faces": { + "down": {"texture": "#face", "uv": [1, 0, 15, 1]}, + "up": {"texture": "#face", "cullface": "up", "uv": [1, 0, 15, 1]}, + "north": {"texture": "#edge"}, + "south": {"texture": "#edge", "cullface": "south"} + } + }, + { + "from": [1, 14, 15], + "to": [15, 16, 16], + "faces": { + "down": {"texture": "#face", "uv": [1, 0, 15, 1]}, + "up": {"texture": "#face", "cullface": "up", "uv": [1, 0, 15, 1]}, + "north": {"texture": "#edge", "cullface": "north"}, + "south": {"texture": "#edge"} + } + }, + { + "from": [1, 14, 7], + "to": [2, 16, 9], + "faces": { + "down": {"texture": "#face", "uv": [1, 7, 2, 9]}, + "up": {"texture": "#face", "cullface": "up", "uv": [1, 7, 2, 9]}, + "north": {"texture": "#face", "uv": [1, 7, 2, 9]}, + "south": {"texture": "#face", "uv": [1, 7, 2, 9]} + } + }, + { + "from": [2, 14, 1], + "to": [4, 16, 15], + "faces": { + "down": {"texture": "#face", "uv": [2, 1, 4, 15]}, + "up": {"texture": "#face", "cullface": "up", "uv": [2, 1, 4, 15]}, + "west": {"texture": "#internal", "uv": [1, 2, 15, 4]}, + "east": {"texture": "#internal", "uv": [1, 2, 15, 4]} + } + }, + { + "from": [4, 14, 2], + "to": [7, 16, 4], + "faces": { + "down": {"texture": "#face", "uv": [4, 2, 7, 4]}, + "up": {"texture": "#face", "cullface": "up", "uv": [4, 2, 7, 4]}, + "north": {"texture": "#face", "uv": [4, 2, 7, 4]}, + "south": {"texture": "#face", "uv": [4, 2, 7, 4]} + } + }, + { + "from": [7, 14, 1], + "to": [9, 16, 15], + "faces": { + "down": {"texture": "#face", "uv": [7, 1, 9, 15]}, + "up": {"texture": "#face", "cullface": "up", "uv": [7, 1, 9, 15]}, + "west": {"texture": "#internal", "uv": [1, 7, 15, 9]}, + "east": {"texture": "#internal", "uv": [1, 7, 15, 9]} + } + }, + { + "from": [9, 14, 12], + "to": [12, 16, 14], + "faces": { + "down": {"texture": "#face", "uv": [9, 12, 12, 14]}, + "up": {"texture": "#face", "cullface": "up", "uv": [9, 12, 12, 14]}, + "north": {"texture": "#face", "uv": [9, 12, 12, 14]}, + "south": {"texture": "#face", "uv": [9, 12, 12, 14]} + } + }, + { + "from": [12, 14, 1], + "to": [14, 16, 15], + "faces": { + "down": {"texture": "#face", "uv": [12, 1, 14, 15]}, + "up": {"texture": "#face", "cullface": "up", "uv": [12, 1, 14, 15]}, + "west": {"texture": "#internal", "uv": [1, 12, 15, 14]}, + "east": {"texture": "#internal", "uv": [1, 12, 15, 14]} + } + }, + { + "from": [14, 14, 7], + "to": [15, 16, 9], + "faces": { + "down": {"texture": "#face", "uv": [14, 7, 15, 9]}, + "up": {"texture": "#face", "cullface": "up", "uv": [14, 7, 15, 9]}, + "north": {"texture": "#face", "uv": [14, 7, 15, 9]}, + "south": {"texture": "#face", "uv": [14, 7, 15, 9]} } } ], diff --git a/src/main/resources/assets/extrahoppers/textures/block/grate.png b/src/main/resources/assets/extrahoppers/textures/block/grate.png new file mode 100644 index 0000000..4ac6926 Binary files /dev/null and b/src/main/resources/assets/extrahoppers/textures/block/grate.png differ diff --git a/src/main/resources/assets/extrahoppers/textures/block/grate_edge.png b/src/main/resources/assets/extrahoppers/textures/block/grate_edge.png new file mode 100644 index 0000000..36f24cb Binary files /dev/null and b/src/main/resources/assets/extrahoppers/textures/block/grate_edge.png differ diff --git a/src/main/resources/assets/extrahoppers/textures/block/grate_internal.png b/src/main/resources/assets/extrahoppers/textures/block/grate_internal.png new file mode 100644 index 0000000..591a96e Binary files /dev/null and b/src/main/resources/assets/extrahoppers/textures/block/grate_internal.png differ