face drilling added

This commit is contained in:
Jottyfan
2026-04-19 15:36:40 +02:00
parent 026e42ce0f
commit 424f365243
5 changed files with 26 additions and 13 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ loader_version=0.18.4
loom_version=1.15-SNAPSHOT loom_version=1.15-SNAPSHOT
# Mod Properties # Mod Properties
mod_version=26.1.0 mod_version=26.1.0.1
maven_group=de.jottyfan.minecraft maven_group=de.jottyfan.minecraft
archives_base_name=quickly archives_base_name=quickly
@@ -33,6 +33,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.world.level.block.state.StateDefinition.Builder;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; 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.EnumProperty; import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
@@ -48,20 +49,21 @@ public class BlockDrill extends FallingBlock implements EntityBlock {
private static final Integer MAX_FUEL = 255; private static final Integer MAX_FUEL = 255;
public static final IntegerProperty FUEL = IntegerProperty.create("fuel", 0, MAX_FUEL); public static final IntegerProperty FUEL = IntegerProperty.create("fuel", 0, MAX_FUEL);
public static final EnumProperty<Direction> FACING = BlockStateProperties.FACING; public static final EnumProperty<Direction> FACING = BlockStateProperties.FACING;
public static final BooleanProperty DOWNWARDS = BooleanProperty.create("downwards");
public BlockDrill(Properties properties) { public BlockDrill(Properties properties) {
super(properties.strength(0.5f)); super(properties.strength(0.5f));
registerDefaultState(stateDefinition.any().setValue(FUEL, 0).setValue(FACING, Direction.DOWN)); registerDefaultState(stateDefinition.any().setValue(FUEL, 0).setValue(FACING, Direction.DOWN).setValue(DOWNWARDS, true));
} }
@Override @Override
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
builder.add(FUEL, FACING); builder.add(FUEL, FACING, DOWNWARDS);
} }
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
return this.defaultBlockState().setValue(FACING, context.getNearestLookingDirection()); return this.defaultBlockState().setValue(FACING, context.getNearestLookingDirection()).setValue(DOWNWARDS, true);
} }
@Override @Override
@@ -112,6 +114,12 @@ public class BlockDrill extends FallingBlock implements EntityBlock {
} }
player.getActiveItem().shrink(1); player.getActiveItem().shrink(1);
} }
} else if (QuicklyItems.COPPERSTUB.equals(item)) {
Direction facing = state.getValue(BlockDrill.FACING);
level.setBlockAndUpdate(pos, QuicklyBlocks.DRILL.defaultBlockState().setValue(FACING, facing).setValue(BlockDrill.DOWNWARDS, false));
if (!level.isClientSide() && player instanceof ServerPlayer serverPlayer && player != null) {
serverPlayer.connection.player.sendSystemMessage(Component.translatable("info.block.drillstraight"), true);
}
} else { } else {
Direction newDirection = hitResult.getDirection(); Direction newDirection = hitResult.getDirection();
newDirection = newDirection.equals(Direction.UP) ? Direction.DOWN : newDirection; newDirection = newDirection.equals(Direction.UP) ? Direction.DOWN : newDirection;
@@ -31,29 +31,32 @@ public class DrillBlockEntity extends BlockEntity {
public static void tick(Level level, BlockPos pos, BlockState state, BlockEntity be) { public static void tick(Level level, BlockPos pos, BlockState state, BlockEntity be) {
if (be instanceof DrillBlockEntity dbe) { if (be instanceof DrillBlockEntity dbe) {
Direction dir = state.getValue(BlockDrill.FACING); Direction dir = state.getValue(BlockDrill.FACING);
Boolean downwards = state.getValue(BlockDrill.DOWNWARDS);
List<BlockPos> list = new ArrayList<>(); List<BlockPos> list = new ArrayList<>();
if (Direction.DOWN.equals(dir)) { if (Direction.DOWN.equals(dir)) {
list = downFrom(pos); list = downFrom(pos);
} else if (Direction.EAST.equals(dir)) { } else if (Direction.EAST.equals(dir)) {
list = directedFrom(pos.east()); list = directedFrom(pos.east(), downwards);
} else if (Direction.SOUTH.equals(dir)) { } else if (Direction.SOUTH.equals(dir)) {
list = directedFrom(pos.south()); list = directedFrom(pos.south(), downwards);
} else if (Direction.WEST.equals(dir)) { } else if (Direction.WEST.equals(dir)) {
list = directedFrom(pos.west()); list = directedFrom(pos.west(), downwards);
} else if (Direction.NORTH.equals(dir)) { } else if (Direction.NORTH.equals(dir)) {
list = directedFrom(pos.north()); list = directedFrom(pos.north(), downwards);
} }
DrillBlockEntity.tick(level, pos, state, dbe, MAXDRILLSTEP, list); DrillBlockEntity.tick(level, pos, state, dbe, MAXDRILLSTEP, list);
} }
} }
public static final List<BlockPos> directedFrom(BlockPos pos) { public static final List<BlockPos> directedFrom(BlockPos pos, Boolean downwards) {
List<BlockPos> list = new ArrayList<>(); List<BlockPos> list = new ArrayList<>();
list.add(pos);
list.add(pos.above());
list.add(pos.above(2));
list.add(pos.above(3)); list.add(pos.above(3));
list.add(pos.above(2));
list.add(pos.above());
list.add(pos);
if (downwards) {
list.add(pos.below()); // must be last position list.add(pos.below()); // must be last position
}
return list; return list;
} }
@@ -1,5 +1,6 @@
{ {
"info.block.drillfuel": "Ladung: %s Bohrungen", "info.block.drillfuel": "Ladung: %s Bohrungen",
"info.block.drillstraight": "auf ebenes Bohren umgestellt",
"info.block.itemhoarder": "enthält: %s", "info.block.itemhoarder": "enthält: %s",
"info.block.monsterhoarder": "Radius: %s, Brenndauer: %s Ticks", "info.block.monsterhoarder": "Radius: %s, Brenndauer: %s Ticks",
"item.quickly.blockcanolaplant": "Rapspflanze", "item.quickly.blockcanolaplant": "Rapspflanze",
@@ -1,5 +1,6 @@
{ {
"info.block.drillfuel": "Load: %s drills", "info.block.drillfuel": "Load: %s drills",
"info.block.drillstraight": "switched to face drilling",
"info.block.itemhoarder": "contains: %s", "info.block.itemhoarder": "contains: %s",
"info.block.monsterhoarder": "radius: %s, burn ticks: %s", "info.block.monsterhoarder": "radius: %s, burn ticks: %s",
"item.quickly.blockcanolaplant": "canola plant", "item.quickly.blockcanolaplant": "canola plant",