Skip to content

Commit

Permalink
3.1 flower tub and aquarium fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
finallion committed Dec 31, 2023
1 parent 6539a6a commit 0f48cb1
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
if (itemStack.isIn(VPTags.TALL_PLANTABLE_ITEMS) && state.get(FLOWERS) == 0) {
blockEntity.insertFlower(itemStack, state.get(FLOWERS));

if (!player.isCreative()) {
itemStack.decrement(1);
}
if (!world.isClient()) {
world.setBlockState(pos, state.with(FLOWERS, 4).with(IS_TALL_FLOWER, true), 3);
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, pos);
Expand All @@ -62,9 +59,6 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
} else if (itemStack.isIn(VPTags.SMALL_PLANTABLE_ITEMS)) {
blockEntity.insertFlower(itemStack, state.get(FLOWERS));

if (!player.isCreative()) {
itemStack.decrement(1);
}
if (!world.isClient()) {
world.setBlockState(pos, state.with(FLOWERS, state.get(FLOWERS) + 1).with(IS_TALL_FLOWER, false), 3);
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
if (itemStack.isIn(VPTags.AQUARIUM_PLANTABLE_ITEMS) && state.get(CORALS) < 4) {
blockEntity.insertCoral(itemStack, state.get(CORALS));

if (!player.isCreative()) {
itemStack.decrement(1);
}

if (!world.isClient()) {
world.setBlockState(pos, state.with(CORALS, state.get(CORALS) + 1), 3);
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, pos);
Expand All @@ -73,10 +69,6 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
} else if (itemStack.getItem() instanceof EntityBucketItem bucketItem && state.get(FISH) < 1) {
blockEntity.insertCoral(itemStack, 4);

if (!player.isCreative()) {
itemStack.decrement(1);
}

if (!world.isClient()) {
world.setBlockState(pos, state.with(FISH, state.get(FISH) + 1), 3);
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, pos);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lion.villagersplus.client.renderer;

import com.lion.villagersplus.VillagersPlus;
import com.lion.villagersplus.blockentities.HorticulturistTableBlockEntity;
import com.lion.villagersplus.blocks.HorticulturistTableBlock;
import net.minecraft.block.*;
Expand All @@ -18,6 +19,34 @@
import net.minecraft.world.World;

public class HorticulturistTableBlockEntityRenderer implements BlockEntityRenderer<HorticulturistTableBlockEntity> {

public static float[] twoFlowerXOffset = new float[]{
VillagersPlus.CONFIG.first_flower_in_two_X_offset,
VillagersPlus.CONFIG.second_flower_in_two_X_offset};
public static float[] twoFlowerZOffset = new float[]{
VillagersPlus.CONFIG.first_flower_in_two_Z_offset,
VillagersPlus.CONFIG.second_flower_in_two_Z_offset};

public static float[] threeFlowerXOffset = new float[]{
VillagersPlus.CONFIG.first_flower_in_three_X_offset,
VillagersPlus.CONFIG.second_flower_in_three_X_offset,
VillagersPlus.CONFIG.third_flower_in_three_X_offset};
public static float[] threeFlowerZOffset = new float[]{
VillagersPlus.CONFIG.first_flower_in_three_Z_offset,
VillagersPlus.CONFIG.second_flower_in_three_Z_offset,
VillagersPlus.CONFIG.third_flower_in_three_Z_offset};

public static float[] fourFlowerXOffset = new float[]{
VillagersPlus.CONFIG.first_flower_in_four_X_offset,
VillagersPlus.CONFIG.second_flower_in_four_X_offset,
VillagersPlus.CONFIG.third_flower_in_four_X_offset,
VillagersPlus.CONFIG.forth_flower_in_four_X_offset};
public static float[] fourFlowerZOffset = new float[]{
VillagersPlus.CONFIG.first_flower_in_four_Z_offset,
VillagersPlus.CONFIG.second_flower_in_four_Z_offset,
VillagersPlus.CONFIG.third_flower_in_four_Z_offset,
VillagersPlus.CONFIG.forth_flower_in_four_Z_offset};

private final BlockRenderManager manager;

public HorticulturistTableBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) {
Expand All @@ -28,77 +57,79 @@ public void render(HorticulturistTableBlockEntity blockEntity, float f, MatrixSt
BlockState blockState = blockEntity.getCachedState();
BlockPos pos = blockEntity.getPos();
DefaultedList<ItemStack> defaultedList = blockEntity.getInventory();
World world = blockEntity.getWorld();

if (blockState.getBlock() instanceof HorticulturistTableBlock) {
matrixStack.push();
if (blockState.get(HorticulturistTableBlock.IS_TALL_FLOWER)) {
Block flower = Block.getBlockFromItem(defaultedList.get(0).getItem());
if (flower instanceof TallPlantBlock) {
Vec3d offset = flower.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
Vec3d offset = flower.getDefaultState().getModelOffset(world, pos);
matrixStack.translate(-offset.x, -offset.y + 0.95D, -offset.z);
renderTallFlower(flower.getDefaultState().getBlock(), blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, true, j);
renderTallFlower(flower.getDefaultState().getBlock(), world, pos, matrixStack, vertexConsumerProvider, true, j);
matrixStack.translate(-offset.x, -offset.y + 1.0D, -offset.z);
renderTallFlower(flower.getDefaultState().getBlock(), blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, false, j);
renderTallFlower(flower.getDefaultState().getBlock(), world, pos, matrixStack, vertexConsumerProvider, false, j);
} else {
Block flowerOne = Block.getBlockFromItem(defaultedList.get(0).getItem());
if (flowerOne.getDefaultState().isOf(Blocks.CACTUS)) {
matrixStack.scale(0.75F, 0.75F, 0.75F);
matrixStack.translate(0.15D, 0.15D, 0.15D);
}

Vec3d offset = flowerOne.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
Vec3d offset = flowerOne.getDefaultState().getModelOffset(world, pos);
matrixStack.translate(-offset.x, -offset.y + 0.95D, -offset.z);
renderFlower(Block.getBlockFromItem(defaultedList.get(0).getItem()), blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
renderFlower(Block.getBlockFromItem(defaultedList.get(0).getItem()), world, pos, matrixStack, vertexConsumerProvider, j);
}
} else {

switch (blockState.get(HorticulturistTableBlock.FLOWERS)) {
case 1 -> {
Block flowerOne = Block.getBlockFromItem(defaultedList.get(0).getItem());
Vec3d offset = flowerOne.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
Vec3d offset = flowerOne.getDefaultState().getModelOffset(world, pos);
matrixStack.translate(-offset.x, -offset.y + 0.95D, -offset.z);
renderFlower(flowerOne, blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
renderFlower(flowerOne, world, pos, matrixStack, vertexConsumerProvider, j);
}
case 2 -> {
Block flowerOne = Block.getBlockFromItem(defaultedList.get(0).getItem());
Block flowerTwo = Block.getBlockFromItem(defaultedList.get(1).getItem());
Vec3d offset = flowerOne.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
Vec3d offset2 = flowerTwo.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
matrixStack.translate(-offset.x + 0.15D, -offset.y + 0.95D, -offset.z + 0.15D);
renderFlower(flowerOne, blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset2.x - 0.3D, -offset2.y, -offset2.z - 0.3D - 0.05D);
renderFlower(flowerTwo, blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
Vec3d offset = flowerOne.getDefaultState().getModelOffset(world, pos);
Vec3d offset2 = flowerTwo.getDefaultState().getModelOffset(world, pos);
matrixStack.translate(-offset.x + twoFlowerXOffset[0], -offset.y + 0.95D, -offset.z + twoFlowerZOffset[0]);
renderFlower(flowerOne, world, pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset2.x + twoFlowerXOffset[1], -offset2.y, -offset2.z + twoFlowerZOffset[1]);
renderFlower(flowerTwo, world, pos, matrixStack, vertexConsumerProvider, j);
}
case 3 -> {
Block flowerOne = Block.getBlockFromItem(defaultedList.get(0).getItem());
Block flowerTwo = Block.getBlockFromItem(defaultedList.get(1).getItem());
Block flowerThree = Block.getBlockFromItem(defaultedList.get(2).getItem());
Vec3d offset = flowerOne.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
Vec3d offset2 = flowerTwo.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
Vec3d offset3 = flowerThree.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
matrixStack.translate(-offset.x + 0.15D, -offset.y + 0.95D, -offset.z);
renderFlower(flowerOne, blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset2.x - 0.3D, -offset2.y - 0.05D, -offset2.z - 0.15D);
renderFlower(flowerTwo, blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset3.x -0.05D, -offset3.y + 0, -offset3.z + 0.3D);
renderFlower(flowerThree, blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
Vec3d offset = flowerOne.getDefaultState().getModelOffset(world, pos);
Vec3d offset2 = flowerTwo.getDefaultState().getModelOffset(world, pos);
Vec3d offset3 = flowerThree.getDefaultState().getModelOffset(world, pos);
matrixStack.translate(-offset.x + threeFlowerXOffset[0], -offset.y + 0.95D, -offset.z + threeFlowerZOffset[0]);
renderFlower(flowerOne, world, pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset2.x + threeFlowerXOffset[1], -offset2.y - 0.05D, -offset2.z + threeFlowerZOffset[1]);
renderFlower(flowerTwo, world, pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset3.x + threeFlowerXOffset[2], -offset3.y + 0, -offset3.z + threeFlowerZOffset[2]);
renderFlower(flowerThree, world, pos, matrixStack, vertexConsumerProvider, j);
}
case 4 -> {
Block flowerOne = Block.getBlockFromItem(defaultedList.get(0).getItem());
Block flowerTwo = Block.getBlockFromItem(defaultedList.get(1).getItem());
Block flowerThree = Block.getBlockFromItem(defaultedList.get(2).getItem());
Block flowerFour = Block.getBlockFromItem(defaultedList.get(3).getItem());
Vec3d offset = flowerOne.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
Vec3d offset2 = flowerTwo.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
Vec3d offset3 = flowerThree.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
Vec3d offset4 = flowerFour.getDefaultState().getModelOffset(blockEntity.getWorld(), pos);
matrixStack.translate(-offset.x + 0.15D, -offset.y + 0.95D, -offset.z + 0.15D);
renderFlower(flowerOne, blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset2.x, -offset2.y - 0.05D, -offset2.z - 0.3D - 0.05D);
renderFlower(Block.getBlockFromItem(defaultedList.get(1).getItem()), blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset3.x - 0.3D, -offset3.y + 0, -offset3.z);
renderFlower(Block.getBlockFromItem(defaultedList.get(2).getItem()), blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset4.x - 0.05D, -offset4.y - 0.05D, -offset4.z + 0.37D);
renderFlower(Block.getBlockFromItem(defaultedList.get(3).getItem()), blockEntity.getWorld(), pos, matrixStack, vertexConsumerProvider, j);
Vec3d offset = flowerOne.getDefaultState().getModelOffset(world, pos);
Vec3d offset2 = flowerTwo.getDefaultState().getModelOffset(world, pos);
Vec3d offset3 = flowerThree.getDefaultState().getModelOffset(world, pos);
Vec3d offset4 = flowerFour.getDefaultState().getModelOffset(world, pos);
matrixStack.translate(-offset.x + fourFlowerXOffset[0], -offset.y + 0.95D, -offset.z + fourFlowerZOffset[0]);
renderFlower(flowerOne, world, pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset2.x + fourFlowerXOffset[1], -offset2.y - 0.05D, -offset2.z + fourFlowerZOffset[1]);
renderFlower(Block.getBlockFromItem(defaultedList.get(1).getItem()), world, pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset3.x + fourFlowerXOffset[2], -offset3.y + 0, -offset3.z + fourFlowerZOffset[2]);
renderFlower(Block.getBlockFromItem(defaultedList.get(2).getItem()), world, pos, matrixStack, vertexConsumerProvider, j);
matrixStack.translate(-offset4.x + fourFlowerXOffset[3], -offset4.y - 0.05D, -offset4.z + fourFlowerZOffset[3]);
renderFlower(Block.getBlockFromItem(defaultedList.get(3).getItem()), world, pos, matrixStack, vertexConsumerProvider, j);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ public void render(OceanographerTableBlockEntity blockEntity, float f, MatrixSta
Entity fish = type.create(world);

if (fish != null && itemStack.getNbt() != null) {
fish.readNbt(itemStack.getOrCreateNbt());
if (fish instanceof AxolotlEntity axolotl && itemStack.getNbt().contains("Variant")) {
axolotl.setVariant(AxolotlEntity.Variant.byId(itemStack.getNbt().getInt("Variant")));
}

if (fish instanceof TropicalFishEntity && itemStack.getNbt().contains("BucketVariantTag")) {
fish.readNbt(itemStack.getOrCreateNbt());

int id = itemStack.getNbt().getInt("BucketVariantTag");
DyeColor pattern = TropicalFishEntity.getPatternDyeColor(id);
DyeColor base = TropicalFishEntity.getBaseDyeColor(id);
Expand Down
41 changes: 36 additions & 5 deletions common/src/main/java/com/lion/villagersplus/config/VPConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,64 @@ public String getDirectory() {
@Description("Weight of the house in the village structure pool. Higher values increase the chance of generating.")
public int plains_alchemist_weight = 10;
public int plains_occultist_weight = 10;
public int plains_horticulturist_weight = 10;
public int plains_horticulturist_weight = 7;
public int plains_oceanographer_weight = 15;

@Description("Weight of the house in a village. Higher values increase the chance of generating.")
public int taiga_alchemist_weight = 10;
public int taiga_occultist_weight = 10;
public int taiga_horticulturist_weight = 10;
public int taiga_horticulturist_weight = 7;
public int taiga_oceanographer_weight = 15;

@Description("Weight of the house in a village. Higher values increase the chance of generating.")
public int savanna_alchemist_weight = 10;
public int savanna_occultist_weight = 10;
public int savanna_horticulturist_weight = 10;
public int savanna_horticulturist_weight = 7;
public int savanna_oceanographer_weight = 15;

@Description("Weight of the house in a village. Higher values increase the chance of generating.")
public int snowy_alchemist_weight = 10;
public int snowy_occultist_weight = 10;
public int snowy_horticulturist_weight = 10;
public int snowy_horticulturist_weight = 7;
public int snowy_oceanographer_weight = 15;

@Description("Weight of the house in a village. Higher values increase the chance of generating.")
public int desert_alchemist_weight = 10;
public int desert_occultist_weight = 10;
public int desert_horticulturist_weight = 10;
public int desert_horticulturist_weight = 7;
public int desert_oceanographer_weight = 15;

@Description("Two flower offsets in flower tub for small flowers. Each offset is added to the following offsets.")
public float first_flower_in_two_X_offset = 0.15F;
public float first_flower_in_two_Z_offset = 0.15F;

public float second_flower_in_two_X_offset = -0.3F;
public float second_flower_in_two_Z_offset = -0.35F;

@Description("Three flower offsets in flower tub for small flowers. Each offset is added to the following offsets.")
public float first_flower_in_three_X_offset = 0.15F;
public float first_flower_in_three_Z_offset = 0F;

public float second_flower_in_three_X_offset = -0.3F;
public float second_flower_in_three_Z_offset = -0.15F;

public float third_flower_in_three_X_offset = -0.05F;
public float third_flower_in_three_Z_offset = 0.3F;

@Description("Four flower offsets in flower tub for small flowers. Each offset is added to the following offsets.")
public float first_flower_in_four_X_offset = 0.15F;
public float first_flower_in_four_Z_offset = 0.15F;

public float second_flower_in_four_X_offset = 0F;
public float second_flower_in_four_Z_offset = -0.35F;

public float third_flower_in_four_X_offset = -0.3F;
public float third_flower_in_four_Z_offset = 0F;

public float forth_flower_in_four_X_offset = -0.05F;
public float forth_flower_in_four_Z_offset = 0.37F;


}


Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void init() {
public static final Predicate<RegistryEntry<PointOfInterestType>> HORTICULTURIST_PREDICATE = (registryEntry) -> registryEntry.value() ==
VPPointOfInterestTypes.HORTICULTURIST_ACACIA_POI.get()
|| registryEntry.value() == VPPointOfInterestTypes.HORTICULTURIST_BAMBOO_POI.get()
|| registryEntry.value() == VPPointOfInterestTypes.HORTICULTURIST_OAK_POI.get()
|| registryEntry.value() == VPPointOfInterestTypes.HORTICULTURIST_BIRCH_POI.get()
|| registryEntry.value() == VPPointOfInterestTypes.HORTICULTURIST_CHERRY_POI.get()
|| registryEntry.value() == VPPointOfInterestTypes.HORTICULTURIST_CRIMSON_POI.get()
Expand Down
Loading

0 comments on commit 0f48cb1

Please sign in to comment.