Skip to content

Commit

Permalink
A bunch of changes that I forgot to fix that were probably the root o…
Browse files Browse the repository at this point in the history
…f the bug with Exposure
  • Loading branch information
crispytwig committed Sep 23, 2024
1 parent 400a72d commit d4c900a
Show file tree
Hide file tree
Showing 272 changed files with 2,593 additions and 22,520 deletions.
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ mixin {
sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {
maven {
url = "https://api.modrinth.com/maven"
}
// Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you

Expand All @@ -116,6 +119,7 @@ dependencies {
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
implementation fg.deobf("maven.modrinth:midnightlib:${midnightlib_version}")

// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
Expand Down Expand Up @@ -146,6 +150,7 @@ tasks.named('processResources', ProcessResources).configure {
loader_version_range: loader_version_range,
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors: mod_authors, mod_description: mod_description,
midnightlib_version: midnightlib_version,
]

inputs.properties replaceProperties
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mappings_channel=official
mappings_version=1.20.1

minecraft_version = 1.20.1
mod_version = 1.0.1
mod_version = 1.1.1

forge_version = 47.1.0
forgegradle_version = 5.1.+
Expand All @@ -21,3 +21,5 @@ mod_description=A mod focused on adding new building blocks with customizability
minecraft_version_range=[1.20.1,1.21)
forge_version_range=[47,)
loader_version_range=[47,)

midnightlib_version = 1.4.2-forge
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 @@ -4,20 +4,19 @@
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.starfish_studios.bbb.registry.BBBBlocks;
import eu.midnightdust.lib.config.MidnightConfig;
import net.minecraft.world.item.HoneycombItem;
import net.minecraft.world.level.block.Block;

import java.util.function.Supplier;

public class BBBVanillaIntegration {
public static final Supplier<BiMap<Block, Block>> WAXABLES = Suppliers.memoize(() -> {
return ImmutableBiMap.<Block, Block>builder()
.put(BBBBlocks.CUT_COPPER_LAYER.get(), BBBBlocks.WAXED_CUT_COPPER_LAYER.get())
.put(BBBBlocks.EXPOSED_CUT_COPPER_LAYER.get(), BBBBlocks.WAXED_EXPOSED_CUT_COPPER_LAYER.get())
.put(BBBBlocks.WEATHERED_CUT_COPPER_LAYER.get(), BBBBlocks.WAXED_WEATHERED_CUT_COPPER_LAYER.get())
.put(BBBBlocks.OXIDIZED_CUT_COPPER_LAYER.get(), BBBBlocks.WAXED_OXIDIZED_CUT_COPPER_LAYER.get())
.build();
});
public static final Supplier<BiMap<Block, Block>> WAXABLES = Suppliers.memoize(() -> ImmutableBiMap.<Block, Block>builder()
.put(BBBBlocks.CUT_COPPER_LAYER.get(), BBBBlocks.WAXED_CUT_COPPER_LAYER.get())
.put(BBBBlocks.EXPOSED_CUT_COPPER_LAYER.get(), BBBBlocks.WAXED_EXPOSED_CUT_COPPER_LAYER.get())
.put(BBBBlocks.WEATHERED_CUT_COPPER_LAYER.get(), BBBBlocks.WAXED_WEATHERED_CUT_COPPER_LAYER.get())
.put(BBBBlocks.OXIDIZED_CUT_COPPER_LAYER.get(), BBBBlocks.WAXED_OXIDIZED_CUT_COPPER_LAYER.get())
.build());

public static void init() {
ImmutableBiMap.Builder<Block, Block> biMap = ImmutableBiMap.<Block, Block>builder().putAll(HoneycombItem.WAXABLES.get());
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/starfish_studios/bbb/BuildingButBetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.starfish_studios.bbb.registry.BBBCreativeModeTab;
import com.starfish_studios.bbb.registry.BBBItems;
import com.starfish_studios.bbb.registry.BBBSoundEvents;
import eu.midnightdust.lib.config.MidnightConfig;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -19,6 +20,8 @@ public class BuildingButBetter {
public static final String MOD_ID = "bbb";

public BuildingButBetter() {
MidnightConfig.init(BuildingButBetter.MOD_ID, BBBConfig.class);

IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
IEventBus eventBus = MinecraftForge.EVENT_BUS;

Expand Down
135 changes: 108 additions & 27 deletions src/main/java/com/starfish_studios/bbb/block/FrameBlock.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.starfish_studios.bbb.block;

import com.starfish_studios.bbb.BBBConfig;
import com.starfish_studios.bbb.block.properties.BBBBlockStateProperties;
import com.starfish_studios.bbb.block.properties.FrameStickDirection;
import com.starfish_studios.bbb.registry.BBBItems;
import com.starfish_studios.bbb.registry.BBBTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.stats.Stats;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
Expand All @@ -27,12 +25,13 @@
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.EntityCollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;

public class FrameBlock extends Block implements SimpleWaterloggedBlock {
public static final BooleanProperty SIDES = BooleanProperty.create("sides");
public static final BooleanProperty CORNERS = BooleanProperty.create("corners");
public static final EnumProperty<FrameStickDirection> FRAME_CENTER = BBBBlockStateProperties.FRAME_CENTER;

public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
Expand All @@ -41,18 +40,39 @@ public class FrameBlock extends Block implements SimpleWaterloggedBlock {
public static final BooleanProperty BOTTOM = BBBBlockStateProperties.BOTTOM;
public static final BooleanProperty LEFT = BBBBlockStateProperties.LEFT;
public static final BooleanProperty RIGHT = BBBBlockStateProperties.RIGHT;

private static final VoxelShape NORTH = Block.box(0, 0, 8, 16, 16, 16);
private static final VoxelShape EAST = Block.box(0, 0, 0, 8, 16, 16);
private static final VoxelShape SOUTH = Block.box(0, 0, 0, 16, 16, 8);
private static final VoxelShape WEST = Block.box(8, 0, 0, 16, 16, 16);
private static final VoxelShape TOP_NORTH_AABB = Block.box(0, 15, 13, 16, 16, 16);
private static final VoxelShape TOP_EAST_AABB = Block.box(0, 15, 0, 3, 16, 16);
private static final VoxelShape TOP_SOUTH_AABB = Block.box(0, 15, 0, 16, 16, 3);
private static final VoxelShape TOP_WEST_AABB = Block.box(13, 15, 0, 16, 16, 16);
private static final VoxelShape BOTTOM_NORTH_AABB = Block.box(0, -1, 13, 16, 0, 16);
private static final VoxelShape BOTTOM_EAST_AABB = Block.box(0, -1, 0, 3, 0, 16);
private static final VoxelShape BOTTOM_SOUTH_AABB = Block.box(0, -1, 0, 16, 0, 3);
private static final VoxelShape BOTTOM_WEST_AABB = Block.box(13, -1, 0, 16, 0, 16);


private static final VoxelShape NORTH_RIGHT_AABB = Block.box(0, 0, 13, 1, 16, 16);
private static final VoxelShape NORTH_LEFT_AABB = Block.box(15, 0, 13, 16, 16, 16);
private static final VoxelShape NORTH_TOP_AABB = Block.box(0, 15, 13, 16, 16, 16);
private static final VoxelShape NORTH_BOTTOM_AABB = Block.box(0, -1, 13, 16, 0, 16);
private static final VoxelShape NORTH_CENTER_AABB = Block.box(4, 0, 13, 12, 16, 16);

private static final VoxelShape WEST_LEFT_AABB = Block.box(13, 0, 0, 16, 16, 1);
private static final VoxelShape WEST_RIGHT_AABB = Block.box(13, 0, 15, 16, 16, 16);
private static final VoxelShape WEST_TOP_AABB = Block.box(13, 15, 0, 16, 16, 16);
private static final VoxelShape WEST_BOTTOM_AABB = Block.box(13, -1, 0, 16, 0, 16);
private static final VoxelShape WEST_CENTER_AABB = Block.box(13, 0, 4, 16, 16, 12);

private static final VoxelShape SOUTH_LEFT_AABB = Block.box(0, 0, 0, 1, 16, 3);
private static final VoxelShape SOUTH_RIGHT_AABB = Block.box(15, 0, 0, 16, 16, 3);
private static final VoxelShape SOUTH_TOP_AABB = Block.box(0, 15, 0, 16, 16, 3);
private static final VoxelShape SOUTH_BOTTOM_AABB = Block.box(0, -1, 0, 16, 0, 3);
private static final VoxelShape SOUTH_CENTER_AABB = Block.box(4, 0, 0, 12, 16, 3);


private static final VoxelShape EAST_LEFT_AABB = Block.box(0, 0, 15, 3, 16, 16);
private static final VoxelShape EAST_RIGHT_AABB = Block.box(0, 0, 0, 3, 16, 1);
private static final VoxelShape EAST_TOP_AABB = Block.box(0, 15, 0, 3, 16, 16);
private static final VoxelShape EAST_BOTTOM_AABB = Block.box(0, -1, 0, 3, 0, 16);
private static final VoxelShape EAST_CENTER_AABB = Block.box(0, 0, 4, 3, 16, 12);



public FrameBlock(Properties properties) {
super(properties);
Expand All @@ -63,13 +83,15 @@ public FrameBlock(Properties properties) {
.setValue(BOTTOM, true)
.setValue(LEFT, true)
.setValue(RIGHT, true)
.setValue(SIDES, true)
.setValue(CORNERS, true)
.setValue(FRAME_CENTER, FrameStickDirection.NONE));
}

@Override
public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) {
if (player.getItemInHand(interactionHand).is(BBBTags.BBBItemTags.HAMMERS)) {
// TODO: This cycles through the frame center options, rotating it sort of like an Item Frame
// region FRAME CENTER CYCLING
if (blockState.getValue(FRAME_CENTER) == FrameStickDirection.NONE) {
blockState = blockState.setValue(FRAME_CENTER, FrameStickDirection.VERTICAL);
} else if (blockState.getValue(FRAME_CENTER) == FrameStickDirection.VERTICAL) {
Expand All @@ -84,6 +106,7 @@ public InteractionResult use(BlockState blockState, Level level, BlockPos blockP
level.setBlock(blockPos, blockState, 3);
level.playSound(player, blockPos, Blocks.SCAFFOLDING.getSoundType(level.getBlockState(blockPos)).getPlaceSound(), player.getSoundSource(), 1.0F, 1.0F);
return InteractionResult.SUCCESS;
// endregion
} else return InteractionResult.PASS;
}

Expand All @@ -97,23 +120,81 @@ public void attack(BlockState blockState, Level level, BlockPos blockPos, Player
}
}

@Override
public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
return switch (blockState.getValue(FACING)) {
case EAST -> EAST;
case SOUTH -> SOUTH;
case WEST -> WEST;
default -> NORTH;
};
if (collisionContext instanceof EntityCollisionContext entityContext && entityContext.getEntity() instanceof Player player && player.isHolding(stack ->
stack.is(BBBTags.BBBItemTags.FRAMES) ||
stack.is(BBBTags.BBBItemTags.HAMMERS) || player.isShiftKeyDown() && !BBBConfig.disableFrameCrouchHitbox) || BBBConfig.alwaysShowFrameHitboxes) {
return switch (blockState.getValue(FACING)) {
case EAST -> EAST;
case SOUTH -> SOUTH;
case WEST -> WEST;
default -> NORTH;
};
}
VoxelShape shape = Shapes.empty();

if (blockState.getValue(FACING) == Direction.NORTH) {
if (blockState.getValue(LEFT)) shape = Shapes.or(shape, NORTH_LEFT_AABB);
if (blockState.getValue(RIGHT)) shape = Shapes.or(shape, NORTH_RIGHT_AABB);
if (blockState.getValue(TOP)) shape = Shapes.or(shape, NORTH_TOP_AABB);
if (blockState.getValue(BOTTOM)) shape = Shapes.or(shape, NORTH_BOTTOM_AABB);
} else if (blockState.getValue(FACING) == Direction.EAST) {
if (blockState.getValue(LEFT)) shape = Shapes.or(shape, EAST_LEFT_AABB);
if (blockState.getValue(RIGHT)) shape = Shapes.or(shape, EAST_RIGHT_AABB);
if (blockState.getValue(TOP)) shape = Shapes.or(shape, EAST_TOP_AABB);
if (blockState.getValue(BOTTOM)) shape = Shapes.or(shape, EAST_BOTTOM_AABB);
} else if (blockState.getValue(FACING) == Direction.SOUTH) {
if (blockState.getValue(LEFT)) shape = Shapes.or(shape, SOUTH_LEFT_AABB);
if (blockState.getValue(RIGHT)) shape = Shapes.or(shape, SOUTH_RIGHT_AABB);
if (blockState.getValue(TOP)) shape = Shapes.or(shape, SOUTH_TOP_AABB);
if (blockState.getValue(BOTTOM)) shape = Shapes.or(shape, SOUTH_BOTTOM_AABB);
} else if (blockState.getValue(FACING) == Direction.WEST) {
if (blockState.getValue(LEFT)) shape = Shapes.or(shape, WEST_LEFT_AABB);
if (blockState.getValue(RIGHT)) shape = Shapes.or(shape, WEST_RIGHT_AABB);
if (blockState.getValue(TOP)) shape = Shapes.or(shape, WEST_TOP_AABB);
if (blockState.getValue(BOTTOM)) shape = Shapes.or(shape, WEST_BOTTOM_AABB);
}
return shape;
}

@Override
public VoxelShape getCollisionShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
return switch (blockState.getValue(FACING)) {
case NORTH -> Shapes.or(blockState.getValue(TOP) ? TOP_NORTH_AABB : Shapes.empty(), blockState.getValue(BOTTOM) ? BOTTOM_NORTH_AABB : Shapes.empty());
case EAST -> Shapes.or(blockState.getValue(TOP) ? TOP_EAST_AABB : Shapes.empty(), blockState.getValue(BOTTOM) ? BOTTOM_EAST_AABB : Shapes.empty());
case SOUTH -> Shapes.or(blockState.getValue(TOP) ? TOP_SOUTH_AABB : Shapes.empty(), blockState.getValue(BOTTOM) ? BOTTOM_SOUTH_AABB : Shapes.empty());
case WEST -> Shapes.or(blockState.getValue(TOP) ? TOP_WEST_AABB : Shapes.empty(), blockState.getValue(BOTTOM) ? BOTTOM_WEST_AABB : Shapes.empty());
default -> Shapes.empty();
};
VoxelShape shape = Shapes.empty();

if (blockState.getValue(FRAME_CENTER) != FrameStickDirection.NONE) {
if (blockState.getValue(FACING) == Direction.NORTH) {
if (blockState.getValue(FRAME_CENTER) != FrameStickDirection.NONE) return Shapes.or(shape, NORTH_CENTER_AABB);
} else if (blockState.getValue(FACING) == Direction.EAST) {
if (blockState.getValue(FRAME_CENTER) != FrameStickDirection.NONE) return Shapes.or(shape, EAST_CENTER_AABB);
} else if (blockState.getValue(FACING) == Direction.SOUTH) {
if (blockState.getValue(FRAME_CENTER) != FrameStickDirection.NONE) return Shapes.or(shape, SOUTH_CENTER_AABB);
} else if (blockState.getValue(FACING) == Direction.WEST) {
if (blockState.getValue(FRAME_CENTER) != FrameStickDirection.NONE) return Shapes.or(shape, WEST_CENTER_AABB);
}
}
if (blockState.getValue(FACING) == Direction.NORTH) {
if (blockState.getValue(LEFT)) shape = Shapes.or(shape, NORTH_LEFT_AABB);
if (blockState.getValue(RIGHT)) shape = Shapes.or(shape, NORTH_RIGHT_AABB);
if (blockState.getValue(TOP)) shape = Shapes.or(shape, NORTH_TOP_AABB);
if (blockState.getValue(BOTTOM)) shape = Shapes.or(shape, NORTH_BOTTOM_AABB);
} else if (blockState.getValue(FACING) == Direction.EAST) {
if (blockState.getValue(LEFT)) shape = Shapes.or(shape, EAST_LEFT_AABB);
if (blockState.getValue(RIGHT)) shape = Shapes.or(shape, EAST_RIGHT_AABB);
if (blockState.getValue(TOP)) shape = Shapes.or(shape, EAST_TOP_AABB);
if (blockState.getValue(BOTTOM)) shape = Shapes.or(shape, EAST_BOTTOM_AABB);
} else if (blockState.getValue(FACING) == Direction.SOUTH) {
if (blockState.getValue(LEFT)) shape = Shapes.or(shape, SOUTH_LEFT_AABB);
if (blockState.getValue(RIGHT)) shape = Shapes.or(shape, SOUTH_RIGHT_AABB);
if (blockState.getValue(TOP)) shape = Shapes.or(shape, SOUTH_TOP_AABB);
if (blockState.getValue(BOTTOM)) shape = Shapes.or(shape, SOUTH_BOTTOM_AABB);
} else if (blockState.getValue(FACING) == Direction.WEST) {
if (blockState.getValue(LEFT)) shape = Shapes.or(shape, WEST_LEFT_AABB);
if (blockState.getValue(RIGHT)) shape = Shapes.or(shape, WEST_RIGHT_AABB);
if (blockState.getValue(TOP)) shape = Shapes.or(shape, WEST_TOP_AABB);
if (blockState.getValue(BOTTOM)) shape = Shapes.or(shape, WEST_BOTTOM_AABB);
}
return shape;
}

public boolean propagatesSkylightDown(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) {
Expand All @@ -139,7 +220,7 @@ public FluidState getFluidState(BlockState state) {

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING, WATERLOGGED, TOP, BOTTOM, LEFT, RIGHT, SIDES, FRAME_CENTER);
builder.add(FACING, WATERLOGGED, TOP, BOTTOM, LEFT, RIGHT, CORNERS, FRAME_CENTER);
}

@Override
Expand Down
Loading

0 comments on commit d4c900a

Please sign in to comment.