Opening a cargo crate now updates its physical model
This commit is contained in:
parent
47f95975e5
commit
95189b7eaf
@ -591,4 +591,14 @@ public class BlockShapes {
|
||||
new SimpleCuboid(0.875d, 0d, 0.5625d, 1d, 0.125d, 0.875d),
|
||||
new SimpleCuboid(0d, 0d, 0.5625d, 0.125d, 0.125d, 0.875d)
|
||||
);
|
||||
|
||||
public static final BlockShape CARGO_CRATE_OPEN = new BlockShape(
|
||||
new SimpleCuboid(0d, 0d, 0d, 1d, 0.8125d, 1d),
|
||||
new SimpleCuboid(0.125d, 0.8125d, 0.125d, 0.875d, 0.9375d, 0.875d),
|
||||
new SimpleCuboid(0d, 0.9375d, 0d, 1d, 1.125d, 1d),
|
||||
new SimpleCuboid(0d, 0.8125d, 0.4375d, 0d, 0.9375d, 0.5625d),
|
||||
new SimpleCuboid(1d, 0.8125d, 0.4375d, 1d, 0.9375d, 0.5625d),
|
||||
new SimpleCuboid(0.4375d, 0.8125d, 1d, 0.5625d, 0.9375d, 1d),
|
||||
new SimpleCuboid(0.4375d, 0.8125d, 0d, 0.5625d, 0.9375d, 0d)
|
||||
);
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package ru.dbotthepony.mc.otm.block
|
||||
|
||||
import com.google.common.collect.ImmutableMap
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.Containers
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.context.BlockPlaceContext
|
||||
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
|
||||
@ -14,7 +16,12 @@ import net.minecraft.world.level.block.state.StateDefinition
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty
|
||||
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.Shapes
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
import ru.dbotthepony.mc.otm.block.entity.CargoCrateBlockEntity
|
||||
import ru.dbotthepony.mc.otm.core.get
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock(
|
||||
Properties.of(Material.STONE, color?.materialColor ?: MaterialColor.COLOR_BLUE).requiresCorrectToolForDrops().strength(1.5f, 30.0f)
|
||||
@ -43,8 +50,22 @@ class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock(
|
||||
return AbstractContainerMenu.getRedstoneSignalFromContainer(tile.container)
|
||||
}
|
||||
|
||||
override fun getShape(
|
||||
p_60555_: BlockState,
|
||||
p_60556_: BlockGetter,
|
||||
p_60557_: BlockPos,
|
||||
p_60558_: CollisionContext
|
||||
): VoxelShape {
|
||||
if (p_60555_[IS_OPEN]) {
|
||||
return CARGO_CRATE_OPEN
|
||||
} else {
|
||||
return Shapes.block()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val IS_OPEN: BooleanProperty = BooleanProperty.create("open")
|
||||
val CARGO_CRATE_OPEN: VoxelShape = BlockShapes.CARGO_CRATE_OPEN.computeShape()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user