Make it compile against 1.19.4
This commit is contained in:
parent
e60dda4810
commit
7e9d5ddbf8
58
src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt
Normal file
58
src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DamageTypes.kt
Normal file
@ -0,0 +1,58 @@
|
||||
package ru.dbotthepony.mc.otm.datagen
|
||||
|
||||
import net.minecraft.core.RegistrySetBuilder
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.data.worldgen.BootstapContext
|
||||
import net.minecraft.tags.DamageTypeTags
|
||||
import net.minecraft.world.damagesource.DamageScaling
|
||||
import net.minecraft.world.damagesource.DamageType
|
||||
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider
|
||||
import net.minecraftforge.data.event.GatherDataEvent
|
||||
import ru.dbotthepony.mc.otm.datagen.tags.TagsProvider
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
|
||||
private fun damageTypes(context: BootstapContext<DamageType>) {
|
||||
context.register(MDamageTypes.EXOPACK_PROBE, DamageType("otm_exopack_probe", DamageScaling.NEVER, 4.0f))
|
||||
context.register(MDamageTypes.BECOME_ANDROID, DamageType("otm_become_android", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.BECOME_HUMANE, DamageType("otm_become_humane", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.EVENT_HORIZON, DamageType("otm_event_horizon", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.HAWKING_RADIATION, DamageType("otm_hawking_radiation", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.EMP, DamageType("otm_emp", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.SHOCKWAVE, DamageType("otm_shockwave", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.PLASMA, DamageType("otm_plasma", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.COSMIC_RAYS, DamageType("otm_cosmic_rays", DamageScaling.NEVER, 0f))
|
||||
context.register(MDamageTypes.EXPLOSIVE_HAMMER, DamageType("otm_explosive_hammer", DamageScaling.NEVER, 0.1f))
|
||||
context.register(MDamageTypes.HAMMER_NAIL, DamageType("otm_hammer_nail", DamageScaling.NEVER, 0.1f))
|
||||
}
|
||||
|
||||
fun registerDamageTypes(event: GatherDataEvent) {
|
||||
val set = RegistrySetBuilder()
|
||||
.add(Registries.DAMAGE_TYPE, ::damageTypes)
|
||||
|
||||
event.generator.addProvider(event.includeServer(), DatapackBuiltinEntriesProvider(event.generator.packOutput, event.lookupProvider, set, setOf(DataGen.MOD_ID)))
|
||||
}
|
||||
|
||||
fun registerDamageTypeTags(provider: TagsProvider.Delegate<DamageType>) {
|
||||
val ignoreArmor = provider.Appender(DamageTypeTags.BYPASSES_ARMOR)
|
||||
val ignoreMagic = provider.Appender(DamageTypeTags.BYPASSES_ENCHANTMENTS)
|
||||
val ignoreInvl = provider.Appender(DamageTypeTags.BYPASSES_INVULNERABILITY)
|
||||
|
||||
ignoreArmor
|
||||
.add(MDamageTypes.EXOPACK_PROBE)
|
||||
.add(MDamageTypes.BECOME_ANDROID)
|
||||
.add(MDamageTypes.BECOME_HUMANE)
|
||||
.add(MDamageTypes.EVENT_HORIZON)
|
||||
.add(MDamageTypes.EMP)
|
||||
.add(MDamageTypes.SHOCKWAVE)
|
||||
.add(MDamageTypes.COSMIC_RAYS)
|
||||
|
||||
ignoreMagic
|
||||
.add(MDamageTypes.EXOPACK_PROBE)
|
||||
.add(MDamageTypes.BECOME_ANDROID)
|
||||
.add(MDamageTypes.BECOME_HUMANE)
|
||||
.add(MDamageTypes.COSMIC_RAYS)
|
||||
|
||||
ignoreInvl
|
||||
.add(MDamageTypes.BECOME_HUMANE)
|
||||
.add(MDamageTypes.BECOME_ANDROID)
|
||||
}
|
@ -525,6 +525,8 @@ object DataGen {
|
||||
event.generator.addProvider(event.includeServer(), matterData)
|
||||
|
||||
registerOreGen(event)
|
||||
registerDamageTypes(event)
|
||||
registerDamageTypeTags(tagsProvider.damageTypes)
|
||||
|
||||
AddEnglishLanguage(languageProvider)
|
||||
AddRussianLanguage(languageProvider)
|
||||
@ -564,5 +566,7 @@ object DataGen {
|
||||
languageProvider.registerProviders()
|
||||
|
||||
addMatterData(matterData)
|
||||
|
||||
tagsProvider.register()
|
||||
}
|
||||
}
|
||||
|
@ -349,13 +349,13 @@ private fun death(provider: MatteryLanguageProvider) {
|
||||
death("otm_emp.player", "%2\$s blew fuzes of %1\$s")
|
||||
death("otm_emp.player.item", "%2\$s blew fuzes of %1\$s using %3\$s")
|
||||
|
||||
death(MRegistry.DAMAGE_EXPLOSIVE_HAMMER_NAME, "%1\$s's fun time with hammer is over")
|
||||
death(MRegistry.DAMAGE_HAMMER_NAIL_NAME, "%1\$s got nailed")
|
||||
death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player", "%1\$s got nailed by %\$2")
|
||||
death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player.item", "%1\$s got nailed by %2\$s using %3\$s")
|
||||
death("otm_explosive_hammer", "%1\$s's fun time with hammer is over")
|
||||
death("otm_hammer_nail", "%1\$s got nailed")
|
||||
death("otm_hammer_nail" + ".player", "%1\$s got nailed by %\$2")
|
||||
death("otm_hammer_nail" + ".player.item", "%1\$s got nailed by %2\$s using %3\$s")
|
||||
|
||||
death(MRegistry.DAMAGE_EXOPACK_PROBE_ID, "%1\$s couldn't handle spinal surgery")
|
||||
death("${MRegistry.DAMAGE_EXOPACK_PROBE_ID}.player", "%1\$s couldn't handle spinal surgery whilst fighting %2\$s")
|
||||
death("otm_exopack_probe", "%1\$s couldn't handle spinal surgery")
|
||||
death("otm_exopack_probe.player", "%1\$s couldn't handle spinal surgery whilst fighting %2\$s")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,13 +354,13 @@ private fun death(provider: MatteryLanguageProvider) {
|
||||
death("otm_emp.player", "%2\$s выбил все предохранители %1\$s")
|
||||
death("otm_emp.player.item", "%2\$s выбил все предохранители %1\$s используя %3\$s")
|
||||
|
||||
death(MRegistry.DAMAGE_EXPLOSIVE_HAMMER_NAME, "Время развлечений у %1\$s с молотком подошло к концу")
|
||||
death(MRegistry.DAMAGE_HAMMER_NAIL_NAME, "%1\$s был пригвождён")
|
||||
death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player", "%1\$s был пригвождён %2\$s")
|
||||
death(MRegistry.DAMAGE_HAMMER_NAIL_NAME + ".player.item", "%1\$s был пригвождён %2\$s используя %3\$s")
|
||||
death("otm_explosive_hammer", "Время развлечений у %1\$s с молотком подошло к концу")
|
||||
death("otm_hammer_nail", "%1\$s был пригвождён")
|
||||
death("otm_hammer_nail" + ".player", "%1\$s был пригвождён %2\$s")
|
||||
death("otm_hammer_nail" + ".player.item", "%1\$s был пригвождён %2\$s используя %3\$s")
|
||||
|
||||
death(MRegistry.DAMAGE_EXOPACK_PROBE_ID, "%1\$s не выдержал спинную хирургию")
|
||||
death("${MRegistry.DAMAGE_EXOPACK_PROBE_ID}.player", "%1\$s не выдержал спинную хирургию пока сражался с %2\$s")
|
||||
death("otm_exopack_probe", "%1\$s не выдержал спинную хирургию")
|
||||
death("otm_exopack_probe.player", "%1\$s не выдержал спинную хирургию пока сражался с %2\$s")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ open class AndroidFeatureType<T : AndroidFeature> {
|
||||
}
|
||||
|
||||
open val displayContents: ComponentContents by lazy {
|
||||
TranslatableContents(displayId)
|
||||
TranslatableContents(displayId, null, arrayOf())
|
||||
}
|
||||
|
||||
open val displayName: Component by lazy {
|
||||
|
@ -460,7 +460,7 @@ class AndroidResearchType(
|
||||
}
|
||||
|
||||
val displayContents: ComponentContents by lazy {
|
||||
TranslatableContents(displayId)
|
||||
TranslatableContents(displayId, null, arrayOf())
|
||||
}
|
||||
|
||||
val displayName: Component get() {
|
||||
|
@ -45,6 +45,7 @@ import ru.dbotthepony.mc.otm.core.math.component3
|
||||
import ru.dbotthepony.mc.otm.core.util.formatPower
|
||||
import ru.dbotthepony.mc.otm.core.genericPositions
|
||||
import ru.dbotthepony.mc.otm.core.holder
|
||||
import ru.dbotthepony.mc.otm.core.isFall
|
||||
import ru.dbotthepony.mc.otm.core.math.plus
|
||||
import ru.dbotthepony.mc.otm.core.math.rotateXDegrees
|
||||
import ru.dbotthepony.mc.otm.core.math.rotateYDegrees
|
||||
|
@ -11,6 +11,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||
import ru.dbotthepony.mc.otm.config.AndroidConfig
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.isFall
|
||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
import ru.dbotthepony.mc.otm.registry.MNames
|
||||
import ru.dbotthepony.mc.otm.triggers.FallDampenersSaveTrigger
|
||||
|
@ -70,7 +70,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable
|
||||
private data class ItemPos(var position: Vector, var ticksSinceActivity: Int)
|
||||
private val rememberPositions = WeakHashMap<ItemEntity, ItemPos>()
|
||||
|
||||
private val serverPredicate = Predicate<Entity> { it is ItemEntity && !it.hasPickUpDelay() && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) }
|
||||
private val serverPredicate = Predicate<Entity> { it is ItemEntity && !it.hasPickUpDelay() && (it.owner == null || it.owner != ply || it.lifespan - it.age <= 200) }
|
||||
private val clientPredicate = Predicate<Entity> { it is ItemEntity && (datatable[it] ?: SharedItemEntityData.EMPTY).let { !it.hasPickupDelay && (it.owner == null || it.owner != ply.uuid || it.lifespan - it.age <= 200) } }
|
||||
|
||||
private fun doTick(server: Boolean) {
|
||||
@ -88,7 +88,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable
|
||||
ent as ItemEntity
|
||||
|
||||
if (server) {
|
||||
WorldNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner, ent.age, ent.lifespan, ent.hasPickUpDelay()))
|
||||
WorldNetworkChannel.send(ply, ItemEntityDataPacket(ent.id, ent.owner?.uuid, ent.age, ent.lifespan, ent.hasPickUpDelay()))
|
||||
|
||||
if (!serverPredicate.test(ent)) {
|
||||
continue
|
||||
|
@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.android.AndroidFeature
|
||||
import ru.dbotthepony.mc.otm.android.AndroidResearchManager
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||
import ru.dbotthepony.mc.otm.capability.energy.extractEnergyExact
|
||||
import ru.dbotthepony.mc.otm.core.isBypassArmor
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
import ru.dbotthepony.mc.otm.registry.StatNames
|
||||
|
@ -32,6 +32,7 @@ import ru.dbotthepony.mc.otm.core.math.times
|
||||
import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel
|
||||
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.client.ShiftPressedCond
|
||||
import ru.dbotthepony.mc.otm.core.damageType
|
||||
import ru.dbotthepony.mc.otm.network.MatteryPacket
|
||||
import ru.dbotthepony.mc.otm.network.ShockwaveEffectPacket
|
||||
import ru.dbotthepony.mc.otm.network.enqueueWork
|
||||
@ -39,9 +40,10 @@ import ru.dbotthepony.mc.otm.network.packetHandled
|
||||
import ru.dbotthepony.mc.otm.network.sender
|
||||
import ru.dbotthepony.mc.otm.onceServer
|
||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MNames
|
||||
import ru.dbotthepony.mc.otm.registry.MSoundEvents
|
||||
import ru.dbotthepony.mc.otm.registry.ShockwaveDamageSource
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import ru.dbotthepony.mc.otm.triggers.ShockwaveDamageMobTrigger
|
||||
import ru.dbotthepony.mc.otm.triggers.ShockwaveTrigger
|
||||
import java.util.function.Supplier
|
||||
@ -134,7 +136,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
seen.add(entity)
|
||||
val multiplier = (1.0 - distanceMultiplier).pow(0.5)
|
||||
|
||||
val source = ShockwaveDamageSource(ply)
|
||||
val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply)
|
||||
val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat() * AndroidConfig.Shockwave.WARDEN_DAMAGE_MULT.toFloat()
|
||||
entity.hurt(source, damage)
|
||||
entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0)
|
||||
@ -150,7 +152,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
|
||||
// don't hurt items, arrows, etc etc
|
||||
if (entity is LivingEntity) {
|
||||
val source = ShockwaveDamageSource(ply)
|
||||
val source = MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.SHOCKWAVE), ply)
|
||||
val damage = multiplier.toFloat() * AndroidConfig.Shockwave.DAMAGE.toFloat()
|
||||
entity.hurt(source, damage)
|
||||
entity.deltaMovement += (entity.position - ply.position).normalize() * (multiplier * 3.0)
|
||||
|
@ -16,12 +16,13 @@ import net.minecraft.world.level.block.BasePressurePlateBlock
|
||||
import net.minecraft.world.level.block.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.BlockSetType
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties
|
||||
import net.minecraft.world.level.material.Material
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.get
|
||||
|
||||
class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) {
|
||||
class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) {
|
||||
override fun appendHoverText(
|
||||
p_49816_: ItemStack,
|
||||
p_49817_: BlockGetter?,
|
||||
@ -42,14 +43,6 @@ class TritaniumPressurePlate(color: DyeColor?) : BasePressurePlateBlock(Properti
|
||||
p_49915_.add(BlockStateProperties.POWERED)
|
||||
}
|
||||
|
||||
override fun playOnSound(level: LevelAccessor, pos: BlockPos) {
|
||||
level.playSound(null, pos, SoundEvents.METAL_PRESSURE_PLATE_CLICK_ON, SoundSource.BLOCKS, 0.3f, 0.9f)
|
||||
}
|
||||
|
||||
override fun playOffSound(level: LevelAccessor, pos: BlockPos) {
|
||||
level.playSound(null, pos, SoundEvents.METAL_PRESSURE_PLATE_CLICK_OFF, SoundSource.BLOCKS, 0.3f, 0.9f)
|
||||
}
|
||||
|
||||
override fun getSignalStrength(level: Level, pos: BlockPos): Int {
|
||||
if (level.getEntitiesOfClass(ServerPlayer::class.java, TOUCH_AABB.move(pos)).isNotEmpty()) {
|
||||
return 15
|
||||
|
@ -21,6 +21,7 @@ import ru.dbotthepony.mc.otm.block.BlackHoleBlock
|
||||
import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue.Companion.queueForLevel
|
||||
import ru.dbotthepony.mc.otm.core.damageType
|
||||
import ru.dbotthepony.mc.otm.core.getExplosionResistance
|
||||
import ru.dbotthepony.mc.otm.core.gracefulBlockBreak
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
@ -32,6 +33,8 @@ import ru.dbotthepony.mc.otm.core.math.getSphericalBlockPositions
|
||||
import ru.dbotthepony.mc.otm.core.nbt.map
|
||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import ru.dbotthepony.mc.otm.matter.MatterManager
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import ru.dbotthepony.mc.otm.triggers.BlackHoleTrigger
|
||||
import java.util.LinkedList
|
||||
import kotlin.math.pow
|
||||
@ -146,7 +149,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery
|
||||
} else {
|
||||
level.explode(
|
||||
null,
|
||||
MRegistry.DAMAGE_HAWKING_RADIATION,
|
||||
MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAWKING_RADIATION)),
|
||||
null,
|
||||
blockPos.x + 0.5,
|
||||
blockPos.y + 0.5,
|
||||
@ -241,7 +244,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery
|
||||
}
|
||||
|
||||
if (distance < gravitationStrength + 1) {
|
||||
living.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat())
|
||||
living.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON)), (gravitationStrength / distance).toFloat())
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +253,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery
|
||||
setDeltaMovement(item, center, distance, false)
|
||||
|
||||
if (distance < gravitationStrength + 1) {
|
||||
if (item.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat()) && item.isRemoved) {
|
||||
if (item.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EVENT_HORIZON)), (gravitationStrength / distance).toFloat()) && item.isRemoved) {
|
||||
if (item.item.item === MItems.GRAVITATIONAL_DISRUPTOR) {
|
||||
collapse()
|
||||
} else {
|
||||
|
@ -42,7 +42,7 @@ class BlockEntitySphereDebugger(p_155229_: BlockPos, p_155230_: BlockState) : Bl
|
||||
|
||||
for (normal in ExplosionRayHive.evenlyDistributedPoints(400)) {
|
||||
val multiplied = normal * 20.0
|
||||
level!!.setBlock(blockPos + BlockPos(multiplied.x, multiplied.y, multiplied.z), Blocks.COAL_BLOCK.defaultBlockState(), Block.UPDATE_ALL)
|
||||
level!!.setBlock(blockPos + BlockPos(multiplied.x.toInt(), multiplied.y.toInt(), multiplied.z.toInt()), Blocks.COAL_BLOCK.defaultBlockState(), Block.UPDATE_ALL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,9 @@ import ru.dbotthepony.mc.otm.core.math.plus
|
||||
import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis
|
||||
import ru.dbotthepony.mc.otm.core.math.up
|
||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.HashMap
|
||||
@ -536,7 +538,7 @@ private data class QueuedExplosion(val x: Double, val y: Double, val z: Double,
|
||||
fun explode(level: Level) {
|
||||
level.explode(
|
||||
null,
|
||||
MRegistry.DAMAGE_HAWKING_RADIATION,
|
||||
MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAWKING_RADIATION)),
|
||||
BlackHoleExplosionDamageCalculator,
|
||||
x,
|
||||
y,
|
||||
@ -601,7 +603,7 @@ class ExplosionQueue(private val level: ServerLevel) : SavedData() {
|
||||
}
|
||||
|
||||
fun explode(x: Double, y: Double, z: Double, radius: Float) {
|
||||
if (level.isOutsideBuildHeight(BlockPos(x, y + 24, z)) || level.isOutsideBuildHeight(BlockPos(x, y - 24, z)))
|
||||
if (level.isOutsideBuildHeight(BlockPos(x.toInt(), y.toInt() + 24, z.toInt())) || level.isOutsideBuildHeight(BlockPos(x.toInt(), y.toInt() - 24, z.toInt())))
|
||||
return
|
||||
|
||||
explosions.add(QueuedExplosion(x, y, z, radius))
|
||||
|
@ -307,7 +307,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
|
||||
override fun getItem(p_18941_: Int): ItemStack {
|
||||
require(p_18941_ == 0) { "Invalid slot ID: $p_18941_" }
|
||||
return craftingRecipe?.resultItem?.copy() ?: ItemStack.EMPTY
|
||||
return craftingRecipe?.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY)?.copy() ?: ItemStack.EMPTY
|
||||
}
|
||||
|
||||
override fun removeItem(index: Int, amount: Int): ItemStack {
|
||||
@ -316,7 +316,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
val craftingRecipe = craftingRecipe
|
||||
val craftingPlayer = craftingPlayer
|
||||
|
||||
if (craftingRecipe == null || craftingPlayer == null || craftingRecipe.resultItem.count != amount) {
|
||||
if (craftingRecipe == null || craftingPlayer == null || craftingRecipe.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY).count != amount) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
@ -430,7 +430,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
scanCraftingGrid()
|
||||
}
|
||||
|
||||
return craftingRecipe.resultItem.copy()
|
||||
return craftingRecipe.getResultItem(level?.registryAccess() ?: return ItemStack.EMPTY).copy()
|
||||
}
|
||||
|
||||
override fun removeItemNoUpdate(p_18951_: Int): ItemStack {
|
||||
@ -438,7 +438,7 @@ class ItemMonitorBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
}
|
||||
|
||||
override fun setItem(p_18944_: Int, p_18945_: ItemStack) {
|
||||
if ((craftingRecipe != null && !craftingRecipe!!.resultItem.isEmpty) || !p_18945_.isEmpty) {
|
||||
if ((craftingRecipe != null && !craftingRecipe!!.let { it.getResultItem(level?.registryAccess() ?: return@let ItemStack.EMPTY) }.isEmpty) || !p_18945_.isEmpty) {
|
||||
throw RuntimeException("BUG-DETECT: Tried to set crafting result slot item to something, and either we have crafting recipe which have valid result, or we are trying to set slot to non empty item: $p_18945_")
|
||||
}
|
||||
}
|
||||
|
@ -72,10 +72,12 @@ class PlatePressBlockEntity(
|
||||
return null to IdleReason.POWER
|
||||
}
|
||||
|
||||
val recipe = level?.recipeManager?.getRecipeFor(MRecipes.PLATE_PRESS, inputContainer, level!!)?.orElse(null) ?: return null to IdleReason.ITEM
|
||||
val level = level ?: return null to null
|
||||
|
||||
val recipe = level.recipeManager.getRecipeFor(MRecipes.PLATE_PRESS, inputContainer, level).orElse(null) ?: return null to IdleReason.ITEM
|
||||
inputContainer[0].shrink(1)
|
||||
inputContainer.setChanged(0)
|
||||
return ItemJob(recipe.resultItem, recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level!!.random)) to null
|
||||
return ItemJob(recipe.getResultItem(level.registryAccess()), recipe.workTime.toDouble(), BASELINE_CONSUMPTION, experience = recipe.experience.sample(level.random)) to null
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -25,6 +25,7 @@ import net.minecraft.world.phys.AABB
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
import net.minecraftforge.common.ForgeHooks
|
||||
import net.minecraftforge.event.ForgeEventFactory
|
||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||
import ru.dbotthepony.mc.otm.block.getShapeForEachState
|
||||
import ru.dbotthepony.mc.otm.core.get
|
||||
@ -63,12 +64,7 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL
|
||||
) {
|
||||
val phantom = EntityType.PHANTOM.create(level) ?: continue
|
||||
phantom.moveTo(spawnPos, 0.0f, 0.0f)
|
||||
|
||||
if (ForgeHooks.canEntitySpawn(phantom, level, spawnPos.x.toDouble(), spawnPos.y.toDouble(), spawnPos.z.toDouble(), null, MobSpawnType.SPAWNER) == -1) {
|
||||
continue
|
||||
}
|
||||
|
||||
groupData = phantom.finalizeSpawn(level, level.getCurrentDifficultyAt(spawnPos), MobSpawnType.SPAWNER, groupData, null)
|
||||
groupData = ForgeEventFactory.onFinalizeSpawn(phantom, level, level.getCurrentDifficultyAt(spawnPos), MobSpawnType.SPAWNER, groupData, null)
|
||||
level.addFreshEntityWithPassengers(phantom)
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ import net.minecraftforge.event.TickEvent
|
||||
import net.minecraftforge.event.TickEvent.PlayerTickEvent
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent
|
||||
import net.minecraftforge.event.entity.living.MobEffectEvent
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent
|
||||
import net.minecraftforge.eventbus.api.Event
|
||||
@ -59,7 +58,6 @@ import ru.dbotthepony.mc.otm.container.stream
|
||||
import ru.dbotthepony.mc.otm.core.*
|
||||
import ru.dbotthepony.mc.otm.core.collect.UUIDIntModifiersMap
|
||||
import ru.dbotthepony.mc.otm.core.collect.filter
|
||||
import ru.dbotthepony.mc.otm.core.collect.nonEmpty
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.core.math.minus
|
||||
import ru.dbotthepony.mc.otm.core.nbt.getCompoundList
|
||||
@ -74,7 +72,9 @@ import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu
|
||||
import ru.dbotthepony.mc.otm.network.*
|
||||
import ru.dbotthepony.mc.otm.network.synchronizer.FieldSynchronizer
|
||||
import ru.dbotthepony.mc.otm.registry.AndroidFeatures
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger
|
||||
import ru.dbotthepony.mc.otm.triggers.AndroidTravelUnderwater
|
||||
import ru.dbotthepony.mc.otm.triggers.BecomeAndroidDeathTrigger
|
||||
@ -418,7 +418,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
if (isAndroid) return
|
||||
|
||||
becomeAndroid()
|
||||
ply.hurt(MRegistry.DAMAGE_BECOME_ANDROID, ply.maxHealth * 2)
|
||||
|
||||
if (!ply.abilities.invulnerable)
|
||||
ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -476,7 +478,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
if (!isAndroid) return
|
||||
|
||||
becomeHumane()
|
||||
ply.hurt(MRegistry.DAMAGE_BECOME_HUMANE, ply.maxHealth * 2)
|
||||
|
||||
if (!ply.abilities.invulnerable)
|
||||
ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, text: Any, scale: Flo
|
||||
return size
|
||||
}
|
||||
|
||||
private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSource, text: Any, scale: Float, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0): Int {
|
||||
private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSource, text: Any, scale: Float, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0): Int {
|
||||
val translation = poseStack.translation()
|
||||
|
||||
poseStack.pushPose()
|
||||
@ -97,7 +97,7 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSo
|
||||
poseStack.scale(scale, scale, scale)
|
||||
val inv = 1f / scale
|
||||
poseStack.translate(translation * inv)
|
||||
val size = drawDuckTyped(poseStack, buffer, text, x * inv, y * inv, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
val size = drawDuckTyped(poseStack, buffer, text, x * inv, y * inv, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
poseStack.popPose()
|
||||
|
||||
return size
|
||||
@ -120,7 +120,7 @@ private fun Font.drawDuckTyped(
|
||||
y: Float,
|
||||
color: Int,
|
||||
drawShadow: Boolean = false,
|
||||
seeThrough: Boolean = false,
|
||||
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
|
||||
packedLightCoords: Int = 15728880,
|
||||
effectColor: Int = 0
|
||||
): Int {
|
||||
@ -129,9 +129,9 @@ private fun Font.drawDuckTyped(
|
||||
}
|
||||
|
||||
val result = when (text) {
|
||||
is Component -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, seeThrough, effectColor, packedLightCoords)
|
||||
is String -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, seeThrough, effectColor, packedLightCoords)
|
||||
is FormattedCharSequence -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, seeThrough, effectColor, packedLightCoords)
|
||||
is Component -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, displayMode, effectColor, packedLightCoords)
|
||||
is String -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, displayMode, effectColor, packedLightCoords)
|
||||
is FormattedCharSequence -> drawInBatch(text, x, y, color, drawShadow, poseStack.last().pose(), buffer, displayMode, effectColor, packedLightCoords)
|
||||
else -> throw ClassCastException(text::class.qualifiedName)
|
||||
}
|
||||
|
||||
@ -176,22 +176,22 @@ private fun Font.drawAlignedDuckTyped(
|
||||
y: Float,
|
||||
color: Int,
|
||||
drawShadow: Boolean = false,
|
||||
seeThrough: Boolean = false,
|
||||
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
|
||||
packedLightCoords: Int = 15728880,
|
||||
effectColor: Int = 0
|
||||
): Int {
|
||||
return when (align) {
|
||||
TextAlign.TOP_LEFT -> drawDuckTyped(poseStack, buffer, text, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.TOP_LEFT -> drawDuckTyped(poseStack, buffer, text, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.TOP_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.TOP_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
|
||||
TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.CENTER_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.CENTER_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.CENTER_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
|
||||
TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.BOTTOM_LEFT -> drawDuckTyped(poseStack, buffer, text, x, (y - lineHeight).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.BOTTOM_CENTER -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text) / 2f).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.BOTTOM_RIGHT -> drawDuckTyped(poseStack, buffer, text, (x - widthDuckTyped(text)).roundToInt().toFloat(), (y - lineHeight).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,22 +221,22 @@ private fun Font.drawScaledAlignedDuckTyped(
|
||||
y: Float,
|
||||
color: Int,
|
||||
drawShadow: Boolean = false,
|
||||
seeThrough: Boolean = false,
|
||||
displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL,
|
||||
packedLightCoords: Int = 15728880,
|
||||
effectColor: Int = 0
|
||||
): Int {
|
||||
return when (align) {
|
||||
TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.TOP_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.TOP_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.TOP_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
|
||||
TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight / 2f * scale).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.CENTER_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight / 2f * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.CENTER_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.CENTER_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale / 2f).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
|
||||
TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
TextAlign.BOTTOM_LEFT -> drawScaledDuckTyped(poseStack, buffer, text, scale, x, (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.BOTTOM_CENTER -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale / 2f).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
TextAlign.BOTTOM_RIGHT -> drawScaledDuckTyped(poseStack, buffer, text, scale, (x - widthDuckTyped(text) * scale).roundToInt().toFloat(), (y - lineHeight * scale).roundToInt().toFloat(), color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,18 +256,18 @@ fun Font.drawScaledAligned(poseStack: PoseStack, text: String, scale: Float, ali
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt())
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: RGBAColor) = drawScaledAligned(poseStack, text, scale, align, x, y, color.toInt())
|
||||
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAlignedDuckTyped(poseStack, buffer, text, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
fun Font.drawAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, align: TextAlign, x: Float, y: Float, color: RGBAColor, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0) = drawAligned(poseStack, buffer, text, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, color: Int, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0,) = drawScaledAlignedDuckTyped(poseStack, buffer, text, scale, align, x, y, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, seeThrough: Boolean = false, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, seeThrough, packedLightCoords, effectColor)
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: String, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: Component, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
fun Font.drawScaledAligned(poseStack: PoseStack, buffer: MultiBufferSource, text: FormattedCharSequence, scale: Float, align: TextAlign, x: Float, y: Float, drawShadow: Boolean = false, displayMode: Font.DisplayMode = Font.DisplayMode.NORMAL, packedLightCoords: Int = 15728880, effectColor: Int = 0, color: RGBAColor) = drawScaledAligned(poseStack, buffer, text, scale, align, x, y, color.toInt(), drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
|
@ -212,7 +212,6 @@ object GlitchRenderer {
|
||||
RenderSystem.disableCull()
|
||||
RenderSystem.disableDepthTest()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.enableTexture()
|
||||
|
||||
if (glitchBuffer.width != minecraft.window.width || glitchBuffer.height != minecraft.window.height) {
|
||||
glitchBuffer.resize(minecraft.window.width, minecraft.window.height, Minecraft.ON_OSX)
|
||||
|
@ -53,7 +53,6 @@ fun drawTexturedRect(
|
||||
v1: Float = 1f
|
||||
) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader)
|
||||
RenderSystem.enableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
|
||||
@ -314,7 +313,6 @@ fun drawRect(
|
||||
height: Float,
|
||||
color: RGBAColor = drawColor
|
||||
) {
|
||||
RenderSystem.disableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorShader)
|
||||
@ -333,7 +331,6 @@ fun drawRect(
|
||||
builder.vertex(matrix, x, y, zLevel).color(color).endVertex()
|
||||
|
||||
tess.end()
|
||||
RenderSystem.enableTexture()
|
||||
}
|
||||
|
||||
fun drawRect(
|
||||
@ -362,7 +359,6 @@ fun drawLine(
|
||||
width: Float,
|
||||
color: RGBAColor = drawColor
|
||||
) {
|
||||
RenderSystem.disableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorShader)
|
||||
@ -412,7 +408,6 @@ fun drawLine(
|
||||
zLevel).color(color).endVertex()
|
||||
|
||||
tess.end()
|
||||
RenderSystem.enableTexture()
|
||||
}
|
||||
|
||||
fun drawLine(
|
||||
|
@ -119,7 +119,6 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context
|
||||
colorSphere(poseStack, size.toFloat())
|
||||
|
||||
RenderSystem.enableCull()
|
||||
RenderSystem.enableTexture()
|
||||
|
||||
poseStack.popPose()
|
||||
|
||||
|
@ -9,6 +9,7 @@ import net.minecraft.client.renderer.block.model.ItemTransforms
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||
import net.minecraft.core.particles.DustParticleOptions
|
||||
import net.minecraft.world.item.ItemDisplayContext
|
||||
import net.minecraft.world.level.levelgen.XoroshiroRandomSource
|
||||
import org.joml.Vector3f
|
||||
import org.lwjgl.opengl.GL14.glBlendColor
|
||||
@ -79,7 +80,7 @@ class MatterReplicatorRenderer(private val context: BlockEntityRendererProvider.
|
||||
|
||||
context.itemRenderer.render(
|
||||
item,
|
||||
ItemTransforms.TransformType.NONE,
|
||||
ItemDisplayContext.NONE,
|
||||
false,
|
||||
pose,
|
||||
source,
|
||||
|
@ -20,12 +20,16 @@ import org.lwjgl.opengl.GL11
|
||||
import org.lwjgl.opengl.GL13
|
||||
import ru.dbotthepony.mc.otm.config.ClientConfig
|
||||
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
|
||||
import ru.dbotthepony.mc.otm.client.render.translation
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.*
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.UserFilteredSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.HeightControls
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants
|
||||
import ru.dbotthepony.mc.otm.core.math.component1
|
||||
import ru.dbotthepony.mc.otm.core.math.component2
|
||||
import ru.dbotthepony.mc.otm.core.math.component3
|
||||
import ru.dbotthepony.mc.otm.core.math.integerDivisionDown
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||
import java.util.Collections
|
||||
@ -62,37 +66,23 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
val quickCraftingType get() = quickCraftingType
|
||||
val isQuickCrafting get() = isQuickCrafting
|
||||
|
||||
fun renderItemStack(absoluteX: Float, absoluteY: Float, itemstack: ItemStack, countOverride: String? = null) {
|
||||
fun renderItemStack(poseStack: PoseStack, itemstack: ItemStack, countOverride: String? = null) {
|
||||
if (!itemstack.isEmpty) {
|
||||
RenderSystem.enableDepthTest()
|
||||
|
||||
val systemPoseStack = RenderSystem.getModelViewStack()
|
||||
|
||||
systemPoseStack.pushPose()
|
||||
systemPoseStack.translate(absoluteX + 1f, absoluteY + 1f, 0f)
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
RenderSystem.depthFunc(GL11.GL_LESS)
|
||||
|
||||
// Thanks Mojang
|
||||
// Very cool
|
||||
// (for int x, int y, which are then cast into doubles anyway)
|
||||
itemRenderer.blitOffset = 1f // Z pos
|
||||
val (x, y) = poseStack.translation()
|
||||
|
||||
itemRenderer.renderAndDecorateItem(
|
||||
poseStack,
|
||||
requireNotNull(ru.dbotthepony.mc.otm.client.minecraft.player) { "yo, dude, what the fuck" },
|
||||
itemstack,
|
||||
0,
|
||||
0,
|
||||
(absoluteX + absoluteY * 1000f).toInt()
|
||||
(x + y * ru.dbotthepony.mc.otm.client.minecraft.window.guiScaledWidth).toInt()
|
||||
)
|
||||
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
itemRenderer.renderGuiItemDecorations(font, itemstack, 0, 0, countOverride)
|
||||
itemRenderer.blitOffset = 0f
|
||||
|
||||
// too big accumulations can lead to Z near clipping issues
|
||||
systemPoseStack.popPose()
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
itemRenderer.renderGuiItemDecorations(poseStack, font, itemstack, 0, 0, countOverride)
|
||||
}
|
||||
}
|
||||
|
||||
@ -520,7 +510,6 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
RenderSystem.defaultBlendFunc()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.enableDepthTest()
|
||||
RenderSystem.enableTexture()
|
||||
RenderSystem.activeTexture(GL13.GL_TEXTURE0)
|
||||
|
||||
for (i in panels.indices.reversed()) {
|
||||
@ -559,7 +548,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
}
|
||||
|
||||
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
|
||||
renderFloatingItem(itemstack, mouseX - 8, mouseY - i2, overrideCount)
|
||||
renderFloatingItem(poseStack, itemstack, mouseX - 8, mouseY - i2, overrideCount)
|
||||
}
|
||||
|
||||
RenderSystem.disableDepthTest()
|
||||
|
@ -4,8 +4,11 @@ import com.google.common.collect.ImmutableList
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceArraySet
|
||||
import net.minecraft.client.gui.ComponentPath
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
import net.minecraft.client.gui.navigation.FocusNavigationEvent
|
||||
import net.minecraft.client.gui.navigation.ScreenRectangle
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.renderer.Rect2i
|
||||
import net.minecraft.network.chat.Component
|
||||
@ -68,7 +71,73 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
width: Float = 10f,
|
||||
height: Float = 10f,
|
||||
) : GuiEventListener {
|
||||
) {
|
||||
// layout engine does not support navigation using keyboard
|
||||
// fuck off
|
||||
val listener: GuiEventListener = object : GuiEventListener {
|
||||
override fun setFocused(p_265728_: Boolean) {
|
||||
if (p_265728_) {
|
||||
if (isVisible())
|
||||
requestFocus()
|
||||
} else {
|
||||
killFocus()
|
||||
}
|
||||
}
|
||||
|
||||
override fun isFocused(): Boolean {
|
||||
return isEverFocused()
|
||||
}
|
||||
|
||||
override fun mouseMoved(p_94758_: Double, p_94759_: Double) {
|
||||
this@EditablePanel.mouseMoved(p_94758_, p_94759_)
|
||||
}
|
||||
|
||||
override fun mouseClicked(p_94737_: Double, p_94738_: Double, p_94739_: Int): Boolean {
|
||||
return this@EditablePanel.mouseClicked(p_94737_, p_94738_, p_94739_)
|
||||
}
|
||||
|
||||
override fun mouseReleased(p_94753_: Double, p_94754_: Double, p_94755_: Int): Boolean {
|
||||
return this@EditablePanel.mouseReleased(p_94753_, p_94754_, p_94755_)
|
||||
}
|
||||
|
||||
override fun mouseDragged(p_94740_: Double, p_94741_: Double, p_94742_: Int, p_94743_: Double, p_94744_: Double): Boolean {
|
||||
return this@EditablePanel.mouseDragged(p_94740_, p_94741_, p_94742_, p_94743_, p_94744_)
|
||||
}
|
||||
|
||||
override fun mouseScrolled(p_94734_: Double, p_94735_: Double, p_94736_: Double): Boolean {
|
||||
return this@EditablePanel.mouseScrolled(p_94734_, p_94735_, p_94736_)
|
||||
}
|
||||
|
||||
override fun keyPressed(p_94745_: Int, p_94746_: Int, p_94747_: Int): Boolean {
|
||||
return this@EditablePanel.keyPressed(p_94745_, p_94746_, p_94747_)
|
||||
}
|
||||
|
||||
override fun keyReleased(p_94750_: Int, p_94751_: Int, p_94752_: Int): Boolean {
|
||||
return this@EditablePanel.keyReleased(p_94750_, p_94751_, p_94752_)
|
||||
}
|
||||
|
||||
override fun charTyped(p_94732_: Char, p_94733_: Int): Boolean {
|
||||
return this@EditablePanel.charTyped(p_94732_, p_94733_)
|
||||
}
|
||||
|
||||
override fun nextFocusPath(p_265234_: FocusNavigationEvent): ComponentPath? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun isMouseOver(p_94748_: Double, p_94749_: Double): Boolean {
|
||||
return this@EditablePanel.isMouseOver(p_94748_, p_94749_)
|
||||
}
|
||||
|
||||
override fun getCurrentFocusPath(): ComponentPath? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getRectangle(): ScreenRectangle {
|
||||
val rect = calculateAbsoluteRectangle()
|
||||
return ScreenRectangle(rect.x.toInt(), rect.y.toInt(), rect.width.toInt(), rect.height.toInt())
|
||||
}
|
||||
}
|
||||
|
||||
var parent: EditablePanel<*>? = null
|
||||
set(value) {
|
||||
if (field === value)
|
||||
@ -808,27 +877,31 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return false to null
|
||||
}
|
||||
|
||||
fun findItemStack(mouseX: Float, mouseY: Float, ignoreMouseInputLock: Boolean = false): Pair<Boolean, ItemStack> {
|
||||
fun findItemStack(mouseX: Float, mouseY: Float, ignoreMouseInputLock: Boolean = false): Pair<EditablePanel<*>?, ItemStack> {
|
||||
if (!isVisible()) {
|
||||
return false to ItemStack.EMPTY
|
||||
return null to ItemStack.EMPTY
|
||||
}
|
||||
|
||||
if (!acceptMouseInput && !ignoreMouseInputLock) {
|
||||
return (mouseX >= absoluteX &&
|
||||
mouseX <= absoluteX + width &&
|
||||
mouseY >= absoluteY &&
|
||||
mouseY <= absoluteY + height) to ItemStack.EMPTY
|
||||
if (mouseX >= absoluteX &&
|
||||
mouseX <= absoluteX + width &&
|
||||
mouseY >= absoluteY &&
|
||||
mouseY <= absoluteY + height) {
|
||||
return this to ItemStack.EMPTY
|
||||
} else {
|
||||
return null to ItemStack.EMPTY
|
||||
}
|
||||
}
|
||||
|
||||
if (grabMouseInput && this is IItemStackPanel) {
|
||||
return true to this.itemStack
|
||||
return this to this.itemStack
|
||||
}
|
||||
|
||||
for (child in visibleChildrenInternal) {
|
||||
val (status, itemStack) = child.findItemStack(mouseX, mouseY, ignoreMouseInputLock)
|
||||
val status = child.findItemStack(mouseX, mouseY, ignoreMouseInputLock)
|
||||
|
||||
if (status) {
|
||||
return true to itemStack
|
||||
if (status.first != null) {
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
@ -839,13 +912,13 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
mouseY <= absoluteY + height
|
||||
) {
|
||||
if (this is IItemStackPanel) {
|
||||
return true to this.itemStack
|
||||
return this to this.itemStack
|
||||
}
|
||||
|
||||
return true to ItemStack.EMPTY
|
||||
return this to ItemStack.EMPTY
|
||||
}
|
||||
|
||||
return false to ItemStack.EMPTY
|
||||
return null to ItemStack.EMPTY
|
||||
}
|
||||
|
||||
fun renderTooltips(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
||||
@ -1296,7 +1369,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
override fun mouseMoved(x: Double, y: Double) {
|
||||
open fun mouseMoved(x: Double, y: Double) {
|
||||
|
||||
}
|
||||
|
||||
@ -1317,7 +1390,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
y in pos.y .. pos2.y
|
||||
}
|
||||
|
||||
final override fun mouseClicked(x: Double, y: Double, button: Int): Boolean {
|
||||
fun mouseClicked(x: Double, y: Double, button: Int): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
if (flashAnyBlocker()) return true
|
||||
|
||||
@ -1368,7 +1441,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return true
|
||||
}
|
||||
|
||||
final override fun mouseReleased(x: Double, y: Double, button: Int): Boolean {
|
||||
fun mouseReleased(x: Double, y: Double, button: Int): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
if (flashAnyBlocker(false)) return true
|
||||
if (grabMouseInput) return mouseReleasedInner(x, y, button)
|
||||
@ -1408,7 +1481,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return true
|
||||
}
|
||||
|
||||
final override fun mouseDragged(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||
fun mouseDragged(x: Double, y: Double, button: Int, xDelta: Double, yDelta: Double): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
if (flashAnyBlocker(false)) return true
|
||||
if (grabMouseInput) return mouseDraggedInner(x, y, button, xDelta, yDelta)
|
||||
@ -1448,7 +1521,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return true
|
||||
}
|
||||
|
||||
final override fun mouseScrolled(x: Double, y: Double, scroll: Double): Boolean {
|
||||
fun mouseScrolled(x: Double, y: Double, scroll: Double): Boolean {
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
|
||||
if (flashAnyBlocker(true)) {
|
||||
@ -1492,7 +1565,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
final override fun keyPressed(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
fun keyPressed(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
if (!isVisible() || !acceptKeyboardInput) return false
|
||||
if (!isEverFocused()) return false
|
||||
if (flashAnyBlocker(true)) return true
|
||||
@ -1512,7 +1585,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
final override fun keyReleased(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
fun keyReleased(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
if (!isVisible() || !acceptKeyboardInput) return false
|
||||
if (!isEverFocused()) return false
|
||||
if (flashAnyBlocker(false)) return true
|
||||
@ -1532,7 +1605,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
final override fun charTyped(codepoint: Char, mods: Int): Boolean {
|
||||
fun charTyped(codepoint: Char, mods: Int): Boolean {
|
||||
if (!isVisible() || !acceptKeyboardInput) return false
|
||||
if (!isEverFocused()) return false
|
||||
if (flashAnyBlocker(false)) return true
|
||||
@ -1548,11 +1621,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun changeFocus(state: Boolean): Boolean {
|
||||
return if (!isVisible()) false else super.changeFocus(state)
|
||||
}
|
||||
|
||||
final override fun isMouseOver(x: Double, y: Double): Boolean { // called to check whenever we are hovering at this
|
||||
fun isMouseOver(x: Double, y: Double): Boolean { // called to check whenever we are hovering at this
|
||||
if (!isVisible() || !acceptMouseInput) return false
|
||||
if (isGrabbingMouseInput()) return true
|
||||
|
||||
|
@ -94,14 +94,15 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
|
||||
return
|
||||
}
|
||||
|
||||
val renderX = absoluteX.toInt() + width.toInt() / 2
|
||||
val renderY = absoluteY.toInt() + (height * 0.9f).toInt()
|
||||
val renderX = width.toInt() / 2
|
||||
val renderY = (height * 0.9f).toInt()
|
||||
|
||||
InventoryScreen.renderEntityInInventory(
|
||||
InventoryScreen.renderEntityInInventoryFollowsMouse(
|
||||
stack,
|
||||
renderX,
|
||||
renderY,
|
||||
renderScale,
|
||||
renderX - mouseX,
|
||||
absoluteX.toInt() + renderX - mouseX,
|
||||
absoluteY + height * 0.15f - mouseY,
|
||||
entity
|
||||
)
|
||||
|
@ -62,11 +62,16 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
||||
return panel.charTyped(p_94732_, p_94733_)
|
||||
}
|
||||
|
||||
override fun changeFocus(p_94756_: Boolean): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun isMouseOver(p_94748_: Double, p_94749_: Double): Boolean {
|
||||
return panel.isMouseOver(p_94748_, p_94749_)
|
||||
}
|
||||
|
||||
override fun setFocused(p_265728_: Boolean) {
|
||||
// no op
|
||||
}
|
||||
|
||||
override fun isFocused(): Boolean {
|
||||
// ага, щас
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ open class EditBoxPanel<out S : Screen>(
|
||||
}
|
||||
|
||||
override fun configureNew(widget: EditBox, recreation: Boolean) {
|
||||
widget.setFocus(isFocusedThis)
|
||||
widget.isFocused = isFocusedThis
|
||||
}
|
||||
|
||||
override fun onFocusChanged() {
|
||||
widget?.setFocus(isFocusedThis)
|
||||
widget?.isFocused = isFocusedThis
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
@ -54,7 +54,7 @@ open class EditBoxPanel<out S : Screen>(
|
||||
|
||||
override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean {
|
||||
if (key == InputConstants.KEY_ESCAPE && widget?.isActive == true) {
|
||||
widget?.setFocus(false)
|
||||
widget?.isFocused = false
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -1151,7 +1151,6 @@ open class TextInputPanel<out S : Screen>(
|
||||
|
||||
RenderSystem.setShader(GameRenderer::getPositionShader)
|
||||
RenderSystem.setShaderColor(cursorColor.red, cursorColor.green, cursorColor.blue, 0.4f)
|
||||
RenderSystem.disableTexture()
|
||||
//RenderSystem.enableColorLogicOp()
|
||||
//RenderSystem.logicOp(GlStateManager.LogicOp.NOR)
|
||||
RenderSystem.disableDepthTest()
|
||||
@ -1170,7 +1169,6 @@ open class TextInputPanel<out S : Screen>(
|
||||
|
||||
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
//RenderSystem.disableColorLogicOp()
|
||||
RenderSystem.enableTexture()
|
||||
RenderSystem.enableDepthTest()
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ abstract class AbstractSlotPanel<out S : MatteryScreen<*>> @JvmOverloads constru
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader)
|
||||
|
||||
if (!itemstack.isEmpty) {
|
||||
screen.renderItemStack(absoluteX, absoluteY, itemstack, countOverride)
|
||||
screen.renderItemStack(stack, itemstack, countOverride)
|
||||
clearDepth(stack)
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ abstract class UserFilteredSlotPanel<out S : MatteryScreen<*>, out T : Slot>(
|
||||
if (slotFilter !== Items.AIR) {
|
||||
val itemStack = ItemStack(slotFilter!!, 1)
|
||||
|
||||
screen.renderItemStack(absoluteX, absoluteY, itemStack, null)
|
||||
screen.renderItemStack(stack, itemStack, null)
|
||||
clearDepth(stack)
|
||||
|
||||
drawColor = SLOT_FILTER_COLOR
|
||||
|
@ -318,33 +318,11 @@ private class AndroidResearchButton(
|
||||
icon.render(stack, 0f, 0f, width, height)
|
||||
} else if (itemIcon != null) {
|
||||
val itemstack = ItemStack(itemIcon, 1)
|
||||
val systemPoseStack = RenderSystem.getModelViewStack()
|
||||
|
||||
systemPoseStack.pushPose()
|
||||
systemPoseStack.translate((absoluteX + 1f).toDouble(), (absoluteY + 1f).toDouble(), 0.0)
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
RenderSystem.depthFunc(GL11.GL_LESS)
|
||||
|
||||
// Thanks Mojang
|
||||
// Very cool
|
||||
// (for int x, int y, which are then cast into doubles anyway)
|
||||
screen.itemRenderer.blitOffset = 1f // Z pos
|
||||
|
||||
screen.itemRenderer.renderAndDecorateItem(
|
||||
requireNotNull(minecraft.player) { "yo, dude, what the fuck" },
|
||||
itemstack,
|
||||
0,
|
||||
0,
|
||||
(absoluteX + absoluteY * 1000f).toInt()
|
||||
)
|
||||
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
screen.itemRenderer.renderGuiItemDecorations(screen.font, itemstack, 0, 0, null)
|
||||
screen.itemRenderer.blitOffset = 0f
|
||||
|
||||
// too big accumulations can lead to Z near clipping issues
|
||||
systemPoseStack.popPose()
|
||||
RenderSystem.applyModelViewMatrix()
|
||||
stack.pushPose()
|
||||
stack.translate(1f, 1f, 0f)
|
||||
screen.renderItemStack(stack, itemstack)
|
||||
stack.popPose()
|
||||
|
||||
clearDepth(stack)
|
||||
} else {
|
||||
|
@ -83,7 +83,6 @@ open class FluidGaugePanel<out S : Screen>(
|
||||
}
|
||||
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader)
|
||||
RenderSystem.enableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
|
@ -71,7 +71,6 @@ open class MatterGaugePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
if (widget.percentage > 0.01f) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader)
|
||||
RenderSystem.enableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
|
@ -4,16 +4,17 @@ import earth.terrarium.ad_astra.AdAstra
|
||||
import earth.terrarium.ad_astra.common.data.Planet
|
||||
import earth.terrarium.ad_astra.common.data.PlanetData
|
||||
import earth.terrarium.ad_astra.common.item.armor.SpaceSuit
|
||||
import earth.terrarium.ad_astra.common.registry.ModDamageSource
|
||||
import earth.terrarium.ad_astra.common.util.ModUtils
|
||||
import earth.terrarium.ad_astra.common.registry.ModDamageSources
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent
|
||||
import net.minecraftforge.fml.ModList
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.config.ServerCompatConfig
|
||||
import ru.dbotthepony.mc.otm.core.damageType
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
|
||||
val isAdAstraLoaded by lazy {
|
||||
ModList.get().isLoaded(AdAstra.MOD_ID)
|
||||
@ -27,7 +28,7 @@ fun onDamageEvent(event: LivingHurtEvent) {
|
||||
if (ServerCompatConfig.AdAstra.ANDROIDS_DO_NOT_NEED_OXYGEN) {
|
||||
if (ply.matteryPlayer?.isAndroid != true) return
|
||||
|
||||
if (event.source === ModDamageSource.OXYGEN) {
|
||||
if (event.source.`is`(ModDamageSources.OXYGEN)) {
|
||||
event.amount = 0f
|
||||
event.isCanceled = true
|
||||
}
|
||||
@ -51,7 +52,7 @@ fun onMatteryTick(event: MatteryPlayerCapability.PostTick) {
|
||||
val yesTritanium = yesTritanium0 + yesTritanium1
|
||||
|
||||
if (rand.nextDouble() <= (noSpacesuits - yesTritanium) * ServerCompatConfig.AdAstra.ANDROID_COSMIC_RAYS_CHANCE) {
|
||||
event.player.hurt(MRegistry.DAMAGE_COSMIC_RAYS, 1f)
|
||||
event.player.hurt(MatteryDamageSource(event.level.registryAccess().damageType(MDamageTypes.COSMIC_RAYS)), 1f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,12 @@ import it.unimi.dsi.fastutil.ints.IntArraySet
|
||||
import mezz.jei.api.IModPlugin
|
||||
import mezz.jei.api.JeiPlugin
|
||||
import mezz.jei.api.constants.RecipeTypes
|
||||
import mezz.jei.api.constants.VanillaTypes
|
||||
import mezz.jei.api.gui.handlers.IGuiContainerHandler
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotView
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView
|
||||
import mezz.jei.api.helpers.IJeiHelpers
|
||||
import mezz.jei.api.ingredients.ITypedIngredient
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler
|
||||
@ -18,6 +20,7 @@ import mezz.jei.api.registration.IRecipeCatalystRegistration
|
||||
import mezz.jei.api.registration.IRecipeCategoryRegistration
|
||||
import mezz.jei.api.registration.IRecipeRegistration
|
||||
import mezz.jei.api.registration.IRecipeTransferRegistration
|
||||
import mezz.jei.api.runtime.IClickableIngredient
|
||||
import net.minecraft.client.renderer.Rect2i
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.entity.player.Player
|
||||
@ -36,6 +39,7 @@ import ru.dbotthepony.mc.otm.registry.MRecipes
|
||||
import java.util.*
|
||||
import java.util.stream.Collectors
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
var isJeiLoaded = false
|
||||
@ -226,12 +230,28 @@ class JEIPlugin : IModPlugin {
|
||||
.collect(Collectors.toList())
|
||||
}
|
||||
|
||||
override fun getIngredientUnderMouse(
|
||||
override fun getClickableIngredientUnderMouse(
|
||||
containerScreen: MatteryScreen<*>,
|
||||
mouseX: Double,
|
||||
mouseY: Double
|
||||
): Any? {
|
||||
return containerScreen.panelsView.stream().map { it.findItemStack(mouseX.toFloat(), mouseY.toFloat(), ignoreMouseInputLock = true) }.filter { it.first }.findAny().orElse(null)?.second
|
||||
): Optional<IClickableIngredient<*>> {
|
||||
return containerScreen.panelsView
|
||||
.stream()
|
||||
.map { it.findItemStack(mouseX.toFloat(), mouseY.toFloat(), ignoreMouseInputLock = true) }
|
||||
.filter { it.first != null }
|
||||
.findAny()
|
||||
.flatMap { a -> helpers.ingredientManager.createTypedIngredient(VanillaTypes.ITEM_STACK, a.second).map { a.first to it } }
|
||||
.map {
|
||||
object : IClickableIngredient<ItemStack> {
|
||||
override fun getTypedIngredient(): ITypedIngredient<ItemStack> {
|
||||
return it.second
|
||||
}
|
||||
|
||||
override fun getArea(): Rect2i {
|
||||
return it.first!!.calculateAbsoluteRectangle().toIntRect()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -4,17 +4,26 @@ import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonSyntaxException
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.JsonOps
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Holder
|
||||
import net.minecraft.core.RegistryAccess
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.nbt.NbtOps
|
||||
import net.minecraft.nbt.Tag
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.network.chat.MutableComponent
|
||||
import net.minecraft.network.chat.contents.LiteralContents
|
||||
import net.minecraft.network.chat.contents.TranslatableContents
|
||||
import net.minecraft.resources.ResourceKey
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.sounds.SoundEvent
|
||||
import net.minecraft.tags.DamageTypeTags
|
||||
import net.minecraft.world.damagesource.DamageSource
|
||||
import net.minecraft.world.damagesource.DamageType
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.material.Fluid
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import net.minecraftforge.registries.ForgeRegistries
|
||||
import net.minecraftforge.registries.IForgeRegistry
|
||||
|
||||
@ -52,7 +61,7 @@ fun <V : Any> Codec<V>.toNbtStrict(value: V): Tag {
|
||||
}
|
||||
|
||||
// 1.19 being 1.19
|
||||
fun TranslatableComponent(key: String, vararg values: Any): MutableComponent = MutableComponent.create(TranslatableContents(key, *values))
|
||||
fun TranslatableComponent(key: String, vararg values: Any): MutableComponent = MutableComponent.create(TranslatableContents(key, null, values))
|
||||
fun TextComponent(value: String): MutableComponent = MutableComponent.create(LiteralContents(value))
|
||||
|
||||
fun <T> IForgeRegistry<T>.getKeyNullable(value: T): ResourceLocation? {
|
||||
@ -73,3 +82,13 @@ fun FriendlyByteBuf.writeRegistryId(value: Item) = writeRegistryId(ForgeRegistri
|
||||
|
||||
// 1.19.3 lol
|
||||
inline val SoundEvent.holder get() = ForgeRegistries.SOUND_EVENTS.getHolder(this).orElse(null) ?: throw NoSuchElementException("$this is missing from ${ForgeRegistries.SOUND_EVENTS}")
|
||||
|
||||
// 1.19.4 :thonkang:
|
||||
inline val DamageSource.isFall get() = `is`(DamageTypeTags.IS_FALL)
|
||||
inline val DamageSource.isBypassArmor get() = `is`(DamageTypeTags.BYPASSES_ARMOR)
|
||||
inline val DamageSource.isExplosion get() = `is`(DamageTypeTags.IS_EXPLOSION)
|
||||
inline val DamageSource.isFire get() = `is`(DamageTypeTags.IS_FIRE)
|
||||
|
||||
fun RegistryAccess.damageType(key: ResourceKey<DamageType>): Holder<DamageType> {
|
||||
return registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(key)
|
||||
}
|
||||
|
@ -157,11 +157,11 @@ class EnumValueCodec<V : Enum<V>>(clazz: Class<out V>) : IStreamCodec<V>, Codec<
|
||||
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<V, T>> {
|
||||
if (ops.compressMaps()) {
|
||||
return ops.getNumberValue(input)
|
||||
.flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error("No such enum with ordinal index $it") }
|
||||
.flatMap { values.getOrNull(it.toInt())?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum with ordinal index $it" } }
|
||||
}
|
||||
|
||||
return ops.getStringValue(input)
|
||||
.flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error("No such enum value $it") }
|
||||
.flatMap { valuesMap[it]?.let { DataResult.success(Pair(it, ops.empty())) } ?: DataResult.error { "No such enum value $it" } }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -41,10 +41,10 @@ object ItemStackCodec : Codec<ItemStack>, TypeAdapter<ItemStack>(), JsonSerializ
|
||||
override fun <T : Any> decode(ops: DynamicOps<T>, input: T): DataResult<Pair<ItemStack, T>> {
|
||||
return ops.getMap(input).flatMap {
|
||||
val item = it["id"]?.let { ForgeRegistries.ITEMS.codec.decode(ops, it) }?.result()?.orElse(null)?.first
|
||||
val count = it["count"]?.let(ops::getNumberValue)?.result()?.orElse(null)?.toInt() ?: return@flatMap DataResult.error("Invalid item count")
|
||||
val count = it["count"]?.let(ops::getNumberValue)?.result()?.orElse(null)?.toInt() ?: return@flatMap DataResult.error { "Invalid item count" }
|
||||
|
||||
if (item == null || item == Items.AIR) {
|
||||
return@flatMap DataResult.error("Unknown item type $item")
|
||||
return@flatMap DataResult.error { "Unknown item type $item" }
|
||||
}
|
||||
|
||||
DataResult.success(ItemStack(item, count))
|
||||
|
@ -69,7 +69,7 @@ class LootPoolAppender(conditions: Array<out LootItemCondition>, pools: Stream<L
|
||||
deque.push(lootTableContextConstructor.newInstance(notExistingLocation, true))
|
||||
DataResult.success(serializer.fromJson(it.convert(JsonOps.INSTANCE).value, LootPool::class.java))
|
||||
} catch(err: JsonSyntaxException) {
|
||||
DataResult.error(err.message)
|
||||
DataResult.error { err.message }
|
||||
} finally {
|
||||
deque.pop()
|
||||
}
|
||||
@ -77,7 +77,7 @@ class LootPoolAppender(conditions: Array<out LootItemCondition>, pools: Stream<L
|
||||
try {
|
||||
DataResult.success(Dynamic(JsonOps.INSTANCE, serializer.toJsonTree(it)))
|
||||
} catch(err: JsonSyntaxException) {
|
||||
DataResult.error(err.message)
|
||||
DataResult.error { err.message }
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
@ -12,8 +12,10 @@ import net.minecraft.world.phys.BlockHitResult
|
||||
import net.minecraft.world.phys.EntityHitResult
|
||||
import net.minecraft.world.phys.HitResult
|
||||
import net.minecraftforge.event.ForgeEventFactory
|
||||
import ru.dbotthepony.mc.otm.core.damageType
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MEntityTypes
|
||||
import ru.dbotthepony.mc.otm.registry.PlasmaDamageSource
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
|
||||
class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityType<out Projectile>, level) {
|
||||
var inflictor: ItemStack? = null
|
||||
@ -36,7 +38,7 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT
|
||||
super.onHitEntity(p_37259_)
|
||||
|
||||
if (!level.isClientSide) {
|
||||
p_37259_.entity.hurt(PlasmaDamageSource(owner, inflictor), damage)
|
||||
p_37259_.entity.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.PLASMA), owner, inflictor), damage)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,9 @@ import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.config.ItemsConfig
|
||||
import ru.dbotthepony.mc.otm.core.*
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import ru.dbotthepony.mc.otm.runIfClient
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@ -212,7 +214,7 @@ class CrudeBatteryItem : BatteryItem(ItemsConfig.Batteries.CRUDE) {
|
||||
mattery.androidEnergy.item = copyStack
|
||||
|
||||
val extraDamageMult = level.random.nextFloat()
|
||||
player.hurt(MRegistry.DAMAGE_EMP, 1.5f + extraDamageMult * 3.5f)
|
||||
player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EMP), inflictor = itemStack), 1.5f + extraDamageMult * 3.5f)
|
||||
|
||||
val debuffDuration = 100 + (100 * (1f - extraDamageMult)).roundToInt()
|
||||
player.addEffect(MobEffectInstance(MobEffects.BLINDNESS, debuffDuration), player)
|
||||
|
@ -98,7 +98,7 @@ class PortableCondensationDriveItem(capacity: Int) :
|
||||
const val FILTER_PATH = "filter"
|
||||
|
||||
fun onPickupEvent(event: EntityItemPickupEvent) {
|
||||
if (event.item.owner != null && event.item.owner != event.entity.uuid && event.item.age < 200 || event.item.item.isEmpty) {
|
||||
if (event.item.owner != null && event.item.owner != event.entity && event.item.age < 200 || event.item.item.isEmpty) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel
|
||||
import java.util.function.Consumer
|
||||
|
||||
private object GravitationStabilizerArmorMaterial : ArmorMaterial {
|
||||
override fun getDurabilityForSlot(p_40410_: EquipmentSlot) = 0
|
||||
override fun getDefenseForSlot(p_40411_: EquipmentSlot) = 3
|
||||
override fun getDurabilityForType(p_40410_: ArmorItem.Type) = 0
|
||||
override fun getDefenseForType(p_40411_: ArmorItem.Type) = 3
|
||||
override fun getEnchantmentValue() = 0
|
||||
override fun getEquipSound(): SoundEvent = SoundEvents.ARMOR_EQUIP_GENERIC
|
||||
override fun getRepairIngredient(): Ingredient = Ingredient.EMPTY
|
||||
@ -41,7 +41,7 @@ private object GravitationStabilizerArmorRenderProperties : IClientItemExtension
|
||||
}
|
||||
}
|
||||
|
||||
class PortableGravitationStabilizerItem : ArmorItem(GravitationStabilizerArmorMaterial, EquipmentSlot.CHEST, Properties().stacksTo(1).rarity(Rarity.RARE)) {
|
||||
class PortableGravitationStabilizerItem : ArmorItem(GravitationStabilizerArmorMaterial, Type.CHESTPLATE, Properties().stacksTo(1).rarity(Rarity.RARE)) {
|
||||
override fun initializeClient(consumer: Consumer<IClientItemExtensions>) {
|
||||
super.initializeClient(consumer)
|
||||
consumer.accept(GravitationStabilizerArmorRenderProperties)
|
||||
|
@ -12,22 +12,22 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||
|
||||
private object SimpleTritaniumArmorMaterial : ArmorMaterial {
|
||||
override fun getDurabilityForSlot(p_40410_: EquipmentSlot): Int {
|
||||
override fun getDurabilityForType(p_40410_: ArmorItem.Type): Int {
|
||||
return when (p_40410_) {
|
||||
EquipmentSlot.HEAD -> 380
|
||||
EquipmentSlot.CHEST -> 590
|
||||
EquipmentSlot.LEGS -> 500
|
||||
EquipmentSlot.FEET -> 420
|
||||
ArmorItem.Type.HELMET -> 380
|
||||
ArmorItem.Type.CHESTPLATE -> 590
|
||||
ArmorItem.Type.LEGGINGS -> 500
|
||||
ArmorItem.Type.BOOTS -> 420
|
||||
else -> throw IllegalArgumentException("yo dude what the fuck $p_40410_")
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefenseForSlot(p_40411_: EquipmentSlot): Int {
|
||||
override fun getDefenseForType(p_40411_: ArmorItem.Type): Int {
|
||||
return when (p_40411_) {
|
||||
EquipmentSlot.FEET -> 2
|
||||
EquipmentSlot.LEGS -> 6
|
||||
EquipmentSlot.CHEST -> 7
|
||||
EquipmentSlot.HEAD -> 2
|
||||
ArmorItem.Type.HELMET -> 2
|
||||
ArmorItem.Type.CHESTPLATE -> 6
|
||||
ArmorItem.Type.LEGGINGS -> 7
|
||||
ArmorItem.Type.BOOTS -> 2
|
||||
else -> throw IllegalArgumentException("yo dude what the fuck $p_40411_")
|
||||
}
|
||||
}
|
||||
@ -43,7 +43,7 @@ private object SimpleTritaniumArmorMaterial : ArmorMaterial {
|
||||
override fun getKnockbackResistance() = 0f
|
||||
}
|
||||
|
||||
class SimpleTritaniumArmorItem(slot: EquipmentSlot) : ArmorItem(SimpleTritaniumArmorMaterial, slot, Properties().stacksTo(1)) {
|
||||
class SimpleTritaniumArmorItem(slot: Type) : ArmorItem(SimpleTritaniumArmorMaterial, slot, Properties().stacksTo(1)) {
|
||||
override fun getArmorTexture(stack: ItemStack, entity: Entity?, slot: EquipmentSlot, type: String?): String? {
|
||||
if (type != "overlay" || slot == EquipmentSlot.FEET)
|
||||
return when (slot) {
|
||||
|
@ -4,6 +4,7 @@ import net.minecraft.client.model.HumanoidModel
|
||||
import net.minecraft.sounds.SoundEvent
|
||||
import net.minecraft.sounds.SoundEvents
|
||||
import net.minecraft.world.damagesource.DamageSource
|
||||
import net.minecraft.world.damagesource.DamageTypes
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.EquipmentSlot
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
@ -21,23 +22,21 @@ import ru.dbotthepony.mc.otm.registry.MItems
|
||||
import java.util.function.Consumer
|
||||
|
||||
private object TritaniumArmorMaterial : ArmorMaterial {
|
||||
override fun getDurabilityForSlot(p_40410_: EquipmentSlot): Int {
|
||||
override fun getDurabilityForType(p_40410_: ArmorItem.Type): Int {
|
||||
return when (p_40410_) {
|
||||
EquipmentSlot.HEAD -> 520
|
||||
EquipmentSlot.CHEST -> 920
|
||||
EquipmentSlot.LEGS -> 650
|
||||
EquipmentSlot.FEET -> 540
|
||||
else -> throw IllegalArgumentException("yo dude what the fuck $p_40410_")
|
||||
ArmorItem.Type.HELMET -> 520
|
||||
ArmorItem.Type.CHESTPLATE -> 920
|
||||
ArmorItem.Type.LEGGINGS -> 650
|
||||
ArmorItem.Type.BOOTS -> 540
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefenseForSlot(p_40411_: EquipmentSlot): Int {
|
||||
override fun getDefenseForType(p_40411_: ArmorItem.Type): Int {
|
||||
return when (p_40411_) {
|
||||
EquipmentSlot.HEAD -> 4
|
||||
EquipmentSlot.CHEST -> 9
|
||||
EquipmentSlot.LEGS -> 7
|
||||
EquipmentSlot.FEET -> 3
|
||||
else -> throw IllegalArgumentException("yo dude what the fuck $p_40411_")
|
||||
ArmorItem.Type.HELMET -> 4
|
||||
ArmorItem.Type.CHESTPLATE -> 9
|
||||
ArmorItem.Type.LEGGINGS -> 7
|
||||
ArmorItem.Type.BOOTS -> 3
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +66,7 @@ private object TritaniumArmorRenderProperties : IClientItemExtensions {
|
||||
}
|
||||
}
|
||||
|
||||
class TritaniumArmorItem(slot: EquipmentSlot) : ArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) {
|
||||
class TritaniumArmorItem(slot: Type) : ArmorItem(TritaniumArmorMaterial, slot, Properties().stacksTo(1).rarity(Rarity.RARE)) {
|
||||
override fun initializeClient(consumer: Consumer<IClientItemExtensions>) {
|
||||
super.initializeClient(consumer)
|
||||
consumer.accept(TritaniumArmorRenderProperties)
|
||||
@ -81,7 +80,7 @@ class TritaniumArmorItem(slot: EquipmentSlot) : ArmorItem(TritaniumArmorMaterial
|
||||
const val TEXTURE_LOCATION = "${OverdriveThatMatters.MOD_ID}:textures/models/armor/tritanium_armor.png"
|
||||
|
||||
fun onHurt(event: LivingAttackEvent) {
|
||||
if (event.source === DamageSource.SWEET_BERRY_BUSH || event.source.msgId == "sweetBerryBush") {
|
||||
if (event.source.typeHolder().`is`(DamageTypes.SWEET_BERRY_BUSH) || event.source.msgId == "sweetBerryBush") {
|
||||
if (
|
||||
event.entity.getItemBySlot(EquipmentSlot.FEET).let { !it.isEmpty && it.item == MItems.TRITANIUM_BOOTS } &&
|
||||
event.entity.getItemBySlot(EquipmentSlot.LEGS).let { !it.isEmpty && it.item == MItems.TRITANIUM_PANTS }
|
||||
|
@ -18,6 +18,8 @@ import ru.dbotthepony.mc.otm.config.ServerConfig
|
||||
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.isExplosion
|
||||
import ru.dbotthepony.mc.otm.core.isFire
|
||||
import ru.dbotthepony.mc.otm.runIfClient
|
||||
import java.util.UUID
|
||||
|
||||
|
@ -14,7 +14,10 @@ import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.onceServer
|
||||
import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.core.damageType
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import ru.dbotthepony.mc.otm.runIfClient
|
||||
|
||||
class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) {
|
||||
@ -55,6 +58,8 @@ class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) {
|
||||
return super.finishUsingItem(itemStack, level, player)
|
||||
}
|
||||
|
||||
val copy = itemStack.copy()
|
||||
|
||||
if (!player.abilities.instabuild)
|
||||
itemStack.shrink(1)
|
||||
|
||||
@ -63,7 +68,7 @@ class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) {
|
||||
|
||||
player.displayClientMessage(TranslatableComponent("otm.exopack.granted1").withStyle(ChatFormatting.GRAY), false)
|
||||
player.displayClientMessage(TranslatableComponent("otm.exopack.granted2").withStyle(ChatFormatting.GRAY), false)
|
||||
player.hurt(MRegistry.DAMAGE_EXOPACK_PROBE, 10f)
|
||||
player.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXOPACK_PROBE), inflictor = copy), 10f)
|
||||
|
||||
for (i in 3 .. 7) {
|
||||
onceServer((i - 1) * 100) {
|
||||
|
@ -25,8 +25,10 @@ import net.minecraftforge.event.level.BlockEvent
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||
import ru.dbotthepony.mc.otm.config.ItemsConfig
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.damageType
|
||||
import ru.dbotthepony.mc.otm.core.getExplosionResistance
|
||||
import ru.dbotthepony.mc.otm.core.gracefulBlockBreak
|
||||
import ru.dbotthepony.mc.otm.core.isExplosion
|
||||
import ru.dbotthepony.mc.otm.core.math.component1
|
||||
import ru.dbotthepony.mc.otm.core.math.component2
|
||||
import ru.dbotthepony.mc.otm.core.math.component3
|
||||
@ -36,8 +38,9 @@ import ru.dbotthepony.mc.otm.core.math.toDoubleVector
|
||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import ru.dbotthepony.mc.otm.core.position
|
||||
import ru.dbotthepony.mc.otm.core.tagNotNull
|
||||
import ru.dbotthepony.mc.otm.registry.HammerNailDamageSource
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
import ru.dbotthepony.mc.otm.triggers.NailedEntityTrigger
|
||||
|
||||
class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1).fireResistant().durability(durability)) {
|
||||
@ -86,7 +89,7 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1).
|
||||
// так как у меня алгоритм "своеобразный", я изобрету велосипед ибо я такой нехороший и непослушный
|
||||
// Трассировка луча используя наивный метод
|
||||
while (canTravel > 0.0) {
|
||||
val blockPos = BlockPos(rayPos)
|
||||
val blockPos = BlockPos.containing(rayPos)
|
||||
|
||||
if (blockPos != lastBlockPos) {
|
||||
if (!level.hasChunkAt(blockPos)) break
|
||||
@ -116,7 +119,7 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1).
|
||||
|
||||
val rayBox = aabb.move(rayPos)
|
||||
val entities = level.getEntities(null, rayBox) { it is LivingEntity && it.isAlive && !it.isSpectator && hitEntities.add(it) } as List<LivingEntity>
|
||||
val damageSource = HammerNailDamageSource(attacker, itemStack)
|
||||
val damageSource = MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.HAMMER_NAIL), attacker, itemStack)
|
||||
|
||||
for (it in entities) {
|
||||
val damage = canTravel * ItemsConfig.ExplosiveHammer.TRAVEL_DAMAGE_MULT
|
||||
@ -143,6 +146,8 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1).
|
||||
if (attacker !is Player || !attacker.isCreative) {
|
||||
unprime(itemStack)
|
||||
|
||||
val copy = itemStack.copy()
|
||||
|
||||
itemStack.hurtAndBreak(1, attacker) {
|
||||
it.broadcastBreakEvent(hand)
|
||||
}
|
||||
@ -166,12 +171,12 @@ class ExplosiveHammerItem(durability: Int = 64) : Item(Properties().stacksTo(1).
|
||||
if (attacker.random.nextDouble() <= ItemsConfig.ExplosiveHammer.FLY_OFF_DAMAGE_CHANCE) {
|
||||
attacker.invulnerableTime = 0
|
||||
val dmg = ItemsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE + attacker.random.nextDouble() * (ItemsConfig.ExplosiveHammer.FLY_OFF_MAX_DAMAGE - ItemsConfig.ExplosiveHammer.FLY_OFF_MIN_DAMAGE)
|
||||
attacker.hurt(MRegistry.DAMAGE_EXPLOSIVE_HAMMER, dmg.toFloat())
|
||||
attacker.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat())
|
||||
}
|
||||
} else if (attacker.random.nextDouble() <= ItemsConfig.ExplosiveHammer.SELF_HARM_CHANCE) {
|
||||
attacker.invulnerableTime = 0
|
||||
val dmg = ItemsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE + attacker.random.nextDouble() * (ItemsConfig.ExplosiveHammer.SELF_HARM_MAX_DAMAGE - ItemsConfig.ExplosiveHammer.SELF_HARM_MIN_DAMAGE)
|
||||
attacker.hurt(MRegistry.DAMAGE_EXPLOSIVE_HAMMER, dmg.toFloat())
|
||||
attacker.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.EXPLOSIVE_HAMMER), inflictor = copy), dmg.toFloat())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemDisplayContext
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Rarity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
@ -438,7 +439,7 @@ abstract class AbstractWeaponItem<D : WeaponDataTable>(val tables: KClass<D>, pr
|
||||
itemInHandRenderer.renderItem(
|
||||
player,
|
||||
stack,
|
||||
ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND,
|
||||
ItemDisplayContext.FIRST_PERSON_RIGHT_HAND,
|
||||
false,
|
||||
pose,
|
||||
event.multiBufferSource,
|
||||
|
@ -38,12 +38,14 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.core.math.DecimalConfigValue
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.damageType
|
||||
import ru.dbotthepony.mc.otm.core.math.defineDecimal
|
||||
import ru.dbotthepony.mc.otm.core.ifPresentK
|
||||
import ru.dbotthepony.mc.otm.core.math.nextVariance
|
||||
import ru.dbotthepony.mc.otm.core.orNull
|
||||
import ru.dbotthepony.mc.otm.registry.EMPDamageSource
|
||||
import ru.dbotthepony.mc.otm.core.util.WriteOnce
|
||||
import ru.dbotthepony.mc.otm.registry.MDamageTypes
|
||||
import ru.dbotthepony.mc.otm.registry.MatteryDamageSource
|
||||
|
||||
class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vanishable {
|
||||
val chargedAttributes: Multimap<Attribute, AttributeModifier>
|
||||
@ -104,7 +106,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani
|
||||
victim.matteryPlayer?.let {
|
||||
if (it.isAndroid) {
|
||||
victim.invulnerableTime = 0
|
||||
victim.hurt(EMPDamageSource(attacker, itemStack), 8f)
|
||||
victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +119,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani
|
||||
victim.matteryPlayer?.let {
|
||||
if (it.isAndroid && it.androidEnergy.extractEnergyExact(ENERGY_ZAP, false)) {
|
||||
it.androidEnergy.extractEnergy(attacker.level.random.nextVariance(ENERGY_ZAP_VARIANCE), false)
|
||||
victim.hurt(EMPDamageSource(attacker), 8f)
|
||||
victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ object MatterManager {
|
||||
it.ingredients.stream()
|
||||
.filter { !it.isActuallyEmpty }
|
||||
.map { it.items.stream().map(::RecipeEntry) },
|
||||
ImmutableStack(it.resultItem),
|
||||
ImmutableStack(it.getResultItem(server.registryAccess())),
|
||||
isCritical = isCritical,
|
||||
name = it.id,
|
||||
allowBacktrack = allowBacktrack
|
||||
@ -584,7 +584,7 @@ object MatterManager {
|
||||
for (item in it.ingredients[c].items) {
|
||||
container[c] = item
|
||||
|
||||
if (!it.assemble(container).isEmpty) {
|
||||
if (!it.assemble(container, server.registryAccess()).isEmpty) {
|
||||
val residue = it.getRemainingItems(container)
|
||||
|
||||
val thisResidue = residue[c]
|
||||
@ -602,7 +602,7 @@ object MatterManager {
|
||||
|
||||
ResolvedRecipe(
|
||||
realIngredients.stream().map { it.stream() },
|
||||
ImmutableStack(it.resultItem),
|
||||
ImmutableStack(it.getResultItem(server.registryAccess())),
|
||||
isCritical = isCritical,
|
||||
name = it.id,
|
||||
allowBacktrack = allowBacktrack
|
||||
|
@ -2,33 +2,75 @@ package ru.dbotthepony.mc.otm.recipe
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import net.minecraft.core.NonNullList
|
||||
import net.minecraft.core.RegistryAccess
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.inventory.CraftingContainer
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.CraftingBookCategory
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer
|
||||
import net.minecraft.world.item.crafting.RecipeType
|
||||
import net.minecraft.world.item.crafting.ShapedRecipe
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraftforge.common.crafting.IShapedRecipe
|
||||
import ru.dbotthepony.mc.otm.capability.matteryEnergy
|
||||
import ru.dbotthepony.mc.otm.container.iterator
|
||||
import ru.dbotthepony.mc.otm.container.stream
|
||||
import ru.dbotthepony.mc.otm.core.filterNotNull
|
||||
|
||||
class EnergyContainerRecipe(
|
||||
id: ResourceLocation,
|
||||
group: String,
|
||||
category: CraftingBookCategory,
|
||||
width: Int,
|
||||
height: Int,
|
||||
ingredients: NonNullList<Ingredient>,
|
||||
result: ItemStack,
|
||||
) : ShapedRecipe(id, group, category, width, height, ingredients, result) {
|
||||
constructor(parent: ShapedRecipe) : this(parent.id, parent.group, parent.category(), parent.width, parent.height, parent.ingredients, parent.resultItem)
|
||||
class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedRecipe<CraftingContainer> by parent {
|
||||
override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int): Boolean {
|
||||
return parent.canCraftInDimensions(p_43999_, p_44000_)
|
||||
}
|
||||
|
||||
override fun assemble(container: CraftingContainer): ItemStack {
|
||||
val itemStack = super.assemble(container)
|
||||
override fun getResultItem(p_267052_: RegistryAccess): ItemStack {
|
||||
return parent.getResultItem(p_267052_)
|
||||
}
|
||||
|
||||
override fun getId(): ResourceLocation {
|
||||
return parent.id
|
||||
}
|
||||
|
||||
override fun category(): CraftingBookCategory {
|
||||
return parent.category()
|
||||
}
|
||||
|
||||
override fun getRemainingItems(p_44004_: CraftingContainer): NonNullList<ItemStack> {
|
||||
return parent.getRemainingItems(p_44004_)
|
||||
}
|
||||
|
||||
override fun getIngredients(): NonNullList<Ingredient> {
|
||||
return parent.ingredients
|
||||
}
|
||||
|
||||
override fun isSpecial(): Boolean {
|
||||
return parent.isSpecial
|
||||
}
|
||||
|
||||
override fun showNotification(): Boolean {
|
||||
return parent.showNotification()
|
||||
}
|
||||
|
||||
override fun getGroup(): String {
|
||||
return parent.group
|
||||
}
|
||||
|
||||
override fun getToastSymbol(): ItemStack {
|
||||
return parent.toastSymbol
|
||||
}
|
||||
|
||||
override fun isIncomplete(): Boolean {
|
||||
return parent.isIncomplete
|
||||
}
|
||||
|
||||
override fun getType(): RecipeType<*> {
|
||||
return parent.type
|
||||
}
|
||||
|
||||
override fun assemble(container: CraftingContainer, registryAccess: RegistryAccess): ItemStack {
|
||||
val itemStack = parent.assemble(container, registryAccess)
|
||||
|
||||
val battery = container.stream()
|
||||
.filter { !it.isEmpty }
|
||||
@ -54,7 +96,7 @@ class EnergyContainerRecipe(
|
||||
}
|
||||
|
||||
override fun matches(container: CraftingContainer, level: Level): Boolean {
|
||||
return super.matches(container, level) && !container.stream().anyMatch { it.isDamaged }
|
||||
return parent.matches(container, level) && !container.stream().anyMatch { it.isDamaged }
|
||||
}
|
||||
|
||||
override fun getSerializer(): RecipeSerializer<EnergyContainerRecipe> {
|
||||
@ -63,15 +105,15 @@ class EnergyContainerRecipe(
|
||||
|
||||
companion object : RecipeSerializer<EnergyContainerRecipe> {
|
||||
override fun fromJson(id: ResourceLocation, data: JsonObject): EnergyContainerRecipe {
|
||||
return EnergyContainerRecipe(Serializer.SHAPED_RECIPE.fromJson(id, data))
|
||||
return EnergyContainerRecipe(ShapedRecipe.Serializer.SHAPED_RECIPE.fromJson(id, data))
|
||||
}
|
||||
|
||||
override fun fromNetwork(id: ResourceLocation, data: FriendlyByteBuf): EnergyContainerRecipe? {
|
||||
return Serializer.SHAPED_RECIPE.fromNetwork(id, data)?.let(::EnergyContainerRecipe)
|
||||
return ShapedRecipe.Serializer.SHAPED_RECIPE.fromNetwork(id, data)?.let(::EnergyContainerRecipe)
|
||||
}
|
||||
|
||||
override fun toNetwork(buff: FriendlyByteBuf, value: EnergyContainerRecipe) {
|
||||
Serializer.SHAPED_RECIPE.toNetwork(buff, value)
|
||||
ShapedRecipe.Serializer.SHAPED_RECIPE.toNetwork(buff, value.parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.recipe
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonSyntaxException
|
||||
import net.minecraft.core.NonNullList
|
||||
import net.minecraft.core.RegistryAccess
|
||||
import net.minecraft.data.recipes.FinishedRecipe
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
@ -42,7 +43,7 @@ class ExplosiveHammerPrimingRecipe(private val _id: ResourceLocation, val payloa
|
||||
result.any { payload.test(it) }
|
||||
}
|
||||
|
||||
override fun assemble(pContainer: CraftingContainer): ItemStack {
|
||||
override fun assemble(pContainer: CraftingContainer, registry: RegistryAccess): ItemStack {
|
||||
val hammer = pContainer.stream().filter { it.isNotEmpty && it.item is ExplosiveHammerItem }.findAny()
|
||||
if (hammer.isEmpty) return ItemStack.EMPTY
|
||||
|
||||
@ -55,7 +56,7 @@ class ExplosiveHammerPrimingRecipe(private val _id: ResourceLocation, val payloa
|
||||
return pWidth * pHeight >= 3
|
||||
}
|
||||
|
||||
override fun getResultItem(): ItemStack {
|
||||
override fun getResultItem(registry: RegistryAccess): ItemStack {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.recipe
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonPrimitive
|
||||
import net.minecraft.core.NonNullList
|
||||
import net.minecraft.core.RegistryAccess
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.util.valueproviders.ConstantFloat
|
||||
@ -62,9 +63,9 @@ class PlatePressRecipe(
|
||||
return input.isActuallyEmpty || output.isActuallyEmpty
|
||||
}
|
||||
|
||||
override fun assemble(p_44001_: Container): ItemStack = outputStack.copy()
|
||||
override fun assemble(p_44001_: Container, registry: RegistryAccess): ItemStack = outputStack.copy()
|
||||
override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int) = true
|
||||
override fun getResultItem(): ItemStack = outputStack
|
||||
override fun getResultItem(registry: RegistryAccess): ItemStack = outputStack
|
||||
|
||||
override fun getId() = id
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonPrimitive
|
||||
import net.minecraft.core.NonNullList
|
||||
import net.minecraft.core.RegistryAccess
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
@ -11,9 +12,14 @@ import net.minecraft.util.GsonHelper
|
||||
import net.minecraft.world.inventory.CraftingContainer
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.CraftingBookCategory
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import net.minecraft.world.item.crafting.Recipe
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer
|
||||
import net.minecraft.world.item.crafting.RecipeType
|
||||
import net.minecraft.world.item.crafting.ShapedRecipe
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraftforge.common.crafting.IShapedRecipe
|
||||
import ru.dbotthepony.mc.otm.container.stream
|
||||
import ru.dbotthepony.mc.otm.core.nbt.set
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
@ -25,17 +31,61 @@ import ru.dbotthepony.mc.otm.core.collect.stream
|
||||
import java.util.stream.Stream
|
||||
|
||||
class UpgradeRecipe(
|
||||
id: ResourceLocation,
|
||||
group: String,
|
||||
category: CraftingBookCategory,
|
||||
width: Int,
|
||||
height: Int,
|
||||
ingredients: NonNullList<Ingredient>,
|
||||
result: ItemStack,
|
||||
val parent: ShapedRecipe,
|
||||
copyPaths: Stream<Op>,
|
||||
val source: ResourceLocation,
|
||||
) : ShapedRecipe(id, group, category, width, height, ingredients, result) {
|
||||
constructor(parent: ShapedRecipe, copyPaths: Stream<Op>, source: ResourceLocation) : this(parent.id, parent.group, parent.category(), parent.width, parent.height, parent.ingredients, parent.resultItem, copyPaths, source)
|
||||
) : CraftingRecipe, IShapedRecipe<CraftingContainer> by parent {
|
||||
override fun matches(p_44002_: CraftingContainer, p_44003_: Level): Boolean {
|
||||
return parent.matches(p_44002_, p_44003_)
|
||||
}
|
||||
|
||||
override fun canCraftInDimensions(p_43999_: Int, p_44000_: Int): Boolean {
|
||||
return parent.canCraftInDimensions(p_43999_, p_44000_)
|
||||
}
|
||||
|
||||
override fun getResultItem(p_267052_: RegistryAccess): ItemStack {
|
||||
return parent.getResultItem(p_267052_)
|
||||
}
|
||||
|
||||
override fun getRemainingItems(p_44004_: CraftingContainer): NonNullList<ItemStack> {
|
||||
return parent.getRemainingItems(p_44004_)
|
||||
}
|
||||
|
||||
override fun getIngredients(): NonNullList<Ingredient> {
|
||||
return parent.ingredients
|
||||
}
|
||||
|
||||
override fun isSpecial(): Boolean {
|
||||
return parent.isSpecial
|
||||
}
|
||||
|
||||
override fun showNotification(): Boolean {
|
||||
return parent.showNotification()
|
||||
}
|
||||
|
||||
override fun getGroup(): String {
|
||||
return parent.group
|
||||
}
|
||||
|
||||
override fun getToastSymbol(): ItemStack {
|
||||
return parent.toastSymbol
|
||||
}
|
||||
|
||||
override fun getId(): ResourceLocation {
|
||||
return parent.id
|
||||
}
|
||||
|
||||
override fun isIncomplete(): Boolean {
|
||||
return parent.isIncomplete
|
||||
}
|
||||
|
||||
override fun getType(): RecipeType<*> {
|
||||
return parent.type
|
||||
}
|
||||
|
||||
override fun category(): CraftingBookCategory {
|
||||
return parent.category()
|
||||
}
|
||||
|
||||
enum class OpType {
|
||||
DIRECT {
|
||||
@ -147,8 +197,8 @@ class UpgradeRecipe(
|
||||
|
||||
val copyPaths: ImmutableList<Op> = copyPaths.collect(ImmutableList.toImmutableList())
|
||||
|
||||
override fun assemble(pInv: CraftingContainer): ItemStack {
|
||||
val result = super.assemble(pInv)
|
||||
override fun assemble(pInv: CraftingContainer, registryAccess: RegistryAccess): ItemStack {
|
||||
val result = parent.assemble(pInv, registryAccess)
|
||||
|
||||
if (result.isEmpty) {
|
||||
return result
|
||||
@ -180,14 +230,14 @@ class UpgradeRecipe(
|
||||
|
||||
override fun fromJson(id: ResourceLocation, data: JsonObject): UpgradeRecipe {
|
||||
return UpgradeRecipe(
|
||||
Serializer.SHAPED_RECIPE.fromJson(id, data),
|
||||
ShapedRecipe.Serializer.SHAPED_RECIPE.fromJson(id, data),
|
||||
GsonHelper.getAsJsonArray(data, "copyPaths").stream().map { deserializeOp(it as JsonObject) },
|
||||
ResourceLocation(GsonHelper.getAsString(data, "source"))
|
||||
)
|
||||
}
|
||||
|
||||
override fun fromNetwork(id: ResourceLocation, buff: FriendlyByteBuf): UpgradeRecipe? {
|
||||
val recipe = Serializer.SHAPED_RECIPE.fromNetwork(id, buff) ?: return null
|
||||
val recipe = ShapedRecipe.Serializer.SHAPED_RECIPE.fromNetwork(id, buff) ?: return null
|
||||
|
||||
return UpgradeRecipe(
|
||||
recipe,
|
||||
@ -197,7 +247,7 @@ class UpgradeRecipe(
|
||||
}
|
||||
|
||||
override fun toNetwork(buff: FriendlyByteBuf, value: UpgradeRecipe) {
|
||||
Serializer.SHAPED_RECIPE.toNetwork(buff, value)
|
||||
ShapedRecipe.Serializer.SHAPED_RECIPE.toNetwork(buff, value.parent)
|
||||
buff.writeCollection(value.copyPaths) { it, v -> it.writeJson(v.serialize()) }
|
||||
buff.writeResourceLocation(value.source)
|
||||
}
|
||||
|
@ -1,248 +0,0 @@
|
||||
package ru.dbotthepony.mc.otm.registry
|
||||
|
||||
import net.minecraft.world.item.CreativeModeTab
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.level.material.FlowingFluid
|
||||
import net.minecraft.world.level.material.Fluids
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities
|
||||
import net.minecraftforge.fluids.FluidStack
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler
|
||||
import net.minecraftforge.registries.ForgeRegistries
|
||||
import ru.dbotthepony.mc.otm.capability.matter.matter
|
||||
import ru.dbotthepony.mc.otm.capability.matteryEnergy
|
||||
import ru.dbotthepony.mc.otm.core.ifPresentK
|
||||
import ru.dbotthepony.mc.otm.core.registryName
|
||||
|
||||
private fun CreativeModeTab.Output.accept(values: Collection<Item>) {
|
||||
for (item in values) {
|
||||
accept(item)
|
||||
}
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.base(values: Map<DyeColor?, Item>) {
|
||||
accept(values[null]!!)
|
||||
}
|
||||
|
||||
private val colorOrder = listOf(
|
||||
null,
|
||||
DyeColor.WHITE,
|
||||
DyeColor.ORANGE,
|
||||
DyeColor.MAGENTA,
|
||||
DyeColor.LIGHT_BLUE,
|
||||
DyeColor.YELLOW,
|
||||
DyeColor.LIME,
|
||||
DyeColor.PINK,
|
||||
DyeColor.GRAY,
|
||||
DyeColor.LIGHT_GRAY,
|
||||
DyeColor.CYAN,
|
||||
DyeColor.PURPLE,
|
||||
DyeColor.BLUE,
|
||||
DyeColor.BROWN,
|
||||
DyeColor.GREEN,
|
||||
DyeColor.RED,
|
||||
DyeColor.BLACK,
|
||||
)
|
||||
|
||||
private fun CreativeModeTab.Output.colored(values: Map<out DyeColor?, Item>) {
|
||||
accept(values[DyeColor.WHITE]!!)
|
||||
accept(values[DyeColor.ORANGE]!!)
|
||||
accept(values[DyeColor.MAGENTA]!!)
|
||||
accept(values[DyeColor.LIGHT_BLUE]!!)
|
||||
accept(values[DyeColor.YELLOW]!!)
|
||||
accept(values[DyeColor.LIME]!!)
|
||||
accept(values[DyeColor.PINK]!!)
|
||||
accept(values[DyeColor.GRAY]!!)
|
||||
accept(values[DyeColor.LIGHT_GRAY]!!)
|
||||
accept(values[DyeColor.CYAN]!!)
|
||||
accept(values[DyeColor.PURPLE]!!)
|
||||
accept(values[DyeColor.BLUE]!!)
|
||||
accept(values[DyeColor.BROWN]!!)
|
||||
accept(values[DyeColor.GREEN]!!)
|
||||
accept(values[DyeColor.RED]!!)
|
||||
accept(values[DyeColor.BLACK]!!)
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.all(values: Map<DyeColor?, Item>) {
|
||||
base(values)
|
||||
colored(values)
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.energized(value: Item) {
|
||||
accept(value)
|
||||
|
||||
val stack = ItemStack(value, 1)
|
||||
val energy = stack.matteryEnergy ?: throw IllegalArgumentException("${value.registryName} does not implement mattery energy capability")
|
||||
energy.fillBattery()
|
||||
|
||||
if (ItemStack(value, 1).matteryEnergy!!.batteryLevel != energy.batteryLevel)
|
||||
accept(stack)
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.energized(values: Iterable<Item>) {
|
||||
for (value in values) {
|
||||
energized(value)
|
||||
}
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.mattery(value: Item) {
|
||||
accept(value)
|
||||
|
||||
val stack = ItemStack(value, 1)
|
||||
val matter = stack.matter ?: throw IllegalArgumentException("${value.registryName} does not implement matter capability")
|
||||
|
||||
matter.fillMatter()
|
||||
|
||||
if (ItemStack(value, 1).matter!!.storedMatter != matter.storedMatter)
|
||||
accept(stack)
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.mattery(values: Iterable<Item>) {
|
||||
for (value in values) {
|
||||
mattery(value)
|
||||
}
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.fluids(value: Item) {
|
||||
accept(value)
|
||||
|
||||
for (fluid in ForgeRegistries.FLUIDS.values) {
|
||||
if (fluid != Fluids.EMPTY && fluid.isSource(fluid.defaultFluidState())) {
|
||||
accept(ItemStack(value, 1).also {
|
||||
it.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK {
|
||||
it.fill(FluidStack(fluid, it.getTankCapacity(0)), IFluidHandler.FluidAction.EXECUTE)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) {
|
||||
with(consumer) {
|
||||
accept(MItems.MACHINES)
|
||||
|
||||
accept(MRegistry.CARGO_CRATES.item)
|
||||
accept(MItems.HOLO_SIGN)
|
||||
|
||||
base(MItems.TRITANIUM_DOOR)
|
||||
base(MItems.TRITANIUM_TRAPDOOR)
|
||||
accept(MRegistry.TRITANIUM_PRESSURE_PLATE.item)
|
||||
accept(MItems.TRITANIUM_ANVIL[0])
|
||||
|
||||
// accept(MItems.MATTER_DUST)
|
||||
|
||||
accept(MItems.TRITANIUM_ORE)
|
||||
accept(MItems.DEEPSLATE_TRITANIUM_ORE)
|
||||
accept(MItems.TRITANIUM_ORE_CLUMP)
|
||||
accept(MItems.TRITANIUM_DUST)
|
||||
accept(MItems.TRITANIUM_NUGGET)
|
||||
accept(MItems.TRITANIUM_INGOT)
|
||||
accept(MItems.TRITANIUM_INGOT_BLOCK)
|
||||
|
||||
accept(MItems.TRITANIUM_TOOLS)
|
||||
accept(MItems.SIMPLE_TRITANIUM_ARMOR)
|
||||
accept(MItems.TRITANIUM_ARMOR)
|
||||
|
||||
energized(MItems.ENERGY_SWORD)
|
||||
energized(MItems.PLASMA_RIFLE)
|
||||
|
||||
accept(MItems.EXPLOSIVE_HAMMER)
|
||||
accept(ItemStack(MItems.EXPLOSIVE_HAMMER).also { MItems.EXPLOSIVE_HAMMER.prime(it) })
|
||||
|
||||
accept(MItems.BLACK_HOLE_SCANNER)
|
||||
accept(MItems.GRAVITATION_FIELD_LIMITER)
|
||||
accept(MItems.GRAVITATION_FIELD_SENSOR)
|
||||
accept(MItems.PORTABLE_GRAVITATION_STABILIZER)
|
||||
accept(MItems.BLACK_HOLE)
|
||||
accept(MItems.GRAVITATIONAL_DISRUPTOR)
|
||||
|
||||
accept(MItems.ESSENCE_SERVO)
|
||||
|
||||
energized(MItems.ALL_BATTERIES)
|
||||
mattery(MItems.MATTER_CAPACITORS)
|
||||
accept(MItems.PATTERN_DRIVE_NORMAL)
|
||||
accept(MItems.PATTERN_DRIVE_CREATIVE)
|
||||
accept(MItems.PATTERN_DRIVE_CREATIVE2)
|
||||
|
||||
fluids(MItems.FLUID_CAPSULE)
|
||||
fluids(MItems.FLUID_TANK)
|
||||
|
||||
base(MItems.CARGO_CRATE_MINECARTS)
|
||||
|
||||
accept(MItems.NUTRIENT_PASTE)
|
||||
|
||||
// exo
|
||||
accept(MItems.EXOPACK_PROBE)
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE)
|
||||
accept(MItems.ExopackUpgrades.CRAFTING_UPGRADE)
|
||||
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_BIG)
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_HUGE)
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER)
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON)
|
||||
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADES)
|
||||
// /exo
|
||||
|
||||
accept(MItems.PILLS)
|
||||
|
||||
accept(MItems.COMPONENTS)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun addDecorativeTabItems(consumer: CreativeModeTab.Output) {
|
||||
with(consumer) {
|
||||
accept(MItems.LABORATORY_LAMP)
|
||||
accept(MItems.LABORATORY_LAMP_INVERTED)
|
||||
accept(MItems.DANGER_STRIPE_BLOCK)
|
||||
accept(MItems.METAL_BEAM)
|
||||
accept(MItems.ENGINE)
|
||||
|
||||
accept(MItems.TRITANIUM_STRIPED_BLOCK)
|
||||
accept(MItems.TRITANIUM_STRIPED_STAIRS)
|
||||
accept(MItems.TRITANIUM_STRIPED_SLAB)
|
||||
accept(MItems.TRITANIUM_STRIPED_WALL)
|
||||
accept(MItems.CARBON_FIBRE_BLOCK)
|
||||
accept(MItems.METAL_JUNK)
|
||||
accept(MItems.METAL_MESH)
|
||||
|
||||
accept(MItems.TRITANIUM_BARS)
|
||||
|
||||
colored(MItems.TRITANIUM_DOOR)
|
||||
colored(MItems.TRITANIUM_TRAPDOOR)
|
||||
accept(MRegistry.TRITANIUM_PRESSURE_PLATE.items.values)
|
||||
|
||||
for (i in 0 until MItems.TRITANIUM_ANVIL.size)
|
||||
accept(MItems.TRITANIUM_ANVIL[i])
|
||||
|
||||
colored(MRegistry.CARGO_CRATES.items)
|
||||
|
||||
colored(MItems.CARGO_CRATE_MINECARTS)
|
||||
|
||||
all(MRegistry.DECORATIVE_CRATE.allItems)
|
||||
|
||||
for (color in colorOrder) {
|
||||
accept(MRegistry.TRITANIUM_BLOCK.allItems[color]!!)
|
||||
accept(MRegistry.TRITANIUM_STAIRS.allItems[color]!!)
|
||||
accept(MRegistry.TRITANIUM_SLAB.allItems[color]!!)
|
||||
accept(MRegistry.TRITANIUM_WALL.allItems[color]!!)
|
||||
}
|
||||
|
||||
all(MRegistry.INDUSTRIAL_GLASS.allItems)
|
||||
all(MRegistry.INDUSTRIAL_GLASS_PANE.allItems)
|
||||
|
||||
colored(MRegistry.UNREFINED_FLOOR_TILES.items)
|
||||
colored(MRegistry.FLOOR_TILES.items)
|
||||
colored(MRegistry.FLOOR_TILES_STAIRS.items)
|
||||
colored(MRegistry.FLOOR_TILES_SLAB.items)
|
||||
|
||||
all(MRegistry.VENT.allItems)
|
||||
all(MRegistry.VENT_ALTERNATIVE.allItems)
|
||||
|
||||
accept(MRegistry.TRITANIUM_STRIPED_BLOCK.flatItems)
|
||||
accept(MRegistry.TRITANIUM_STRIPED_STAIRS.flatItems)
|
||||
accept(MRegistry.TRITANIUM_STRIPED_SLAB.flatItems)
|
||||
accept(MRegistry.TRITANIUM_STRIPED_WALL.flatItems)
|
||||
}
|
||||
}
|
@ -1,192 +0,0 @@
|
||||
package ru.dbotthepony.mc.otm.registry
|
||||
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.damagesource.DamageSource
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
|
||||
class ImmutableDamageSource(private val parent: DamageSource) : DamageSource(parent.msgId) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return parent == other
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return parent.hashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return parent.toString()
|
||||
}
|
||||
|
||||
override fun isProjectile(): Boolean {
|
||||
return parent.isProjectile
|
||||
}
|
||||
|
||||
override fun setProjectile(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun isExplosion(): Boolean {
|
||||
return parent.isExplosion
|
||||
}
|
||||
|
||||
override fun setExplosion(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun isBypassArmor(): Boolean {
|
||||
return parent.isBypassArmor
|
||||
}
|
||||
|
||||
override fun isDamageHelmet(): Boolean {
|
||||
return parent.isDamageHelmet
|
||||
}
|
||||
|
||||
override fun getFoodExhaustion(): Float {
|
||||
return parent.foodExhaustion
|
||||
}
|
||||
|
||||
override fun isBypassInvul(): Boolean {
|
||||
return parent.isBypassInvul
|
||||
}
|
||||
|
||||
override fun isBypassMagic(): Boolean {
|
||||
return parent.isBypassMagic
|
||||
}
|
||||
|
||||
override fun getDirectEntity(): Entity? {
|
||||
return parent.directEntity
|
||||
}
|
||||
|
||||
override fun getEntity(): Entity? {
|
||||
return parent.entity
|
||||
}
|
||||
|
||||
override fun bypassArmor(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun damageHelmet(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun bypassInvul(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun bypassMagic(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun setIsFire(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun setNoAggro(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun getLocalizedDeathMessage(p_19343_: LivingEntity): Component {
|
||||
return super.getLocalizedDeathMessage(p_19343_)
|
||||
}
|
||||
|
||||
override fun isFire(): Boolean {
|
||||
return parent.isFire
|
||||
}
|
||||
|
||||
override fun isNoAggro(): Boolean {
|
||||
return parent.isNoAggro
|
||||
}
|
||||
|
||||
override fun getMsgId(): String {
|
||||
return parent.getMsgId()
|
||||
}
|
||||
|
||||
override fun setScalesWithDifficulty(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun scalesWithDifficulty(): Boolean {
|
||||
return parent.scalesWithDifficulty()
|
||||
}
|
||||
|
||||
override fun isMagic(): Boolean {
|
||||
return parent.isMagic
|
||||
}
|
||||
|
||||
override fun setMagic(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun isFall(): Boolean {
|
||||
return parent.isFall
|
||||
}
|
||||
|
||||
override fun setIsFall(): DamageSource {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun isCreativePlayer(): Boolean {
|
||||
return parent.isCreativePlayer
|
||||
}
|
||||
|
||||
override fun getSourcePosition(): Vec3? {
|
||||
return parent.sourcePosition
|
||||
}
|
||||
}
|
||||
|
||||
abstract class MatteryDamageSource(name: String, private val entity: Entity? = null, val inflictor: ItemStack? = null) : DamageSource(name) {
|
||||
override fun getLocalizedDeathMessage(victim: LivingEntity): Component {
|
||||
val itemStack = inflictor ?: (entity as LivingEntity?)?.mainHandItem ?: ItemStack.EMPTY
|
||||
|
||||
if (!itemStack.isEmpty && itemStack.hasCustomHoverName()) {
|
||||
return TranslatableComponent("death.attack.$msgId.player.item", victim.displayName, entity!!.displayName, itemStack.displayName)
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
return TranslatableComponent("death.attack.$msgId.player", victim.displayName, entity.displayName)
|
||||
}
|
||||
|
||||
return TranslatableComponent("death.attack.$msgId", victim.displayName)
|
||||
}
|
||||
|
||||
final override fun getEntity(): Entity? {
|
||||
return entity
|
||||
}
|
||||
}
|
||||
|
||||
class EMPDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_EMP_NAME, entity, inflictor) {
|
||||
init {
|
||||
bypassArmor()
|
||||
bypassMagic()
|
||||
}
|
||||
|
||||
override fun scalesWithDifficulty(): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
class ShockwaveDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_SHOCKWAVE_NAME, entity, inflictor) {
|
||||
init {
|
||||
bypassArmor()
|
||||
}
|
||||
|
||||
override fun scalesWithDifficulty(): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
class PlasmaDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_PLASMA_NAME, entity, inflictor) {
|
||||
override fun scalesWithDifficulty(): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
class HammerNailDamageSource(entity: Entity? = null, inflictor: ItemStack? = null) : MatteryDamageSource(MRegistry.DAMAGE_HAMMER_NAIL_NAME, entity, inflictor) {
|
||||
override fun scalesWithDifficulty(): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ import net.minecraft.world.level.block.TrapDoorBlock
|
||||
import net.minecraft.world.level.block.WallBlock
|
||||
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.material.Material
|
||||
import net.minecraft.world.level.material.MaterialColor
|
||||
import net.minecraftforge.eventbus.api.IEventBus
|
||||
@ -190,7 +191,7 @@ object MBlocks {
|
||||
}
|
||||
|
||||
val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ ->
|
||||
object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) {
|
||||
object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) {
|
||||
override fun appendHoverText(
|
||||
p_49816_: ItemStack,
|
||||
p_49817_: BlockGetter?,
|
||||
@ -218,7 +219,7 @@ object MBlocks {
|
||||
}
|
||||
|
||||
val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ ->
|
||||
object : TrapDoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) {
|
||||
object : TrapDoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), BlockSetType.IRON) {
|
||||
override fun appendHoverText(
|
||||
p_49816_: ItemStack,
|
||||
p_49817_: BlockGetter?,
|
||||
|
@ -2,14 +2,257 @@ package ru.dbotthepony.mc.otm.registry
|
||||
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.item.CreativeModeTab
|
||||
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.CreativeModeTabEvent
|
||||
import net.minecraftforge.fluids.FluidStack
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler
|
||||
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.CreativeMenuComparator
|
||||
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.WriteOnce
|
||||
import ru.dbotthepony.mc.otm.registry.MItems.BATTERY_CREATIVE
|
||||
|
||||
private fun CreativeModeTab.Output.accept(values: Collection<Item>) {
|
||||
for (item in values) {
|
||||
accept(item)
|
||||
}
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.base(values: Map<DyeColor?, Item>) {
|
||||
accept(values[null]!!)
|
||||
}
|
||||
|
||||
private val colorOrder = listOf(
|
||||
null,
|
||||
DyeColor.WHITE,
|
||||
DyeColor.ORANGE,
|
||||
DyeColor.MAGENTA,
|
||||
DyeColor.LIGHT_BLUE,
|
||||
DyeColor.YELLOW,
|
||||
DyeColor.LIME,
|
||||
DyeColor.PINK,
|
||||
DyeColor.GRAY,
|
||||
DyeColor.LIGHT_GRAY,
|
||||
DyeColor.CYAN,
|
||||
DyeColor.PURPLE,
|
||||
DyeColor.BLUE,
|
||||
DyeColor.BROWN,
|
||||
DyeColor.GREEN,
|
||||
DyeColor.RED,
|
||||
DyeColor.BLACK,
|
||||
)
|
||||
|
||||
private fun CreativeModeTab.Output.colored(values: Map<out DyeColor?, Item>) {
|
||||
accept(values[DyeColor.WHITE]!!)
|
||||
accept(values[DyeColor.ORANGE]!!)
|
||||
accept(values[DyeColor.MAGENTA]!!)
|
||||
accept(values[DyeColor.LIGHT_BLUE]!!)
|
||||
accept(values[DyeColor.YELLOW]!!)
|
||||
accept(values[DyeColor.LIME]!!)
|
||||
accept(values[DyeColor.PINK]!!)
|
||||
accept(values[DyeColor.GRAY]!!)
|
||||
accept(values[DyeColor.LIGHT_GRAY]!!)
|
||||
accept(values[DyeColor.CYAN]!!)
|
||||
accept(values[DyeColor.PURPLE]!!)
|
||||
accept(values[DyeColor.BLUE]!!)
|
||||
accept(values[DyeColor.BROWN]!!)
|
||||
accept(values[DyeColor.GREEN]!!)
|
||||
accept(values[DyeColor.RED]!!)
|
||||
accept(values[DyeColor.BLACK]!!)
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.all(values: Map<DyeColor?, Item>) {
|
||||
base(values)
|
||||
colored(values)
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.energized(value: Item) {
|
||||
accept(value)
|
||||
|
||||
val stack = ItemStack(value, 1)
|
||||
val energy = stack.matteryEnergy ?: throw IllegalArgumentException("${value.registryName} does not implement mattery energy capability")
|
||||
energy.fillBattery()
|
||||
|
||||
if (ItemStack(value, 1).matteryEnergy!!.batteryLevel != energy.batteryLevel)
|
||||
accept(stack)
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.energized(values: Iterable<Item>) {
|
||||
for (value in values) {
|
||||
energized(value)
|
||||
}
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.mattery(value: Item) {
|
||||
accept(value)
|
||||
|
||||
val stack = ItemStack(value, 1)
|
||||
val matter = stack.matter ?: throw IllegalArgumentException("${value.registryName} does not implement matter capability")
|
||||
|
||||
matter.fillMatter()
|
||||
|
||||
if (ItemStack(value, 1).matter!!.storedMatter != matter.storedMatter)
|
||||
accept(stack)
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.mattery(values: Iterable<Item>) {
|
||||
for (value in values) {
|
||||
mattery(value)
|
||||
}
|
||||
}
|
||||
|
||||
private fun CreativeModeTab.Output.fluids(value: Item) {
|
||||
accept(value)
|
||||
|
||||
for (fluid in ForgeRegistries.FLUIDS.values) {
|
||||
if (fluid != Fluids.EMPTY && fluid.isSource(fluid.defaultFluidState())) {
|
||||
accept(ItemStack(value, 1).also {
|
||||
it.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).ifPresentK {
|
||||
it.fill(FluidStack(fluid, it.getTankCapacity(0)), IFluidHandler.FluidAction.EXECUTE)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) {
|
||||
with(consumer) {
|
||||
accept(MItems.MACHINES)
|
||||
|
||||
accept(MRegistry.CARGO_CRATES.item)
|
||||
accept(MItems.HOLO_SIGN)
|
||||
|
||||
base(MItems.TRITANIUM_DOOR)
|
||||
base(MItems.TRITANIUM_TRAPDOOR)
|
||||
accept(MRegistry.TRITANIUM_PRESSURE_PLATE.item)
|
||||
accept(MItems.TRITANIUM_ANVIL[0])
|
||||
|
||||
// accept(MItems.MATTER_DUST)
|
||||
|
||||
accept(MItems.TRITANIUM_ORE)
|
||||
accept(MItems.DEEPSLATE_TRITANIUM_ORE)
|
||||
accept(MItems.TRITANIUM_ORE_CLUMP)
|
||||
accept(MItems.TRITANIUM_DUST)
|
||||
accept(MItems.TRITANIUM_NUGGET)
|
||||
accept(MItems.TRITANIUM_INGOT)
|
||||
accept(MItems.TRITANIUM_INGOT_BLOCK)
|
||||
|
||||
accept(MItems.TRITANIUM_TOOLS)
|
||||
accept(MItems.SIMPLE_TRITANIUM_ARMOR)
|
||||
accept(MItems.TRITANIUM_ARMOR)
|
||||
|
||||
energized(MItems.ENERGY_SWORD)
|
||||
energized(MItems.PLASMA_RIFLE)
|
||||
|
||||
accept(MItems.EXPLOSIVE_HAMMER)
|
||||
accept(ItemStack(MItems.EXPLOSIVE_HAMMER).also { MItems.EXPLOSIVE_HAMMER.prime(it) })
|
||||
|
||||
accept(MItems.BLACK_HOLE_SCANNER)
|
||||
accept(MItems.GRAVITATION_FIELD_LIMITER)
|
||||
accept(MItems.GRAVITATION_FIELD_SENSOR)
|
||||
accept(MItems.PORTABLE_GRAVITATION_STABILIZER)
|
||||
accept(MItems.BLACK_HOLE)
|
||||
accept(MItems.GRAVITATIONAL_DISRUPTOR)
|
||||
|
||||
accept(MItems.ESSENCE_SERVO)
|
||||
|
||||
energized(MItems.ALL_BATTERIES)
|
||||
mattery(MItems.MATTER_CAPACITORS)
|
||||
accept(MItems.PATTERN_DRIVE_NORMAL)
|
||||
accept(MItems.PATTERN_DRIVE_CREATIVE)
|
||||
accept(MItems.PATTERN_DRIVE_CREATIVE2)
|
||||
|
||||
fluids(MItems.FLUID_CAPSULE)
|
||||
fluids(MItems.FLUID_TANK)
|
||||
|
||||
base(MItems.CARGO_CRATE_MINECARTS)
|
||||
|
||||
accept(MItems.NUTRIENT_PASTE)
|
||||
|
||||
// exo
|
||||
accept(MItems.EXOPACK_PROBE)
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_CREATIVE)
|
||||
accept(MItems.ExopackUpgrades.CRAFTING_UPGRADE)
|
||||
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_BIG)
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_HUGE)
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_WITHER)
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADE_ENDER_DRAGON)
|
||||
|
||||
accept(MItems.ExopackUpgrades.INVENTORY_UPGRADES)
|
||||
// /exo
|
||||
|
||||
accept(MItems.PILLS)
|
||||
|
||||
accept(MItems.COMPONENTS)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addDecorativeTabItems(consumer: CreativeModeTab.Output) {
|
||||
with(consumer) {
|
||||
accept(MItems.LABORATORY_LAMP)
|
||||
accept(MItems.LABORATORY_LAMP_INVERTED)
|
||||
accept(MItems.DANGER_STRIPE_BLOCK)
|
||||
accept(MItems.METAL_BEAM)
|
||||
accept(MItems.ENGINE)
|
||||
|
||||
accept(MItems.TRITANIUM_STRIPED_BLOCK)
|
||||
accept(MItems.TRITANIUM_STRIPED_STAIRS)
|
||||
accept(MItems.TRITANIUM_STRIPED_SLAB)
|
||||
accept(MItems.TRITANIUM_STRIPED_WALL)
|
||||
accept(MItems.CARBON_FIBRE_BLOCK)
|
||||
accept(MItems.METAL_JUNK)
|
||||
accept(MItems.METAL_MESH)
|
||||
|
||||
accept(MItems.TRITANIUM_BARS)
|
||||
|
||||
colored(MItems.TRITANIUM_DOOR)
|
||||
colored(MItems.TRITANIUM_TRAPDOOR)
|
||||
accept(MRegistry.TRITANIUM_PRESSURE_PLATE.items.values)
|
||||
|
||||
for (i in 0 until MItems.TRITANIUM_ANVIL.size)
|
||||
accept(MItems.TRITANIUM_ANVIL[i])
|
||||
|
||||
colored(MRegistry.CARGO_CRATES.items)
|
||||
|
||||
colored(MItems.CARGO_CRATE_MINECARTS)
|
||||
|
||||
all(MRegistry.DECORATIVE_CRATE.allItems)
|
||||
|
||||
for (color in colorOrder) {
|
||||
accept(MRegistry.TRITANIUM_BLOCK.allItems[color]!!)
|
||||
accept(MRegistry.TRITANIUM_STAIRS.allItems[color]!!)
|
||||
accept(MRegistry.TRITANIUM_SLAB.allItems[color]!!)
|
||||
accept(MRegistry.TRITANIUM_WALL.allItems[color]!!)
|
||||
}
|
||||
|
||||
all(MRegistry.INDUSTRIAL_GLASS.allItems)
|
||||
all(MRegistry.INDUSTRIAL_GLASS_PANE.allItems)
|
||||
|
||||
colored(MRegistry.UNREFINED_FLOOR_TILES.items)
|
||||
colored(MRegistry.FLOOR_TILES.items)
|
||||
colored(MRegistry.FLOOR_TILES_STAIRS.items)
|
||||
colored(MRegistry.FLOOR_TILES_SLAB.items)
|
||||
|
||||
all(MRegistry.VENT.allItems)
|
||||
all(MRegistry.VENT_ALTERNATIVE.allItems)
|
||||
|
||||
accept(MRegistry.TRITANIUM_STRIPED_BLOCK.flatItems)
|
||||
accept(MRegistry.TRITANIUM_STRIPED_STAIRS.flatItems)
|
||||
accept(MRegistry.TRITANIUM_STRIPED_SLAB.flatItems)
|
||||
accept(MRegistry.TRITANIUM_STRIPED_WALL.flatItems)
|
||||
}
|
||||
}
|
||||
|
||||
object MCreativeTabs {
|
||||
var MAIN by WriteOnce<CreativeModeTab>()
|
||||
private set
|
||||
@ -23,7 +266,7 @@ object MCreativeTabs {
|
||||
it.icon { ItemStack(BATTERY_CREATIVE, 1) }
|
||||
it.title(TranslatableComponent("itemGroup.otm"))
|
||||
|
||||
it.displayItems { features, consumer, flag ->
|
||||
it.displayItems { _, consumer ->
|
||||
addMainCreativeTabItems(consumer)
|
||||
}
|
||||
}
|
||||
@ -32,7 +275,7 @@ object MCreativeTabs {
|
||||
it.icon { ItemStack(MRegistry.VENT.item, 1) }
|
||||
it.title(TranslatableComponent("itemGroup.otm_decorative"))
|
||||
|
||||
it.displayItems { features, consumer, flag ->
|
||||
it.displayItems { _, consumer ->
|
||||
addDecorativeTabItems(consumer)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package ru.dbotthepony.mc.otm.registry
|
||||
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.resources.ResourceKey
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.damagesource.DamageType
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
|
||||
object MDamageTypes {
|
||||
private fun register(name: String): ResourceKey<DamageType> = ResourceKey.create(Registries.DAMAGE_TYPE, ResourceLocation(OverdriveThatMatters.MOD_ID, name))
|
||||
|
||||
val BECOME_ANDROID = register("become_android")
|
||||
val BECOME_HUMANE = register("become_humane")
|
||||
val EVENT_HORIZON = register("event_horizon")
|
||||
val HAWKING_RADIATION = register("hawking_radiation")
|
||||
val EXOPACK_PROBE = register("exopack_probe")
|
||||
val EMP = register("emp")
|
||||
val SHOCKWAVE = register("shockwave")
|
||||
val PLASMA = register("plasma")
|
||||
val COSMIC_RAYS = register("cosmic_rays")
|
||||
val EXPLOSIVE_HAMMER = register("explosive_hammer")
|
||||
val HAMMER_NAIL = register("hammer_nail")
|
||||
}
|
@ -218,15 +218,15 @@ object MItems {
|
||||
::TRITANIUM_SHIELD,
|
||||
)
|
||||
|
||||
val TRITANIUM_HELMET: TritaniumArmorItem by registry.register(MNames.TRITANIUM_HELMET) { TritaniumArmorItem(EquipmentSlot.HEAD) }
|
||||
val TRITANIUM_CHESTPLATE: TritaniumArmorItem by registry.register(MNames.TRITANIUM_CHESTPLATE) { TritaniumArmorItem(EquipmentSlot.CHEST) }
|
||||
val TRITANIUM_PANTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_PANTS) { TritaniumArmorItem(EquipmentSlot.LEGS) }
|
||||
val TRITANIUM_BOOTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_BOOTS) { TritaniumArmorItem(EquipmentSlot.FEET) }
|
||||
val TRITANIUM_HELMET: TritaniumArmorItem by registry.register(MNames.TRITANIUM_HELMET) { TritaniumArmorItem(ArmorItem.Type.HELMET) }
|
||||
val TRITANIUM_CHESTPLATE: TritaniumArmorItem by registry.register(MNames.TRITANIUM_CHESTPLATE) { TritaniumArmorItem(ArmorItem.Type.CHESTPLATE) }
|
||||
val TRITANIUM_PANTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_PANTS) { TritaniumArmorItem(ArmorItem.Type.LEGGINGS) }
|
||||
val TRITANIUM_BOOTS: TritaniumArmorItem by registry.register(MNames.TRITANIUM_BOOTS) { TritaniumArmorItem(ArmorItem.Type.BOOTS) }
|
||||
|
||||
val SIMPLE_TRITANIUM_HELMET: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_HELMET) { SimpleTritaniumArmorItem(EquipmentSlot.HEAD) }
|
||||
val SIMPLE_TRITANIUM_CHESTPLATE: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_CHESTPLATE) { SimpleTritaniumArmorItem(EquipmentSlot.CHEST) }
|
||||
val SIMPLE_TRITANIUM_PANTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_PANTS) { SimpleTritaniumArmorItem(EquipmentSlot.LEGS) }
|
||||
val SIMPLE_TRITANIUM_BOOTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_BOOTS) { SimpleTritaniumArmorItem(EquipmentSlot.FEET) }
|
||||
val SIMPLE_TRITANIUM_HELMET: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_HELMET) { SimpleTritaniumArmorItem(ArmorItem.Type.HELMET) }
|
||||
val SIMPLE_TRITANIUM_CHESTPLATE: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_CHESTPLATE) { SimpleTritaniumArmorItem(ArmorItem.Type.CHESTPLATE) }
|
||||
val SIMPLE_TRITANIUM_PANTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_PANTS) { SimpleTritaniumArmorItem(ArmorItem.Type.LEGGINGS) }
|
||||
val SIMPLE_TRITANIUM_BOOTS: SimpleTritaniumArmorItem by registry.register(MNames.SIMPLE_TRITANIUM_BOOTS) { SimpleTritaniumArmorItem(ArmorItem.Type.BOOTS) }
|
||||
|
||||
val TRITANIUM_ARMOR = SupplierList(
|
||||
::TRITANIUM_HELMET,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.registry
|
||||
|
||||
import net.minecraft.client.gui.screens.MenuScreens
|
||||
import net.minecraft.world.flag.FeatureFlags
|
||||
import net.minecraft.world.inventory.MenuType
|
||||
import net.minecraftforge.eventbus.api.IEventBus
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
|
||||
@ -67,35 +68,35 @@ import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
|
||||
object MMenus {
|
||||
private val registry = DeferredRegister.create(ForgeRegistries.MENU_TYPES, OverdriveThatMatters.MOD_ID)
|
||||
|
||||
val ANDROID_STATION: MenuType<*> by registry.register(MNames.ANDROID_STATION) { MenuType(::AndroidStationMenu) }
|
||||
val BATTERY_BANK: MenuType<*> by registry.register(MNames.BATTERY_BANK) { MenuType(::BatteryBankMenu) }
|
||||
val MATTER_DECOMPOSER: MenuType<*> by registry.register(MNames.MATTER_DECOMPOSER) { MenuType(::MatterDecomposerMenu) }
|
||||
val MATTER_CAPACITOR_BANK: MenuType<*> by registry.register(MNames.MATTER_CAPACITOR_BANK) { MenuType(::MatterCapacitorBankMenu) }
|
||||
val PATTERN_STORAGE: MenuType<*> by registry.register(MNames.PATTERN_STORAGE) { MenuType(::PatternStorageMenu) }
|
||||
val MATTER_SCANNER: MenuType<*> by registry.register(MNames.MATTER_SCANNER) { MenuType(::MatterScannerMenu) }
|
||||
val MATTER_PANEL: MenuType<*> by registry.register(MNames.MATTER_PANEL) { MenuType(::MatterPanelMenu) }
|
||||
val MATTER_REPLICATOR: MenuType<*> by registry.register(MNames.MATTER_REPLICATOR) { MenuType(::MatterReplicatorMenu) }
|
||||
val MATTER_BOTTLER: MenuType<*> by registry.register(MNames.MATTER_BOTTLER) { MenuType(::MatterBottlerMenu) }
|
||||
val DRIVE_VIEWER: MenuType<*> by registry.register(MNames.DRIVE_VIEWER) { MenuType(::DriveViewerMenu) }
|
||||
val CARGO_CRATE: MenuType<*> by registry.register(MNames.CARGO_CRATE) { MenuType(::CargoCrateMenu) }
|
||||
val MINECART_CARGO_CRATE: MenuType<*> by registry.register(MNames.MINECART_CARGO_CRATE) { MenuType(::MinecartCargoCrateMenu) }
|
||||
val DRIVE_RACK: MenuType<*> by registry.register(MNames.DRIVE_RACK) { MenuType(::DriveRackMenu) }
|
||||
val ITEM_MONITOR: MenuType<*> by registry.register(MNames.ITEM_MONITOR) { MenuType(::ItemMonitorMenu) }
|
||||
val ENERGY_COUNTER: MenuType<*> by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu) }
|
||||
val CHEMICAL_GENERATOR: MenuType<*> by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu) }
|
||||
val PLATE_PRESS: MenuType<*> by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu) }
|
||||
val MATTER_RECYCLER: MenuType<*> by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu) }
|
||||
val ENERGY_SERVO: MenuType<*> by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu) }
|
||||
val HOLO_SIGN: MenuType<HoloSignMenu> by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu) }
|
||||
val COBBLESTONE_GENERATOR: MenuType<CobblerMenu> by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu) }
|
||||
val ESSENCE_STORAGE: MenuType<EssenceStorageMenu> by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu) }
|
||||
val ITEM_REPAIER: MenuType<MatterReconstructorMenu> by registry.register(MNames.MATTER_RECONSTRUCTOR) { MenuType(::MatterReconstructorMenu) }
|
||||
val FLUID_TANK: MenuType<FluidTankMenu> by registry.register(MNames.FLUID_TANK) { MenuType(::FluidTankMenu) }
|
||||
val ANDROID_STATION: MenuType<AndroidStationMenu> by registry.register(MNames.ANDROID_STATION) { MenuType(::AndroidStationMenu, FeatureFlags.VANILLA_SET) }
|
||||
val BATTERY_BANK: MenuType<BatteryBankMenu> by registry.register(MNames.BATTERY_BANK) { MenuType(::BatteryBankMenu, FeatureFlags.VANILLA_SET) }
|
||||
val MATTER_DECOMPOSER: MenuType<MatterDecomposerMenu> by registry.register(MNames.MATTER_DECOMPOSER) { MenuType(::MatterDecomposerMenu, FeatureFlags.VANILLA_SET) }
|
||||
val MATTER_CAPACITOR_BANK: MenuType<MatterCapacitorBankMenu> by registry.register(MNames.MATTER_CAPACITOR_BANK) { MenuType(::MatterCapacitorBankMenu, FeatureFlags.VANILLA_SET) }
|
||||
val PATTERN_STORAGE: MenuType<PatternStorageMenu> by registry.register(MNames.PATTERN_STORAGE) { MenuType(::PatternStorageMenu, FeatureFlags.VANILLA_SET) }
|
||||
val MATTER_SCANNER: MenuType<MatterScannerMenu> by registry.register(MNames.MATTER_SCANNER) { MenuType(::MatterScannerMenu, FeatureFlags.VANILLA_SET) }
|
||||
val MATTER_PANEL: MenuType<MatterPanelMenu> by registry.register(MNames.MATTER_PANEL) { MenuType(::MatterPanelMenu, FeatureFlags.VANILLA_SET) }
|
||||
val MATTER_REPLICATOR: MenuType<MatterReplicatorMenu> by registry.register(MNames.MATTER_REPLICATOR) { MenuType(::MatterReplicatorMenu, FeatureFlags.VANILLA_SET) }
|
||||
val MATTER_BOTTLER: MenuType<MatterBottlerMenu> by registry.register(MNames.MATTER_BOTTLER) { MenuType(::MatterBottlerMenu, FeatureFlags.VANILLA_SET) }
|
||||
val DRIVE_VIEWER: MenuType<DriveViewerMenu> by registry.register(MNames.DRIVE_VIEWER) { MenuType(::DriveViewerMenu, FeatureFlags.VANILLA_SET) }
|
||||
val CARGO_CRATE: MenuType<CargoCrateMenu> by registry.register(MNames.CARGO_CRATE) { MenuType(::CargoCrateMenu, FeatureFlags.VANILLA_SET) }
|
||||
val MINECART_CARGO_CRATE: MenuType<MinecartCargoCrateMenu> by registry.register(MNames.MINECART_CARGO_CRATE) { MenuType(::MinecartCargoCrateMenu, FeatureFlags.VANILLA_SET) }
|
||||
val DRIVE_RACK: MenuType<DriveRackMenu> by registry.register(MNames.DRIVE_RACK) { MenuType(::DriveRackMenu, FeatureFlags.VANILLA_SET) }
|
||||
val ITEM_MONITOR: MenuType<ItemMonitorMenu> by registry.register(MNames.ITEM_MONITOR) { MenuType(::ItemMonitorMenu, FeatureFlags.VANILLA_SET) }
|
||||
val ENERGY_COUNTER: MenuType<EnergyCounterMenu> by registry.register(MNames.ENERGY_COUNTER) { MenuType(::EnergyCounterMenu, FeatureFlags.VANILLA_SET) }
|
||||
val CHEMICAL_GENERATOR: MenuType<ChemicalGeneratorMenu> by registry.register(MNames.CHEMICAL_GENERATOR) { MenuType(::ChemicalGeneratorMenu, FeatureFlags.VANILLA_SET) }
|
||||
val PLATE_PRESS: MenuType<PlatePressMenu> by registry.register(MNames.PLATE_PRESS) { MenuType(::PlatePressMenu, FeatureFlags.VANILLA_SET) }
|
||||
val MATTER_RECYCLER: MenuType<MatterRecyclerMenu> by registry.register(MNames.MATTER_RECYCLER) { MenuType(::MatterRecyclerMenu, FeatureFlags.VANILLA_SET) }
|
||||
val ENERGY_SERVO: MenuType<EnergyServoMenu> by registry.register(MNames.ENERGY_SERVO) { MenuType(::EnergyServoMenu, FeatureFlags.VANILLA_SET) }
|
||||
val HOLO_SIGN: MenuType<HoloSignMenu> by registry.register(MNames.HOLO_SIGN) { MenuType(::HoloSignMenu, FeatureFlags.VANILLA_SET) }
|
||||
val COBBLESTONE_GENERATOR: MenuType<CobblerMenu> by registry.register(MNames.COBBLESTONE_GENERATOR) { MenuType(::CobblerMenu, FeatureFlags.VANILLA_SET) }
|
||||
val ESSENCE_STORAGE: MenuType<EssenceStorageMenu> by registry.register(MNames.ESSENCE_STORAGE) { MenuType(::EssenceStorageMenu, FeatureFlags.VANILLA_SET) }
|
||||
val ITEM_REPAIER: MenuType<MatterReconstructorMenu> by registry.register(MNames.MATTER_RECONSTRUCTOR) { MenuType(::MatterReconstructorMenu, FeatureFlags.VANILLA_SET) }
|
||||
val FLUID_TANK: MenuType<FluidTankMenu> by registry.register(MNames.FLUID_TANK) { MenuType(::FluidTankMenu, FeatureFlags.VANILLA_SET) }
|
||||
|
||||
val STORAGE_BUS: MenuType<*> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu) }
|
||||
val STORAGE_EXPORTER: MenuType<*> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu) }
|
||||
val STORAGE_IMPORTER: MenuType<*> by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterMenu) }
|
||||
val STORAGE_POWER_SUPPLIER: MenuType<*> by registry.register(MNames.STORAGE_POWER_SUPPLIER) { MenuType(::StoragePowerSupplierMenu) }
|
||||
val STORAGE_BUS: MenuType<StorageBusMenu> by registry.register(MNames.STORAGE_BUS) { MenuType(::StorageBusMenu, FeatureFlags.VANILLA_SET) }
|
||||
val STORAGE_EXPORTER: MenuType<StorageExporterMenu> by registry.register(MNames.STORAGE_EXPORTER) { MenuType(::StorageExporterMenu, FeatureFlags.VANILLA_SET) }
|
||||
val STORAGE_IMPORTER: MenuType<StorageImporterMenu> by registry.register(MNames.STORAGE_IMPORTER) { MenuType(::StorageImporterMenu, FeatureFlags.VANILLA_SET) }
|
||||
val STORAGE_POWER_SUPPLIER: MenuType<StoragePowerSupplierMenu> by registry.register(MNames.STORAGE_POWER_SUPPLIER) { MenuType(::StoragePowerSupplierMenu, FeatureFlags.VANILLA_SET) }
|
||||
|
||||
internal fun register(bus: IEventBus) {
|
||||
registry.register(bus)
|
||||
@ -105,29 +106,29 @@ object MMenus {
|
||||
@Suppress("unchecked_cast")
|
||||
private fun registerClient(event: FMLClientSetupEvent) {
|
||||
event.enqueueWork {
|
||||
MenuScreens.register(ANDROID_STATION as MenuType<AndroidStationMenu>, ::AndroidStationScreen)
|
||||
MenuScreens.register(BATTERY_BANK as MenuType<BatteryBankMenu>, ::BatteryBankScreen)
|
||||
MenuScreens.register(MATTER_DECOMPOSER as MenuType<MatterDecomposerMenu>, ::MatterDecomposerScreen)
|
||||
MenuScreens.register(MATTER_CAPACITOR_BANK as MenuType<MatterCapacitorBankMenu>, ::MatterCapacitorBankScreen)
|
||||
MenuScreens.register(PATTERN_STORAGE as MenuType<PatternStorageMenu>, ::PatternStorageScreen)
|
||||
MenuScreens.register(MATTER_SCANNER as MenuType<MatterScannerMenu>, ::MatterScannerScreen)
|
||||
MenuScreens.register(MATTER_PANEL as MenuType<MatterPanelMenu>, ::MatterPanelScreen)
|
||||
MenuScreens.register(MATTER_REPLICATOR as MenuType<MatterReplicatorMenu>, ::MatterReplicatorScreen)
|
||||
MenuScreens.register(MATTER_BOTTLER as MenuType<MatterBottlerMenu>, ::MatterBottlerScreen)
|
||||
MenuScreens.register(DRIVE_VIEWER as MenuType<DriveViewerMenu>, ::DriveViewerScreen)
|
||||
MenuScreens.register(CARGO_CRATE as MenuType<CargoCrateMenu>, ::CargoCrateScreen)
|
||||
MenuScreens.register(MINECART_CARGO_CRATE as MenuType<MinecartCargoCrateMenu>, ::MinecartCargoCrateScreen)
|
||||
MenuScreens.register(DRIVE_RACK as MenuType<DriveRackMenu>, ::DriveRackScreen)
|
||||
MenuScreens.register(ITEM_MONITOR as MenuType<ItemMonitorMenu>, ::ItemMonitorScreen)
|
||||
MenuScreens.register(ENERGY_COUNTER as MenuType<EnergyCounterMenu>, ::EnergyCounterScreen)
|
||||
MenuScreens.register(CHEMICAL_GENERATOR as MenuType<ChemicalGeneratorMenu>, ::ChemicalGeneratorScreen)
|
||||
MenuScreens.register(PLATE_PRESS as MenuType<PlatePressMenu>, ::PlatePressScreen)
|
||||
MenuScreens.register(MATTER_RECYCLER as MenuType<MatterRecyclerMenu>, ::MatterRecyclerScreen)
|
||||
MenuScreens.register(STORAGE_BUS as MenuType<StorageBusMenu>, ::StorageBusScreen)
|
||||
MenuScreens.register(STORAGE_EXPORTER as MenuType<StorageExporterMenu>, ::StorageExporterScreen)
|
||||
MenuScreens.register(STORAGE_IMPORTER as MenuType<StorageImporterMenu>, ::StorageImporterScreen)
|
||||
MenuScreens.register(STORAGE_POWER_SUPPLIER as MenuType<StoragePowerSupplierMenu>, ::StoragePowerSupplierScreen)
|
||||
MenuScreens.register(ENERGY_SERVO as MenuType<EnergyServoMenu>, ::EnergyServoScreen)
|
||||
MenuScreens.register(ANDROID_STATION, ::AndroidStationScreen)
|
||||
MenuScreens.register(BATTERY_BANK, ::BatteryBankScreen)
|
||||
MenuScreens.register(MATTER_DECOMPOSER, ::MatterDecomposerScreen)
|
||||
MenuScreens.register(MATTER_CAPACITOR_BANK, ::MatterCapacitorBankScreen)
|
||||
MenuScreens.register(PATTERN_STORAGE, ::PatternStorageScreen)
|
||||
MenuScreens.register(MATTER_SCANNER, ::MatterScannerScreen)
|
||||
MenuScreens.register(MATTER_PANEL, ::MatterPanelScreen)
|
||||
MenuScreens.register(MATTER_REPLICATOR, ::MatterReplicatorScreen)
|
||||
MenuScreens.register(MATTER_BOTTLER, ::MatterBottlerScreen)
|
||||
MenuScreens.register(DRIVE_VIEWER, ::DriveViewerScreen)
|
||||
MenuScreens.register(CARGO_CRATE, ::CargoCrateScreen)
|
||||
MenuScreens.register(MINECART_CARGO_CRATE, ::MinecartCargoCrateScreen)
|
||||
MenuScreens.register(DRIVE_RACK, ::DriveRackScreen)
|
||||
MenuScreens.register(ITEM_MONITOR, ::ItemMonitorScreen)
|
||||
MenuScreens.register(ENERGY_COUNTER, ::EnergyCounterScreen)
|
||||
MenuScreens.register(CHEMICAL_GENERATOR, ::ChemicalGeneratorScreen)
|
||||
MenuScreens.register(PLATE_PRESS, ::PlatePressScreen)
|
||||
MenuScreens.register(MATTER_RECYCLER, ::MatterRecyclerScreen)
|
||||
MenuScreens.register(STORAGE_BUS, ::StorageBusScreen)
|
||||
MenuScreens.register(STORAGE_EXPORTER, ::StorageExporterScreen)
|
||||
MenuScreens.register(STORAGE_IMPORTER, ::StorageImporterScreen)
|
||||
MenuScreens.register(STORAGE_POWER_SUPPLIER, ::StoragePowerSupplierScreen)
|
||||
MenuScreens.register(ENERGY_SERVO, ::EnergyServoScreen)
|
||||
MenuScreens.register(HOLO_SIGN, ::HoloSignScreen)
|
||||
MenuScreens.register(COBBLESTONE_GENERATOR, ::CobblerScreen)
|
||||
MenuScreens.register(ESSENCE_STORAGE, ::EssenceStorageScreen)
|
||||
|
@ -4,7 +4,6 @@ import net.minecraft.advancements.CriteriaTriggers
|
||||
import net.minecraft.client.renderer.item.ItemProperties
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.damagesource.DamageSource
|
||||
import net.minecraft.world.entity.EntityType
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.block.*
|
||||
@ -30,7 +29,6 @@ import ru.dbotthepony.mc.otm.capability.matteryEnergy
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
import ru.dbotthepony.mc.otm.item.weapon.EnergySwordItem
|
||||
import ru.dbotthepony.mc.otm.registry.objects.ColoredDecorativeBlock
|
||||
import ru.dbotthepony.mc.otm.registry.objects.CrateProperties
|
||||
import ru.dbotthepony.mc.otm.registry.objects.DecorativeBlock
|
||||
import ru.dbotthepony.mc.otm.registry.objects.StripedColoredDecorativeBlock
|
||||
import ru.dbotthepony.mc.otm.triggers.AndroidBatteryTrigger
|
||||
@ -169,47 +167,6 @@ object MRegistry {
|
||||
return@DecorativeBlock IronBarsBlock(properties)
|
||||
}
|
||||
|
||||
val CRATE_RED = CrateProperties(MaterialColor.COLOR_RED, "crate_red")
|
||||
val CRATE_BLUE = CrateProperties(MaterialColor.COLOR_BLUE, "crate_blue")
|
||||
val CRATE_YELLOW = CrateProperties(MaterialColor.COLOR_YELLOW, "crate_yellow")
|
||||
val CRATE_GREEN = CrateProperties(MaterialColor.COLOR_GREEN, "crate_green")
|
||||
val CRATE_BLACK = CrateProperties(MaterialColor.COLOR_BLACK, "crate_black")
|
||||
val CRATE_PINK = CrateProperties(MaterialColor.COLOR_PINK, "crate_pink")
|
||||
val CRATE_PURPLE = CrateProperties(MaterialColor.COLOR_PURPLE, "crate_purple")
|
||||
|
||||
val CRATE_LIST = listOf(
|
||||
CRATE_RED,
|
||||
CRATE_BLUE,
|
||||
CRATE_YELLOW,
|
||||
CRATE_GREEN,
|
||||
CRATE_BLACK,
|
||||
CRATE_PINK,
|
||||
CRATE_PURPLE,
|
||||
)
|
||||
|
||||
const val DAMAGE_BECOME_ANDROID_ID = "otm_become_android"
|
||||
const val DAMAGE_BECOME_HUMANE_ID = "otm_become_humane"
|
||||
const val DAMAGE_EVENT_HORIZON_ID = "otm_event_horizon"
|
||||
const val DAMAGE_HAWKING_RADIATION_ID = "otm_hawking_radiation"
|
||||
const val DAMAGE_EXOPACK_PROBE_ID = "otm_exopack_probe"
|
||||
const val DAMAGE_EMP_NAME = "otm_emp"
|
||||
const val DAMAGE_SHOCKWAVE_NAME = "otm_shockwave"
|
||||
const val DAMAGE_PLASMA_NAME = "otm_plasma"
|
||||
const val DAMAGE_COSMIC_RAYS_NAME = "otm_cosmic_rays"
|
||||
const val DAMAGE_EXPLOSIVE_HAMMER_NAME = "otm_explosive_hammer"
|
||||
const val DAMAGE_HAMMER_NAIL_NAME = "otm_hammer_nail"
|
||||
|
||||
val DAMAGE_EXOPACK_PROBE = ImmutableDamageSource(DamageSource(DAMAGE_EXOPACK_PROBE_ID).bypassArmor().bypassMagic())
|
||||
|
||||
val DAMAGE_BECOME_ANDROID = ImmutableDamageSource(DamageSource(DAMAGE_BECOME_ANDROID_ID).bypassArmor().bypassInvul().bypassMagic())
|
||||
val DAMAGE_BECOME_HUMANE = ImmutableDamageSource(DamageSource(DAMAGE_BECOME_HUMANE_ID).bypassArmor().bypassInvul().bypassMagic())
|
||||
val DAMAGE_EVENT_HORIZON = ImmutableDamageSource(DamageSource(DAMAGE_EVENT_HORIZON_ID).bypassMagic().bypassArmor())
|
||||
val DAMAGE_HAWKING_RADIATION = ImmutableDamageSource(DamageSource(DAMAGE_HAWKING_RADIATION_ID))
|
||||
val DAMAGE_COSMIC_RAYS = ImmutableDamageSource(DamageSource(DAMAGE_COSMIC_RAYS_NAME).bypassArmor().bypassMagic())
|
||||
val DAMAGE_EXPLOSIVE_HAMMER = ImmutableDamageSource(DamageSource(DAMAGE_EXPLOSIVE_HAMMER_NAME))
|
||||
|
||||
val DAMAGE_EMP: DamageSource = ImmutableDamageSource(EMPDamageSource())
|
||||
|
||||
val TRITANIUM_STRIPED_BLOCK = StripedColoredDecorativeBlock(MNames.TRITANIUM_STRIPED_BLOCK, { colorA, _ ->
|
||||
Block(BlockBehaviour.Properties.of(Material.METAL, colorA.materialColor)
|
||||
.sound(SoundType.BASALT)
|
||||
|
@ -0,0 +1,35 @@
|
||||
package ru.dbotthepony.mc.otm.registry
|
||||
|
||||
import net.minecraft.core.Holder
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.damagesource.DamageSource
|
||||
import net.minecraft.world.damagesource.DamageType
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
|
||||
class MatteryDamageSource(
|
||||
type: Holder<DamageType>,
|
||||
entity: Entity? = null,
|
||||
inflictor: ItemStack? = null,
|
||||
entityInflictor: Entity? = null,
|
||||
pos: Vec3? = null
|
||||
) : DamageSource(type, entity, entityInflictor, pos) {
|
||||
val inflictor = inflictor?.copy()
|
||||
|
||||
override fun getLocalizedDeathMessage(victim: LivingEntity): Component {
|
||||
val itemStack = inflictor ?: (entity as? LivingEntity)?.mainHandItem ?: ItemStack.EMPTY
|
||||
|
||||
if (!itemStack.isEmpty && itemStack.hasCustomHoverName()) {
|
||||
return TranslatableComponent("death.attack.$msgId.player.item", victim.displayName, entity!!.displayName, itemStack.displayName)
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
return TranslatableComponent("death.attack.$msgId.player", victim.displayName, entity!!.displayName)
|
||||
}
|
||||
|
||||
return TranslatableComponent("death.attack.$msgId", victim.displayName)
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package ru.dbotthepony.mc.otm.registry.objects
|
||||
|
||||
import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.SoundType
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.MaterialColor
|
||||
|
||||
class CrateProperties(val color: MaterialColor, val name: String) {
|
||||
fun makeBlock(): Block {
|
||||
return Block(
|
||||
BlockBehaviour.Properties.of(Material.METAL, color)
|
||||
.sound(SoundType.METAL)
|
||||
.requiresCorrectToolForDrops()
|
||||
.strength(5.0F, 6.0F)
|
||||
)
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ public net.minecraft.server.level.ServerPlayer f_143380_ # containerListener
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97762_(I)V # checkHotbarMouseClicked
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97818_()V # recalculateQuickCraftRemaining
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97744_(DD)Lnet/minecraft/world/inventory/Slot; # findSlot
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_97782_(Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem
|
||||
protected net.minecraft.client.gui.screens.inventory.AbstractContainerScreen m_274323_(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V # renderFloatingItem
|
||||
|
||||
protected net.minecraft.client.resources.TextureAtlasHolder f_118884_ # textureAtlas
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user