generated from QuiltMC/quilt-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from ZekeSmith/1.20
Add Curve Block
- Loading branch information
Showing
7 changed files
with
315 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/java/io/github/debuggyteam/architecture_extensions/blocks/CurveBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
src/main/resources/assets/architecture_extensions/models/block/curve.gltf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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//P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oQU+AACAPwAAAIAAAAAAAAAAgLaEbD9B8cM+AAAAgGTMfT/LoQU+AACAPwAAAIAAAACAAAAAgEMcSz9R2hs/AAAAgLaEbD9B8cM+AACAPwAAAIAAAAAAAAAAgFHaGz9DHEs/AAAAgEMcSz9R2hs/AACAPwAAAAAAAAAAAAAAgEHxwz62hGw/AAAAgFHaGz9DHEs/AACAPwAAAAAAAACAAAAAgMuhBT5kzH0/AAAAgEHxwz62hGw/AACAPwAAAAAAAACAAAAAgMuhBT5kzH0/BwAqACYABwALACoAIAAFACQAIAABAAUADQAvACwADQAdAC8AIwAIACcAIwAEAAgAHgACACEAHgAAAAIAEQAXABUAEQAWABcAGQAUABsAGQAQABQAHwAiABIAIgAlABIAHwASABgAEgAoACsAEgArAC4AJQAoABIADwATABwAAwAaABMABgADABMAEwAPAAwADAAJABMACQAGABMACgAtACkACgAOAC0AiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA2klEQVR4Xo2SoQ7CQBBE95cw2AqCJAHDB2BAYbDFYgjB4HA4JD/Bb5XMJtNMptsGMel1393mZm7js1t10HO76K7Hffc9bHqRkb8u50E9AKD7uskN7XKea9YrrvVA4dTMUu/HrV/jAKQcDchQhwLXhgDRAF/WlI3xcL+41pRn5dnAPdEv6pqJizwbMDT6om/NRBuRZwP3VHke2wMe1TtrLlUmmstgDqoZoL2KZwbqif/qVzPxUHMO3LP7Vc/O08LUO0/NAZqVcwD9m0nwjV06B86Ul3Pgnn0PGfQDd4RKtBJ9p+oAAAAOZVhJZk1NACoAAAAIAAAAAAAAANJTkwAAAABJRU5ErkJgggAAAA==" | ||
} | ||
] | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/resources/assets/architecture_extensions/templates/blockstate/template_curve.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/resources/assets/architecture_extensions/templates/model/block/template_curve.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
} | ||
} | ||
} |