diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt index d57c6f303..9b7e6ab92 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/BlackHoleBlock.kt @@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes class BlackHoleBlock : - Block(Properties.of(Material.AIR, DyeColor.BLACK).noCollission().pushReaction(PushReaction.BLOCK).sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock { + Block(Properties.of(Material.AIR, DyeColor.BLACK).noCollission().sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock { override fun getShape( p_60555_: BlockState, p_60556_: BlockGetter, @@ -30,6 +30,10 @@ class BlackHoleBlock : return SHAPE } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return BlackHoleBlockEntity(blockPos, blockState) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt index d0405c814..04301faa0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/Cables.kt @@ -14,14 +14,14 @@ 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 net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.BooleanOp 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.MatterCableBlockEntity import ru.dbotthepony.mc.otm.block.entity.StorageCableBlockEntity -import ru.dbotthepony.mc.otm.block.entity.cable.EnergyCableBlockEntity import java.util.Collections import java.util.EnumMap @@ -38,6 +38,10 @@ abstract class CableBlock(properties: Properties) : MatteryBlock(properties) { override fun hasDynamicShape() = true + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { builder.add( CONNECTION_SOUTH, @@ -103,7 +107,7 @@ abstract class CableBlock(properties: Properties) : MatteryBlock(properties) { } } -class MatterCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { +class MatterCableBlock : CableBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { private val shapes = generateShapes(0.15) @Suppress("OVERRIDE_DEPRECATION") @@ -116,7 +120,7 @@ class MatterCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).req } } -class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { +class StorageCableBlock : CableBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { private val shapes = generateShapes(0.185) @Suppress("OVERRIDE_DEPRECATION") @@ -129,7 +133,7 @@ class StorageCableBlock : CableBlock(Properties.of().mapColor(MapColor.METAL).re } } -class EnergyCableBlock(val factory: (blockPos: BlockPos, blockState: BlockState) -> BlockEntity) : CableBlock(Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { +class EnergyCableBlock(val factory: (blockPos: BlockPos, blockState: BlockState) -> BlockEntity) : CableBlock(Properties.of(Material.METAL).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.0f, 6.0f)), EntityBlock { private val shapes = generateShapes(0.185) @Suppress("OVERRIDE_DEPRECATION") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt index 2643ffc89..c2709a0dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/ExplosionDebuggerBlock.kt @@ -9,15 +9,21 @@ 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.PushReaction import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger import ru.dbotthepony.mc.otm.registry.MBlockEntities -class BlockExplosionDebugger : Block(Properties.of().sound(SoundType.STONE)), EntityBlock { +class BlockExplosionDebugger : Block(Properties.of(Material.METAL).sound(SoundType.STONE)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return BlockEntityExplosionDebugger(p_153215_, p_153216_) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun getTicker( p_153212_: Level, p_153213_: BlockState, @@ -31,7 +37,7 @@ class BlockExplosionDebugger : Block(Properties.of().sound(SoundType.STONE)), En } } -class BlockSphereDebugger : Block(Properties.of()), EntityBlock { +class BlockSphereDebugger : Block(Properties.of(Material.STONE)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return BlockEntitySphereDebugger(p_153215_, p_153216_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index c7806370f..666dbf084 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -20,7 +20,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.Property -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled @@ -238,7 +238,7 @@ abstract class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block } companion object { - val DEFAULT_PROPERTIES: Properties = Properties.of().mapColor(MapColor.METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f) + val DEFAULT_PROPERTIES: Properties = Properties.of(Material.METAL).requiresCorrectToolForDrops().destroyTime(1.5f).explosionResistance(25.0f) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt index 09826b342..3074a4033 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/CargoCrateBlock.kt @@ -13,7 +13,8 @@ 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 net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape @@ -23,7 +24,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.shapes.BlockShapes class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock( - Properties.of().mapColor(color?.mapColor ?: MapColor.COLOR_BLUE).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.5f, 30.0f) + Properties.of(Material.METAL, color ?: DyeColor.BLUE).requiresCorrectToolForDrops().sound(SoundType.METAL).strength(1.5f, 30.0f) ), EntityBlock { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { return CargoCrateBlockEntity(blockPos, blockState) @@ -34,6 +35,10 @@ class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock( builder.add(IS_OPEN) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { return super.getStateForPlacement(context)?.setValue(IS_OPEN, false) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt index 9e2a1fbd5..af30a777e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/DevChestBlock.kt @@ -4,11 +4,17 @@ 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 net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity -class DevChestBlock : RotatableMatteryBlock(Properties.of().destroyTime(-1f).explosionResistance(360000f)), EntityBlock { +class DevChestBlock : RotatableMatteryBlock(Properties.of(Material.METAL).destroyTime(-1f).explosionResistance(360000f)), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return DevChestBlockEntity(p_153215_, p_153216_) } + + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.NORMAL + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt index d879d13a3..3c26d807c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/EngineBlock.kt @@ -3,12 +3,14 @@ package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.TooltipFlag import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock @@ -17,7 +19,7 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_ORANGE).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { +class EngineBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.ORANGE).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -28,6 +30,10 @@ class EngineBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLO p_49818_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.DARK_GRAY)) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.NORMAL + } + override fun rotationFreedom(): BlockRotationFreedom { return BlockRotationFreedom.DIRECTIONAL } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt index faab35e82..8713d0210 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/InfiniteWaterSourceBlock.kt @@ -7,15 +7,21 @@ 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.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MaterialColor +import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity -class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of().destroyTime(1.5f).explosionResistance(10f).requiresCorrectToolForDrops().mapColor(MapColor.WATER)), EntityBlock { +class InfiniteWaterSourceBlock : RotatableMatteryBlock(Properties.of(Material.METAL, MaterialColor.WATER).destroyTime(1.5f).explosionResistance(10f).requiresCorrectToolForDrops()), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return InfiniteWaterSourceBlockEntity(p_153215_, p_153216_) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType): BlockEntityTicker? { if (p_153212_.isClientSide) return null diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt index 3dc4aa81c..090ee9ef2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/LaboratoryLamp.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.block.decorative import net.minecraft.ChatFormatting import net.minecraft.core.BlockPos import net.minecraft.network.chat.Component +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.item.TooltipFlag @@ -13,7 +14,8 @@ import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockStateProperties -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape @@ -28,12 +30,16 @@ import ru.dbotthepony.mc.otm.registry.MBlocks private val FACING_FULL = BlockRotationFreedom.DIRECTIONAL.property -class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).noCollission().noLootTable().replaceable().lightLevel { 15 }) { +class LaboratoryLampLight : Block(Properties.of(Material.AIR).strength(-1.0F, 3600000.8F).noCollission().noLootTable().lightLevel { 15 }) { override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) builder.add(FACING_FULL) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.DESTROY + } + override fun hasDynamicShape(): Boolean { return true } @@ -102,11 +108,15 @@ class LaboratoryLampLight : Block(Properties.of().strength(-1.0F, 3600000.8F).no } } -class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of().mapColor(MapColor.METAL).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) { +class LaboratoryLamp(val invertRedstone: Boolean) : Block(Properties.of(Material.METAL, DyeColor.WHITE).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()) { init { registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.LIT, !invertRedstone)) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.NORMAL + } + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) builder.add(FACING_FULL) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt index 2f02e1a24..1a37c06e3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/decorative/TritaniumPressurePlate.kt @@ -19,10 +19,12 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.BlockStateProperties +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.get -class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of().mapColor(color ?: DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { +class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt index 285a6c7ca..921d991b8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/CargoCrateBlockEntity.kt @@ -19,7 +19,7 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.gameevent.GameEvent -import net.minecraft.world.level.storage.loot.LootParams +import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.phys.Vec3 @@ -105,7 +105,7 @@ class CargoCrateBlockEntity( val lootTableSeed = lootTableSeed ?: 0L val server = level?.server ?: return - val loot = server.lootData.getLootTable(lootTable) + val loot = server.lootTables.get(lootTable) if (ply is ServerPlayer) { CriteriaTriggers.GENERATE_LOOT.trigger(ply, lootTable) @@ -114,15 +114,16 @@ class CargoCrateBlockEntity( this.lootTable = null this.lootTableSeed = null - val params = LootParams.Builder(level as ServerLevel) + val params = LootContext.Builder(level as ServerLevel) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition)) if (ply != null) { params.withLuck(ply.luck).withParameter(LootContextParams.THIS_ENTITY, ply) } + params.withOptionalRandomSeed(lootTableSeed) Containers.dropContents(level as ServerLevel, blockPos, container) - loot.fill(container, params.create(LootContextParamSets.CHEST), lootTableSeed) + loot.fill(container, params.create(LootContextParamSets.CHEST)) } override val defaultDisplayName: Component diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt index 5b3afa5ef..94845f127 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/AndroidChargerBlock.kt @@ -20,6 +20,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 import net.minecraft.world.level.block.state.properties.EnumProperty +import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -37,7 +38,7 @@ import ru.dbotthepony.mc.otm.core.math.plus import ru.dbotthepony.mc.otm.oncePre import ru.dbotthepony.mc.otm.shapes.BlockShapes -class AndroidChargerBlock : RotatableMatteryBlock(Properties.of().destroyTime(2.5f).explosionResistance(40f).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops()), EntityBlock { +class AndroidChargerBlock : RotatableMatteryBlock(Properties.of(Material.METAL).destroyTime(2.5f).explosionResistance(40f).requiresCorrectToolForDrops()), EntityBlock { enum class Type : StringRepresentable { BASE, MIDDLE, @@ -48,6 +49,10 @@ class AndroidChargerBlock : RotatableMatteryBlock(Properties.of().destroyTime(2. } } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) builder.add(PART) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt index b6a0aaa1a..6a132d543 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/EnergyServoBlock.kt @@ -1,6 +1,7 @@ package ru.dbotthepony.mc.otm.block.tech import net.minecraft.core.BlockPos +import net.minecraft.world.item.DyeColor import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.Level import net.minecraft.world.level.block.EntityBlock @@ -9,7 +10,8 @@ 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.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock @@ -19,11 +21,15 @@ import ru.dbotthepony.mc.otm.core.get import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.shapes.BlockShapes -class EnergyServoBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()), EntityBlock { +class EnergyServoBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).explosionResistance(12f).destroyTime(2f).requiresCorrectToolForDrops()), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return EnergyServoBlockEntity(p_153215_, p_153216_) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun getTicker( p_153212_: Level, p_153213_: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt index e2f33127e..71ebb5841 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/GravitationStabilizerBlock.kt @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.SectionPos import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter @@ -18,7 +19,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -36,13 +37,17 @@ import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes import kotlin.math.PI -private val props = BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).pushReaction(PushReaction.BLOCK).requiresCorrectToolForDrops().strength(3f, 600.0f) +private val props = BlockBehaviour.Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).requiresCorrectToolForDrops().strength(3f, 600.0f) class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { return GravitationStabilizerBlockEntity(p_153215_, p_153216_) } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun getTicker( p_153212_: Level, p_153213_: BlockState, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index 9e0ff3fe7..b654f1e0a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -8,6 +8,7 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.MobSpawnType import net.minecraft.world.entity.SpawnGroupData import net.minecraft.world.entity.monster.Phantom +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.ItemStack import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.level.BlockGetter @@ -20,7 +21,8 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraft.world.level.block.state.properties.DoubleBlockHalf -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.AABB import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -34,7 +36,7 @@ import ru.dbotthepony.mc.otm.once import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.shapes.BlockShapes -class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).destroyTime(3f).explosionResistance(12f).randomTicks()) { +class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).destroyTime(3f).explosionResistance(12f).randomTicks()) { @Suppress("OVERRIDE_DEPRECATION") override fun randomTick( blockState: BlockState, @@ -68,6 +70,10 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of().mapColor(Map } } + override fun getPistonPushReaction(p_60584_: BlockState): PushReaction { + return PushReaction.BLOCK + } + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { super.createBlockStateDefinition(builder) builder.add(BlockStateProperties.DOUBLE_BLOCK_HALF) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt index d8b1c49c4..53c1f89e7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt @@ -3,12 +3,13 @@ package ru.dbotthepony.mc.otm.client.render import com.google.common.collect.ImmutableList import com.mojang.blaze3d.vertex.BufferBuilder import com.mojang.blaze3d.vertex.VertexConsumer -import com.mojang.blaze3d.vertex.VertexSorting +import it.unimi.dsi.fastutil.ints.IntArrays import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.Sheets +import org.joml.Vector3f private fun equals(existing: ImmutableList?, types: Array): Boolean { if (types.isEmpty()) { @@ -63,7 +64,8 @@ private fun equals(existing: ImmutableList?, types: ImmutableList= 0) { "Invalid minimal buffer size $minimalInitialBufferSize" } require(maximalInitialBufferSize >= minimalInitialBufferSize) { "Maximal buffer size $maximalInitialBufferSize must be greater or equal to minimal buffer size $minimalInitialBufferSize" } @@ -350,7 +352,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit for (state in bufferList) { if (state.dirty) { state.dirty = false - state.type.end(state.builder, vertexSorting) + state.type.end(state.builder, sortX, sortY, sortZ) } } } @@ -360,7 +362,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit if (state.dirty) { state.dirty = false - type.end(state.builder, vertexSorting) + type.end(state.builder, sortX, sortY, sortZ) } } @@ -369,7 +371,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit if (state.dirty) { state.dirty = false - type.end(state.builder, vertexSorting) + type.end(state.builder, sortX, sortY, sortZ) } for (ustate in state.dependants) { @@ -380,7 +382,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit private fun endBatchChain(state: State) { if (state.dirty) { state.dirty = false - state.type.end(state.builder, vertexSorting) + state.type.end(state.builder, sortX, sortY, sortZ) } for (ustate in state.dependants) { @@ -390,7 +392,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit companion object { @JvmField - val GUI = DynamicBufferSource(maximalInitialBufferSize = 2 shl 8, vertexSorting = VertexSorting.ORTHOGRAPHIC_Z) + val GUI = DynamicBufferSource(maximalInitialBufferSize = 2 shl 8) @JvmField val WORLD = DynamicBufferSource(minimalInitialBufferSize = 2 shl 12) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt index 891815dad..cf9383d38 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/FontRenderer.kt @@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.component3 -private val buffer = DynamicBufferSource(vertexSorting = VertexSorting.ORTHOGRAPHIC_Z) +private val buffer = DynamicBufferSource() private fun buffer() = buffer private fun Font.drawInBatch( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt index e72eb091d..dfa97516c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MGUIGraphics.kt @@ -1,17 +1,23 @@ package ru.dbotthepony.mc.otm.client.render import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.BufferUploader +import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.Tesselator +import com.mojang.blaze3d.vertex.VertexFormat import net.minecraft.client.gui.Font - +import net.minecraft.client.gui.GuiComponent +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent +import net.minecraft.client.gui.screens.inventory.tooltip.TooltipRenderUtil +import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.MultiBufferSource -import net.minecraft.client.renderer.RenderBuffers import net.minecraft.client.renderer.texture.TextureAtlasSprite import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.util.FormattedCharSequence import net.minecraft.world.item.ItemStack +import net.minecraftforge.client.ForgeHooksClient import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.core.math.RGBAColor import kotlin.math.PI @@ -29,7 +35,7 @@ class MGUIGraphics(val pose: PoseStack) { } fun renderFakeItem(itemStack: ItemStack, x: Int, y: Int) { - parent.renderFakeItem(itemStack, x, y) + minecraft.itemRenderer.renderGuiItem(pose, itemStack, x, y) } fun drawLine( @@ -81,10 +87,59 @@ class MGUIGraphics(val pose: PoseStack) { } fun renderComponentTooltip(font: Font, lines: MutableList, x: Int, y: Int, itemStack: ItemStack = ItemStack.EMPTY) { - parent.renderComponentTooltip(font, lines, x, y, itemStack) + if (lines.isNotEmpty()) { + val mapped = lines.map { ClientTooltipComponent.create(it.visualOrderText) } + val preEvent = ForgeHooksClient.onRenderTooltipPre(itemStack, pose, x, y, width, height, mapped, font, font) + + if (preEvent.isCanceled) return + var i = 0 + var j = if (lines.size == 1) -2 else 0 + + for (line in mapped) { + val k = line.getWidth(preEvent.font) + if (k > i) i = k + j += line.height + } + + pose.pushPose() + val tesselator = Tesselator.getInstance() + val bufferbuilder = tesselator.builder + RenderSystem.setShader { GameRenderer.getPositionColorShader() } + bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR) + val matrix4f = pose.last().pose() + val colorEvent = ForgeHooksClient.onRenderTooltipColor(itemStack, pose, x, y, preEvent.font, mapped) + + TooltipRenderUtil.renderTooltipBackground(GuiComponent::fillGradient, matrix4f, bufferbuilder, x, y, i, j, 400, colorEvent.backgroundStart, colorEvent.backgroundEnd, colorEvent.borderStart, colorEvent.borderEnd) + RenderSystem.enableDepthTest() + RenderSystem.enableBlend() + RenderSystem.defaultBlendFunc() + BufferUploader.drawWithShader(bufferbuilder.end()) + + pose.translate(0.0f, 0.0f, 400.0f) + var yCurrent = y + + for (i in mapped.indices) { + val line = mapped[i] + line.renderText(preEvent.font, x, yCurrent, matrix4f, bufferSource) + yCurrent += line.height + if (i == 0) 2 else 0 + } + + bufferSource.endBatch() + + yCurrent = y + + for (i in mapped.indices) { + val line = mapped[i] + line.renderImage(preEvent.font, x, yCurrent, pose, minecraft.itemRenderer) + yCurrent += line.height + if (i == 0) 2 else 0 + } + + pose.popPose() + } } fun flush() { + bufferSource.endBatch() } fun draw( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 1ce1d3d89..390f880b2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels.slot import com.mojang.blaze3d.systems.RenderSystem -import net.minecraft.client.gui.screens.Screen.getTooltipFromItem import net.minecraft.client.renderer.GameRenderer import net.minecraft.network.chat.Component import net.minecraft.world.item.ItemStack @@ -43,7 +42,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru } protected open fun getItemStackTooltip(stack: ItemStack): MutableList { - return getTooltipFromItem(ru.dbotthepony.mc.otm.client.minecraft, stack) + return screen.getTooltipFromItem(stack) } override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt index 41da7dc50..3abd71787 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt @@ -70,11 +70,14 @@ open class SlotPanel, out T : Slot> @JvmOverloads const itemstack = carried.copy() dragHit = true - val k = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount( + AbstractContainerMenu.getQuickCraftSlotCount( screen.quickCraftSlots, screen.quickCraftingType, - itemstack - ) + slot.item.count, slot.getMaxStackSize(itemstack)) + itemstack, + slot.item.count + ) + + val k = Math.min(slot.item.count, slot.getMaxStackSize(itemstack)) if (itemstack.count > k) { countOverride = ChatFormatting.YELLOW.toString() + k diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 60b1fca84..0966efef3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -57,7 +57,7 @@ private fun Player.getCuriosSlotsImpl(): List> { val stacks = curio.stacks for (slot in 0 until stacks.slots) { - val regular = CurioSlot(this, stacks, slot, identifier, 0, 0, curio.renders, curio.canToggleRendering()) + val regular = CurioSlot(this, stacks, slot, identifier, 0, 0, curio.renders) if (curio.hasCosmetic()) { val cosmetic = CosmeticCurioSlot(this, curio.cosmeticStacks, slot, identifier, 0, 0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt index a3ce8ca09..ca75aeba9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MatterEntanglerRecipeCategory.kt @@ -75,8 +75,8 @@ object MatterEntanglerRecipeCategory : IRecipeCategory, ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, xOffset + 89f, yOffset + 18f + 4f) } - override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, guiGraphics: GuiGraphics, mouseX: Double, mouseY: Double) { - val wrap = MGUIGraphics(guiGraphics) + override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, poseStack: PoseStack, mouseX: Double, mouseY: Double) { + val wrap = MGUIGraphics(poseStack) renderMatterGauge(wrap, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat()) renderEnergyGauge(wrap, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt index 7ac0538f4..4e94fa4b5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt @@ -68,11 +68,11 @@ object MicrowaveRecipeCategory : IRecipeCategory, IDrawable { override fun draw( recipe: MicrowaveRecipe, recipeSlotsView: IRecipeSlotsView, - graphics: GuiGraphics, + poseStack: PoseStack, mouseX: Double, mouseY: Double ) { - val wrap = MGUIGraphics(graphics) + val wrap = MGUIGraphics(poseStack) wrap.draw(TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK) val average = recipe.experience.toString() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt index 3df88999a..9ecf82023 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/ChestUpgraderItem.kt @@ -18,7 +18,7 @@ import net.minecraft.world.level.block.LevelEvent import net.minecraft.world.level.block.entity.BarrelBlockEntity import net.minecraft.world.level.block.entity.ChestBlockEntity import net.minecraft.world.level.gameevent.GameEvent -import net.minecraft.world.level.storage.loot.LootParams +import net.minecraft.world.level.storage.loot.LootContext import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraftforge.event.entity.player.PlayerInteractEvent import ru.dbotthepony.mc.otm.OverdriveThatMatters.MOD_ID @@ -70,7 +70,7 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { val level = context.level as ServerLevel - val lootparams = LootParams.Builder(level) + val lootparams = LootContext.Builder(level) .withParameter(LootContextParams.ORIGIN, Vector.atCenterOf(context.clickedPos)) .withParameter(LootContextParams.TOOL, stack) .withOptionalParameter(LootContextParams.BLOCK_ENTITY, hitBlockEntity) @@ -155,7 +155,7 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) { } cart.clearContent() - (cart as AbstractMinecart).destroy(cart.damageSources().genericKill()) + (cart as AbstractMinecart).destroy(cart.damageSources().generic()) level.addFreshEntity(newCart) level.gameEvent(GameEvent.ENTITY_PLACE, event.pos, GameEvent.Context.of(event.entity, level.getBlockState(event.pos.below()))) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt index f73d1e979..9c1cc83f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/weapon/EnergySwordItem.kt @@ -24,6 +24,7 @@ import net.minecraft.world.item.enchantment.Enchantments import net.minecraft.world.level.Level import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.material.Material import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ToolAction import net.minecraftforge.common.ToolActions @@ -84,11 +85,17 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani val energy = itemStack.getCapability(MatteryCapability.ENERGY).orNull() ?: return 1f if (blockState.`is`(Blocks.COBWEB)) { - return if (energy.batteryLevel < COBWEB_POWER_COST) 2f else 25f - } else if (blockState.`is`(BlockTags.SWORD_EFFICIENT)) { - return if (energy.batteryLevel < PLANT_POWER_COST) 1.5f else 8f - } else { - return 1f + if (energy.batteryLevel < COBWEB_POWER_COST) { + return 2f + } else { + return 25f + } + } + + return when (blockState.material) { + Material.PLANT, Material.REPLACEABLE_PLANT, Material.VEGETABLE -> if (energy.batteryLevel < PLANT_POWER_COST) 1.5f else 4f + Material.LEAVES -> if (energy.batteryLevel < PLANT_POWER_COST) 1.5f else 8f + else -> 1f } } @@ -161,9 +168,10 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani if (blockState.getDestroySpeed(p_41417_, p_41419_) != 0f && (user !is Player || !user.isCreative)) { val energy = itemStack.matteryEnergy - if (blockState.`is`(BlockTags.SWORD_EFFICIENT)) { - if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true) - energy.extractEnergyExact(user.level.random.nextVariance(PLANT_POWER_COST_VARIANCE), false) + when (blockState.material) { + Material.PLANT, Material.REPLACEABLE_PLANT, Material.VEGETABLE, Material.LEAVES -> + if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true) + energy.extractEnergyExact(user.level.random.nextVariance(PLANT_POWER_COST_VARIANCE), false) } if (blockState.`is`(Blocks.COBWEB)) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index b8467b1db..b9a735e3e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -1592,7 +1592,7 @@ object MatterManager { val targetFile = File(MINECRAFT_SERVER.serverDirectory, "otm/registry_dumps/${filter.name.lowercase()}_${System.currentTimeMillis() / 1_000L}.csv") File(MINECRAFT_SERVER.serverDirectory, "otm/registry_dumps").mkdirs() - stack.source.sendSuccess({ TranslatableComponent("otm.dumping_matter_registry", targetFile.absolutePath) }, false) + stack.source.sendSuccess(TranslatableComponent("otm.dumping_matter_registry", targetFile.absolutePath), false) val writer = targetFile.bufferedWriter(Charsets.UTF_8) @@ -1638,7 +1638,7 @@ object MatterManager { writer.close() - stack.source.sendSuccess({ TranslatableComponent("otm.dumped_matter_registry", targetFile.absolutePath) }, true) + stack.source.sendSuccess(TranslatableComponent("otm.dumped_matter_registry", targetFile.absolutePath), true) return 0 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt index bb75430c5..4fe772498 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -27,7 +27,8 @@ import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.NoteBlockInstrument -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MaterialColor import net.minecraft.world.level.material.PushReaction import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.registries.DeferredRegister @@ -143,22 +144,21 @@ object MBlocks { val FLUID_TANK: FluidTankBlock by registry.register(MNames.FLUID_TANK) { FluidTankBlock() } val DEV_CHEST: DevChestBlock by registry.register(MNames.DEV_CHEST) { DevChestBlock() } - val LIQUID_XP: LiquidBlock by registry.register("liquid_xp") { LiquidBlock(MFluids::LIQUID_XP, BlockBehaviour.Properties.of().mapColor(MapColor.EMERALD).replaceable().noCollission().strength(100.0f).pushReaction(PushReaction.DESTROY).noLootTable().liquid().sound(SoundType.EMPTY)) } + val LIQUID_XP: LiquidBlock by registry.register("liquid_xp") { LiquidBlock(MFluids::LIQUID_XP, BlockBehaviour.Properties.of(Material.WATER, MaterialColor.EMERALD).noCollission().strength(100.0f).noLootTable().sound(SoundType.POWDER_SNOW)) } val TRITANIUM_ORE: Block by registry.register(MNames.TRITANIUM_ORE) { DropExperienceBlock( - BlockBehaviour.Properties.of() - .mapColor(MapColor.STONE) + BlockBehaviour.Properties.of(Material.STONE) .strength(3.25f, 6.0f) .requiresCorrectToolForDrops(), UniformInt.of(0, 3) ) } val TRITANIUM_INGOT_BLOCK: Block by registry.register(MNames.TRITANIUM_INGOT_BLOCK) { - Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).sound(SoundType.METAL).explosionResistance(400f).destroyTime(3f).requiresCorrectToolForDrops()) + Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.BLUE).sound(SoundType.METAL).explosionResistance(400f).destroyTime(3f).requiresCorrectToolForDrops()) } val METAL_JUNK: Block by registry.register(MNames.METAL_JUNK) { - object : Block(BlockBehaviour.Properties.of().sound(SoundType.NETHERITE_BLOCK).mapColor(MapColor.COLOR_GRAY).explosionResistance(45f).destroyTime(3f).requiresCorrectToolForDrops()) { + object : Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).sound(SoundType.NETHERITE_BLOCK).explosionResistance(45f).destroyTime(3f).requiresCorrectToolForDrops()) { override fun appendHoverText( p_49816_: ItemStack, p_49817_: BlockGetter?, @@ -172,20 +172,18 @@ object MBlocks { } val METAL_MESH: Block by registry.register(MNames.METAL_MESH) { - Block(BlockBehaviour.Properties.of() - .mapColor(MapColor.COLOR_GRAY) + Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY) .noOcclusion() .sound(SoundType.COPPER).explosionResistance(30f) .destroyTime(2f).requiresCorrectToolForDrops()) } val TRITANIUM_BARS: IronBarsBlock by registry.register(MNames.TRITANIUM_BARS) { - IronBarsBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(45f).destroyTime(2.5f).requiresCorrectToolForDrops()) + IronBarsBlock(BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE).sound(SoundType.METAL).explosionResistance(45f).destroyTime(2.5f).requiresCorrectToolForDrops()) } val DEEPSLATE_TRITANIUM_ORE: Block by registry.register(MNames.DEEPSLATE_TRITANIUM_ORE) { DropExperienceBlock( - BlockBehaviour.Properties.of() - .mapColor(MapColor.DEEPSLATE) + BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE) .sound(SoundType.DEEPSLATE) .strength(4.75f, 6.5f) .requiresCorrectToolForDrops().sound(SoundType.DEEPSLATE), @@ -193,14 +191,14 @@ object MBlocks { ) } val TRITANIUM_RAW_BLOCK: Block by registry.register(MNames.TRITANIUM_RAW_BLOCK) { Block( - BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_LIGHT_BLUE).instrument(NoteBlockInstrument.BASEDRUM).strength(8.0f, 10f).requiresCorrectToolForDrops() + BlockBehaviour.Properties.of(Material.STONE, DyeColor.LIGHT_BLUE).strength(8.0f, 10f).requiresCorrectToolForDrops() ) } val LABORATORY_LAMP: Block by registry.register(MNames.LABORATORY_LAMP) { LaboratoryLamp(false) } val LABORATORY_LAMP_INVERTED: Block by registry.register(MNames.LABORATORY_LAMP_INVERTED) { LaboratoryLamp(true) } val LABORATORY_LAMP_LIGHT: Block by registry.register(MNames.LABORATORY_LAMP_LIGHT) { LaboratoryLampLight() } - val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) } - val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_GRAY).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } + val DANGER_STRIPE_BLOCK: Block by registry.register(MNames.DANGER_STRIPE_BLOCK) { Block(BlockBehaviour.Properties.of(Material.STONE, DyeColor.GRAY).explosionResistance(6f).destroyTime(1.5f).requiresCorrectToolForDrops()) } + val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) } val ENGINE: Block by registry.register(MNames.ENGINE) { EngineBlock() } val HOLO_SIGN: Block by registry.register(MNames.HOLO_SIGN) { HoloSignBlock() } @@ -212,12 +210,10 @@ object MBlocks { val anvils = ArrayList<() -> Block>() for (i in 0 until TRITANIUM_ANVIL_VARIANTS) { - val props = BlockBehaviour.Properties.of() - .mapColor(MapColor.COLOR_LIGHT_BLUE) + val props = BlockBehaviour.Properties.of(Material.HEAVY_METAL, DyeColor.LIGHT_BLUE) .sound(SoundType.ANVIL) .destroyTime(2.5f - i * 0.15f) .explosionResistance(1200f - i * 80f) - .pushReaction(PushReaction.BLOCK) .requiresCorrectToolForDrops() anvils.add(registry.register(MNames.TRITANIUM_ANVIL + i) { AnvilBlock(props) }::get) @@ -228,12 +224,10 @@ object MBlocks { val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ -> object : DoorBlock( - Properties.of() - .mapColor(color ?: DyeColor.LIGHT_BLUE) + Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE) .explosionResistance(80f) .noOcclusion() .destroyTime(3f) - .pushReaction(PushReaction.DESTROY) .requiresCorrectToolForDrops(), BlockSetType.IRON ) { @@ -265,8 +259,7 @@ object MBlocks { val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> object : TrapDoorBlock( - Properties.of() - .mapColor(color ?: DyeColor.LIGHT_BLUE) + Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE) .explosionResistance(80f) .noOcclusion().destroyTime(3f) .requiresCorrectToolForDrops() @@ -309,8 +302,7 @@ object MBlocks { } val TRITANIUM_STRIPED_BLOCK: Block by registry.register(MNames.TRITANIUM_STRIPED_BLOCK) { Block( - BlockBehaviour.Properties.of() - .mapColor(MapColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(80f) @@ -331,8 +323,7 @@ object MBlocks { } val CARBON_FIBRE_BLOCK: Block by registry.register(MNames.CARBON_FIBRE_BLOCK) { Block( - BlockBehaviour.Properties.of() - .mapColor(MapColor.COLOR_GRAY) + BlockBehaviour.Properties.of(Material.METAL, DyeColor.BLACK) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(40f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt index 258ca4ed1..118ae68ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MCreativeTabs.kt @@ -1,27 +1,24 @@ package ru.dbotthepony.mc.otm.registry -import net.minecraft.core.registries.Registries import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.CreativeModeTab -import net.minecraft.world.item.CreativeModeTabs import net.minecraft.world.item.DyeColor import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.level.material.Fluids import net.minecraftforge.common.capabilities.ForgeCapabilities -import net.minecraftforge.event.BuildCreativeModeTabContentsEvent -import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.event.CreativeModeTabEvent import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.capability.IFluidHandler -import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.matter.matter import ru.dbotthepony.mc.otm.capability.matteryEnergy -import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.registryName +import ru.dbotthepony.mc.otm.core.util.CreativeMenuItemComparator +import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.registry.MItems.BATTERY_CREATIVE private fun CreativeModeTab.Output.accept(values: Collection) { @@ -271,34 +268,30 @@ private fun addDecorativeTabItems(consumer: CreativeModeTab.Output) { } object MCreativeTabs { - private val registry = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, OverdriveThatMatters.MOD_ID) + var MAIN by WriteOnce() + private set + var DECORATIVE by WriteOnce() + private set - val MAIN: CreativeModeTab by registry.register("main") { - CreativeModeTab.builder() - .title(TranslatableComponent("itemGroup.otm")) - .icon { ItemStack(BATTERY_CREATIVE, 1) } - .withTabsBefore(CreativeModeTabs.SPAWN_EGGS) - .build() - } - - val DECORATIVE: CreativeModeTab by registry.register("decorative") { - CreativeModeTab.builder() - .title(TranslatableComponent("itemGroup.otm_decorative")) - .icon { ItemStack(MRegistry.VENT.item, 1) } - .withTabsBefore(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) - .build() - } - - internal fun initialize(bus: IEventBus) { - registry.register(bus) - } - - fun register(event: BuildCreativeModeTabContentsEvent) { + fun register(event: CreativeModeTabEvent.Register) { CreativeMenuItemComparator.invalidate() - when (event.tab) { - MAIN -> addMainCreativeTabItems(event) - DECORATIVE -> addDecorativeTabItems(event) + MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) { + it.icon { ItemStack(BATTERY_CREATIVE, 1) } + it.title(TranslatableComponent("itemGroup.otm")) + + it.displayItems { _, consumer -> + addMainCreativeTabItems(consumer) + } + } + + DECORATIVE = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "decorative")) { + it.icon { ItemStack(MRegistry.VENT.item, 1) } + it.title(TranslatableComponent("itemGroup.otm_decorative")) + + it.displayItems { _, consumer -> + addDecorativeTabItems(consumer) + } } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt index 715970109..90b228bb3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -2,7 +2,9 @@ package ru.dbotthepony.mc.otm.registry import com.google.common.collect.ImmutableSet import com.google.common.collect.Streams +import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.advancements.CriteriaTriggers +import net.minecraft.client.gui.Font import net.minecraft.client.renderer.item.ItemProperties import net.minecraft.core.BlockPos import net.minecraft.core.cauldron.CauldronInteraction @@ -11,15 +13,19 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.ai.village.poi.PoiType import net.minecraft.world.entity.ai.village.poi.PoiTypes +import net.minecraft.world.item.DyeColor import net.minecraft.world.item.DyeableArmorItem +import net.minecraft.world.item.ItemStack import net.minecraft.world.item.Items import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.* import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.properties.NoteBlockInstrument -import net.minecraft.world.level.material.MapColor +import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MaterialColor import net.minecraftforge.api.distmarker.Dist +import net.minecraftforge.client.IItemDecorator import net.minecraftforge.client.event.RegisterColorHandlersEvent import net.minecraftforge.client.event.RegisterItemDecorationsEvent import net.minecraftforge.client.model.DynamicFluidContainerModel @@ -88,8 +94,7 @@ object MRegistry { val CARGO_CRATES = DecorativeBlock(MNames.CARGO_CRATE, ::CargoCrateBlock) val DECORATIVE_CRATE = DecorativeBlock.simple(MNames.DECORATIVE_CRATE) { - BlockBehaviour.Properties.of() - .mapColor(it?.mapColor ?: MapColor.SNOW) + BlockBehaviour.Properties.of(Material.METAL, MaterialColor.SNOW) .sound(SoundType.METAL) .requiresCorrectToolForDrops() .explosionResistance(10f) @@ -97,8 +102,7 @@ object MRegistry { } val TRITANIUM_BLOCK = DecorativeBlock.simple(MNames.TRITANIUM_BLOCK) { - BlockBehaviour.Properties.of() - .mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(80f) @@ -123,8 +127,7 @@ object MRegistry { val TRITANIUM_PRESSURE_PLATE = DecorativeBlock(MNames.TRITANIUM_PRESSURE_PLATE, ::TritaniumPressurePlate) val VENT = DecorativeBlock.simple(MNames.VENT) { - BlockBehaviour.Properties.of() - .mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(20f) @@ -132,8 +135,7 @@ object MRegistry { } val VENT_ALTERNATIVE = DecorativeBlock.simple(MNames.VENT_ALTERNATIVE) { - BlockBehaviour.Properties.of() - .mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE) + BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(20f) @@ -141,8 +143,7 @@ object MRegistry { } val FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.FLOOR_TILES) { - BlockBehaviour.Properties.of() - .mapColor(it.mapColor) + BlockBehaviour.Properties.of(Material.STONE, it) .sound(SoundType.STONE) .requiresCorrectToolForDrops() .strength(1.5f, 6f) @@ -160,17 +161,14 @@ object MRegistry { } val UNREFINED_FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.UNREFINED_FLOOR_TILES) { - BlockBehaviour.Properties.of() - .mapColor(it.mapColor) + BlockBehaviour.Properties.of(Material.CLAY, it) .sound(SoundType.GRAVEL) .strength(1f, 2f) } val INDUSTRIAL_GLASS = DecorativeBlock(MNames.INDUSTRIAL_GLASS) { color -> val properties = - BlockBehaviour.Properties.of() - .mapColor(if (color != null) color.mapColor else MapColor.NONE) - .instrument(NoteBlockInstrument.HAT) + BlockBehaviour.Properties.of(Material.GLASS, color?.materialColor ?: MaterialColor.NONE) .destroyTime(1.5f) .explosionResistance(40f) .requiresCorrectToolForDrops() @@ -190,9 +188,7 @@ object MRegistry { val INDUSTRIAL_GLASS_PANE = DecorativeBlock(MNames.INDUSTRIAL_GLASS_PANE) { color -> val properties = - BlockBehaviour.Properties.of() - .mapColor(if (color != null) color.mapColor else MapColor.NONE) - .instrument(NoteBlockInstrument.HAT) + BlockBehaviour.Properties.of(Material.GLASS, color?.materialColor ?: MaterialColor.NONE) .strength(1.25f, 5.0f) .requiresCorrectToolForDrops() .sound(SoundType.GLASS) @@ -206,8 +202,7 @@ object MRegistry { } val TRITANIUM_STRIPED_BLOCK = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_BLOCK, { colorA, _ -> - Block(BlockBehaviour.Properties.of() - .mapColor(colorA.mapColor) + Block(BlockBehaviour.Properties.of(Material.METAL, colorA) .sound(SoundType.BASALT) .requiresCorrectToolForDrops() .explosionResistance(80f) @@ -263,7 +258,7 @@ object MRegistry { bus.addListener(this::registerItemColorHandlers) bus.addListener(this::registerItemDecorators) - MCreativeTabs.initialize(bus) + bus.addListener(MCreativeTabs::register) DecimalProvider.register(bus) AndroidResearchDescription.register(bus) @@ -371,7 +366,16 @@ object MRegistry { } private fun registerItemDecorators(event: RegisterItemDecorationsEvent) { - event.register(Items.SHIELD, MatteryGUI::renderShieldCooldownOverlay) - event.register(MItems.TRITANIUM_SHIELD, MatteryGUI::renderShieldCooldownOverlay) + event.register(Items.SHIELD, object : IItemDecorator { + override fun render(poseStack: PoseStack, font: Font, stack: ItemStack, xOffset: Int, yOffset: Int): Boolean { + return MatteryGUI.renderShieldCooldownOverlay(poseStack, font, stack, xOffset, yOffset) + } + }) + + event.register(MItems.TRITANIUM_SHIELD, object : IItemDecorator { + override fun render(poseStack: PoseStack, font: Font, stack: ItemStack, xOffset: Int, yOffset: Int): Boolean { + return MatteryGUI.renderShieldCooldownOverlay(poseStack, font, stack, xOffset, yOffset) + } + }) } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 86504a276..d00eefc3f 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -12,25 +12,30 @@ public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_1696 public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97732_ # menu public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_169604_ # playerInventoryTitle -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97706_ # clickedSlot -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97707_ # snapbackEnd -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97708_ # quickdropSlot -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97709_ # lastClickSlot -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97710_ # isSplittingStack -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97711_ # draggingItem -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97712_ # snapbackStartX -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97713_ # snapbackStartY -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97714_ # snapbackTime -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97715_ # snapbackItem -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97716_ # quickdropTime -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97717_ # quickCraftingType -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97718_ # quickCraftingButton -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97719_ # skipNextRelease -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97720_ # quickCraftingRemainder -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97721_ # lastClickTime -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97722_ # lastClickButton -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97723_ # doubleclick -protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97724_ # lastQuickMoved +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97706_ # clickedSlot +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97707_ # snapbackEnd +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97708_ # quickdropSlot +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97709_ # lastClickSlot +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97710_ # isSplittingStack +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97711_ # draggingItem +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97712_ # snapbackStartX +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97713_ # snapbackStartY +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97714_ # snapbackTime +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97715_ # snapbackItem +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97716_ # quickdropTime +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97717_ # quickCraftingType +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97718_ # quickCraftingButton +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97719_ # skipNextRelease +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97720_ # quickCraftingRemainder +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97721_ # lastClickTime +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97722_ # lastClickButton +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97723_ # doubleclick +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97724_ # lastQuickMoved +public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_274323_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem + +public net.minecraft.client.gui.GuiComponent m_168740_(Lcom/mojang/blaze3d/vertex/PoseStack;IIIIIII)V # fillGradient +public net.minecraft.client.gui.GuiComponent m_93123_(Lorg/joml/Matrix4f;Lcom/mojang/blaze3d/vertex/BufferBuilder;IIIIIII)V # fillGradient +public net.minecraft.client.gui.GuiComponent m_93179_(Lcom/mojang/blaze3d/vertex/PoseStack;IIIIII)V # fillGradient public net.minecraft.world.item.BlockItem f_150696_ # BLOCK_ENTITY_TAG