Identifier stillSpriteLocation = new Identifier("block/water_still"); Identifier dynamicSpriteLocation = new Identifier("block/water_flow"); // here I tell to use only 16x16 area of the water texture FabricSprite stillAcidSprite = new FabricSprite(stillSpriteLocation, 16, 16); // same, but 32 FabricSprite dynamicAcidSprite = new FabricSprite(dynamicSpriteLocation, 32, 32); registry.register(stillAcidSprite); registry.register(dynamicAcidSprite); // this renderer is responsible for drawing fluids in a world FluidRenderHandler acidRenderHandler = new FluidRenderHandler() { // return the sprites: still sprite goes first into the array, flowing/dynamic goes last @Override public Sprite[] getFluidSprites(ExtendedBlockView extendedBlockView, BlockPos blockPos, FluidState fluidState) { return new Sprite[] {stillAcidSprite, dynamicAcidSprite}; }
// apply light green color @Override public int getFluidColor(ExtendedBlockView view, BlockPos pos, FluidState state) { return 0x4cc248; } };
// registering the same renderer for both fluid variants is intentional
FluidRenderHandlerRegistry.INSTANCE.register(Mod.stillAcid, acidRenderHandler); FluidRenderHandlerRegistry.INSTANCE.register(Mod.flowingAcid, acidRenderHandler); });</code> 然后剩下要做的就是创建必要的Json文件和纹理,但是您现在应该知道该怎么做。 ===== Generation in a world ===== 要在世界上产生酸湖,可以使用在ModInitializer中创建的 net.minecraft.world.gen.feature.LakeFeature :
LakeFeature acidFeature = Registry.register(Registry.FEATURE, new Identifier(MODID,"acid_lake"), new LakeFeature(dynamic -> new LakeFeatureConfig(acid.getDefaultState())));然后将其放入所需的生物群系中以生成:
// I tell it to generate like water lakes, with a rarity of 40 (the higher is the number, the lesser is the generation chance): Biomes.FOREST.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, Biome.configureFeature(acidFeature, new LakeFeatureConfig(acid.getDefaultState()), Decorator.WATER_LAKE, new LakeDecoratorConfig(40)));本教程到此结束。