Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gltf stuff #37

Merged
merged 17 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
modImplementation libs.quilted.fabric.api

modImplementation include("maven.modrinth:static-data:1.0.1+1.20")
modImplementation include("maven.modrinth:suspicious-shapes:1.0.0+1.20.1")
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx1G
org.gradle.parallel = true

# Mod Properties
version = 3.0.0+1.20.1
version = 3.1.0+1.20.1
maven_group = io.github.debuggyteam
archives_base_name = architecture_extensions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void onInitialize(ModContainer mod) {
DeferredRegistration.register(item.getModId(), group, groupedBlock, blockTypes, CALLBACK_ADD_TO_ITEM_GROUP);
}
} catch (IOException ex) {
throw new RuntimeException("There was a problem getting staticdata for mod container '"+item.getModId()+"' with resource id '"+item.getResourceId()+"'.", ex);
throw new RuntimeException("There was a problem getting staticdata for mod container '" + item.getModId() + "' with resource id '"+item.getResourceId()+"'.", ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@ public class VanillaIntegration implements ArchExIntegration {
private static final BlockGroup BAMBOO_ROD = BlockGroup.of(new BlockGroup.GroupedBlock("bamboo", Blocks.BAMBOO, (type, textureId) -> "minecraft:block/bamboo_stalk", RecipeConfigurator.simple("bamboo_rod"), MapColor.PLANT));
private static final BlockGroup COPPER_ROD = BlockGroup.of(new BlockGroup.GroupedBlock("copper", Blocks.LIGHTNING_ROD, (type, textureId) -> "architecture_extensions:block/copper_rod", RecipeConfigurator.simple("copper_rod"), MapColor.ORANGE));
private static final BlockGroup IRON_ROD = BlockGroup.of(new BlockGroup.GroupedBlock("iron", Blocks.IRON_BARS, (type, textureId) -> "minecraft:block/iron_bars", RecipeConfigurator.simple("iron_rod")));
private static final BlockGroup IRON_H_BEAM = BlockGroup.of(new BlockGroup.GroupedBlock("iron", Blocks.ANVIL, (type, textureId) -> "architecture_extensions:block/tube_steel", RecipeConfigurator.simple("iron_h_beam"), MapColor.METAL));

private static final BlockGroup TUBE_STEEL = BlockGroup.of(new BlockGroup.GroupedBlock("iron", Blocks.ANVIL, (type, textureId) -> {
return switch (textureId) {
case "texture_top" -> "architecture_extensions:block/tube_steel_top";
default -> "architecture_extensions:block/tube_steel";
};
}, RecipeConfigurator.simple("iron_tube_steel"), MapColor.METAL));
private static final BlockGroup IRON_H_BEAM = BlockGroup.of(new BlockGroup.GroupedBlock("iron", Blocks.ANVIL, (type, textureId) -> "architecture_extensions:block/iron_tube_metal", RecipeConfigurator.simple("iron_h_beam"), MapColor.METAL));


private static final BlockGroup TUBE_METAL = BlockGroup.of(
new BlockGroup.GroupedBlock("iron", Blocks.ANVIL, (type, textureId) -> {
return switch (textureId) {
case "texture_up" -> "architecture_extensions:block/iron_tube_metal_top";
default -> "architecture_extensions:block/iron_tube_metal";
};
}, RecipeConfigurator.simple("iron_tube_metal"), MapColor.METAL),
new BlockGroup.GroupedBlock("copper", Blocks.ANVIL, (type, textureId) -> {
return switch (textureId) {
case "texture_up" -> "architecture_extensions:block/copper_tube_metal_top";
default -> "architecture_extensions:block/copper_tube_metal";
};
}, RecipeConfigurator.simple("copper_tube_metal"), MapColor.METAL)
);

@Override
public void integrate(Context ctx) {
Expand Down Expand Up @@ -49,10 +58,32 @@ public void integrate(Context ctx) {
);

ctx.makeArchExBlocks(
BlockType.FACADE, VanillaBlockGroups.WOOD, VanillaBlockGroups.STONE,
VanillaBlockGroups.AQUATIC_STONE, VanillaBlockGroups.PROCESSED_STONE,
VanillaBlockGroups.BRICK, VanillaBlockGroups.TILE, VanillaBlockGroups.CRYSTAL,
VanillaBlockGroups.TERRACOTTA, VanillaBlockGroups.CONCRETE
BlockType.FACADE,
VanillaBlockGroups.WOOD, VanillaBlockGroups.STONE,
VanillaBlockGroups.AQUATIC_STONE, VanillaBlockGroups.PROCESSED_STONE,
VanillaBlockGroups.BRICK, VanillaBlockGroups.TILE, VanillaBlockGroups.CRYSTAL,
VanillaBlockGroups.TERRACOTTA, VanillaBlockGroups.CONCRETE
);

ctx.makeArchExBlocks(
BlockType.ROUND_FENCE_POST,
VanillaBlockGroups.WOOD, VanillaBlockGroups.STONE, VanillaBlockGroups.AQUATIC_STONE,
VanillaBlockGroups.PROCESSED_STONE, VanillaBlockGroups.BRICK, VanillaBlockGroups.TILE,
VanillaBlockGroups.CRYSTAL
);

ctx.makeArchExBlocks(
BlockType.ROUND_ARCH,
VanillaBlockGroups.WOOD, VanillaBlockGroups.STONE, VanillaBlockGroups.AQUATIC_STONE,
VanillaBlockGroups.PROCESSED_STONE, VanillaBlockGroups.BRICK, VanillaBlockGroups.TILE,
VanillaBlockGroups.CRYSTAL
);

ctx.makeArchExBlocks(
BlockType.OCTAGONAL_COLUMN,
VanillaBlockGroups.WOOD, VanillaBlockGroups.STONE, VanillaBlockGroups.AQUATIC_STONE,
VanillaBlockGroups.PROCESSED_STONE, VanillaBlockGroups.BRICK, VanillaBlockGroups.TILE,
VanillaBlockGroups.CRYSTAL
);

ctx.makeArchExBlocks(BlockType.BEAM, VanillaBlockGroups.WOOD);
Expand All @@ -63,10 +94,10 @@ public void integrate(Context ctx) {
ctx.makeArchExBlocks(BlockType.POST_LANTERN, VanillaBlockGroups.WOOD);
ctx.makeArchExBlocks(BlockType.ROD, BAMBOO_ROD, COPPER_ROD, IRON_ROD);
ctx.makeArchExBlocks(BlockType.LATTICE, VanillaBlockGroups.WOOD);
ctx.makeArchExBlocks(BlockType.TUBE_STEEL, TUBE_STEEL);
ctx.makeArchExBlocks(BlockType.TRANSOM, VanillaBlockGroups.WOOD);

ctx.makeArchExBlocks(BlockType.I_BEAM, TUBE_STEEL);

ctx.makeArchExBlocks(BlockType.TUBE_METAL, TUBE_METAL);
ctx.makeArchExBlocks(BlockType.I_BEAM, TUBE_METAL);
ctx.makeArchExBlocks(BlockType.H_BEAM, IRON_H_BEAM);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import java.util.Locale;
import java.util.function.BiFunction;

import io.github.debuggyteam.architecture_extensions.blocks.RoundArchBlock;
import io.github.debuggyteam.architecture_extensions.blocks.FacadeBlock;
import io.github.debuggyteam.architecture_extensions.blocks.IBeamBlock;
import io.github.debuggyteam.architecture_extensions.blocks.LatticeBlock;
import io.github.debuggyteam.architecture_extensions.blocks.OctagonalColumnBlock;
import io.github.debuggyteam.architecture_extensions.blocks.RoundFencePostBlock;
import io.github.debuggyteam.architecture_extensions.blocks.TransomBlock;
import io.github.debuggyteam.architecture_extensions.blocks.TubeSteelBlock;
import io.github.debuggyteam.architecture_extensions.util.SafeRenderLayer;
Expand Down Expand Up @@ -46,9 +49,12 @@ public enum BlockType {
WALL_POST((baseBlock, settings) -> new WallPostBlock(settings), 2.5f, noVariants(), SafeRenderLayer.SOLID),
LATTICE((baseBlock, settings) -> new LatticeBlock(settings), 1.5f, noVariants(), SafeRenderLayer.SOLID),
FACADE((baseBlock, settings) -> new FacadeBlock(settings), 1.5f, noVariants(), SafeRenderLayer.SOLID),
TUBE_STEEL((baseBlock, settings) -> new TubeSteelBlock(settings), 8f, noVariants(), SafeRenderLayer.SOLID),
TUBE_METAL((baseBlock, settings) -> new TubeSteelBlock(settings), 8f, noVariants(), SafeRenderLayer.SOLID),
I_BEAM((baseBlock, settings) -> new IBeamBlock(settings), 8f, noVariants(), SafeRenderLayer.SOLID),
TRANSOM((baseBlock, settings) -> new TransomBlock(settings), 1.5f, noVariants(), SafeRenderLayer.TRANSLUCENT);
TRANSOM((baseBlock, settings) -> new TransomBlock(settings), 1.5f, noVariants(), SafeRenderLayer.TRANSLUCENT),
OCTAGONAL_COLUMN((baseBlock, settings) -> new OctagonalColumnBlock(settings), 1.5f, variantsOf("", "cap", "double_cap"), SafeRenderLayer.SOLID),
ROUND_ARCH((baseBlock, settings) -> new RoundArchBlock(settings), 1.5f, noVariants(), SafeRenderLayer.SOLID),
ROUND_FENCE_POST((baseBlock, settings) -> new RoundFencePostBlock(settings), 1.5f, noVariants(), SafeRenderLayer.SOLID);

private final BiFunction<Block, QuiltBlockSettings, Block> creator;
private final float strength;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package io.github.debuggyteam.architecture_extensions.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PillarBlock;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.Waterloggable;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;

public class OctagonalColumnBlock extends PillarBlock implements Waterloggable {
public static final BooleanProperty MIN_CAP = BooleanProperty.of("min_cap");
public static final BooleanProperty MAX_CAP = BooleanProperty.of("max_cap");
public static final EnumProperty<Direction.Axis> AXIS = Properties.AXIS;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;

protected static final VoxelShape X_AXIS_BOX = Block.createCuboidShape(0.0, 4.0, 4.0, 16.0, 12.0, 12.0);
protected static final VoxelShape Y_AXIS_BOX = Block.createCuboidShape(4.0, 0.0, 4.0, 12.0, 16.0, 12.0);
protected static final VoxelShape Z_AXIS_BOX = Block.createCuboidShape(4.0, 4.0, 0.0, 12.0, 12.0, 16.0);

public OctagonalColumnBlock(Settings settings) {
super(settings);
this.setDefaultState(
this.getDefaultState()
.with(WATERLOGGED, false)
.with(AXIS, Direction.Axis.Y)
.with(MIN_CAP, false)
.with(MAX_CAP, false)
); // Thanks LambdAurora!
}

// The following deals with block rotation
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return changeRotation(state, rotation);
}

public static BlockState changeRotation(BlockState state, BlockRotation rotation) {
return switch (rotation) {
case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.get(AXIS)) {
case X -> state.with(AXIS, Direction.Axis.Z);
case Z -> state.with(AXIS, Direction.Axis.X);
default -> state;
};
default -> state;
};
}

// The following block of code below deals with block collision.
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
Direction.Axis cardinalDir = state.get(AXIS);
return switch (cardinalDir) {
case X -> X_AXIS_BOX;
case Y -> Y_AXIS_BOX;
case Z -> Z_AXIS_BOX;
};
}

// Deals with placing the block properly in accordance to direction.
@Override
public BlockState getPlacementState(ItemPlacementContext context) {
BlockState initialState = this.getDefaultState().with(AXIS, context.getSide().getAxis());
return getUpdatedState(context.getWorld(), context.getBlockPos(), initialState);
}

@Override
public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState();
}

@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (state.get(WATERLOGGED)) world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));

return getUpdatedState(world, pos, state);
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(AXIS, MIN_CAP, MAX_CAP, WATERLOGGED);
}

public BlockState getUpdatedState(WorldAccess world, BlockPos pos, BlockState state) {
Direction.Axis selfAxis = state.get(AXIS);

BlockState minNeighbor = world.getBlockState(pos.offset(selfAxis, -1));
boolean minCap = !(minNeighbor.getBlock() instanceof OctagonalColumnBlock &&
minNeighbor.get(AXIS) == selfAxis);

BlockState maxNeighbor = world.getBlockState(pos.offset(selfAxis, 1));
boolean maxCap = !(maxNeighbor.getBlock() instanceof OctagonalColumnBlock &&
maxNeighbor.get(AXIS) == selfAxis);

return state.with(MIN_CAP, minCap).with(MAX_CAP, maxCap);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package io.github.debuggyteam.architecture_extensions.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.block.enums.BlockHalf;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;

import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings;

public class RoundArchBlock extends HorizontalFacingBlock {
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
public static final EnumProperty<BlockHalf> HALF = Properties.BLOCK_HALF;

public RoundArchBlock(QuiltBlockSettings settings) {
super(settings);
}

@Override
public BlockState getPlacementState(ItemPlacementContext context) {
// Thanks Falkreon
BlockHalf half = switch(context.getSide()) {
case UP -> BlockHalf.BOTTOM;
case DOWN -> BlockHalf.TOP;
default -> {
double sideHitHeight = context.getHitPos().getY() - context.getBlockPos().getY();
if (sideHitHeight > 0.5) {
yield BlockHalf.TOP;
} else {
yield BlockHalf.BOTTOM;
}
}
};

return this.getDefaultState().with(FACING, context.getPlayerFacing()).with(HALF, half);
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(FACING, HALF);
}

@Override
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) {
return VoxelShapes.empty();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package io.github.debuggyteam.architecture_extensions.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PillarBlock;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.Waterloggable;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;

public class RoundFencePostBlock extends PillarBlock implements Waterloggable {
public static final EnumProperty<Direction.Axis> AXIS = Properties.AXIS;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;

protected static final VoxelShape X_AXIS_BOX = Block.createCuboidShape(0.0, 5.0, 5.0, 16.0, 11.0, 11.0);
protected static final VoxelShape Y_AXIS_BOX = Block.createCuboidShape(5.0, 0.0, 5.0, 11.0, 16.0, 11.0);
protected static final VoxelShape Z_AXIS_BOX = Block.createCuboidShape(5.0, 5.0, 0.0, 11.0, 11.0, 16.0);

public RoundFencePostBlock(Settings settings) {
super(settings);
setDefaultState(this.stateManager.getDefaultState().with(AXIS, Direction.Axis.Y));
}

// The following deals with block rotation
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return changeRotation(state, rotation);
}

public static BlockState changeRotation(BlockState state, BlockRotation rotation) {
return switch (rotation) {
case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.get(AXIS)) {
case X -> state.with(AXIS, Direction.Axis.Z);
case Z -> state.with(AXIS, Direction.Axis.X);
default -> state;
};
default -> state;
};
}

// Both of the following blocks of code below deals with block collision.
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
Direction.Axis cardinalDir = state.get(AXIS);
return switch (cardinalDir) {
case X -> X_AXIS_BOX;
case Y -> Y_AXIS_BOX;
case Z -> Z_AXIS_BOX;
};
}

// Deals with placing the block properly in accordance to direction.
@Override
public BlockState getPlacementState(ItemPlacementContext context) {
return this.getDefaultState().with(AXIS, context.getSide().getAxis()).with(WATERLOGGED, context.getWorld().getFluidState(context.getBlockPos()).getFluid() == Fluids.WATER);
}

@Override
public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState();
}

@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (state.get(WATERLOGGED)) world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));

return state;
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(AXIS, WATERLOGGED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.Axis;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
Expand Down
Loading