More backporting

This commit is contained in:
DBotThePony 2024-01-01 11:19:20 +07:00
parent e3e02dbad2
commit 0bcc078fe9
Signed by: DBot
GPG Key ID: DCC23B5715498507
30 changed files with 299 additions and 167 deletions

View File

@ -20,7 +20,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes import ru.dbotthepony.mc.otm.shapes.BlockShapes
class BlackHoleBlock : 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( override fun getShape(
p_60555_: BlockState, p_60555_: BlockState,
p_60556_: BlockGetter, p_60556_: BlockGetter,
@ -30,6 +30,10 @@ class BlackHoleBlock :
return SHAPE return SHAPE
} }
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.BLOCK
}
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return BlackHoleBlockEntity(blockPos, blockState) return BlackHoleBlockEntity(blockPos, blockState)
} }

View File

@ -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.BlockState
import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BooleanProperty 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.BooleanOp
import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.entity.MatterCableBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatterCableBlockEntity
import ru.dbotthepony.mc.otm.block.entity.StorageCableBlockEntity import ru.dbotthepony.mc.otm.block.entity.StorageCableBlockEntity
import ru.dbotthepony.mc.otm.block.entity.cable.EnergyCableBlockEntity
import java.util.Collections import java.util.Collections
import java.util.EnumMap import java.util.EnumMap
@ -38,6 +38,10 @@ abstract class CableBlock(properties: Properties) : MatteryBlock(properties) {
override fun hasDynamicShape() = true override fun hasDynamicShape() = true
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.BLOCK
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) { override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add( builder.add(
CONNECTION_SOUTH, 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) private val shapes = generateShapes(0.15)
@Suppress("OVERRIDE_DEPRECATION") @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) private val shapes = generateShapes(0.185)
@Suppress("OVERRIDE_DEPRECATION") @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) private val shapes = generateShapes(0.185)
@Suppress("OVERRIDE_DEPRECATION") @Suppress("OVERRIDE_DEPRECATION")

View File

@ -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.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.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.BlockEntityExplosionDebugger
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger
import ru.dbotthepony.mc.otm.registry.MBlockEntities 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return BlockEntityExplosionDebugger(p_153215_, p_153216_) return BlockEntityExplosionDebugger(p_153215_, p_153216_)
} }
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.BLOCK
}
override fun <T : BlockEntity?> getTicker( override fun <T : BlockEntity?> getTicker(
p_153212_: Level, p_153212_: Level,
p_153213_: BlockState, 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return BlockEntitySphereDebugger(p_153215_, p_153216_) return BlockEntitySphereDebugger(p_153215_, p_153216_)
} }

View File

@ -20,7 +20,7 @@ import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.EntityBlock import net.minecraft.world.level.block.EntityBlock
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.properties.Property 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.BlockHitResult
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled import ru.dbotthepony.mc.otm.block.entity.IRedstoneControlled
@ -238,7 +238,7 @@ abstract class MatteryBlock(properties: Properties = DEFAULT_PROPERTIES) : Block
} }
companion object { 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)
} }
} }

View File

@ -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.BlockState
import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BooleanProperty 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.CollisionContext
import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape 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 import ru.dbotthepony.mc.otm.shapes.BlockShapes
class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock( 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 { ), EntityBlock {
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity { override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return CargoCrateBlockEntity(blockPos, blockState) return CargoCrateBlockEntity(blockPos, blockState)
@ -34,6 +35,10 @@ class CargoCrateBlock(val color: DyeColor?) : RotatableMatteryBlock(
builder.add(IS_OPEN) builder.add(IS_OPEN)
} }
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.BLOCK
}
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? { override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
return super.getStateForPlacement(context)?.setValue(IS_OPEN, false) return super.getStateForPlacement(context)?.setValue(IS_OPEN, false)
} }

View File

@ -4,11 +4,17 @@ import net.minecraft.core.BlockPos
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
import net.minecraft.world.level.block.state.BlockState 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.RotatableMatteryBlock
import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return DevChestBlockEntity(p_153215_, p_153216_) return DevChestBlockEntity(p_153215_, p_153216_)
} }
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.NORMAL
}
} }

View File

@ -3,12 +3,14 @@ package ru.dbotthepony.mc.otm.block.decorative
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.TooltipFlag import net.minecraft.world.item.TooltipFlag
import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.SoundType
import net.minecraft.world.level.block.state.BlockState 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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.core.math.BlockRotationFreedom
import ru.dbotthepony.mc.otm.shapes.BlockShapes 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( override fun appendHoverText(
p_49816_: ItemStack, p_49816_: ItemStack,
p_49817_: BlockGetter?, 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)) p_49818_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.DARK_GRAY))
} }
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.NORMAL
}
override fun rotationFreedom(): BlockRotationFreedom { override fun rotationFreedom(): BlockRotationFreedom {
return BlockRotationFreedom.DIRECTIONAL return BlockRotationFreedom.DIRECTIONAL
} }

View File

@ -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.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.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.RotatableMatteryBlock
import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return InfiniteWaterSourceBlockEntity(p_153215_, p_153216_) return InfiniteWaterSourceBlockEntity(p_153215_, p_153216_)
} }
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.BLOCK
}
override fun <T : BlockEntity> getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType<T>): BlockEntityTicker<T>? { override fun <T : BlockEntity> getTicker(p_153212_: Level, p_153213_: BlockState, p_153214_: BlockEntityType<T>): BlockEntityTicker<T>? {
if (p_153212_.isClientSide) if (p_153212_.isClientSide)
return null return null

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.block.decorative
import net.minecraft.ChatFormatting import net.minecraft.ChatFormatting
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items import net.minecraft.world.item.Items
import net.minecraft.world.item.TooltipFlag 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.BlockState
import net.minecraft.world.level.block.state.StateDefinition 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.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.CollisionContext
import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape 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 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<Block, BlockState>) { override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
super.createBlockStateDefinition(builder) super.createBlockStateDefinition(builder)
builder.add(FACING_FULL) builder.add(FACING_FULL)
} }
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.DESTROY
}
override fun hasDynamicShape(): Boolean { override fun hasDynamicShape(): Boolean {
return true 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 { init {
registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.LIT, !invertRedstone)) registerDefaultState(stateDefinition.any().setValue(BlockStateProperties.LIT, !invertRedstone))
} }
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.NORMAL
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) { override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
super.createBlockStateDefinition(builder) super.createBlockStateDefinition(builder)
builder.add(FACING_FULL) builder.add(FACING_FULL)

View File

@ -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.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.BlockSetType
import net.minecraft.world.level.block.state.properties.BlockStateProperties 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.TranslatableComponent
import ru.dbotthepony.mc.otm.core.get 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( override fun appendHoverText(
p_49816_: ItemStack, p_49816_: ItemStack,
p_49817_: BlockGetter?, p_49817_: BlockGetter?,

View File

@ -19,7 +19,7 @@ import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.gameevent.GameEvent 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.LootContextParamSets
import net.minecraft.world.level.storage.loot.parameters.LootContextParams import net.minecraft.world.level.storage.loot.parameters.LootContextParams
import net.minecraft.world.phys.Vec3 import net.minecraft.world.phys.Vec3
@ -105,7 +105,7 @@ class CargoCrateBlockEntity(
val lootTableSeed = lootTableSeed ?: 0L val lootTableSeed = lootTableSeed ?: 0L
val server = level?.server ?: return val server = level?.server ?: return
val loot = server.lootData.getLootTable(lootTable) val loot = server.lootTables.get(lootTable)
if (ply is ServerPlayer) { if (ply is ServerPlayer) {
CriteriaTriggers.GENERATE_LOOT.trigger(ply, lootTable) CriteriaTriggers.GENERATE_LOOT.trigger(ply, lootTable)
@ -114,15 +114,16 @@ class CargoCrateBlockEntity(
this.lootTable = null this.lootTable = null
this.lootTableSeed = 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)) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition))
if (ply != null) { if (ply != null) {
params.withLuck(ply.luck).withParameter(LootContextParams.THIS_ENTITY, ply) params.withLuck(ply.luck).withParameter(LootContextParams.THIS_ENTITY, ply)
} }
params.withOptionalRandomSeed(lootTableSeed)
Containers.dropContents(level as ServerLevel, blockPos, container) 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 override val defaultDisplayName: Component

View File

@ -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.BlockState
import net.minecraft.world.level.block.state.StateDefinition import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.EnumProperty 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.level.material.PushReaction
import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape 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.oncePre
import ru.dbotthepony.mc.otm.shapes.BlockShapes 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 { enum class Type : StringRepresentable {
BASE, BASE,
MIDDLE, 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<Block, BlockState>) { override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
super.createBlockStateDefinition(builder) super.createBlockStateDefinition(builder)
builder.add(PART) builder.add(PART)

View File

@ -1,6 +1,7 @@
package ru.dbotthepony.mc.otm.block.tech package ru.dbotthepony.mc.otm.block.tech
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.world.item.DyeColor
import net.minecraft.world.level.BlockGetter 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
@ -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.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.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.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape import net.minecraft.world.phys.shapes.VoxelShape
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock 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.registry.MBlockEntities
import ru.dbotthepony.mc.otm.shapes.BlockShapes 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 { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return EnergyServoBlockEntity(p_153215_, p_153216_) return EnergyServoBlockEntity(p_153215_, p_153216_)
} }
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.BLOCK
}
override fun <T : BlockEntity?> getTicker( override fun <T : BlockEntity?> getTicker(
p_153212_: Level, p_153212_: Level,
p_153213_: BlockState, p_153213_: BlockState,

View File

@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos
import net.minecraft.core.Direction import net.minecraft.core.Direction
import net.minecraft.core.SectionPos import net.minecraft.core.SectionPos
import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter 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.BlockBehaviour
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition 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.level.material.PushReaction
import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape 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 ru.dbotthepony.mc.otm.shapes.BlockShapes
import kotlin.math.PI 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 { class BlockGravitationStabilizer : RotatableMatteryBlock(props), EntityBlock {
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity { override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
return GravitationStabilizerBlockEntity(p_153215_, p_153216_) return GravitationStabilizerBlockEntity(p_153215_, p_153216_)
} }
override fun getPistonPushReaction(p_60584_: BlockState): PushReaction {
return PushReaction.BLOCK
}
override fun <T : BlockEntity?> getTicker( override fun <T : BlockEntity?> getTicker(
p_153212_: Level, p_153212_: Level,
p_153213_: BlockState, p_153213_: BlockState,

View File

@ -8,6 +8,7 @@ import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.MobSpawnType import net.minecraft.world.entity.MobSpawnType
import net.minecraft.world.entity.SpawnGroupData import net.minecraft.world.entity.SpawnGroupData
import net.minecraft.world.entity.monster.Phantom import net.minecraft.world.entity.monster.Phantom
import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.context.BlockPlaceContext import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter 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.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraft.world.level.block.state.properties.BlockStateProperties
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf 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.AABB
import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape 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.registry.MBlocks
import ru.dbotthepony.mc.otm.shapes.BlockShapes 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") @Suppress("OVERRIDE_DEPRECATION")
override fun randomTick( override fun randomTick(
blockState: BlockState, 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<Block, BlockState>) { override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
super.createBlockStateDefinition(builder) super.createBlockStateDefinition(builder)
builder.add(BlockStateProperties.DOUBLE_BLOCK_HALF) builder.add(BlockStateProperties.DOUBLE_BLOCK_HALF)

View File

@ -3,12 +3,13 @@ package ru.dbotthepony.mc.otm.client.render
import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableList
import com.mojang.blaze3d.vertex.BufferBuilder import com.mojang.blaze3d.vertex.BufferBuilder
import com.mojang.blaze3d.vertex.VertexConsumer 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.Reference2ObjectOpenHashMap
import it.unimi.dsi.fastutil.objects.ReferenceArraySet import it.unimi.dsi.fastutil.objects.ReferenceArraySet
import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.RenderType
import net.minecraft.client.renderer.Sheets import net.minecraft.client.renderer.Sheets
import org.joml.Vector3f
private fun equals(existing: ImmutableList<RenderType>?, types: Array<out RenderType>): Boolean { private fun equals(existing: ImmutableList<RenderType>?, types: Array<out RenderType>): Boolean {
if (types.isEmpty()) { if (types.isEmpty()) {
@ -63,7 +64,8 @@ private fun equals(existing: ImmutableList<RenderType>?, types: ImmutableList<Re
* *
* Allows to batch OTM's geometry * Allows to batch OTM's geometry
*/ */
class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInitialBufferSize: Int = Int.MAX_VALUE, val vertexSorting: VertexSorting = VertexSorting.DISTANCE_TO_ORIGIN) : MultiBufferSource { // 1.19.4 and earlier: there is no actual quad sorting
class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInitialBufferSize: Int = Int.MAX_VALUE, val sortX: Int = 0, val sortY: Int = 0, val sortZ: Int = 0) : MultiBufferSource {
init { init {
require(minimalInitialBufferSize >= 0) { "Invalid minimal buffer size $minimalInitialBufferSize" } require(minimalInitialBufferSize >= 0) { "Invalid minimal buffer size $minimalInitialBufferSize" }
require(maximalInitialBufferSize >= minimalInitialBufferSize) { "Maximal buffer size $maximalInitialBufferSize must be greater or equal to 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) { for (state in bufferList) {
if (state.dirty) { if (state.dirty) {
state.dirty = false 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) { if (state.dirty) {
state.dirty = false 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) { if (state.dirty) {
state.dirty = false state.dirty = false
type.end(state.builder, vertexSorting) type.end(state.builder, sortX, sortY, sortZ)
} }
for (ustate in state.dependants) { for (ustate in state.dependants) {
@ -380,7 +382,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit
private fun endBatchChain(state: State) { private fun endBatchChain(state: State) {
if (state.dirty) { if (state.dirty) {
state.dirty = false state.dirty = false
state.type.end(state.builder, vertexSorting) state.type.end(state.builder, sortX, sortY, sortZ)
} }
for (ustate in state.dependants) { for (ustate in state.dependants) {
@ -390,7 +392,7 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit
companion object { companion object {
@JvmField @JvmField
val GUI = DynamicBufferSource(maximalInitialBufferSize = 2 shl 8, vertexSorting = VertexSorting.ORTHOGRAPHIC_Z) val GUI = DynamicBufferSource(maximalInitialBufferSize = 2 shl 8)
@JvmField @JvmField
val WORLD = DynamicBufferSource(minimalInitialBufferSize = 2 shl 12) val WORLD = DynamicBufferSource(minimalInitialBufferSize = 2 shl 12)

View File

@ -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.component2
import ru.dbotthepony.mc.otm.core.math.component3 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 buffer() = buffer
private fun Font.drawInBatch( private fun Font.drawInBatch(

View File

@ -1,17 +1,23 @@
package ru.dbotthepony.mc.otm.client.render package ru.dbotthepony.mc.otm.client.render
import com.mojang.blaze3d.systems.RenderSystem 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.PoseStack
import com.mojang.blaze3d.vertex.Tesselator import com.mojang.blaze3d.vertex.Tesselator
import com.mojang.blaze3d.vertex.VertexFormat
import net.minecraft.client.gui.Font 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.MultiBufferSource
import net.minecraft.client.renderer.RenderBuffers
import net.minecraft.client.renderer.texture.TextureAtlasSprite import net.minecraft.client.renderer.texture.TextureAtlasSprite
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.util.FormattedCharSequence import net.minecraft.util.FormattedCharSequence
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraftforge.client.ForgeHooksClient
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
import kotlin.math.PI import kotlin.math.PI
@ -29,7 +35,7 @@ class MGUIGraphics(val pose: PoseStack) {
} }
fun renderFakeItem(itemStack: ItemStack, x: Int, y: Int) { fun renderFakeItem(itemStack: ItemStack, x: Int, y: Int) {
parent.renderFakeItem(itemStack, x, y) minecraft.itemRenderer.renderGuiItem(pose, itemStack, x, y)
} }
fun drawLine( fun drawLine(
@ -81,10 +87,59 @@ class MGUIGraphics(val pose: PoseStack) {
} }
fun renderComponentTooltip(font: Font, lines: MutableList<Component>, x: Int, y: Int, itemStack: ItemStack = ItemStack.EMPTY) { fun renderComponentTooltip(font: Font, lines: MutableList<Component>, 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() { fun flush() {
bufferSource.endBatch()
} }
fun draw( fun draw(

View File

@ -1,7 +1,6 @@
package ru.dbotthepony.mc.otm.client.screen.panels.slot package ru.dbotthepony.mc.otm.client.screen.panels.slot
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import net.minecraft.client.gui.screens.Screen.getTooltipFromItem
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
@ -43,7 +42,7 @@ abstract class AbstractSlotPanel<out S : MatteryScreen<*>> @JvmOverloads constru
} }
protected open fun getItemStackTooltip(stack: ItemStack): MutableList<Component> { protected open fun getItemStackTooltip(stack: ItemStack): MutableList<Component> {
return getTooltipFromItem(ru.dbotthepony.mc.otm.client.minecraft, stack) return screen.getTooltipFromItem(stack)
} }
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {

View File

@ -70,11 +70,14 @@ open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads const
itemstack = carried.copy() itemstack = carried.copy()
dragHit = true dragHit = true
val k = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount( AbstractContainerMenu.getQuickCraftSlotCount(
screen.quickCraftSlots, screen.quickCraftSlots,
screen.quickCraftingType, screen.quickCraftingType,
itemstack itemstack,
) + slot.item.count, slot.getMaxStackSize(itemstack)) slot.item.count
)
val k = Math.min(slot.item.count, slot.getMaxStackSize(itemstack))
if (itemstack.count > k) { if (itemstack.count > k) {
countOverride = ChatFormatting.YELLOW.toString() + k countOverride = ChatFormatting.YELLOW.toString() + k

View File

@ -57,7 +57,7 @@ private fun Player.getCuriosSlotsImpl(): List<PlayerSlot<Slot, Slot>> {
val stacks = curio.stacks val stacks = curio.stacks
for (slot in 0 until stacks.slots) { 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()) { if (curio.hasCosmetic()) {
val cosmetic = CosmeticCurioSlot(this, curio.cosmeticStacks, slot, identifier, 0, 0) val cosmetic = CosmeticCurioSlot(this, curio.cosmeticStacks, slot, identifier, 0, 0)

View File

@ -75,8 +75,8 @@ object MatterEntanglerRecipeCategory : IRecipeCategory<IMatterEntanglerRecipe>,
ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, xOffset + 89f, yOffset + 18f + 4f) ProgressGaugePanel.GAUGE_BACKGROUND.render(wrap, xOffset + 89f, yOffset + 18f + 4f)
} }
override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, guiGraphics: GuiGraphics, mouseX: Double, mouseY: Double) { override fun draw(recipe: IMatterEntanglerRecipe, recipeSlotsView: IRecipeSlotsView, poseStack: PoseStack, mouseX: Double, mouseY: Double) {
val wrap = MGUIGraphics(guiGraphics) val wrap = MGUIGraphics(poseStack)
renderMatterGauge(wrap, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat()) renderMatterGauge(wrap, 13f, 6f, drainSpeed = (recipe.matter / Decimal(300)).toFloat())
renderEnergyGauge(wrap, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat()) renderEnergyGauge(wrap, 4f, 6f, drainSpeed = (recipe.ticks / 2000.0).toFloat())

View File

@ -68,11 +68,11 @@ object MicrowaveRecipeCategory : IRecipeCategory<MicrowaveRecipe>, IDrawable {
override fun draw( override fun draw(
recipe: MicrowaveRecipe, recipe: MicrowaveRecipe,
recipeSlotsView: IRecipeSlotsView, recipeSlotsView: IRecipeSlotsView,
graphics: GuiGraphics, poseStack: PoseStack,
mouseX: Double, mouseX: Double,
mouseY: 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) wrap.draw(TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK)
val average = recipe.experience.toString() val average = recipe.experience.toString()

View File

@ -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.BarrelBlockEntity
import net.minecraft.world.level.block.entity.ChestBlockEntity import net.minecraft.world.level.block.entity.ChestBlockEntity
import net.minecraft.world.level.gameevent.GameEvent 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.minecraft.world.level.storage.loot.parameters.LootContextParams
import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.minecraftforge.event.entity.player.PlayerInteractEvent
import ru.dbotthepony.mc.otm.OverdriveThatMatters.MOD_ID 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 level = context.level as ServerLevel
val lootparams = LootParams.Builder(level) val lootparams = LootContext.Builder(level)
.withParameter(LootContextParams.ORIGIN, Vector.atCenterOf(context.clickedPos)) .withParameter(LootContextParams.ORIGIN, Vector.atCenterOf(context.clickedPos))
.withParameter(LootContextParams.TOOL, stack) .withParameter(LootContextParams.TOOL, stack)
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, hitBlockEntity) .withOptionalParameter(LootContextParams.BLOCK_ENTITY, hitBlockEntity)
@ -155,7 +155,7 @@ class ChestUpgraderItem : Item(Properties().stacksTo(1)) {
} }
cart.clearContent() cart.clearContent()
(cart as AbstractMinecart).destroy(cart.damageSources().genericKill()) (cart as AbstractMinecart).destroy(cart.damageSources().generic())
level.addFreshEntity(newCart) level.addFreshEntity(newCart)
level.gameEvent(GameEvent.ENTITY_PLACE, event.pos, GameEvent.Context.of(event.entity, level.getBlockState(event.pos.below()))) level.gameEvent(GameEvent.ENTITY_PLACE, event.pos, GameEvent.Context.of(event.entity, level.getBlockState(event.pos.below())))

View File

@ -24,6 +24,7 @@ import net.minecraft.world.item.enchantment.Enchantments
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.Blocks
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.material.Material
import net.minecraftforge.common.ForgeConfigSpec import net.minecraftforge.common.ForgeConfigSpec
import net.minecraftforge.common.ToolAction import net.minecraftforge.common.ToolAction
import net.minecraftforge.common.ToolActions 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 val energy = itemStack.getCapability(MatteryCapability.ENERGY).orNull() ?: return 1f
if (blockState.`is`(Blocks.COBWEB)) { if (blockState.`is`(Blocks.COBWEB)) {
return if (energy.batteryLevel < COBWEB_POWER_COST) 2f else 25f if (energy.batteryLevel < COBWEB_POWER_COST) {
} else if (blockState.`is`(BlockTags.SWORD_EFFICIENT)) { return 2f
return if (energy.batteryLevel < PLANT_POWER_COST) 1.5f else 8f
} else { } else {
return 1f 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,7 +168,8 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani
if (blockState.getDestroySpeed(p_41417_, p_41419_) != 0f && (user !is Player || !user.isCreative)) { if (blockState.getDestroySpeed(p_41417_, p_41419_) != 0f && (user !is Player || !user.isCreative)) {
val energy = itemStack.matteryEnergy val energy = itemStack.matteryEnergy
if (blockState.`is`(BlockTags.SWORD_EFFICIENT)) { when (blockState.material) {
Material.PLANT, Material.REPLACEABLE_PLANT, Material.VEGETABLE, Material.LEAVES ->
if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true) if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true)
energy.extractEnergyExact(user.level.random.nextVariance(PLANT_POWER_COST_VARIANCE), false) energy.extractEnergyExact(user.level.random.nextVariance(PLANT_POWER_COST_VARIANCE), false)
} }

View File

@ -1592,7 +1592,7 @@ object MatterManager {
val targetFile = File(MINECRAFT_SERVER.serverDirectory, "otm/registry_dumps/${filter.name.lowercase()}_${System.currentTimeMillis() / 1_000L}.csv") 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() 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) val writer = targetFile.bufferedWriter(Charsets.UTF_8)
@ -1638,7 +1638,7 @@ object MatterManager {
writer.close() 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 return 0
} }

View File

@ -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.BlockState
import net.minecraft.world.level.block.state.properties.BlockSetType import net.minecraft.world.level.block.state.properties.BlockSetType
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument 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.minecraft.world.level.material.PushReaction
import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.DeferredRegister
@ -143,22 +144,21 @@ object MBlocks {
val FLUID_TANK: FluidTankBlock by registry.register(MNames.FLUID_TANK) { FluidTankBlock() } val FLUID_TANK: FluidTankBlock by registry.register(MNames.FLUID_TANK) { FluidTankBlock() }
val DEV_CHEST: DevChestBlock by registry.register(MNames.DEV_CHEST) { DevChestBlock() } 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( val TRITANIUM_ORE: Block by registry.register(MNames.TRITANIUM_ORE) { DropExperienceBlock(
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.STONE)
.mapColor(MapColor.STONE)
.strength(3.25f, 6.0f) .strength(3.25f, 6.0f)
.requiresCorrectToolForDrops(), .requiresCorrectToolForDrops(),
UniformInt.of(0, 3) UniformInt.of(0, 3)
) } ) }
val TRITANIUM_INGOT_BLOCK: Block by registry.register(MNames.TRITANIUM_INGOT_BLOCK) { 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) { 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( override fun appendHoverText(
p_49816_: ItemStack, p_49816_: ItemStack,
p_49817_: BlockGetter?, p_49817_: BlockGetter?,
@ -172,20 +172,18 @@ object MBlocks {
} }
val METAL_MESH: Block by registry.register(MNames.METAL_MESH) { val METAL_MESH: Block by registry.register(MNames.METAL_MESH) {
Block(BlockBehaviour.Properties.of() Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY)
.mapColor(MapColor.COLOR_GRAY)
.noOcclusion() .noOcclusion()
.sound(SoundType.COPPER).explosionResistance(30f) .sound(SoundType.COPPER).explosionResistance(30f)
.destroyTime(2f).requiresCorrectToolForDrops()) .destroyTime(2f).requiresCorrectToolForDrops())
} }
val TRITANIUM_BARS: IronBarsBlock by registry.register(MNames.TRITANIUM_BARS) { 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( val DEEPSLATE_TRITANIUM_ORE: Block by registry.register(MNames.DEEPSLATE_TRITANIUM_ORE) { DropExperienceBlock(
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE)
.mapColor(MapColor.DEEPSLATE)
.sound(SoundType.DEEPSLATE) .sound(SoundType.DEEPSLATE)
.strength(4.75f, 6.5f) .strength(4.75f, 6.5f)
.requiresCorrectToolForDrops().sound(SoundType.DEEPSLATE), .requiresCorrectToolForDrops().sound(SoundType.DEEPSLATE),
@ -193,14 +191,14 @@ object MBlocks {
) } ) }
val TRITANIUM_RAW_BLOCK: Block by registry.register(MNames.TRITANIUM_RAW_BLOCK) { Block( 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: 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_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 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 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().mapColor(MapColor.COLOR_GRAY).sound(SoundType.METAL).explosionResistance(14f).destroyTime(2.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 ENGINE: Block by registry.register(MNames.ENGINE) { EngineBlock() }
val HOLO_SIGN: Block by registry.register(MNames.HOLO_SIGN) { HoloSignBlock() } val HOLO_SIGN: Block by registry.register(MNames.HOLO_SIGN) { HoloSignBlock() }
@ -212,12 +210,10 @@ object MBlocks {
val anvils = ArrayList<() -> Block>() val anvils = ArrayList<() -> Block>()
for (i in 0 until TRITANIUM_ANVIL_VARIANTS) { for (i in 0 until TRITANIUM_ANVIL_VARIANTS) {
val props = BlockBehaviour.Properties.of() val props = BlockBehaviour.Properties.of(Material.HEAVY_METAL, DyeColor.LIGHT_BLUE)
.mapColor(MapColor.COLOR_LIGHT_BLUE)
.sound(SoundType.ANVIL) .sound(SoundType.ANVIL)
.destroyTime(2.5f - i * 0.15f) .destroyTime(2.5f - i * 0.15f)
.explosionResistance(1200f - i * 80f) .explosionResistance(1200f - i * 80f)
.pushReaction(PushReaction.BLOCK)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
anvils.add(registry.register(MNames.TRITANIUM_ANVIL + i) { AnvilBlock(props) }::get) 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, _ -> val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ ->
object : DoorBlock( object : DoorBlock(
Properties.of() Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE)
.mapColor(color ?: DyeColor.LIGHT_BLUE)
.explosionResistance(80f) .explosionResistance(80f)
.noOcclusion() .noOcclusion()
.destroyTime(3f) .destroyTime(3f)
.pushReaction(PushReaction.DESTROY)
.requiresCorrectToolForDrops(), .requiresCorrectToolForDrops(),
BlockSetType.IRON BlockSetType.IRON
) { ) {
@ -265,8 +259,7 @@ object MBlocks {
val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ -> val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ ->
object : TrapDoorBlock( object : TrapDoorBlock(
Properties.of() Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE)
.mapColor(color ?: DyeColor.LIGHT_BLUE)
.explosionResistance(80f) .explosionResistance(80f)
.noOcclusion().destroyTime(3f) .noOcclusion().destroyTime(3f)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
@ -309,8 +302,7 @@ object MBlocks {
} }
val TRITANIUM_STRIPED_BLOCK: Block by registry.register(MNames.TRITANIUM_STRIPED_BLOCK) { Block( val TRITANIUM_STRIPED_BLOCK: Block by registry.register(MNames.TRITANIUM_STRIPED_BLOCK) { Block(
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE)
.mapColor(MapColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT) .sound(SoundType.BASALT)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.explosionResistance(80f) .explosionResistance(80f)
@ -331,8 +323,7 @@ object MBlocks {
} }
val CARBON_FIBRE_BLOCK: Block by registry.register(MNames.CARBON_FIBRE_BLOCK) { Block( val CARBON_FIBRE_BLOCK: Block by registry.register(MNames.CARBON_FIBRE_BLOCK) { Block(
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.METAL, DyeColor.BLACK)
.mapColor(MapColor.COLOR_GRAY)
.sound(SoundType.BASALT) .sound(SoundType.BASALT)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.explosionResistance(40f) .explosionResistance(40f)

View File

@ -1,27 +1,24 @@
package ru.dbotthepony.mc.otm.registry package ru.dbotthepony.mc.otm.registry
import net.minecraft.core.registries.Registries
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.CreativeModeTab
import net.minecraft.world.item.CreativeModeTabs
import net.minecraft.world.item.DyeColor import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.Item import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.material.Fluids import net.minecraft.world.level.material.Fluids
import net.minecraftforge.common.capabilities.ForgeCapabilities import net.minecraftforge.common.capabilities.ForgeCapabilities
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent import net.minecraftforge.event.CreativeModeTabEvent
import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.fluids.FluidStack import net.minecraftforge.fluids.FluidStack
import net.minecraftforge.fluids.capability.IFluidHandler import net.minecraftforge.fluids.capability.IFluidHandler
import net.minecraftforge.registries.DeferredRegister
import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistries
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.capability.matter.matter import ru.dbotthepony.mc.otm.capability.matter.matter
import ru.dbotthepony.mc.otm.capability.matteryEnergy 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.TranslatableComponent
import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.ifPresentK
import ru.dbotthepony.mc.otm.core.registryName 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 import ru.dbotthepony.mc.otm.registry.MItems.BATTERY_CREATIVE
private fun CreativeModeTab.Output.accept(values: Collection<Item>) { private fun CreativeModeTab.Output.accept(values: Collection<Item>) {
@ -271,34 +268,30 @@ private fun addDecorativeTabItems(consumer: CreativeModeTab.Output) {
} }
object MCreativeTabs { object MCreativeTabs {
private val registry = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, OverdriveThatMatters.MOD_ID) var MAIN by WriteOnce<CreativeModeTab>()
private set
var DECORATIVE by WriteOnce<CreativeModeTab>()
private set
val MAIN: CreativeModeTab by registry.register("main") { fun register(event: CreativeModeTabEvent.Register) {
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) {
CreativeMenuItemComparator.invalidate() CreativeMenuItemComparator.invalidate()
when (event.tab) { MAIN = event.registerCreativeModeTab(ResourceLocation(OverdriveThatMatters.MOD_ID, "main")) {
MAIN -> addMainCreativeTabItems(event) it.icon { ItemStack(BATTERY_CREATIVE, 1) }
DECORATIVE -> addDecorativeTabItems(event) 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)
}
} }
} }
} }

View File

@ -2,7 +2,9 @@ package ru.dbotthepony.mc.otm.registry
import com.google.common.collect.ImmutableSet import com.google.common.collect.ImmutableSet
import com.google.common.collect.Streams import com.google.common.collect.Streams
import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.advancements.CriteriaTriggers import net.minecraft.advancements.CriteriaTriggers
import net.minecraft.client.gui.Font
import net.minecraft.client.renderer.item.ItemProperties import net.minecraft.client.renderer.item.ItemProperties
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.core.cauldron.CauldronInteraction 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.EntityType
import net.minecraft.world.entity.ai.village.poi.PoiType import net.minecraft.world.entity.ai.village.poi.PoiType
import net.minecraft.world.entity.ai.village.poi.PoiTypes 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.DyeableArmorItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items import net.minecraft.world.item.Items
import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.block.* import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.state.BlockBehaviour import net.minecraft.world.level.block.state.BlockBehaviour
import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument 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.api.distmarker.Dist
import net.minecraftforge.client.IItemDecorator
import net.minecraftforge.client.event.RegisterColorHandlersEvent import net.minecraftforge.client.event.RegisterColorHandlersEvent
import net.minecraftforge.client.event.RegisterItemDecorationsEvent import net.minecraftforge.client.event.RegisterItemDecorationsEvent
import net.minecraftforge.client.model.DynamicFluidContainerModel import net.minecraftforge.client.model.DynamicFluidContainerModel
@ -88,8 +94,7 @@ object MRegistry {
val CARGO_CRATES = DecorativeBlock(MNames.CARGO_CRATE, ::CargoCrateBlock) val CARGO_CRATES = DecorativeBlock(MNames.CARGO_CRATE, ::CargoCrateBlock)
val DECORATIVE_CRATE = DecorativeBlock.simple(MNames.DECORATIVE_CRATE) { val DECORATIVE_CRATE = DecorativeBlock.simple(MNames.DECORATIVE_CRATE) {
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.METAL, MaterialColor.SNOW)
.mapColor(it?.mapColor ?: MapColor.SNOW)
.sound(SoundType.METAL) .sound(SoundType.METAL)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.explosionResistance(10f) .explosionResistance(10f)
@ -97,8 +102,7 @@ object MRegistry {
} }
val TRITANIUM_BLOCK = DecorativeBlock.simple(MNames.TRITANIUM_BLOCK) { val TRITANIUM_BLOCK = DecorativeBlock.simple(MNames.TRITANIUM_BLOCK) {
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE)
.mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT) .sound(SoundType.BASALT)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.explosionResistance(80f) .explosionResistance(80f)
@ -123,8 +127,7 @@ object MRegistry {
val TRITANIUM_PRESSURE_PLATE = DecorativeBlock(MNames.TRITANIUM_PRESSURE_PLATE, ::TritaniumPressurePlate) val TRITANIUM_PRESSURE_PLATE = DecorativeBlock(MNames.TRITANIUM_PRESSURE_PLATE, ::TritaniumPressurePlate)
val VENT = DecorativeBlock.simple(MNames.VENT) { val VENT = DecorativeBlock.simple(MNames.VENT) {
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE)
.mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT) .sound(SoundType.BASALT)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.explosionResistance(20f) .explosionResistance(20f)
@ -132,8 +135,7 @@ object MRegistry {
} }
val VENT_ALTERNATIVE = DecorativeBlock.simple(MNames.VENT_ALTERNATIVE) { val VENT_ALTERNATIVE = DecorativeBlock.simple(MNames.VENT_ALTERNATIVE) {
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.METAL, DyeColor.LIGHT_BLUE)
.mapColor(it?.mapColor ?: MapColor.COLOR_LIGHT_BLUE)
.sound(SoundType.BASALT) .sound(SoundType.BASALT)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.explosionResistance(20f) .explosionResistance(20f)
@ -141,8 +143,7 @@ object MRegistry {
} }
val FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.FLOOR_TILES) { val FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.FLOOR_TILES) {
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.STONE, it)
.mapColor(it.mapColor)
.sound(SoundType.STONE) .sound(SoundType.STONE)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.strength(1.5f, 6f) .strength(1.5f, 6f)
@ -160,17 +161,14 @@ object MRegistry {
} }
val UNREFINED_FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.UNREFINED_FLOOR_TILES) { val UNREFINED_FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.UNREFINED_FLOOR_TILES) {
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.CLAY, it)
.mapColor(it.mapColor)
.sound(SoundType.GRAVEL) .sound(SoundType.GRAVEL)
.strength(1f, 2f) .strength(1f, 2f)
} }
val INDUSTRIAL_GLASS = DecorativeBlock(MNames.INDUSTRIAL_GLASS) { color -> val INDUSTRIAL_GLASS = DecorativeBlock(MNames.INDUSTRIAL_GLASS) { color ->
val properties = val properties =
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.GLASS, color?.materialColor ?: MaterialColor.NONE)
.mapColor(if (color != null) color.mapColor else MapColor.NONE)
.instrument(NoteBlockInstrument.HAT)
.destroyTime(1.5f) .destroyTime(1.5f)
.explosionResistance(40f) .explosionResistance(40f)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
@ -190,9 +188,7 @@ object MRegistry {
val INDUSTRIAL_GLASS_PANE = DecorativeBlock(MNames.INDUSTRIAL_GLASS_PANE) { color -> val INDUSTRIAL_GLASS_PANE = DecorativeBlock(MNames.INDUSTRIAL_GLASS_PANE) { color ->
val properties = val properties =
BlockBehaviour.Properties.of() BlockBehaviour.Properties.of(Material.GLASS, color?.materialColor ?: MaterialColor.NONE)
.mapColor(if (color != null) color.mapColor else MapColor.NONE)
.instrument(NoteBlockInstrument.HAT)
.strength(1.25f, 5.0f) .strength(1.25f, 5.0f)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.sound(SoundType.GLASS) .sound(SoundType.GLASS)
@ -206,8 +202,7 @@ object MRegistry {
} }
val TRITANIUM_STRIPED_BLOCK = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_BLOCK, { colorA, _ -> val TRITANIUM_STRIPED_BLOCK = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_BLOCK, { colorA, _ ->
Block(BlockBehaviour.Properties.of() Block(BlockBehaviour.Properties.of(Material.METAL, colorA)
.mapColor(colorA.mapColor)
.sound(SoundType.BASALT) .sound(SoundType.BASALT)
.requiresCorrectToolForDrops() .requiresCorrectToolForDrops()
.explosionResistance(80f) .explosionResistance(80f)
@ -263,7 +258,7 @@ object MRegistry {
bus.addListener(this::registerItemColorHandlers) bus.addListener(this::registerItemColorHandlers)
bus.addListener(this::registerItemDecorators) bus.addListener(this::registerItemDecorators)
MCreativeTabs.initialize(bus) bus.addListener(MCreativeTabs::register)
DecimalProvider.register(bus) DecimalProvider.register(bus)
AndroidResearchDescription.register(bus) AndroidResearchDescription.register(bus)
@ -371,7 +366,16 @@ object MRegistry {
} }
private fun registerItemDecorators(event: RegisterItemDecorationsEvent) { private fun registerItemDecorators(event: RegisterItemDecorationsEvent) {
event.register(Items.SHIELD, MatteryGUI::renderShieldCooldownOverlay) event.register(Items.SHIELD, object : IItemDecorator {
event.register(MItems.TRITANIUM_SHIELD, MatteryGUI::renderShieldCooldownOverlay) 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)
}
})
} }
} }

View File

@ -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_97732_ # menu
public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_169604_ # playerInventoryTitle public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_169604_ # playerInventoryTitle
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97706_ # clickedSlot public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97706_ # clickedSlot
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97707_ # snapbackEnd public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97707_ # snapbackEnd
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97708_ # quickdropSlot public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97708_ # quickdropSlot
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97709_ # lastClickSlot public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97709_ # lastClickSlot
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97710_ # isSplittingStack public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97710_ # isSplittingStack
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97711_ # draggingItem public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97711_ # draggingItem
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97712_ # snapbackStartX public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97712_ # snapbackStartX
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97713_ # snapbackStartY public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97713_ # snapbackStartY
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97714_ # snapbackTime public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97714_ # snapbackTime
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97715_ # snapbackItem public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97715_ # snapbackItem
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97716_ # quickdropTime public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97716_ # quickdropTime
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97717_ # quickCraftingType public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97717_ # quickCraftingType
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97718_ # quickCraftingButton public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97718_ # quickCraftingButton
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97719_ # skipNextRelease public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97719_ # skipNextRelease
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97720_ # quickCraftingRemainder public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97720_ # quickCraftingRemainder
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97721_ # lastClickTime public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97721_ # lastClickTime
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97722_ # lastClickButton public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97722_ # lastClickButton
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen f_97723_ # doubleclick public 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_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 public net.minecraft.world.item.BlockItem f_150696_ # BLOCK_ENTITY_TAG