face drilling added
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ loader_version=0.18.4
|
||||
loom_version=1.15-SNAPSHOT
|
||||
|
||||
# Mod Properties
|
||||
mod_version=26.1.0
|
||||
mod_version=26.1.0.1
|
||||
maven_group=de.jottyfan.minecraft
|
||||
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.StateDefinition.Builder;
|
||||
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.IntegerProperty;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
@@ -48,20 +49,21 @@ public class BlockDrill extends FallingBlock implements EntityBlock {
|
||||
private static final Integer MAX_FUEL = 255;
|
||||
public static final IntegerProperty FUEL = IntegerProperty.create("fuel", 0, MAX_FUEL);
|
||||
public static final EnumProperty<Direction> FACING = BlockStateProperties.FACING;
|
||||
public static final BooleanProperty DOWNWARDS = BooleanProperty.create("downwards");
|
||||
|
||||
public BlockDrill(Properties properties) {
|
||||
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
|
||||
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
|
||||
builder.add(FUEL, FACING);
|
||||
builder.add(FUEL, FACING, DOWNWARDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return this.defaultBlockState().setValue(FACING, context.getNearestLookingDirection());
|
||||
return this.defaultBlockState().setValue(FACING, context.getNearestLookingDirection()).setValue(DOWNWARDS, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,6 +114,12 @@ public class BlockDrill extends FallingBlock implements EntityBlock {
|
||||
}
|
||||
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 {
|
||||
Direction newDirection = hitResult.getDirection();
|
||||
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) {
|
||||
if (be instanceof DrillBlockEntity dbe) {
|
||||
Direction dir = state.getValue(BlockDrill.FACING);
|
||||
Boolean downwards = state.getValue(BlockDrill.DOWNWARDS);
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
if (Direction.DOWN.equals(dir)) {
|
||||
list = downFrom(pos);
|
||||
} else if (Direction.EAST.equals(dir)) {
|
||||
list = directedFrom(pos.east());
|
||||
list = directedFrom(pos.east(), downwards);
|
||||
} else if (Direction.SOUTH.equals(dir)) {
|
||||
list = directedFrom(pos.south());
|
||||
list = directedFrom(pos.south(), downwards);
|
||||
} else if (Direction.WEST.equals(dir)) {
|
||||
list = directedFrom(pos.west());
|
||||
list = directedFrom(pos.west(), downwards);
|
||||
} else if (Direction.NORTH.equals(dir)) {
|
||||
list = directedFrom(pos.north());
|
||||
list = directedFrom(pos.north(), downwards);
|
||||
}
|
||||
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.add(pos);
|
||||
list.add(pos.above());
|
||||
list.add(pos.above(2));
|
||||
list.add(pos.above(3));
|
||||
list.add(pos.below()); // must be last position
|
||||
list.add(pos.above(2));
|
||||
list.add(pos.above());
|
||||
list.add(pos);
|
||||
if (downwards) {
|
||||
list.add(pos.below()); // must be last position
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"info.block.drillfuel": "Ladung: %s Bohrungen",
|
||||
"info.block.drillstraight": "auf ebenes Bohren umgestellt",
|
||||
"info.block.itemhoarder": "enthält: %s",
|
||||
"info.block.monsterhoarder": "Radius: %s, Brenndauer: %s Ticks",
|
||||
"item.quickly.blockcanolaplant": "Rapspflanze",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"info.block.drillfuel": "Load: %s drills",
|
||||
"info.block.drillstraight": "switched to face drilling",
|
||||
"info.block.itemhoarder": "contains: %s",
|
||||
"info.block.monsterhoarder": "radius: %s, burn ticks: %s",
|
||||
"item.quickly.blockcanolaplant": "canola plant",
|
||||
|
||||
Reference in New Issue
Block a user