missing shapes

This commit is contained in:
YuRaNnNzZZ 2024-08-30 16:53:47 +03:00
parent 85279c4de8
commit f1d011d7c4
Signed by: YuRaNnNzZZ
GPG Key ID: 5F71738C85A6006D
3 changed files with 63 additions and 0 deletions

View File

@ -804,4 +804,33 @@ public class BlockShapes {
new SimpleCuboid(0.125d, 0.3125d, 0.25d, 0.875d, 0.9375d, 0.875d), new SimpleCuboid(0.125d, 0.3125d, 0.25d, 0.875d, 0.9375d, 0.875d),
new SimpleCuboid(0.1875d, 0.5d, 0.875d, 0.8125d, 0.875d, 0.9375d) new SimpleCuboid(0.1875d, 0.5d, 0.875d, 0.8125d, 0.875d, 0.9375d)
); );
public static final BlockShape INFINITE_WATER_SOURCE = new BlockShape(
new SimpleCuboid(0.625d, 0d, 0d, 1d, 1d, 0.5625d),
new SimpleCuboid(0d, 0.625d, 0d, 0.625d, 1d, 0.5625d),
new SimpleCuboid(0d, 0d, 0d, 0.625d, 0.375d, 0.5625d),
new SimpleCuboid(0d, 0.375d, 0.3125d, 0.625d, 0.625d, 0.5625d),
new SimpleCuboid(0.5625d, 0.0625d, 0.5625d, 0.9375d, 0.875d, 0.9375d),
new SimpleCuboid(0.0625d, 0.0625d, 0.5625d, 0.4375d, 0.875d, 0.9375d),
new SimpleCuboid(0.125d, 0.875d, 0.625d, 0.875d, 0.9375d, 0.875d),
new SimpleCuboid(0d, 0d, 0.5625d, 1d, 1d, 1d),
new SimpleCuboid(0d, 1d, 0.5625d, 1d, 0d, 1d),
new SimpleCuboid(0.0625d, 0.375d, 0.0625d, 0.625d, 0.625d, 0.3125d)
);
public static final BlockShape PAINTER = new BlockShape(
new SimpleCuboid(0d, 0.5d, 0d, 1d, 0.625d, 1d),
new SimpleCuboid(0d, 0d, 0d, 1d, 0.125d, 0.9375d),
new SimpleCuboid(0d, 0.125d, 0.3125d, 1d, 0.5d, 0.9375d),
new SimpleCuboid(0d, 0.625d, 0.5625d, 1d, 1d, 1d),
new SimpleCuboid(0.625d, 0.125d, 0.0625d, 0.75d, 0.5d, 0.3125d),
new SimpleCuboid(0.4375d, 0.125d, 0.0625d, 0.5625d, 0.5d, 0.3125d),
new SimpleCuboid(0.8125d, 0.125d, 0.0625d, 0.9375d, 0.5d, 0.3125d),
new SimpleCuboid(0.0625d, 0.125d, 0.0625d, 0.375d, 0.5d, 0.3125d),
new SimpleCuboid(0.0625d, 0.59375d, 0.0625d, 0.9375d, 0.65625d, 0.5d),
new SimpleCuboid(0.0625d, 0d, 0.9375d, 0.3125d, 0.5d, 1d),
new SimpleCuboid(0.6875d, 0d, 0.9375d, 0.9375d, 0.5d, 1d),
new SimpleCuboid(0d, 0.625d, 0d, 0d, 0.8125d, 0.5625d),
new SimpleCuboid(1d, 0.625d, 0d, 1d, 0.8125d, 0.5625d)
);
} }

View File

@ -6,6 +6,7 @@ import net.minecraft.world.InteractionResult
import net.minecraft.world.ItemInteractionResult import net.minecraft.world.ItemInteractionResult
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.EntityBlock
import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntity
@ -15,9 +16,14 @@ import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.material.MapColor import net.minecraft.world.level.material.MapColor
import net.minecraft.world.level.material.PushReaction import net.minecraft.world.level.material.PushReaction
import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.BlockHitResult
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape
import net.neoforged.neoforge.fluids.FluidUtil import net.neoforged.neoforge.fluids.FluidUtil
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity
import ru.dbotthepony.mc.otm.block.getShapeForEachState
import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.shapes.BlockShapes
class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTime(1.5f).explosionResistance(10f).pushReaction(PushReaction.NORMAL).requiresCorrectToolForDrops().mapColor(MapColor.WATER)), EntityBlock { class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTime(1.5f).explosionResistance(10f).pushReaction(PushReaction.NORMAL).requiresCorrectToolForDrops().mapColor(MapColor.WATER)), EntityBlock {
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
@ -46,4 +52,15 @@ class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTi
return BlockEntityTicker { _, _, _, p_155256_ -> if (p_155256_ is InfiniteWaterSourceBlockEntity) p_155256_.tick() } return BlockEntityTicker { _, _, _, p_155256_ -> if (p_155256_ is InfiniteWaterSourceBlockEntity) p_155256_.tick() }
} }
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.INFINITE_WATER_SOURCE.rotateFromNorth(it[rotationProperty]).computeShape() }
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
context: CollisionContext
): VoxelShape {
return shapes[state]!!
}
} }

View File

@ -6,6 +6,7 @@ import net.minecraft.world.InteractionResult
import net.minecraft.world.ItemInteractionResult import net.minecraft.world.ItemInteractionResult
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.EntityBlock
import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.entity.BlockEntity
@ -13,9 +14,14 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker
import net.minecraft.world.level.block.entity.BlockEntityType 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.phys.BlockHitResult import net.minecraft.world.phys.BlockHitResult
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape
import net.neoforged.neoforge.fluids.FluidUtil import net.neoforged.neoforge.fluids.FluidUtil
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.PainterBlockEntity
import ru.dbotthepony.mc.otm.block.getShapeForEachState
import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.shapes.BlockShapes
class PainterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock { class PainterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBlock {
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
@ -42,4 +48,15 @@ class PainterBlock : RotatableMatteryBlock(DEFAULT_MACHINE_PROPERTIES), EntityBl
if (p_153212_.isClientSide) return null if (p_153212_.isClientSide) return null
return BlockEntityTicker { p_155253_, p_155254_, p_155255_, p_155256_ -> if (p_155256_ is PainterBlockEntity) p_155256_.tick() } return BlockEntityTicker { p_155253_, p_155254_, p_155255_, p_155256_ -> if (p_155256_ is PainterBlockEntity) p_155256_.tick() }
} }
private val shapes = getShapeForEachState(rotationProperty) { BlockShapes.PAINTER.rotateFromNorth(it[rotationProperty]).computeShape() }
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
context: CollisionContext
): VoxelShape {
return shapes[state]!!
}
} }