Move more to kotlin, add shapes and locale to item monitor and drive rack
This commit is contained in:
parent
59a30e4935
commit
9261562de7
@ -11,6 +11,8 @@ const models = [
|
||||
|
||||
['chemical_generator', 'chemical_generator_idle'],
|
||||
['matter_bottler', 'matter_bottler_idle'],
|
||||
'drive_rack',
|
||||
'item_monitor',
|
||||
];
|
||||
|
||||
const fs = require('fs')
|
||||
|
@ -1,55 +1,62 @@
|
||||
package ru.dbotthepony.mc.otm.block;
|
||||
package ru.dbotthepony.mc.otm.block
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import ru.dbotthepony.mc.otm.Registry;
|
||||
import ru.dbotthepony.mc.otm.block.entity.BlockEntityBlackHole;
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes;
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.EntityBlock
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.MaterialColor
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
import ru.dbotthepony.mc.otm.Registry
|
||||
import ru.dbotthepony.mc.otm.block.entity.BlockEntityBlackHole
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
public class BlockBlackHole extends Block implements EntityBlock {
|
||||
public BlockBlackHole() {
|
||||
super(Properties.of(
|
||||
new Material.Builder(MaterialColor.COLOR_BLACK).noCollider().nonSolid().build()
|
||||
).strength(-1, 7200000.0F));
|
||||
class BlockBlackHole :
|
||||
Block(Properties.of(Material.Builder(MaterialColor.COLOR_BLACK).noCollider().nonSolid().build()).strength(-1f, 7200000.0f)), EntityBlock {
|
||||
override fun getShape(
|
||||
p_60555_: BlockState,
|
||||
p_60556_: BlockGetter,
|
||||
p_60557_: BlockPos,
|
||||
p_60558_: CollisionContext
|
||||
): VoxelShape {
|
||||
return SHAPE
|
||||
}
|
||||
|
||||
public static final VoxelShape SHAPE = BlockShapes.BLACK_HOLE.computeShape();
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public VoxelShape getShape(BlockState p_60555_, BlockGetter p_60556_, BlockPos p_60557_, CollisionContext p_60558_) {
|
||||
return SHAPE;
|
||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
|
||||
return BlockEntityBlackHole(blockPos, blockState)
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
return new BlockEntityBlackHole(blockPos, blockState);
|
||||
override fun <T : BlockEntity?> getTicker(
|
||||
p_153212_: Level,
|
||||
p_153213_: BlockState,
|
||||
p_153214_: BlockEntityType<T>
|
||||
): BlockEntityTicker<T>? {
|
||||
if (p_153214_ !== Registry.BlockEntities.BLACK_HOLE) return null
|
||||
|
||||
return if (p_153212_.isClientSide) BlockEntityTicker { level: Level, blockPos: BlockPos, blockState: BlockState, t: T ->
|
||||
BlockEntityBlackHole.clientTicker(
|
||||
level,
|
||||
blockPos,
|
||||
blockState,
|
||||
t
|
||||
)
|
||||
} else BlockEntityTicker { level: Level, blockPos: BlockPos, blockState: BlockState, t: T ->
|
||||
BlockEntityBlackHole.ticker(
|
||||
level,
|
||||
blockPos,
|
||||
blockState,
|
||||
t
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level p_153212_, BlockState p_153213_, BlockEntityType<T> p_153214_) {
|
||||
if (p_153214_ != Registry.BlockEntities.BLACK_HOLE)
|
||||
return null;
|
||||
|
||||
return p_153212_.isClientSide ? BlockEntityBlackHole::clientTicker : BlockEntityBlackHole::ticker;
|
||||
companion object {
|
||||
private val SHAPE = BlockShapes.BLACK_HOLE.computeShape()
|
||||
}
|
||||
}
|
@ -1,56 +1,52 @@
|
||||
package ru.dbotthepony.mc.otm.block;
|
||||
package ru.dbotthepony.mc.otm.block
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import ru.dbotthepony.mc.otm.block.entity.BlockEntityCargoCrate;
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.Containers
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.EntityBlock
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty
|
||||
import ru.dbotthepony.mc.otm.block.entity.BlockEntityCargoCrate
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
public class BlockCargoCrate extends BlockMatteryRotatable implements EntityBlock {
|
||||
public static final BooleanProperty IS_OPEN = BooleanProperty.create("open");
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
return new BlockEntityCargoCrate(blockPos, blockState);
|
||||
class BlockCargoCrate : BlockMatteryRotatable(), EntityBlock {
|
||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity? {
|
||||
return BlockEntityCargoCrate(blockPos, blockState)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(IS_OPEN);
|
||||
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
|
||||
super.createBlockStateDefinition(builder)
|
||||
builder.add(IS_OPEN)
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return super.getStateForPlacement(context).setValue(IS_OPEN, false);
|
||||
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
|
||||
return super.getStateForPlacement(context)!!.setValue(IS_OPEN, false)
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onRemove(BlockState old_block_state, Level level, BlockPos block_pos, BlockState new_block_state, boolean p_51542_) {
|
||||
if (!old_block_state.is(new_block_state.getBlock())) {
|
||||
BlockEntity blockentity = level.getBlockEntity(block_pos);
|
||||
override fun onRemove(
|
||||
old_block_state: BlockState,
|
||||
level: Level,
|
||||
block_pos: BlockPos,
|
||||
new_block_state: BlockState,
|
||||
p_51542_: Boolean
|
||||
) {
|
||||
if (!old_block_state.`is`(new_block_state.block)) {
|
||||
val blockentity = level.getBlockEntity(block_pos)
|
||||
|
||||
if (blockentity instanceof BlockEntityCargoCrate crate) {
|
||||
Containers.dropContents(level, block_pos, crate.container);
|
||||
if (blockentity is BlockEntityCargoCrate) {
|
||||
Containers.dropContents(level, block_pos, blockentity.container);
|
||||
level.updateNeighbourForOutputSignal(block_pos, this);
|
||||
}
|
||||
|
||||
super.onRemove(old_block_state, level, block_pos, new_block_state, p_51542_);
|
||||
super.onRemove(old_block_state, level, block_pos, new_block_state, p_51542_)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val IS_OPEN = BooleanProperty.create("open")
|
||||
}
|
||||
}
|
@ -1,21 +1,40 @@
|
||||
package ru.dbotthepony.mc.otm.block;
|
||||
package ru.dbotthepony.mc.otm.block
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.dbotthepony.mc.otm.block.entity.BlockEntityDriveRack;
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.block.EntityBlock
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
import ru.dbotthepony.mc.otm.block.entity.BlockEntityDriveRack
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
class BlockDriveRack : BlockMatteryRotatable(), EntityBlock {
|
||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
|
||||
return BlockEntityDriveRack(blockPos, blockState)
|
||||
}
|
||||
|
||||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
public class BlockDriveRack extends BlockMatteryRotatable implements EntityBlock {
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
return new BlockEntityDriveRack(blockPos, blockState);
|
||||
override fun getShape(
|
||||
p_60555_: BlockState,
|
||||
p_60556_: BlockGetter,
|
||||
p_60557_: BlockPos,
|
||||
p_60558_: CollisionContext
|
||||
): VoxelShape {
|
||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val def = BlockShapes.DRIVE_RACK.computeShape()
|
||||
|
||||
private val SHAPES: List<VoxelShape> = listOf(
|
||||
def,
|
||||
def,
|
||||
def,
|
||||
BlockShapes.DRIVE_RACK.rotate(Direction.NORTH).computeShape(),
|
||||
BlockShapes.DRIVE_RACK.rotate(Direction.WEST).computeShape(),
|
||||
BlockShapes.DRIVE_RACK.rotate(Direction.EAST).computeShape()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,40 @@
|
||||
package ru.dbotthepony.mc.otm.block;
|
||||
package ru.dbotthepony.mc.otm.block
|
||||
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import ru.dbotthepony.mc.otm.block.entity.BlockEntityItemMonitor;
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.block.EntityBlock
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
import ru.dbotthepony.mc.otm.block.entity.BlockEntityItemMonitor
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
class BlockItemMonitor : BlockMatteryRotatable(), EntityBlock {
|
||||
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
|
||||
return BlockEntityItemMonitor(blockPos, blockState)
|
||||
}
|
||||
|
||||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
public class BlockItemMonitor extends BlockMatteryRotatable implements EntityBlock {
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
return new BlockEntityItemMonitor(blockPos, blockState);
|
||||
override fun getShape(
|
||||
p_60555_: BlockState,
|
||||
p_60556_: BlockGetter,
|
||||
p_60557_: BlockPos,
|
||||
p_60558_: CollisionContext
|
||||
): VoxelShape {
|
||||
return SHAPES[p_60555_.getValue(FACING).ordinal]
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val def = BlockShapes.ITEM_MONITOR.computeShape()
|
||||
|
||||
private val SHAPES: List<VoxelShape> = listOf(
|
||||
def,
|
||||
def,
|
||||
def,
|
||||
BlockShapes.ITEM_MONITOR.rotate(Direction.NORTH).computeShape(),
|
||||
BlockShapes.ITEM_MONITOR.rotate(Direction.WEST).computeShape(),
|
||||
BlockShapes.ITEM_MONITOR.rotate(Direction.EAST).computeShape()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -154,6 +154,8 @@
|
||||
"block.overdrive_that_matters.black_hole": "Local Anomalous Singular Gravitation Field",
|
||||
"block.overdrive_that_matters.energy_counter": "Energy Counter",
|
||||
"block.overdrive_that_matters.chemical_generator": "Chemical Generator",
|
||||
"block.overdrive_that_matters.drive_rack": "Condensation Drive Rack",
|
||||
"block.overdrive_that_matters.item_monitor": "Item Monitor",
|
||||
|
||||
"otm.container.matter_panel.number_input": "Input replication task count",
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user