-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
1,143 additions
and
3 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
src/main/java/com/kpabr/backrooms/block/CrackedCopperPipeBlock.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,107 @@ | ||
package com.kpabr.backrooms.block; | ||
|
||
import net.minecraft.block.*; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.fluid.Fluids; | ||
import net.minecraft.item.ItemPlacementContext; | ||
import net.minecraft.state.StateManager.Builder; | ||
import net.minecraft.state.property.BooleanProperty; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.util.BlockMirror; | ||
import net.minecraft.util.BlockRotation; | ||
import net.minecraft.util.function.BooleanBiFunction; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.util.shape.VoxelShapes; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.WorldAccess; | ||
|
||
import java.util.Map; | ||
|
||
public class CrackedCopperPipeBlock extends Block implements Waterloggable{ | ||
public static final BooleanProperty NORTH = ConnectingBlock.NORTH; | ||
public static final BooleanProperty EAST = ConnectingBlock.EAST; | ||
public static final BooleanProperty SOUTH = ConnectingBlock.SOUTH; | ||
public static final BooleanProperty WEST = ConnectingBlock.WEST; | ||
public static final BooleanProperty UP = ConnectingBlock.UP; | ||
public static final BooleanProperty DOWN = ConnectingBlock.DOWN; | ||
private static final Map<Direction, BooleanProperty> FACING_PROPERTIES = ConnectingBlock.FACING_PROPERTIES; | ||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; | ||
|
||
public CrackedCopperPipeBlock(Settings settings) { | ||
super(settings); | ||
this.setDefaultState(this.stateManager.getDefaultState().with(NORTH, true).with(EAST, true).with(SOUTH, true).with(WEST, true).with(UP, true).with(DOWN, true).with(WATERLOGGED, false)); | ||
} | ||
|
||
public BlockState getPlacementState(ItemPlacementContext ctx) { | ||
BlockView blockView = ctx.getWorld(); | ||
BlockPos blockPos = ctx.getBlockPos(); | ||
return this.getDefaultState() | ||
.with(DOWN, blockView.getBlockState(blockPos.down()).isOf(this)) | ||
.with(UP, blockView.getBlockState(blockPos.up()).isOf(this)) | ||
.with(NORTH, blockView.getBlockState(blockPos.north()).isOf(this)) | ||
.with(EAST, blockView.getBlockState(blockPos.east()).isOf(this)) | ||
.with(SOUTH, blockView.getBlockState(blockPos.south()).isOf(this)) | ||
.with(WEST, blockView.getBlockState(blockPos.west()).isOf(this)) | ||
.with(WATERLOGGED, blockView.getFluidState(blockPos).getFluid() == Fluids.WATER); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { | ||
if (state.get(WATERLOGGED)) { | ||
world. createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); | ||
} | ||
if(neighborState.isOf(this)) return state.with(FACING_PROPERTIES.get(direction), true); | ||
return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
public BlockState rotate(BlockState state, BlockRotation rotation) { | ||
return state | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.NORTH)), state.get(NORTH)) | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.SOUTH)), state.get(SOUTH)) | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.EAST)), state.get(EAST)) | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.WEST)), state.get(WEST)) | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.DOWN)), state.get(DOWN)) | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.UP)), state.get(UP)); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
public BlockState mirror(BlockState state, BlockMirror mirror) { | ||
return state | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.NORTH)), state.get(NORTH)) | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.SOUTH)), state.get(SOUTH)) | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.EAST)), state.get(EAST)) | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.WEST)), state.get(WEST)) | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.DOWN)), state.get(DOWN)) | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.UP)), state.get(UP)); | ||
} | ||
|
||
protected void appendProperties(Builder<Block, BlockState> builder) { | ||
builder.add(UP, DOWN, NORTH, EAST, SOUTH, WEST, WATERLOGGED); | ||
} | ||
@Override | ||
public FluidState getFluidState(BlockState state) { | ||
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); | ||
} | ||
@SuppressWarnings("deprecation") | ||
@Override | ||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) { | ||
VoxelShape finalShape = VoxelShapes.cuboid(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f); | ||
if (state.get(NORTH)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.25f, 0.25f, 0.0f, 0.75f, 0.75f, 0.75f), BooleanBiFunction.OR); | ||
if (state.get(SOUTH)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 1.0f), BooleanBiFunction.OR); | ||
if (state.get(EAST)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.25f, 0.25f, 0.25f, 1.0f, 0.75f, 0.75f), BooleanBiFunction.OR); | ||
if (state.get(WEST)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.0f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f), BooleanBiFunction.OR); | ||
if (state.get(DOWN)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.25f, 0.0f, 0.25f, 0.75f, 0.75f, 0.75f), BooleanBiFunction.OR); | ||
if (state.get(UP)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.25f, 0.25f, 0.25f, 0.75f, 1.0f, 0.75f), BooleanBiFunction.OR); | ||
|
||
return finalShape; | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
src/main/java/com/kpabr/backrooms/block/CrackedPipeBlock.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,107 @@ | ||
package com.kpabr.backrooms.block; | ||
|
||
import net.minecraft.block.*; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.fluid.Fluids; | ||
import net.minecraft.item.ItemPlacementContext; | ||
import net.minecraft.state.StateManager.Builder; | ||
import net.minecraft.state.property.BooleanProperty; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.util.BlockMirror; | ||
import net.minecraft.util.BlockRotation; | ||
import net.minecraft.util.function.BooleanBiFunction; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.util.shape.VoxelShapes; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.WorldAccess; | ||
|
||
import java.util.Map; | ||
|
||
public class CrackedPipeBlock extends Block implements Waterloggable{ | ||
public static final BooleanProperty NORTH = ConnectingBlock.NORTH; | ||
public static final BooleanProperty EAST = ConnectingBlock.EAST; | ||
public static final BooleanProperty SOUTH = ConnectingBlock.SOUTH; | ||
public static final BooleanProperty WEST = ConnectingBlock.WEST; | ||
public static final BooleanProperty UP = ConnectingBlock.UP; | ||
public static final BooleanProperty DOWN = ConnectingBlock.DOWN; | ||
private static final Map<Direction, BooleanProperty> FACING_PROPERTIES = ConnectingBlock.FACING_PROPERTIES; | ||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; | ||
|
||
public CrackedPipeBlock(Settings settings) { | ||
super(settings); | ||
this.setDefaultState(this.stateManager.getDefaultState().with(NORTH, true).with(EAST, true).with(SOUTH, true).with(WEST, true).with(UP, true).with(DOWN, true).with(WATERLOGGED, false)); | ||
} | ||
|
||
public BlockState getPlacementState(ItemPlacementContext ctx) { | ||
BlockView blockView = ctx.getWorld(); | ||
BlockPos blockPos = ctx.getBlockPos(); | ||
return this.getDefaultState() | ||
.with(DOWN, blockView.getBlockState(blockPos.down()).isOf(this)) | ||
.with(UP, blockView.getBlockState(blockPos.up()).isOf(this)) | ||
.with(NORTH, blockView.getBlockState(blockPos.north()).isOf(this)) | ||
.with(EAST, blockView.getBlockState(blockPos.east()).isOf(this)) | ||
.with(SOUTH, blockView.getBlockState(blockPos.south()).isOf(this)) | ||
.with(WEST, blockView.getBlockState(blockPos.west()).isOf(this)) | ||
.with(WATERLOGGED, blockView.getFluidState(blockPos).getFluid() == Fluids.WATER); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { | ||
if (state.get(WATERLOGGED)) { | ||
world. createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); | ||
} | ||
if(neighborState.isOf(this)) return state.with(FACING_PROPERTIES.get(direction), true); | ||
return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
public BlockState rotate(BlockState state, BlockRotation rotation) { | ||
return state | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.NORTH)), state.get(NORTH)) | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.SOUTH)), state.get(SOUTH)) | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.EAST)), state.get(EAST)) | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.WEST)), state.get(WEST)) | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.DOWN)), state.get(DOWN)) | ||
.with(FACING_PROPERTIES.get(rotation.rotate(Direction.UP)), state.get(UP)); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
public BlockState mirror(BlockState state, BlockMirror mirror) { | ||
return state | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.NORTH)), state.get(NORTH)) | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.SOUTH)), state.get(SOUTH)) | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.EAST)), state.get(EAST)) | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.WEST)), state.get(WEST)) | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.DOWN)), state.get(DOWN)) | ||
.with(FACING_PROPERTIES.get(mirror.apply(Direction.UP)), state.get(UP)); | ||
} | ||
|
||
protected void appendProperties(Builder<Block, BlockState> builder) { | ||
builder.add(UP, DOWN, NORTH, EAST, SOUTH, WEST, WATERLOGGED); | ||
} | ||
@Override | ||
public FluidState getFluidState(BlockState state) { | ||
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); | ||
} | ||
@SuppressWarnings("deprecation") | ||
@Override | ||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) { | ||
VoxelShape finalShape = VoxelShapes.cuboid(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f); | ||
if (state.get(NORTH)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.25f, 0.25f, 0.0f, 0.75f, 0.75f, 0.75f), BooleanBiFunction.OR); | ||
if (state.get(SOUTH)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 1.0f), BooleanBiFunction.OR); | ||
if (state.get(EAST)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.25f, 0.25f, 0.25f, 1.0f, 0.75f, 0.75f), BooleanBiFunction.OR); | ||
if (state.get(WEST)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.0f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f), BooleanBiFunction.OR); | ||
if (state.get(DOWN)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.25f, 0.0f, 0.25f, 0.75f, 0.75f, 0.75f), BooleanBiFunction.OR); | ||
if (state.get(UP)) | ||
finalShape = VoxelShapes.combine(finalShape, VoxelShapes.cuboid(0.25f, 0.25f, 0.25f, 0.75f, 1.0f, 0.75f), BooleanBiFunction.OR); | ||
|
||
return finalShape; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.kpabr.backrooms.block; | ||
|
||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; | ||
import net.minecraft.block.DoorBlock; | ||
|
||
public class PlateDoor extends DoorBlock { | ||
public PlateDoor(FabricBlockSettings settings) { | ||
super(settings); | ||
} | ||
} |
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
114 changes: 114 additions & 0 deletions
114
src/main/resources/assets/backrooms/blockstates/cracked_copper_pipe.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,114 @@ | ||
{ | ||
"multipart": [ | ||
{ | ||
"apply": { | ||
"model": "backrooms:block/cracked_copper_pipe_turn" | ||
}, | ||
"when": { | ||
"OR": [ | ||
{"up": "true", "north": "true"}, | ||
{"up": "true", "east": "true"}, | ||
{"up": "true", "south": "true"}, | ||
{"up": "true", "west": "true"}, | ||
{"north": "true", "east": "true"}, | ||
{"east": "true", "south": "true"}, | ||
{"south": "true", "west": "true"}, | ||
{"west": "true", "north": "true"}, | ||
{"down": "true", "north": "true"}, | ||
{"down": "true", "east": "true"}, | ||
{"down": "true", "south": "true"}, | ||
{"down": "true", "west": "true"}, | ||
{"north": "true", "south": "false"}, | ||
{"east": "true", "west": "false"}, | ||
{"south": "true", "north": "false"}, | ||
{"west": "true", "east": "false"}, | ||
{"up": "true", "down": "false"}, | ||
{"down": "true", "up": "false"}, | ||
{"north": "false", "south": "false", "east": "false", "west": "false", "up": "false", "down": "false"} | ||
] | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "backrooms:block/cracked_copper_pipe_edge" | ||
}, | ||
"when": { | ||
"north": "true" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "backrooms:block/cracked_copper_pipe_edge", | ||
"uvlock": "true", | ||
"y": 90 | ||
}, | ||
"when": { | ||
"east": "true" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "backrooms:block/cracked_copper_pipe_edge", | ||
"uvlock": "true", | ||
"y": 180 | ||
}, | ||
"when": { | ||
"south": "true" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "backrooms:block/cracked_copper_pipe_edge", | ||
"uvlock": "true", | ||
"y": 270 | ||
}, | ||
"when": { | ||
"west": "true" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "backrooms:block/cracked_copper_pipe_edge", | ||
"uvlock": "true", | ||
"x": 270 | ||
}, | ||
"when": { | ||
"up": "true" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "backrooms:block/cracked_copper_pipe_edge", | ||
"uvlock": "true", | ||
"x": 90 | ||
}, | ||
"when": { | ||
"down": "true" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "backrooms:block/cracked_copper_pipe_ns" | ||
}, | ||
"when": { | ||
"north": "true", "south": "true", "east": "false", "west": "false", "up": "false", "down": "false" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "backrooms:block/cracked_copper_pipe_ew" | ||
}, | ||
"when": { | ||
"north": "false", "south": "false", "east": "true", "west": "true", "up": "false", "down": "false" | ||
} | ||
}, | ||
{ | ||
"apply": { | ||
"model": "backrooms:block/cracked_copper_pipe_ud" | ||
}, | ||
"when": { | ||
"north": "false", "south": "false", "east": "false", "west": "false", "up": "true", "down": "true" | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.