Skip to content

Commit

Permalink
Add double tall plant renderer (#5964)
Browse files Browse the repository at this point in the history
  • Loading branch information
voidsong-dragonfly authored Jun 20, 2024
1 parent 731e77e commit 9c07555
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ private void flowers(RecipeOutput out)
flower(out, Blocks.LILY_OF_THE_VALLEY);
flower(out, Blocks.CORNFLOWER);
flower(out, Blocks.BLUE_ORCHID, Blocks.MUD);
flower(out, Blocks.LILAC);
flower(out, Blocks.SUNFLOWER);
flower(out, Blocks.ROSE_BUSH);
flower(out, Blocks.PEONY);
doubleFlower(out, Blocks.LILAC);
doubleFlower(out, Blocks.SUNFLOWER);
doubleFlower(out, Blocks.ROSE_BUSH);
doubleFlower(out, Blocks.PEONY);
flower(out, Blocks.WITHER_ROSE, Blocks.SOUL_SOIL);
}

Expand All @@ -129,11 +129,25 @@ private void flower(RecipeOutput out, Block flowerBlock, ItemLike soil)
.setRender(new RenderFunctionGeneric(flowerBlock))
.build(out, toRL("cloche/"+flowerBlock.builtInRegistryHolder().key().location().getPath()));
}
private void doubleFlower(RecipeOutput out, Block flowerBlock, ItemLike soil)
{
ClocheRecipeBuilder.builder()
.output(flowerBlock)
.seed(flowerBlock)
.soil(soil)
.setTime(480)
.setRender(new RenderFunctionDoubleFlower(flowerBlock))
.build(out, toRL("cloche/"+flowerBlock.builtInRegistryHolder().key().location().getPath()));
}

private void flower(RecipeOutput out, Block flowerBlock)
{
flower(out, flowerBlock, Blocks.DIRT);
}
private void doubleFlower(RecipeOutput out, Block flowerBlock)
{
doubleFlower(out, flowerBlock, Blocks.DIRT);
}

private void mushrooms(RecipeOutput out)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.block.state.properties.Property;
import org.joml.Vector3f;
Expand All @@ -49,6 +51,7 @@ public static void init()
register("stem", RenderFunctionStem.CODEC);
register("generic", RenderFunctionGeneric.CODEC);

register("doubleflower", RenderFunctionDoubleFlower.CODEC);
register("hemp", RenderFunctionHemp.CODEC);
register("chorus", RenderFunctionChorus.CODEC);
}
Expand Down Expand Up @@ -243,6 +246,41 @@ public Codec<? extends ClocheRenderFunction> codec()
}
}

public static class RenderFunctionDoubleFlower implements ClocheRenderFunction
{
public static final Codec<RenderFunctionDoubleFlower> CODEC = byBlockCodec(f -> f.cropBlock, RenderFunctionDoubleFlower::new);

final Block cropBlock;

public RenderFunctionDoubleFlower(Block cropBlock)
{
this.cropBlock = cropBlock;
}

@Override
public float getScale(ItemStack seed, float growth)
{
return 0.75f;
}

@Override
public Collection<Pair<BlockState, Transformation>> getBlocks(ItemStack stack, float growth)
{
Vector3f transl = new Vector3f(0.5f-growth/2, 0, 0.5f-growth/2);
Vector3f transl1 = new Vector3f(0.5f-growth/2, 0+growth, 0.5f-growth/2);
Vector3f scale = new Vector3f(growth, growth, growth);
return ImmutableList.of(
Pair.of(this.cropBlock.defaultBlockState(), new Transformation(transl, null, scale, null)),
Pair.of(this.cropBlock.defaultBlockState().setValue(DoublePlantBlock.HALF, DoubleBlockHalf.UPPER), new Transformation(transl1, null, scale, null)));
}

@Override
public Codec<? extends ClocheRenderFunction> codec()
{
return CODEC;
}
}

public static class RenderFunctionChorus implements ClocheRenderFunction
{
public static final Codec<RenderFunctionChorus> CODEC = Codec.unit(new RenderFunctionChorus());
Expand Down

0 comments on commit 9c07555

Please sign in to comment.