IceMetalPunk Posted April 3, 2020 Posted April 3, 2020 (edited) I'm having some trouble with the model of a new block I've added in a mod I'm developing. The block is basically supposed to look like an upside-down composter in shape, with different textures. It can be filled, which is tied to a tile entity that updates its block state. The F3 menu shows that the block state is updating correctly as it fills, but even at state level=9, it never renders the "scarlet smoke" inside. I've gotten a similar block to work just fine right-side up without transparency, but this one (which uses the "translucent" render layer) isn't rendering the inner contents. (It also looks like there may be some weird rendering along the edge of the open face, but that's more minor.) I basically copied the model for my working right-side-up block, which in turn was slightly modified from the vanilla composter model. I then tried to modify the numbers and such to "flip it" so the open side was at the bottom instead of the top, and that's when things went wrong. I'm not sure if I have culling settings wrong, or if I've miscalculated the numbers for the vertices... I just know I can't get it to render right. Here's the blockstate, model, and texture files: https://www.dropbox.com/s/06vcd8kdd6yi3et/SA_Models.zip?dl=1 Can someone help me figure out where I've gone wrong? Rendering/modeling/art has never been my strong suit in any development... Edited April 7, 2020 by IceMetalPunk Solved Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheGreyGhost Posted April 4, 2020 Posted April 4, 2020 Hi My guess: { "textures": { "particle": "scarlet_alchemy:block/scarlet_smoke_0", "inside": "scarlet_alchemy:block/scarlet_smoke_0" }, "elements": [ { "from": [ 2, 0, 2 ], "to": [ 14, 15, 14 ], "faces": { "up": { "texture": "#inside", "cullface": "up" } } } ] } If you are trying to look at the inside from the bottom of the composter instead of the top, then you should be using "down", not "up". An "up" face with "cullface:up" is invisible from the bottom. It's only visible from the top side of the face, which I'm guessing is inside your block. -TGG 1 Quote
IceMetalPunk Posted April 5, 2020 Author Posted April 5, 2020 (edited) On 4/3/2020 at 8:08 PM, TheGreyGhost said: Hi My guess: { "textures": { "particle": "scarlet_alchemy:block/scarlet_smoke_0", "inside": "scarlet_alchemy:block/scarlet_smoke_0" }, "elements": [ { "from": [ 2, 0, 2 ], "to": [ 14, 15, 14 ], "faces": { "up": { "texture": "#inside", "cullface": "up" } } } ] } If you are trying to look at the inside from the bottom of the composter instead of the top, then you should be using "down", not "up". An "up" face with "cullface:up" is invisible from the bottom. It's only visible from the top side of the face, which I'm guessing is inside your block. -TGG Thank you! I think I'm starting to understand how culling and face definitions work a little better now. I've gotten my block to look nearly perfect. The only issue I'm having now is that when I place this block above a solid block, like grass, the block below culls its top face, which you can see through the transparent parts of my block's texture. This doesn't happen with vanilla transparent blocks, like glass, but I can't figure out what I need to specify to stop that from happening with mine. The vanilla glass blocks don't seem to have any special settings in their models for this, so I thought it must be code related, but I've copied the methods from AbstractGlassBlock that I thought were related to rendering, and it still has this issue. Here's the new models: https://www.dropbox.com/s/zl9x3ok7ipx649q/SA_Models_2.zip?dl=1 And here's the code for the ScarletCollectorBlock class: package com.icemetalpunk.scarlet_alchemy.blocks; import java.util.HashSet; import com.icemetalpunk.scarlet_alchemy.ScarletAlchemy; import com.icemetalpunk.scarlet_alchemy.tiles.SATileEntityProvider; import com.icemetalpunk.scarlet_alchemy.tiles.ScarletCollectorTileEntity; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.state.IntegerProperty; import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.IForgeRegistry; public class ScarletCollectorBlock extends Block implements SABlock, SATileEntityProvider { /* * FIXME: Model has broken/weird culling, making the filled smoke invisible * among other issues. */ protected SABlockAbilities blockAbilities = new SABlockAbilities(this); public static TileEntityType<?> teType; public static final IntegerProperty SMOKE_LEVEL = IntegerProperty.create("level", 0, 9); public ScarletCollectorBlock() { super(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.5F)); this.setRegistryName(new ResourceLocation(ScarletAlchemy.MOD_ID, "scarlet_collector")); this.setDefaultState(this.stateContainer.getBaseState().with(SMOKE_LEVEL, Integer.valueOf(0))); } @Override protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { builder.add(SMOKE_LEVEL); } @Override public boolean hasTileEntity(BlockState state) { return true; } @Override public TileEntity createTileEntity(final BlockState state, final IBlockReader world) { return new ScarletCollectorTileEntity(); } @OnlyIn(Dist.CLIENT) public float func_220080_a(BlockState state, IBlockReader worldIn, BlockPos pos) { return 1.0F; } public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { return true; } public boolean func_229869_c_(BlockState p_229869_1_, IBlockReader p_229869_2_, BlockPos p_229869_3_) { return false; } public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) { return false; } @Override public ActionResultType func_225533_a_(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) { // TOOD: Add right-click functionality? return ActionResultType.PASS; } @Override public boolean hasBlockItem() { return this.blockAbilities.hasBlockItem(); } @Override public BlockItem createBlockItem() { return this.blockAbilities.createBlockItem(new Item.Properties().maxStackSize(64)); } @Override public void registerItem(IForgeRegistry<Item> reg) { this.blockAbilities.registerItem(reg); } @Override public void registerTileEntity(IForgeRegistry<TileEntityType<? extends TileEntity>> reg) { HashSet<Block> blockSet = new HashSet<Block>(); blockSet.add(this); teType = (new TileEntityType<ScarletCollectorTileEntity>(() -> new ScarletCollectorTileEntity(), blockSet, null)).setRegistryName(this.getRegistryName()); reg.register(teType); } } I know some of those methods are missing their mappings; that's how they are in my copy of the AbstractGlassBlock class as well. Not sure why, but it seemed to work for another block of mine (scarlet smoke, a full translucent block), so I copied it over. I wondered if it was related to the material, but I tried using Material.GLASS instead of Material.ROCK and it still culled the top of the block below mine. Any suggestions? EDIT: I also found the isOpaqueCube method, but it seems that method is final and can't be overridden, so I'm not sure if there's something I need to do to work with that or not. I know vanilla glass blocks don't touch that, though, and they work, so... yeah, I'm lost Edited April 5, 2020 by IceMetalPunk Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
Animefan8888 Posted April 6, 2020 Posted April 6, 2020 3 hours ago, IceMetalPunk said: Any suggestions? RenderTypeLookup.setRenderLayer and RenderLayer.getCutoutMipped is the one you will want i think. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
IceMetalPunk Posted April 6, 2020 Author Posted April 6, 2020 3 minutes ago, Animefan8888 said: RenderTypeLookup.setRenderLayer and RenderLayer.getCutoutMipped is the one you will want i think. I'm already using the setRenderLayer method, but I'm setting it to the translucent layer. It needs to show the inner contents with an alpha channel (which it now is), so I can't use the cutout layer. I see vanilla stained glass blocks, ice blocks, etc. use the translucent layer as well, so shouldn't that do the job? Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheGreyGhost Posted April 6, 2020 Posted April 6, 2020 Hi Perhaps try the notSolid() property, I think that's how glass does it. public static final Block GLASS = register("glass", new GlassBlock(Block.Properties.create(Material.GLASS).hardnessAndResistance(0.3F).sound(SoundType.GLASS).notSolid())); -TGG 1 Quote
IceMetalPunk Posted April 7, 2020 Author Posted April 7, 2020 16 hours ago, TheGreyGhost said: Hi Perhaps try the notSolid() property, I think that's how glass does it. public static final Block GLASS = register("glass", new GlassBlock(Block.Properties.create(Material.GLASS).hardnessAndResistance(0.3F).sound(SoundType.GLASS).notSolid())); -TGG Yes! That was the missing piece, thank you so much! I could have sworn that method was related to movement, not rendering, probably because the field it clears is also cleared in the doesNotBlockMovement method... I guess it's just by default that things which don't block movement aren't considered to be solid renders, either. Anyway, thanks again, I'm glad this is finally solved Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.