1.14.4-28.1.0树叶方块添加颜色

暗夜


自己制作了几颗树,但是树叶是以灰度图的样子被渲染了出来。
构造树叶方块仿照了原版的方法:

new LeavesBlock(Block.Properties.create(Material.LEAVES).hardnessAndResistance(0.2F).tickRandomly().sound(SoundType.PLANT)

在mod主类中添加了如下方法:

@SubscribeEvent
public void blockColors(ColorHandlerEvent.Block event) {
    event.getBlockColors().register(new ModBlockTinter(), OTLBlocks.pinus_caribaea_leaves, OTLBlocks.pinus_palustris_leaves, OTLBlocks.pinus_taeda_leaves);
}

ModBlockTinter类:

public class ModBlockTinter implements IBlockColor {
    @Override
    public int getColor(BlockState state, @Nullable IEnviromentBlockReader p_getColor_2_, @Nullable BlockPos pos, int tineIndex) {
        return 2319364;
    }
}

blockstates:

{
  "variants": {
    "": { "model": "ontheland:block/pinus_caribaea_leaves" }
  }
}

models/block:

  "parent": "block/block",
  "textures": {
    "all": "ontheland:block/pinus_caribaea_leaves",
    "particle": "#all"
  },
  "elements": [
    {
      "from": [0, 0, 0],
      "to": [16, 16, 16],
      "faces": {
        "down": {"texture": "#all","tintindex": 1,"cullface": "down"},
        "up": {"texture": "#all","tintindex": 2,"cullface": "up"},
        "north": {"texture": "#all","tintindex": 3,"cullface": "north"},
        "south": {"texture": "#all","tintindex": 4,"cullface": "south"},
        "west": {"texture": "#all","tintindex": 5,"cullface": "west"},
        "east": {"texture": "#all","tintindex": 6,"cullface": "east"}
      }
    }
  ]
}

对了,tags标签也加了。我应该怎么做


FledgeXu


首先你让你的叶子继承于LeavesBlock试试。
另外叶子的颜色不是由叶子自己决定的,是由生物群系决定的,具体原理我也不是很清楚。


暗夜


问题解决了,之前的方法全部废弃。
解决方法参见:Forge 文档
最后还是回到了最初的地方 :joy:


system


该主题在最后一个回复创建后7天后自动关闭。不再允许新的回复。