Skip to content

Commit

Permalink
Fixed #114 Removed redundant rope block checking logic
Browse files Browse the repository at this point in the history
Eliminated the block state checking for ropes surrounding the HopsCropBlock. This simplifies the generation of voxel shapes and reduces unnecessary complexity.
  • Loading branch information
Alatyami committed Sep 6, 2024
1 parent fa441fe commit a055e12
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/main/java/growthcraft/cellar/block/HopsCropBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import growthcraft.core.block.RopeBlock;
import growthcraft.core.init.GrowthcraftTags;
import growthcraft.lib.block.GrowthcraftCropsRopeBlock;
import growthcraft.lib.utils.BlockStateUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
Expand All @@ -29,10 +28,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;

import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class HopsCropBlock extends GrowthcraftCropsRopeBlock {

Expand All @@ -55,16 +52,7 @@ public HopsCropBlock() {
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
VoxelShape ropeVoxel = super.getShape(state, worldIn, pos, context);

ArrayList<VoxelShape> voxelShapeArrayList = new ArrayList<VoxelShape>();
Map<String, BlockState> blockMap = BlockStateUtils.getSurroundingBlockState(worldIn, pos);

if (blockMap.get("north").is(GrowthcraftTags.Blocks.ROPE)) voxelShapeArrayList.add(NORTH_BOUNDING_BOX);
if (blockMap.get("east").is(GrowthcraftTags.Blocks.ROPE)) voxelShapeArrayList.add(EAST_BOUNDING_BOX);
if (blockMap.get("south").is(GrowthcraftTags.Blocks.ROPE)) voxelShapeArrayList.add(SOUTH_BOUNDING_BOX);
if (blockMap.get("west").is(GrowthcraftTags.Blocks.ROPE)) voxelShapeArrayList.add(WEST_BOUNDING_BOX);
if (blockMap.get("above").is(GrowthcraftTags.Blocks.ROPE)) voxelShapeArrayList.add(UP_BOUNDING_BOX);
if (blockMap.get("below").is(GrowthcraftTags.Blocks.ROPE)) voxelShapeArrayList.add(DOWN_BOUNDING_BOX);

ArrayList<VoxelShape> voxelShapeArrayList = new ArrayList<>();
voxelShapeArrayList.add(CUSTOM_SHAPE_BY_AGE[state.getValue(AGE)]);
voxelShapeArrayList.add(ropeVoxel);

Expand Down

0 comments on commit a055e12

Please sign in to comment.