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

Add Curve Block #54

Merged
merged 2 commits into from
Sep 13, 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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public void integrate(Context ctx) {
VanillaBlockGroups.BRICK, VanillaBlockGroups.TILE, VanillaBlockGroups.CRYSTAL
);

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

ctx.makeArchExBlocks(BlockType.WALL_COLUMN,
VanillaBlockGroups.STONE, VanillaBlockGroups.AQUATIC_STONE, VanillaBlockGroups.PROCESSED_STONE,
VanillaBlockGroups.BRICK, VanillaBlockGroups.TILE, VanillaBlockGroups.CRYSTAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Locale;

import io.github.debuggyteam.architecture_extensions.blocks.RoundArchBlock;
import io.github.debuggyteam.architecture_extensions.blocks.CurveBlock;
import io.github.debuggyteam.architecture_extensions.blocks.FacadeBlock;
import io.github.debuggyteam.architecture_extensions.blocks.IBeamBlock;
import io.github.debuggyteam.architecture_extensions.blocks.LatticeBlock;
Expand Down Expand Up @@ -40,6 +41,7 @@
public enum BlockType {
ARCH (ArchBlock::new, 2.5f, variantsOf("", "inner", "outer"), SafeRenderLayer.SOLID),
BEAM (BeamBlock::new, 1.5f),
CURVE (CurveBlock::new, 1.5f),
H_BEAM (BeamBlock::new, 8.0f),
WALL_COLUMN (WallColumnBlock::new, 2.5f, variantsOf("", "cap"), SafeRenderLayer.SOLID),
FENCE_POST (FencePostBlock::new, 1.5f),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package io.github.debuggyteam.architecture_extensions.blocks;

import io.github.debuggyteam.architecture_extensions.api.BlockType.TypedGroupedBlock;
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.text.MutableText;
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 CurveBlock extends HorizontalFacingBlock implements TypedGrouped {
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
public static final EnumProperty<BlockHalf> HALF = Properties.BLOCK_HALF;

protected final TypedGroupedBlock typedGroupedBlock;

protected static final VoxelShape SHAPE_TOP = Block.createCuboidShape(0.0, 8.0, 0.0, 16.0, 16.0, 16.0);
protected static final VoxelShape SHAPE_BOTTOM = Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 8.0, 16.0);

public CurveBlock(Block baseBlock, QuiltBlockSettings settings, TypedGroupedBlock typedGroupedBlock) {
super(settings);
this.typedGroupedBlock = typedGroupedBlock;
}

@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();
}

@Override
public TypedGroupedBlock getTypedGroupedBlock() {
return typedGroupedBlock;
}

@Override
public MutableText getName() {
return getServerTranslation();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"architecture_extensions.block_type.round_arch": "Arch",
"architecture_extensions.block_type.beam": "Beam",
"architecture_extensions.block_type.crown_molding": "Crown Molding",
"architecture_extensions.block_type.curve": "Curve",
"architecture_extensions.block_type.facade": "Facade",
"architecture_extensions.block_type.fence_post": "Fence Post",
"architecture_extensions.block_type.round_fence_post": "Fence Post",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"asset":{
"generator":"Khronos glTF Blender I/O v3.5.30",
"version":"2.0"
},
"scene":0,
"scenes":[
{
"name":"Scene",
"nodes":[
0
]
}
],
"nodes":[
{
"mesh":0,
"name":"Cylinder.001"
}
],
"materials":[
{
"doubleSided":true,
"name":"Material.003",
"pbrMetallicRoughness":{
"baseColorTexture":{
"index":0
},
"metallicFactor":0,
"roughnessFactor":0.4000000059604645
}
}
],
"meshes":[
{
"name":"Cylinder.002",
"primitives":[
{
"attributes":{
"POSITION":0,
"TEXCOORD_0":1,
"NORMAL":2
},
"indices":3,
"material":0
}
]
}
],
"textures":[
{
"sampler":0,
"source":0
}
],
"images":[
{
"bufferView":4,
"mimeType":"image/png",
"name":"bricks"
}
],
"accessors":[
{
"bufferView":0,
"componentType":5126,
"count":48,
"max":[
0.4999999403953552,
0.5000000596046448,
0.4999998211860657
],
"min":[
-0.5000002384185791,
-0.5000000596046448,
-0.5000004172325134
],
"type":"VEC3"
},
{
"bufferView":1,
"componentType":5126,
"count":48,
"type":"VEC2"
},
{
"bufferView":2,
"componentType":5126,
"count":48,
"type":"VEC3"
},
{
"bufferView":3,
"componentType":5123,
"count":84,
"type":"SCALAR"
}
],
"bufferViews":[
{
"buffer":0,
"byteLength":576,
"byteOffset":0,
"target":34962
},
{
"buffer":0,
"byteLength":384,
"byteOffset":576,
"target":34962
},
{
"buffer":0,
"byteLength":576,
"byteOffset":960,
"target":34962
},
{
"buffer":0,
"byteLength":168,
"byteOffset":1536,
"target":34963
},
{
"buffer":0,
"byteLength":301,
"byteOffset":1704
}
],
"samplers":[
{
"magFilter":9728,
"minFilter":9984
}
],
"buffers":[
{
"byteLength":2008,
"uri":"data:application/octet-stream;base64,AgAAvwEAAD8CAAC/AgAAv9aN7j4u+Ha+AgAAv9aN7j4u+Ha+AgAAv9aN7j4u+Ha+AgAAv65nuz4AAIi0AgAAv65nuz4AAIi0AgAAv65nuz4AAIi0AgAAv8wTVD64E1Q+AgAAv8wTVD64E1Q+AgAAv8wTVD64E1Q+BAAAvwAAALSoZ7s+BAAAvwAAALSoZ7s+BAAAvwAAALSoZ7s+BAAAvyv4dr7Mje4+BAAAvyv4dr7Mje4+BAAAvyv4dr7Mje4++v//Pvr//74FAAC/+v//Pvr//74FAAC/+v//Pvr//74FAAC/BAAAv/r//74HAAC/BAAAv/r//74HAAC/BAAAv/r//74HAAC/+P//PgEAAL/6//8+BAAAv/7//772//8+/v//PgEAAD8BAAC//v//PgEAAD8BAAC/AgAAvwEAAD8DAAC/AgAAvwEAAD8DAAC/BAAAvwEAAL/2//8+BAAAvwEAAL/2//8+/v//PgEAAD8AAAC//P//PtaN7j4m+Ha+/P//PtaN7j4m+Ha+/P//PtaN7j4m+Ha+/P//Pq5nuz4AAAC0/P//Pq5nuz4AAAC0/P//Pq5nuz4AAAC0/P//PswTVD7AE1Q+/P//PswTVD7AE1Q+/P//PswTVD7AE1Q++P//PgAAQLSsZ7s++P//PgAAQLSsZ7s++P//PgAAQLSsZ7s++P//Pi/4dr7Qje4++P//Pi/4dr7Qje4++P//Pi/4dr7Qje4++P//PgAAAL/6//8++P//PgAAAL/6//8+ANfUOwDd1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AAACAAAAAgEMcSz9R2hs/AAAAgLaEbD9B8cM+AACAPwAAAIAAAAAAAAAAgFHaGz9DHEs/AAAAgEMcSz9R2hs/AACAPwAAAAAAAAAAAAAAgEHxwz62hGw/AAAAgFHaGz9DHEs/AACAPwAAAAAAAACAAAAAgMuhBT5kzH0/AAAAgEHxwz62hGw/AACAPwAAAAAAAACAAAAAgMuhBT5kzH0/BwAqACYABwALACoAIAAFACQAIAABAAUADQAvACwADQAdAC8AIwAIACcAIwAEAAgAHgACACEAHgAAAAIAEQAXABUAEQAWABcAGQAUABsAGQAQABQAHwAiABIAIgAlABIAHwASABgAEgAoACsAEgArAC4AJQAoABIADwATABwAAwAaABMABgADABMAEwAPAAwADAAJABMACQAGABMACgAtACkACgAOAC0AiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA2klEQVR4Xo2SoQ7CQBBE95cw2AqCJAHDB2BAYbDFYgjB4HA4JD/Bb5XMJtNMptsGMel1393mZm7js1t10HO76K7Hffc9bHqRkb8u50E9AKD7uskN7XKea9YrrvVA4dTMUu/HrV/jAKQcDchQhwLXhgDRAF/WlI3xcL+41pRn5dnAPdEv6pqJizwbMDT6om/NRBuRZwP3VHke2wMe1TtrLlUmmstgDqoZoL2KZwbqif/qVzPxUHMO3LP7Vc/O08LUO0/NAZqVcwD9m0nwjV06B86Ul3Pgnn0PGfQDd4RKtBJ9p+oAAAAOZVhJZk1NACoAAAAIAAAAAAAAANJTkwAAAABJRU5ErkJgggAAAA=="
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"variants": {
"facing=east,half=bottom": {
"model": "{model}",
"y": 90
},
"facing=east,half=top": {
"model": "{model}",
"x": 180,
"y": 270,
"uvlock": true
},
"facing=north,half=bottom": {
"model": "{model}",
"y": 0,
"uvlock": true
},
"facing=north,half=top": {
"model": "{model}",
"x": 180,
"y": 180,
"uvlock": true
},
"facing=south,half=bottom": {
"model": "{model}",
"y": 180,
"uvlock": true
},
"facing=south,half=top": {
"model": "{model}",
"x": 180,
"y": 360,
"uvlock": true
},
"facing=west,half=bottom": {
"model": "{model}",
"y": 270,
"uvlock": true
},
"facing=west,half=top": {
"model": "{model}",
"x": 180,
"y": 90,
"uvlock": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"parent": "architecture_extensions:block/curve.gltf",
"loader": "suspicious_shapes:gltf",
"textures": {
"particle": "#texture",
"all": "#texture"
},
"uvlock": true,
"display": {
"thirdperson_righthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"thirdperson_lefthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"firstperson_righthand": {
"rotation": [0, 315, 0],
"scale": [0.4, 0.4, 0.4]
},
"firstperson_lefthand": {
"rotation": [0, 315, 0],
"scale": [0.4, 0.4, 0.4]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, 45, 0],
"scale": [0.625, 0.625, 0.625]
},
"head": {
"rotation": [0, 180, 0],
"translation": [0, 13, 7]
},
"fixed": {
"scale": [0.5, 0.5, 0.5]
}
}
}