Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
- Connection helper no longer checks solid blocks when checking up/down - only the connection type. Otherwise connecting down will almost always be true as you're probably placing the object on solid blocks.
- Fixed ShapeUtils creating box from vec3 creating a box that was inset by the provided amount instead of being the provided size
- Fixed prepareModels function not using the provided nameSuffix (which was breaking toggle blocks)
  • Loading branch information
Fureniku committed Jan 14, 2024
1 parent f21b4bd commit ca09a89
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/fureniku/metropolis/Metropolis.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Metropolis {
public static final Logger LOGGER = LogUtils.getLogger();
public static Metropolis INSTANCE;

public static final boolean ENABLE_DEBUG = true; // For testing metropolis stuff internally. Should be disabled on release.
public static final boolean ENABLE_DEBUG = false; // For testing metropolis stuff internally. Should be disabled on release.
public static RegistrationTest registrationTest;

public Metropolis() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected BlockState getPlacementState(BlockPlaceContext context) {
@Override
protected VoxelShape getShapeFromBlockState(BlockState state) {
if (_rotationHelper != null && _connectHorizontalHelper != null) {
//replace with a new subhelper which generates the rotated connecting shapes on construction
//TODO replace with a new subhelper which generates the rotated connecting shapes on construction
//return shape;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,23 @@ private BlockState checkNewState(Level level, BlockState currentState, BlockPos

private boolean checkMatchOnSide(Level level, BlockPos posToCheck, Block block, Direction dir) {
if (_checkUp) {
if (checkMatch(level, posToCheck.above(), block, dir)) {
if (checkMatch(level, posToCheck.above(), block, dir, false)) {
return true;
}
}
if (_checkDown) {
if (checkMatch(level, posToCheck.below(), block, dir)) {
if (checkMatch(level, posToCheck.below(), block, dir, false)) {
return true;
}
}
return checkMatch(level, posToCheck, block, dir);
return checkMatch(level, posToCheck, block, dir, _connectSolid);
}

private boolean checkMatch(Level level, BlockPos posToCheck, Block block, Direction dir) {
private boolean checkMatch(Level level, BlockPos posToCheck, Block block, Direction dir, boolean checkSolid) {
BlockState stateCheck = level.getBlockState(posToCheck);
Block blockCheck = stateCheck.getBlock();
BlockConnectionType type = _connectionType;
if (_connectSolid && stateCheck.isFaceSturdy(level, posToCheck, dir.getOpposite())) {
if (checkSolid && stateCheck.isFaceSturdy(level, posToCheck, dir.getOpposite())) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ public BlockModelBuilder prepareModels(Block block, String modelDir, String mode
public BlockModelBuilder prepareModels(Block block, String nameSuffix, String modelDir, String modelName, TextureSet[] resources) {
BlockModelBuilder bmb;
if (modelName == null || resources == null) {
bmb = getModelFilesWithTexture(block, "", modelDir + block.getName(), modLoc(modelDir + block.getName()));
bmb = getModelFilesWithTexture(block, nameSuffix, modelDir + block.getName(), modLoc(modelDir + block.getName()));
} else {
bmb = applyTexturesToModel(resources, getModelFilesWithTexture(block, "", modelDir + modelName, resources[0].getTexture()));
bmb = applyTexturesToModel(resources, getModelFilesWithTexture(block, nameSuffix, modelDir + modelName, resources[0].getTexture()));
if (resources.length > 1) {
for (int i = 1; i < resources.length; i++) {
bmb = bmb.texture(resources[i].getKey(), resources[i].getTexture());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ public void init(IEventBus modEventBus) {
VoxelShape[] shapeB = ShapeUtils.makeShapes(2.5f, 4f, 16f);
VoxelShape[] shapes = ShapeUtils.combineMultiShapes(shapeA, shapeB);

//TODO re-test partials (not currently working)
MetroBlockDecorativeBuilder partial = new MetroBlockDecorativeBuilder(_props).setModelDirectory("blocks/decorative/");

blockNames.add(registerBlockSet("test_connecting_enum_same", () ->
new MetroBlockDecorativeBuilder(_props)
.setModelDirectory("blocks/decorative/")
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/fureniku/metropolis/utils/ShapeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public static VoxelShape makeShape(float size, float height) {
}

public static VoxelShape makeShape(Vec3 shape) {
return Block.box(shape.x, 0, shape.z, 16-shape.x, shape.y, 16-shape.z);
double x = shape.x/2;
double z = shape.z/2;
return Block.box(8-x, 0, 8-z, 8+x, shape.y, 8+z);
}

/**
Expand Down

0 comments on commit ca09a89

Please sign in to comment.