-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ face side block logic and hanging painting
Signed-off-by: LocusAzzurro <dingzx1997@gmail.com>
- Loading branch information
1 parent
f9691d7
commit be0371b
Showing
12 changed files
with
217 additions
and
3 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
34 changes: 34 additions & 0 deletions
34
src/generated/resources/assets/ultramarine/blockstates/long_hanging_painting.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,34 @@ | ||
{ | ||
"variants": { | ||
"facing=north,waterlogged=false": { | ||
"model": "ultramarine:block/long_hanging_painting", | ||
"y": 180 | ||
}, | ||
"facing=south,waterlogged=false": { | ||
"model": "ultramarine:block/long_hanging_painting" | ||
}, | ||
"facing=west,waterlogged=false": { | ||
"model": "ultramarine:block/long_hanging_painting", | ||
"y": 90 | ||
}, | ||
"facing=east,waterlogged=false": { | ||
"model": "ultramarine:block/long_hanging_painting", | ||
"y": 270 | ||
}, | ||
"facing=north,waterlogged=true": { | ||
"model": "ultramarine:block/long_hanging_painting", | ||
"y": 180 | ||
}, | ||
"facing=south,waterlogged=true": { | ||
"model": "ultramarine:block/long_hanging_painting" | ||
}, | ||
"facing=west,waterlogged=true": { | ||
"model": "ultramarine:block/long_hanging_painting", | ||
"y": 90 | ||
}, | ||
"facing=east,waterlogged=true": { | ||
"model": "ultramarine:block/long_hanging_painting", | ||
"y": 270 | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/generated/resources/assets/ultramarine/models/item/long_hanging_painting.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,3 @@ | ||
{ | ||
"parent": "ultramarine:block/long_hanging_painting" | ||
} |
16 changes: 16 additions & 0 deletions
16
src/generated/resources/data/ultramarine/loot_tables/blocks/long_hanging_painting.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,16 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"name": "long_hanging_painting", | ||
"rolls": 1.0, | ||
"bonus_rolls": 0.0, | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "ultramarine:long_hanging_painting" | ||
} | ||
] | ||
} | ||
] | ||
} |
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
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
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
76 changes: 76 additions & 0 deletions
76
src/main/java/com/voxelutopia/ultramarine/world/block/SideFaceBlock.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,76 @@ | ||
package com.voxelutopia.ultramarine.world.block; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.item.context.BlockPlaceContext; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.LevelReader; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.HorizontalDirectionalBlock; | ||
import net.minecraft.world.level.block.SimpleWaterloggedBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.BlockStateProperties; | ||
import net.minecraft.world.level.block.state.properties.BooleanProperty; | ||
import net.minecraft.world.level.block.state.properties.DirectionProperty; | ||
import net.minecraft.world.level.material.FluidState; | ||
import net.minecraft.world.level.material.Fluids; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class SideFaceBlock extends Block implements BaseBlockPropertyHolder, SimpleWaterloggedBlock { | ||
|
||
protected final BaseBlockProperty property; | ||
|
||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; | ||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; | ||
|
||
protected static final VoxelShape EAST_AABB = Block.box(0.0D, 0.0D, 0.0D, 1.0D, 16.0D, 16.0D); | ||
protected static final VoxelShape WEST_AABB = Block.box(15.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D); | ||
protected static final VoxelShape SOUTH_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 1.0D); | ||
protected static final VoxelShape NORTH_AABB = Block.box(0.0D, 0.0D, 15.0D, 16.0D, 16.0D, 16.0D); | ||
public SideFaceBlock(BaseBlockProperty property) { | ||
super(property.properties.noOcclusion()); | ||
this.property = property; | ||
this.registerDefaultState(this.getStateDefinition().any() | ||
.setValue(FACING, Direction.NORTH) | ||
.setValue(WATERLOGGED, false)); | ||
} | ||
|
||
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { | ||
return switch (pState.getValue(FACING)) { | ||
case NORTH -> NORTH_AABB; | ||
case SOUTH -> SOUTH_AABB; | ||
case WEST -> WEST_AABB; | ||
default -> EAST_AABB; | ||
}; | ||
} | ||
|
||
@Nullable | ||
public BlockState getStateForPlacement(BlockPlaceContext pContext) { | ||
BlockState state = this.defaultBlockState(); | ||
FluidState fluidstate = pContext.getLevel().getFluidState(pContext.getClickedPos()); | ||
|
||
Direction direction = pContext.getClickedFace(); | ||
if (direction.getAxis().isHorizontal()){ | ||
return state.setValue(FACING, direction) | ||
.setValue(WATERLOGGED, fluidstate.getType() == Fluids.WATER); | ||
} | ||
return null; | ||
} | ||
|
||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) { | ||
pBuilder.add(FACING, WATERLOGGED); | ||
} | ||
|
||
public FluidState getFluidState(BlockState pState) { | ||
return pState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(pState); | ||
} | ||
|
||
@Override | ||
public BaseBlockProperty getProperty() { | ||
return this.property; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/main/resources/assets/ultramarine/models/block/long_hanging_painting.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,68 @@ | ||
{ | ||
"credit": "Made with Blockbench", | ||
"texture_size": [64, 64], | ||
"render_type": "cutout", | ||
"textures": { | ||
"1": "ultramarine:block/long_hanging_painting", | ||
"particle": "ultramarine:item/xuan_paper" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [0, -16, 0.1], | ||
"to": [16, 32, 0.1], | ||
"faces": { | ||
"north": {"uv": [4.25, 0, 8.25, 12], "texture": "#1"}, | ||
"east": {"uv": [8.75, 0, 8.75, 12], "texture": "#1"}, | ||
"south": {"uv": [0, 0, 4, 12], "texture": "#1"}, | ||
"west": {"uv": [8.5, 0, 8.5, 12], "texture": "#1"}, | ||
"up": {"uv": [13, 0, 9, 0], "rotation": 180, "texture": "#1"}, | ||
"down": {"uv": [13, 0.25, 9, 0.25], "rotation": 180, "texture": "#1"} | ||
} | ||
} | ||
], | ||
"display": { | ||
"thirdperson_righthand": { | ||
"rotation": [72.91, 11.8, 4.18], | ||
"translation": [1.75, -2.25, 0], | ||
"scale": [0.375, 0.375, 0.375] | ||
}, | ||
"thirdperson_lefthand": { | ||
"rotation": [72.91, 11.8, 4.18], | ||
"translation": [1.75, -2.25, 0], | ||
"scale": [0.375, 0.375, 0.375] | ||
}, | ||
"firstperson_righthand": { | ||
"translation": [3, 3.25, 2], | ||
"scale": [0.3, 0.3, 0.3] | ||
}, | ||
"firstperson_lefthand": { | ||
"translation": [3, 3.25, 2], | ||
"scale": [0.3, 0.3, 0.3] | ||
}, | ||
"ground": { | ||
"translation": [0, 3, 2], | ||
"scale": [0.25, 0.25, 0.25] | ||
}, | ||
"gui": { | ||
"rotation": [30, 45, 0], | ||
"translation": [1.75, -0.75, 0], | ||
"scale": [0.33, 0.33, 0.33] | ||
}, | ||
"head": { | ||
"translation": [0, -15.75, 1.25] | ||
}, | ||
"fixed": { | ||
"rotation": [0, 0, 18.75], | ||
"translation": [3.25, -1.25, -16.1], | ||
"scale": [2, 2, 2] | ||
} | ||
}, | ||
"groups": [ | ||
{ | ||
"name": "group", | ||
"origin": [8, 8, 8], | ||
"color": 0, | ||
"children": [0] | ||
} | ||
] | ||
} |
Binary file added
BIN
+1.35 KB
src/main/resources/assets/ultramarine/textures/block/long_hanging_painting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.