Skip to content

Commit

Permalink
refactor: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed May 24, 2024
1 parent b9ff540 commit d14e3d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/main/java/net/zepalesque/redux/block/ReduxBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ public class ReduxBlocks {
public static DeferredBlock<AetherShortGrassBlock> SHORT_AETHER_GRASS = register("short_aether_grass",
() -> new AetherShortGrassBlock(
Properties.ofFullCopy(Blocks.SHORT_GRASS)
// TODO: Check if this is necessary
.hasPostProcess((state, level, pos) -> true)
));


private static <T extends Block> DeferredBlock<T> register(final String name, final Supplier<? extends T> block, Function<DeferredBlock<T>, Supplier<? extends Item>> item) {
DeferredBlock<T> obj = ReduxBlocks.BLOCKS.register(name, block);
ReduxItems.ITEMS.register(name, item.apply(obj));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

// TODO: Look over and see if things can be rewritten
import java.util.List;

public class AetherShortGrassBlock extends AetherBushBlock {
protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 7.0D, 14.0D);
protected static final VoxelShape SHAPE_TALL = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
protected static final VoxelShape SHAPE_SHORT = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 5.0D, 14.0D);
public static final List<VoxelShape> SHAPES = List.of(
Block.box(2.0D, 0.0D, 2.0D, 14.0D, 7.0D, 14.0D),
Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D),
Block.box(2.0D, 0.0D, 2.0D, 14.0D, 5.0D, 14.0D)
);
protected static VoxelShape COLLISION_SHAPE = Shapes.empty();

public AetherShortGrassBlock(Properties properties) {
Expand All @@ -37,12 +40,13 @@ public AetherShortGrassBlock(Properties properties) {
}
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
GrassSize size = pState.getValue(ReduxStates.GRASS_SIZE);
return size == GrassSize.small ? SHAPE_SHORT : size == GrassSize.tall ? SHAPE_TALL : SHAPE;
return SHAPES.get(size.ordinal());
}

@Override
public boolean canBeReplaced(BlockState pState, BlockPlaceContext pUseContext) {
return super.canBeReplaced(pState, pUseContext) && (pUseContext.getItemInHand().getItem() instanceof BlockItem blockItem && !blockItem.getBlock().builtInRegistryHolder().is(ReduxTags.Blocks.AETHER_GRASS_NONREPLACING));
return super.canBeReplaced(pState, pUseContext) &&
pUseContext.getItemInHand().is(ReduxTags.Items.AETHER_GRASS_NONREPLACING);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/zepalesque/redux/data/tags/ReduxTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public class ReduxTags {

public static class Blocks {

public static final TagKey<Block> AETHER_GRASS_NONREPLACING = tag("aether_grass_nonreplacing");

public static TagKey<Block> tag(String name) {
return TagKey.create(Registries.BLOCK, Redux.loc(name));
}
}

public static class Items {


public static final TagKey<Item> AETHER_GRASS_NONREPLACING = tag("aether_grass_nonreplacing");

public static TagKey<Item> tag(String name) {
return TagKey.create(Registries.ITEM, Redux.loc(name));
}
Expand Down

0 comments on commit d14e3d7

Please sign in to comment.