如何制作半透明的流体方块?

LucunJi


版本信息
你使用的IDE:IDEA
你使用的IDE版本: 2019.3 x64
Forge版本: 1.15.2-31.1.17
Minecraft版本: 1.15.2
Mapping 文件版本: 20200225-1.15.1(snapshot)

错误情况简述
想制作一个像水一样半透明渲染的流体,但是实际效果是不透明的。

相关代码
方块注册:

@ObjectHolder(NoitaCraft.MOD_ID)
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class NoitaBlocks {
     @ObjectHolder("berserkium") public static FlowingFluidBlock BERSERKIUM;

    @SubscribeEvent
    public static void onBlockRegistry(final RegistryEvent.Register<Block> event) {
        event.getRegistry().register(new FlowingFluidBlock(() -> NoitaFluids.BERSERKIUM,
                Block.Properties.create(Material.WATER).doesNotBlockMovement().notSolid().hardnessAndResistance(100).noDrops()) {
            @Override
            public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) {
                if (entityIn instanceof LivingEntity) {
                    ((LivingEntity) entityIn).addPotionEffect(new EffectInstance(Effects.STRENGTH, 30));
                }
            }
        }
                .setRegistryName(NoitaCraft.MOD_ID, "berserkium"));
    }
}

流体注册:

@ObjectHolder(NoitaCraft.MOD_ID)
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class NoitaFluids {
    @ObjectHolder("berserkium") public static FlowingFluid BERSERKIUM;
    @ObjectHolder("flowing_berserkium") public static FlowingFluid FLOWING_BERSERKIUM;

    @SubscribeEvent
    public static void onFluidRegistry(final RegistryEvent.Register<Fluid> event) {
        ForgeFlowingFluid.Properties berserkiumProperties = new ForgeFlowingFluid.Properties(
                () -> BERSERKIUM,
                () -> FLOWING_BERSERKIUM,
                FluidAttributes.builder(
                        new ResourceLocation("block/water_still"),
                        new ResourceLocation("block/water_flow"))
                        .overlay(new ResourceLocation("block/water_overlay"))
                        .color(new Color(241, 97, 63).getRGB() + 0xFF000000)
                .luminosity(3)
        ).block(() -> NoitaBlocks.BERSERKIUM);
        event.getRegistry().registerAll(
                new ForgeFlowingFluid.Source(berserkiumProperties).setRegistryName(NoitaCraft.MOD_ID, "berserkium"),
                new ForgeFlowingFluid.Flowing(berserkiumProperties).setRegistryName(NoitaCraft.MOD_ID, "flowing_berserkium")
        );
    }
}

berserkium.json

{
  "variants": {
    "": { "model": "block/water" }
  }
}

查到的资料
试过 Forge 论坛上的 RenderTypeLookup,RenderTypeLookup.setRenderLayer(NoitaBlocks.BERSERKIUM, RenderType.getTranslucent()); 没用。


LucunJi


应当在客户端启动时对静止和流动的流体用

RenderTypeLookup.setRenderLayer(NoitaFluids.BERSERKIUM, RenderType.getTranslucent());
RenderTypeLookup.setRenderLayer(NoitaFluids.FLOWING_BERSERKIUM, RenderType.getTranslucent());

而非对方块调用,错误示范:
RenderTypeLookup.setRenderLayer(NoitaBlocks.BERSERKIUM, RenderType.getTranslucent());


system


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