Skip to content

Commit

Permalink
[~+] v2.0 progress
Browse files Browse the repository at this point in the history
CHANGELOG.md describes all
  • Loading branch information
crispytwig committed May 26, 2024
1 parent c3a87f0 commit 7c78af8
Show file tree
Hide file tree
Showing 61 changed files with 2,116 additions and 97 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# CHANGELOG
- ### There's a config now !!
- ### Urns can now be interacted with Dirt -- when they are filled in this way, plants can be placed atop them.
- To remove the Dirt, simply right-click the Urn with any Shovel -- this uses the #minecraft:shovels tag, so any item tagged as a Shovel will work.
- Urns utilize Supplementaries' "prevents_offset_above" tag, so when using Supplementaries, plants will not have a random offset when placed inside of Urns. This prevents them from being placed on the edges of the Urn.
- ### Stone Frames + Frame Tweaks
- Frames now have custom hitboxes, and can be interacted through. Their more precise hitboxes will be replaced with a larger hitbox when holding Hammers or Frames or crouching.
- **There is a config available to change these hitboxes to always be visible or to not get show at all when crouching.**
- Frame tooltips also change depending on which config option you have enabled!
- Stone Frames act the same as normal wooden Frames -- the only differences are their materials and styles.
- Frames now have custom sizing when placed in Item Frames, allowing them to encompass the Item Frame _(but with a different shape)_, allowing for further Frame customization and build opportunities.
- Wooden Frames and stone Frames alike no longer have an odd pixel gap when placed on corners. The corner gap fills -- this is a simple model change.
- Frames no longer have z-fighting when customized with Debug Sticks or placed on opposing corners.
- ### Added Balustrades
- Balustrades replace the functionality of placing Trapdoors on top of Lecterns, but in all wood types.
- Balustrades can be interacted with a Hammer on either their top or bottom half to toggle the top and bottom respectively. Their center beam cannot be toggled, and uses the texture of Wooden Walls / Beams so they can better connect with them.
- Balustrades can be **SHIFT** + right-clicked with a Hammer to tilt the top cube to represent a slightly taller Lectern. Doing so will give them a custom hitbox, but they will act the same otherwise.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ group = project.maven_group

repositories {
maven { url = "https://maven.tterrag.com/" }
maven { url = "https://api.modrinth.com/maven" } // LazyDFU
maven { url = "https://api.modrinth.com/maven" } // Modrinth
maven { url = "https://maven.terraformersmc.com/releases/" } // Mod Menu
maven { url = "https://mvn.devos.one/snapshots/" } // Create Fabric, Porting Lib, Forge Tags, Milk Lib, Registrate Fabric
maven { url = "https://cursemaven.com" } // Forge Config API Port
Expand Down Expand Up @@ -56,6 +56,7 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"

// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ fabric_version=0.90.4+1.20.1
fabric_registrate_version = 1.3.62-MC1.20.1
fabric_flywheel_version = 0.6.9-1
fabric_create_version = 0.5.1-d-build.1161+mc1.20.1

midnightlib_version = 1.4.1-fabric
9 changes: 9 additions & 0 deletions src/main/java/com/starfish_studios/bbb/BBBConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.starfish_studios.bbb;

import eu.midnightdust.lib.config.MidnightConfig;

public class BBBConfig extends MidnightConfig {
@Entry(category = "text") public static boolean disableShiftTooltips = false;
@Entry(category = "text") public static boolean alwaysShowFrameHitboxes = false;
@Entry(category = "text") public static boolean disableFrameCrouchHitbox = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.FoliageColor;
import net.minecraft.world.level.GrassColor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;

public class BBBVanillaIntegration {

Expand All @@ -19,6 +27,7 @@ public static class Client {
public static void clientInit() {
registerBlockRenderLayers();
registerBlockEntityRenderers();
registerBlockColors();
}

//client methods
Expand All @@ -27,6 +36,27 @@ private static void registerBlockEntityRenderers() {
BlockEntityRendererRegistry.register(BBBBlockEntityType.BLOCK, context -> new BlockBlockRenderer());
}

private static void registerBlockColors() {

ColorProviderRegistry<Block, BlockColor> blockColor = ColorProviderRegistry.BLOCK;
blockColor.register((state, world, pos, tintIndex) -> {
if (world == null || pos == null) {
return FoliageColor.getDefaultColor();
}
return BiomeColors.getAverageFoliageColor(world, pos);
},
BBBBlocks.OAK_LATTICE
);

ColorProviderRegistry.ITEM.register((stack, tintIndex) -> {
BlockState blockState = ((BlockItem)stack.getItem()).getBlock().defaultBlockState();
return blockColor.get(((BlockItem)stack.getItem()).getBlock()).getColor(blockState, null, null, tintIndex);
}
// BBBBlocks.OAK_LATTICE
);

}

private static void registerBlockRenderLayers() {
BlockRenderLayerMap.INSTANCE.putBlocks(RenderType.cutout(),
BBBBlocks.IRON_FENCE,
Expand All @@ -50,7 +80,8 @@ private static void registerBlockRenderLayers() {
BBBBlocks.WARPED_LADDER,
BBBBlocks.MANGROVE_LADDER,
BBBBlocks.BAMBOO_LADDER,
BBBBlocks.CHERRY_LADDER
BBBBlocks.CHERRY_LADDER,
BBBBlocks.OAK_LATTICE
);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/starfish_studios/bbb/BuildingButBetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.reflect.Reflection;
import com.starfish_studios.bbb.event.BlockUseEvent;
import com.starfish_studios.bbb.registry.*;
import eu.midnightdust.lib.config.MidnightConfig;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.registry.OxidizableBlocksRegistry;
Expand All @@ -22,6 +23,7 @@ public class BuildingButBetter implements ModInitializer {

@Override
public void onInitialize() {
MidnightConfig.init(MOD_ID, BBBConfig.class);
BlockUseEvent.EVENT.register(new BlockUseEvent());
Reflection.initialize(
BBBCreativeModeTab.class,
Expand Down
112 changes: 112 additions & 0 deletions src/main/java/com/starfish_studios/bbb/block/BalustradeBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.starfish_studios.bbb.block;

import com.starfish_studios.bbb.block.properties.BBBBlockStateProperties;
import com.starfish_studios.bbb.block.properties.ColumnType;
import com.starfish_studios.bbb.registry.BBBTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

public class BalustradeBlock extends Block implements SimpleWaterloggedBlock {
public static BooleanProperty TOP = BBBBlockStateProperties.TOP;
public static BooleanProperty BOTTOM = BBBBlockStateProperties.BOTTOM;
public static BooleanProperty TILTED = BooleanProperty.create("tilted");
public static final DirectionProperty FACING = BlockStateProperties.FACING;
public static BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;

public static VoxelShape BOTTOM_AABB = Block.box(0, 0, 0, 16, 2, 16);
public static VoxelShape TOP_AABB = Block.box(0, 12, 0, 16, 16, 16);
public static VoxelShape PILLAR_AABB = Block.box(4, 0, 4, 12, 16, 12);

public static VoxelShape NORTH_TILTED_AABB = Shapes.or(
Block.box(0, 12, 0, 16, 17, 8),
Block.box(0, 15, 8, 16, 20, 16)
);
public static VoxelShape SOUTH_TILTED_AABB = Shapes.or(
Block.box(0, 12, 8, 16, 17, 16),
Block.box(0, 15, 0, 16, 20, 8)
);
public static VoxelShape EAST_TILTED_AABB = Shapes.or(
Block.box(8, 10, 0, 16, 17, 16),
Block.box(0, 15, 0, 8, 20, 16)
);
public static VoxelShape WEST_TILTED_AABB = Shapes.or(
Block.box(0, 10, 0, 8, 17, 16),
Block.box(8, 15, 0, 16, 20, 16)
);

public BalustradeBlock(Properties properties) {
super(properties);
this.registerDefaultState(this.stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(TOP, true)
.setValue(BOTTOM, true)
.setValue(TILTED, false)
.setValue(WATERLOGGED, false));
}

@Override
public InteractionResult use(BlockState state, Level level, BlockPos blockPos, Player player, InteractionHand hand, BlockHitResult hitResult) {
if (player.getItemInHand(hand).is(BBBTags.BBBItemTags.HAMMERS)) {
if (hitResult.getLocation().y - (double)blockPos.getY() > 0.5D) {
level.setBlockAndUpdate(blockPos, state.cycle(TOP));
} else if (hitResult.getLocation().y - (double)blockPos.getY() < 0.5D) {
level.setBlockAndUpdate(blockPos, state.cycle(BOTTOM));
}
level.playSound(player, blockPos, state.getSoundType().getPlaceSound(), player.getSoundSource(), 1.0F, 1.0F);
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
}

@Override
public VoxelShape getShape(BlockState state, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
VoxelShape shape = PILLAR_AABB;
if (state.getValue(TILTED) && state.getValue(TOP)) {
shape = switch (state.getValue(FACING)) {
case NORTH -> Shapes.or(shape, NORTH_TILTED_AABB);
case SOUTH -> Shapes.or(shape, SOUTH_TILTED_AABB);
case EAST -> Shapes.or(shape, EAST_TILTED_AABB);
case WEST -> Shapes.or(shape, WEST_TILTED_AABB);
default -> shape;
};
} else if (state.getValue(TOP)) shape = Shapes.or(shape, TOP_AABB);
if (state.getValue(BOTTOM)) shape = Shapes.or(shape, BOTTOM_AABB);
return shape;
}

@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
return this.defaultBlockState()
.setValue(FACING, context.getHorizontalDirection().getOpposite())
.setValue(WATERLOGGED, context.getLevel().getFluidState(context.getClickedPos()).getType() == Fluids.WATER);
}

public FluidState getFluidState(BlockState blockState) {
return blockState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(blockState);
}

protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(TOP, BOTTOM, WATERLOGGED, FACING, TILTED);
}
}
Loading

0 comments on commit 7c78af8

Please sign in to comment.