generated from neoforged/MDK
-
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.
- Loading branch information
Showing
20 changed files
with
349 additions
and
919 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
67 changes: 67 additions & 0 deletions
67
src/main/java/net/aaw/bellsandwhistles/block/custom/MetalBogieStepsBlock.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,67 @@ | ||
package net.aaw.bellsandwhistles.block.custom; | ||
|
||
import com.simibubi.create.content.decoration.MetalLadderBlock; | ||
import com.simibubi.create.content.equipment.wrench.IWrenchable; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.entity.LivingEntity; | ||
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.state.BlockState; | ||
import net.minecraft.world.phys.shapes.BooleanOp; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class MetalBogieStepsBlock extends MetalLadderBlock implements IWrenchable { | ||
public MetalBogieStepsBlock(Properties pProperties) { | ||
super(pProperties); | ||
} | ||
public float getShadeBrightness(BlockState pState, BlockGetter pLevel, BlockPos pPos) { | ||
return 1.0F; | ||
} | ||
|
||
public boolean propagatesSkylightDown(BlockState pState, BlockGetter pReader, BlockPos pPos) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isLadder(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) { | ||
return super.isLadder(state, level, pos, entity); | ||
} | ||
|
||
private static final VoxelShape SHAPE = Stream.of( | ||
Block.box(2, -9, 14, 14, 16, 16), | ||
Block.box(1, -3, 12, 15, -2, 16), | ||
Block.box(3, -9, 12, 13, -8, 16) | ||
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(); | ||
public static VoxelShape rotateShape(Direction from, Direction to, VoxelShape shape) { | ||
VoxelShape[] buffer = new VoxelShape[]{shape, Shapes.empty()}; | ||
|
||
int times = (to.ordinal() - from.get2DDataValue() + 4) % 4; | ||
for (int i = 0; i < times; i++) { | ||
buffer[0].forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> buffer[1] = Shapes.or(buffer[1], Shapes.create(1 - maxZ, minY, minX, 1 - minZ, maxY, maxX))); | ||
buffer[0] = buffer[1]; | ||
buffer[1] = Shapes.empty(); | ||
} | ||
|
||
return buffer[0]; | ||
} | ||
@Override | ||
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { | ||
switch ((Direction)pState.getValue(FACING)) { | ||
case NORTH: | ||
return SHAPE; | ||
case SOUTH: | ||
return rotateShape(Direction.NORTH, Direction.WEST, SHAPE); | ||
case WEST: | ||
return rotateShape(Direction.NORTH, Direction.EAST, SHAPE); | ||
case EAST: | ||
default: | ||
return rotateShape(Direction.NORTH, Direction.SOUTH, SHAPE); | ||
} | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
src/main/java/net/aaw/bellsandwhistles/block/custom/MetalGrabRailsBlock.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
28 changes: 0 additions & 28 deletions
28
src/main/java/net/aaw/bellsandwhistles/block/custom/MetalPilotBlock.java
This file was deleted.
Oops, something went wrong.
89 changes: 89 additions & 0 deletions
89
src/main/java/net/aaw/bellsandwhistles/block/custom/PilotBlock.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,89 @@ | ||
package net.aaw.bellsandwhistles.block.custom; | ||
|
||
import com.simibubi.create.content.equipment.wrench.IWrenchable; | ||
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.block.*; | ||
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.DirectionProperty; | ||
import net.minecraft.world.phys.shapes.BooleanOp; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class PilotBlock extends Block implements IWrenchable{ | ||
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; | ||
public PilotBlock(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
public BlockState getStateForPlacement(BlockPlaceContext pContext) { | ||
return this.defaultBlockState().setValue(FACING, pContext.getHorizontalDirection().getOpposite()); | ||
} | ||
|
||
@Override | ||
public BlockState rotate(BlockState pState, Rotation pRotation) { | ||
return pState.setValue(FACING, pRotation.rotate(pState.getValue(FACING))); | ||
} | ||
|
||
@Override | ||
public BlockState mirror(BlockState pState, Mirror pMirror) { | ||
return pState.rotate(pMirror.getRotation(pState.getValue(FACING))); | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) { | ||
pBuilder.add(FACING); | ||
} | ||
public float getShadeBrightness(BlockState pState, BlockGetter pLevel, BlockPos pPos) { | ||
return 1.0F; | ||
} | ||
|
||
public boolean propagatesSkylightDown(BlockState pState, BlockGetter pReader, BlockPos pPos) { | ||
return true; | ||
} | ||
private static final VoxelShape SHAPE = Stream.of( | ||
Block.box(0.25, -11, 3, 16.25, 5, 19), | ||
Block.box(16.25, -11, 10, 22.25, 5, 19), | ||
Block.box(-5.75, -11, 10, 0.25, 5, 19), | ||
Block.box(0.25, 5, 7, 16.25, 14, 19), | ||
Block.box(-5.75, -12, 9, 22.25, -11, 20), | ||
Block.box(-6.75, -12, 11, 23.25, -11, 20), | ||
Block.box(1.25, -12, 2, 15.25, -11, 9), | ||
Block.box(-0.75, -12, 4, 17.25, -11, 9) | ||
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(); | ||
|
||
public static VoxelShape rotateShape(Direction from, Direction to, VoxelShape shape) { | ||
VoxelShape[] buffer = new VoxelShape[]{shape, Shapes.empty()}; | ||
|
||
int times = (to.ordinal() - from.get2DDataValue() + 4) % 4; | ||
for (int i = 0; i < times; i++) { | ||
buffer[0].forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> buffer[1] = Shapes.or(buffer[1], Shapes.create(1 - maxZ, minY, minX, 1 - minZ, maxY, maxX))); | ||
buffer[0] = buffer[1]; | ||
buffer[1] = Shapes.empty(); | ||
} | ||
|
||
return buffer[0]; | ||
} | ||
@Override | ||
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { | ||
switch ((Direction)pState.getValue(FACING)) { | ||
case NORTH: | ||
return SHAPE; | ||
case SOUTH: | ||
return rotateShape(Direction.NORTH, Direction.WEST, SHAPE); | ||
case WEST: | ||
return rotateShape(Direction.NORTH, Direction.EAST, SHAPE); | ||
case EAST: | ||
default: | ||
return rotateShape(Direction.NORTH, Direction.SOUTH, SHAPE); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.