Some backporting
This commit is contained in:
parent
cc82146f0a
commit
e563b85946
@ -34,7 +34,7 @@ public class FoodDataMixin {
|
||||
// полностью подменяем логику если андроид
|
||||
lastFoodLevel = foodLevel;
|
||||
|
||||
if (player.level().getDifficulty() == Difficulty.PEACEFUL) {
|
||||
if (player.level.getDifficulty() == Difficulty.PEACEFUL) {
|
||||
exhaustionLevel = 0f;
|
||||
} else {
|
||||
tickTimer = 0;
|
||||
|
@ -29,7 +29,7 @@ public class MixinAbstractHurtingProjectile {
|
||||
AbstractHurtingProjectile proj = (AbstractHurtingProjectile)(Object)this;
|
||||
|
||||
if (cap.isAndroid() && proj.getOwner() != entity) {
|
||||
entity.level().playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level().random.nextFloat() * 0.1f);
|
||||
entity.level.playSound(entity, proj.blockPosition(), MSoundEvents.INSTANCE.getANDROID_PROJ_PARRY(), SoundSource.PLAYERS, 1.0f, 0.95f + entity.level.random.nextFloat() * 0.1f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ abstract class AndroidSwitchableFeature(type: AndroidFeatureType<*>, android: Ma
|
||||
val cooldownPercent: Float get() {
|
||||
if (maxCooldown <= 0) return 0.0f
|
||||
|
||||
if (ply.level() is ClientLevel) {
|
||||
if (ply.level is ClientLevel) {
|
||||
return ((cooldown.toFloat() - minecraft.partialTick) / maxCooldown.toFloat()).coerceIn(0.0f, 1.0f)
|
||||
}
|
||||
|
||||
|
@ -71,29 +71,29 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
}
|
||||
|
||||
private fun canSupportPlayer(blockPos: BlockPos): Boolean {
|
||||
val state = ply.level().getBlockState(blockPos)
|
||||
val state = ply.level.getBlockState(blockPos)
|
||||
|
||||
if (state.`is`(BlockTags.CLIMBABLE)) {
|
||||
return true // ladders can always support player
|
||||
}
|
||||
|
||||
val shape = state.getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply))
|
||||
val shape = state.getCollisionShape(ply.level, blockPos, CollisionContext.of(ply))
|
||||
return Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_SUPPORT_PLAYER, BooleanOp.AND)
|
||||
}
|
||||
|
||||
private fun isWall(blockPos: BlockPos): Boolean {
|
||||
val shape = ply.level().getBlockState(blockPos).getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply))
|
||||
val shape = ply.level.getBlockState(blockPos).getCollisionShape(ply.level, blockPos, CollisionContext.of(ply))
|
||||
return Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_NOT_FENCE, BooleanOp.AND)
|
||||
}
|
||||
|
||||
private fun isAirGap(blockPos: BlockPos): Boolean {
|
||||
val state = ply.level().getBlockState(blockPos)
|
||||
val state = ply.level.getBlockState(blockPos)
|
||||
|
||||
if (state.isAir) {
|
||||
return true
|
||||
}
|
||||
|
||||
val shape = state.getCollisionShape(ply.level(), blockPos, CollisionContext.of(ply))
|
||||
val shape = state.getCollisionShape(ply.level, blockPos, CollisionContext.of(ply))
|
||||
return shape.isEmpty || !Shapes.joinIsNotEmpty(shape, SHAPE_CHECK_SUPPORT_PLAYER, BooleanOp.AND)
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
val headPosition = ply.eyePosition
|
||||
val aimVector = ply.getViewVector(1f)
|
||||
|
||||
val result = ply.level().clip(ClipContext(
|
||||
val result = ply.level.clip(ClipContext(
|
||||
headPosition,
|
||||
headPosition + aimVector * (AndroidConfig.EnderTeleporter.MAX_DISTANCE * 2.0),
|
||||
ClipContext.Block.COLLIDER,
|
||||
@ -199,14 +199,14 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
val searchDirection: IntProgression
|
||||
|
||||
if (ply.isShiftKeyDown) {
|
||||
searchDirection = -1 downTo ply.level().minBuildHeight - ply.level().maxBuildHeight
|
||||
searchDirection = -1 downTo ply.level.minBuildHeight - ply.level.maxBuildHeight
|
||||
} else {
|
||||
searchDirection = (if (ply.level().getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ply.level().maxBuildHeight - ply.level().minBuildHeight
|
||||
searchDirection = (if (ply.level.getBlockState(result.blockPos).`is`(BlockTags.CLIMBABLE)) -1 else 0) .. ply.level.maxBuildHeight - ply.level.minBuildHeight
|
||||
}
|
||||
|
||||
for (y in searchDirection) {
|
||||
val pos = BlockPos(result.blockPos.x, result.blockPos.y + y + 1, result.blockPos.z)
|
||||
val state = ply.level().getBlockState(pos)
|
||||
val state = ply.level.getBlockState(pos)
|
||||
|
||||
if (state.`is`(Blocks.BEDROCK)) {
|
||||
// Can't phase through bedrock
|
||||
@ -258,9 +258,9 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
phasedBlocks = 0
|
||||
phasedBlocksList.clear()
|
||||
|
||||
for (y in 0 downTo ply.level().maxBuildHeight - ply.level().minBuildHeight) {
|
||||
for (y in 0 downTo ply.level.maxBuildHeight - ply.level.minBuildHeight) {
|
||||
val pos = BlockPos(result.blockPos.x, result.blockPos.y + y, result.blockPos.z)
|
||||
val state = ply.level().getBlockState(pos)
|
||||
val state = ply.level.getBlockState(pos)
|
||||
|
||||
if (state.`is`(Blocks.BEDROCK)) {
|
||||
// Can't phase through bedrock
|
||||
@ -302,7 +302,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5)
|
||||
|
||||
if (event.isCanceled) {
|
||||
(ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level().random.nextLong()))
|
||||
(ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong()))
|
||||
return false
|
||||
}
|
||||
|
||||
@ -310,9 +310,9 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
lastTeleport = ply.server!!.tickCount
|
||||
android.androidEnergy.extractEnergy(AndroidConfig.EnderTeleporter.ENERGY_COST, false)
|
||||
|
||||
ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level().random.nextFloat() * 0.4f)
|
||||
ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level.random.nextFloat() * 0.4f)
|
||||
ply.teleportTo(event.targetX, event.targetY, event.targetZ)
|
||||
ply.level().playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level().random.nextFloat() * 0.4f)
|
||||
ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level.random.nextFloat() * 0.4f)
|
||||
|
||||
ply.deltaMovement = Vector(0.0, 0.0, 0.0)
|
||||
ply.resetFallDistance()
|
||||
@ -352,8 +352,8 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
||||
val builder = source.getBuffer(linesIgnoreZRenderType)
|
||||
|
||||
for (blockPos in phasedBlocks) {
|
||||
val blockState = ply.level().getBlockState(blockPos)
|
||||
val shape = blockState.getShape(ply.level(), blockPos, collisionContext)
|
||||
val blockState = ply.level.getBlockState(blockPos)
|
||||
val shape = blockState.getShape(ply.level, blockPos, collisionContext)
|
||||
|
||||
LevelRenderer.renderShape(
|
||||
poseStack,
|
||||
|
@ -45,7 +45,7 @@ class ItemEntityDataPacket(val itemUUID: Int, val owner: UUID? = null, val age:
|
||||
}
|
||||
|
||||
override fun play(context: MNetworkContext) {
|
||||
val level = minecraft.player?.level() as ClientLevel? ?: return
|
||||
val level = minecraft.player?.level as ClientLevel? ?: return
|
||||
val entity = level.getEntity(itemUUID) as ItemEntity? ?: return
|
||||
datatable[entity] = SharedItemEntityData(owner, age, lifespan, hasPickupDelay)
|
||||
}
|
||||
@ -69,7 +69,7 @@ class ItemMagnetFeature(capability: MatteryPlayerCapability) : AndroidSwitchable
|
||||
return
|
||||
}
|
||||
|
||||
val entities = ply.level().getEntitiesInEllipsoid(
|
||||
val entities = ply.level.getEntitiesInEllipsoid(
|
||||
ply.position,
|
||||
Vector(AndroidConfig.Magnet.RADIUS_HORIZONTAL, AndroidConfig.Magnet.RADIUS_VERTICAL, AndroidConfig.Magnet.RADIUS_HORIZONTAL),
|
||||
if (server) Predicate<Entity> { it is ItemEntity } else clientPredicate
|
||||
|
@ -38,7 +38,7 @@ object TriggerJumpBoostPacket : MatteryPacket {
|
||||
if (feature.isActive && feature.cooldown <= 4 && mattery.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, false)) {
|
||||
feature.putOnCooldown()
|
||||
|
||||
context.sender.level().playSound(
|
||||
context.sender.level.playSound(
|
||||
context.sender, context.sender,
|
||||
MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS,
|
||||
1f, 1f
|
||||
@ -73,20 +73,20 @@ class JumpBoostFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
}
|
||||
|
||||
val old = lastGround
|
||||
lastGround = ply.onGround()
|
||||
lastGround = ply.isOnGround
|
||||
|
||||
if (isActive && cooldown <= 0 && old != lastGround && !lastGround && isJumping && isShifting && ply.xRot <= ClientConfig.JUMP_BOOST_LOOK_ANGLE && android.androidEnergy.extractEnergyExact(AndroidConfig.JumpBoost.ENERGY_COST, true)) {
|
||||
ply.deltaMovement += Vector(0.0, AndroidConfig.JumpBoost.POWER * (level + 1) / 20.0, 0.0)
|
||||
putOnCooldown()
|
||||
MatteryPlayerNetworkChannel.sendToServer(TriggerJumpBoostPacket)
|
||||
|
||||
ply.level().playSound(
|
||||
ply.level.playSound(
|
||||
ply, ply,
|
||||
MSoundEvents.ANDROID_JUMP_BOOST, SoundSource.PLAYERS,
|
||||
1f, 1f
|
||||
)
|
||||
|
||||
SmokeParticlesPacket.makeSmoke(ply.x, ply.y, ply.z, ply.random, ply.level())
|
||||
SmokeParticlesPacket.makeSmoke(ply.x, ply.y, ply.z, ply.random, ply.level)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class NanobotsRegenerationFeature(android: MatteryPlayerCapability) : AndroidFea
|
||||
private var healTicks = 0
|
||||
|
||||
override fun tickServer() {
|
||||
if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (ply.isHurt && ply.level.gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
ticksPassed++
|
||||
|
||||
val waitTime = AndroidConfig.NanobotsRegeneration.COOLDOWN.getOrElse(healTicks) { AndroidConfig.NanobotsRegeneration.COOLDOWN.last() }
|
||||
|
@ -93,7 +93,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
ShockwaveTrigger.trigger(ply as ServerPlayer)
|
||||
MatteryPlayerNetworkChannel.sendTrackingAndSelf(ply, ShockwaveEffectPacket(ply.position))
|
||||
|
||||
ply.level().playSound(
|
||||
ply.level.playSound(
|
||||
null,
|
||||
ply,
|
||||
MSoundEvents.ANDROID_SHOCKWAVE,
|
||||
@ -104,13 +104,13 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
}
|
||||
|
||||
// TODO: raycasting
|
||||
val entities = ply.level().getEntitiesInEllipsoid(
|
||||
val entities = ply.level.getEntitiesInEllipsoid(
|
||||
ply.position,
|
||||
Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL, AndroidConfig.Shockwave.RADIUS_VERTICAL, AndroidConfig.Shockwave.RADIUS_HORIZONTAL),
|
||||
except = ply,
|
||||
) { (it !is LivingEntity || !it.isSpectator && it.isAlive) }
|
||||
|
||||
val wardens = ply.level().getEntitiesInEllipsoid(
|
||||
val wardens = ply.level.getEntitiesInEllipsoid(
|
||||
Warden::class.java,
|
||||
ply.position,
|
||||
Vector(AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN, AndroidConfig.Shockwave.RADIUS_VERTICAL_WARDEN, AndroidConfig.Shockwave.RADIUS_HORIZONTAL_WARDEN),
|
||||
@ -122,7 +122,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
seen.add(entity)
|
||||
val multiplier = (1.0 - distanceMultiplier).pow(0.5)
|
||||
|
||||
val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), 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)
|
||||
@ -138,7 +138,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
|
||||
// don't hurt items, arrows, etc etc
|
||||
if (entity is LivingEntity) {
|
||||
val source = MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.SHOCKWAVE), 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)
|
||||
@ -158,21 +158,21 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
for (blockPos in getEllipsoidBlockPositions(AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_VERTICAL.roundToInt(), AndroidConfig.Shockwave.RADIUS_HORIZONTAL.roundToInt())) {
|
||||
val newBlockPos = blockPos + rounded
|
||||
|
||||
val blockState = ply.level().getBlockState(newBlockPos)
|
||||
val blockState = ply.level.getBlockState(newBlockPos)
|
||||
|
||||
if (!blockState.isAir && blockState.getExplosionResistance(ply.level(), newBlockPos) <= 0f && ply.level().getBlockEntity(newBlockPos) == null && blockState.block.defaultDestroyTime() >= 0f) {
|
||||
// Block.dropResources(blockState, ply.level(), newBlockPos)
|
||||
// blockState.block.destroy(ply.level(), newBlockPos, blockState)
|
||||
// ply.level().setBlock(newBlockPos, blockState.fluidState.createLegacyBlock(), Block.UPDATE_ALL)
|
||||
if (!blockState.isAir && blockState.getExplosionResistance(ply.level, newBlockPos) <= 0f && ply.level.getBlockEntity(newBlockPos) == null && blockState.block.defaultDestroyTime() >= 0f) {
|
||||
// Block.dropResources(blockState, ply.level, newBlockPos)
|
||||
// blockState.block.destroy(ply.level, newBlockPos, blockState)
|
||||
// ply.level.setBlock(newBlockPos, blockState.fluidState.createLegacyBlock(), Block.UPDATE_ALL)
|
||||
|
||||
ply.level().destroyBlock(newBlockPos, true)
|
||||
ply.level.destroyBlock(newBlockPos, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun ticker(isClient: Boolean) {
|
||||
if (!ply.onGround() || ply.isSpectator) {
|
||||
if (!ply.isOnGround || ply.isSpectator) {
|
||||
airTicks = (airTicks + 1).coerceAtMost(3)
|
||||
} else {
|
||||
airTicks = (airTicks - 1).coerceAtLeast(0)
|
||||
@ -192,7 +192,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
||||
creativeFlightTicks == 0
|
||||
) {
|
||||
val old = wasMidair
|
||||
wasMidair = !ply.onGround()
|
||||
wasMidair = !ply.isOnGround
|
||||
|
||||
if (wasMidair) {
|
||||
highestSpeed = (-ply.deltaMovement.y).coerceAtLeast(highestSpeed)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.block
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.Block
|
||||
@ -10,7 +11,7 @@ import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraft.world.level.material.MapColor
|
||||
import net.minecraft.world.level.material.Material
|
||||
import net.minecraft.world.level.material.PushReaction
|
||||
import net.minecraft.world.phys.shapes.CollisionContext
|
||||
import net.minecraft.world.phys.shapes.VoxelShape
|
||||
@ -19,7 +20,7 @@ import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
import ru.dbotthepony.mc.otm.shapes.BlockShapes
|
||||
|
||||
class BlackHoleBlock :
|
||||
Block(Properties.of().mapColor(MapColor.COLOR_BLACK).noCollission().pushReaction(PushReaction.BLOCK).sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock {
|
||||
Block(Properties.of(Material.AIR, DyeColor.BLACK).noCollission().pushReaction(PushReaction.BLOCK).sound(SoundType.STONE).strength(-1f, 7200000.0f)), EntityBlock {
|
||||
override fun getShape(
|
||||
p_60555_: BlockState,
|
||||
p_60556_: BlockGetter,
|
||||
|
@ -33,7 +33,7 @@ class ExperienceStorage(val maxExperience: DoubleSupplier = DoubleSupplier { Dou
|
||||
|
||||
if (whole > 0) {
|
||||
experience -= whole
|
||||
ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole)
|
||||
ExperienceOrb.award(player.level as ServerLevel, player.position(), whole)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
@Cancelable
|
||||
data class PreTick(val capability: MatteryPlayerCapability) : Event() {
|
||||
val player get() = capability.ply
|
||||
val level: Level get() = capability.ply.level()
|
||||
val level: Level get() = capability.ply.level
|
||||
|
||||
override fun isCancelable(): Boolean {
|
||||
return true
|
||||
@ -161,7 +161,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
*/
|
||||
data class PostTick(val capability: MatteryPlayerCapability) : Event() {
|
||||
val player get() = capability.ply
|
||||
val level: Level get() = capability.ply.level()
|
||||
val level: Level get() = capability.ply.level
|
||||
|
||||
override fun isCancelable(): Boolean {
|
||||
return false
|
||||
@ -174,7 +174,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
*/
|
||||
data class ItemStackLeftoverEvent(val stack: ItemStack, val capability: MatteryPlayerCapability) : Event() {
|
||||
val player get() = capability.ply
|
||||
val level: Level get() = capability.ply.level()
|
||||
val level: Level get() = capability.ply.level
|
||||
|
||||
override fun isCancelable(): Boolean {
|
||||
return false
|
||||
@ -525,7 +525,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
|
||||
override fun computeNextJob(): JobContainer<ItemJob> {
|
||||
if (!exopackEnergy.batteryLevel.isPositive) return JobContainer.noEnergy()
|
||||
val level = ply.level() as? ServerLevel ?: return JobContainer.failure()
|
||||
val level = ply.level as? ServerLevel ?: return JobContainer.failure()
|
||||
val recipe = cache.getRecipeFor(input, level)
|
||||
|
||||
if (recipe.isEmpty) {
|
||||
@ -542,7 +542,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
override fun onJobTick(status: JobStatus<ItemJob>) {
|
||||
super.onJobTick(status)
|
||||
|
||||
if (isExopackVisible && ply.level().random.nextFloat() <= 0.05f) {
|
||||
if (isExopackVisible && ply.level.random.nextFloat() <= 0.05f) {
|
||||
MatteryPlayerNetworkChannel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with { ply as ServerPlayer }, ExopackSmokePacket(ply.uuid))
|
||||
}
|
||||
}
|
||||
@ -685,7 +685,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
becomeAndroid()
|
||||
|
||||
if (!ply.abilities.invulnerable)
|
||||
ply.hurt(MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2)
|
||||
ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_ANDROID)), ply.maxHealth * 2)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -747,7 +747,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
becomeHumane()
|
||||
|
||||
if (!ply.abilities.invulnerable)
|
||||
ply.hurt(MatteryDamageSource(ply.level().registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2)
|
||||
ply.hurt(MatteryDamageSource(ply.level.registryAccess().damageType(MDamageTypes.BECOME_HUMANE)), ply.maxHealth * 2)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -808,7 +808,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
if (featureMap.containsKey(feature.type)) return false
|
||||
featureMap[feature.type] = feature
|
||||
|
||||
if (!ply.level().isClientSide) {
|
||||
if (!ply.level.isClientSide) {
|
||||
queuedTicks.add(feature::applyModifiers)
|
||||
}
|
||||
|
||||
@ -836,7 +836,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
|
||||
featureMap[feature] = factory
|
||||
|
||||
if (!ply.level().isClientSide && isAndroid) {
|
||||
if (!ply.level.isClientSide && isAndroid) {
|
||||
queuedTicks.add(factory::applyModifiers)
|
||||
}
|
||||
|
||||
@ -861,7 +861,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
val removed = featureMap.remove(feature)
|
||||
|
||||
if (removed != null) {
|
||||
if (!ply.level().isClientSide && isAndroid) {
|
||||
if (!ply.level.isClientSide && isAndroid) {
|
||||
queuedTicks.add(removed::removeModifiers)
|
||||
}
|
||||
|
||||
@ -1034,7 +1034,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
instance.deserializeNBT(featureTag)
|
||||
addFeature(instance)
|
||||
|
||||
if (!ply.level().isClientSide) {
|
||||
if (!ply.level.isClientSide) {
|
||||
queuedTicks.add(instance::applyModifiers)
|
||||
}
|
||||
}
|
||||
@ -1088,7 +1088,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
if (hasExopack) {
|
||||
for ((i, stack) in exopackContainer.withIndex()) {
|
||||
if (!stack.isEmpty) {
|
||||
stack.inventoryTick(ply.level(), ply, i + 41, false)
|
||||
stack.inventoryTick(ply.level, ply, i + 41, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1197,8 +1197,8 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
ply.isSwimming = false
|
||||
|
||||
if (ply is ServerPlayer) {
|
||||
if (ply.level().dimension().location() != lastDimension) {
|
||||
lastDimension = ply.level().dimension().location()
|
||||
if (ply.level.dimension().location() != lastDimension) {
|
||||
lastDimension = ply.level.dimension().location()
|
||||
wasInLiquid = false
|
||||
lastOutsideLiquid = ply.position
|
||||
}
|
||||
@ -1243,7 +1243,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
while (stats.foodLevel > 18 && androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT / 2, false)) {
|
||||
stats.foodLevel--
|
||||
}
|
||||
} else if (ply.level().difficulty != Difficulty.PEACEFUL) {
|
||||
} else if (ply.level.difficulty != Difficulty.PEACEFUL) {
|
||||
stats.foodLevel = stats.foodLevel.coerceAtMost(18)
|
||||
}
|
||||
|
||||
@ -1255,7 +1255,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
stats.setSaturation(stats.saturationLevel + (extracted / AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT).toFloat())
|
||||
}
|
||||
|
||||
if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level().difficulty != Difficulty.PEACEFUL) {
|
||||
if (androidEnergy.batteryLevel <= Decimal.TEN && !ply.isCreative && ply.level.difficulty != Difficulty.PEACEFUL) {
|
||||
if (stats.saturationLevel > 1f) {
|
||||
if (androidEnergy.receiveEnergyExact(AndroidConfig.ANDROID_ENERGY_PER_HUNGER_POINT, false)) {
|
||||
stats.setSaturation(stats.saturationLevel - 1f)
|
||||
@ -1272,7 +1272,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
}
|
||||
|
||||
if (androidEnergy.batteryLevel <= Decimal.TEN) {
|
||||
if (--nextDischargeHurt <= 0 && ply.hurt(DamageSource(ply.level().registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) {
|
||||
if (--nextDischargeHurt <= 0 && ply.hurt(DamageSource(ply.level.registryAccess().damageType(MDamageTypes.ANDROID_DISCHARGE)), 1f)) {
|
||||
nextDischargeHurt = 20
|
||||
}
|
||||
|
||||
@ -1285,13 +1285,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
} else {
|
||||
nextDischargeHurt = 20
|
||||
|
||||
if (ply.isHurt && ply.level().gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (ply.isHurt && ply.level.gameRules.getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (--nextHealTick <= 0) {
|
||||
nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION
|
||||
nextHealTick = if (ply.level.difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION
|
||||
ply.heal(1f)
|
||||
}
|
||||
} else {
|
||||
nextHealTick = if (ply.level().difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION
|
||||
nextHealTick = if (ply.level.difficulty == Difficulty.PEACEFUL) 10 else AndroidConfig.TIME_BETWEEN_NATURAL_REGENERATION
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1418,7 +1418,7 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
|
||||
pos.mul(RenderSystem.getProjectionMatrix())
|
||||
pos.mul(poseStack.last().pose())
|
||||
makeSmoke(cam.x + pos.x, cam.y + pos.y, cam.z + pos.z, ply.level().random, ply.level())
|
||||
makeSmoke(cam.x + pos.x, cam.y + pos.y, cam.z + pos.z, ply.level.random, ply.level)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1513,13 +1513,13 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
|
||||
val ent = event.player
|
||||
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
if (!ent.level().isClientSide) {
|
||||
if (!ent.level.isClientSide) {
|
||||
ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK {
|
||||
it.preTick()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ent.level().isClientSide) {
|
||||
if (ent.level.isClientSide) {
|
||||
ent.getCapability(MatteryCapability.MATTERY_PLAYER).ifPresentK {
|
||||
it.tickClient()
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl
|
||||
|
||||
val x = minecraft.window.guiScaledWidth.toFloat() * .5f + iconSize / 2f
|
||||
val y = minecraft.window.guiScaledHeight.toFloat() * .5f - iconSize / 2f
|
||||
val wrap = MGUIGraphics(event.guiGraphics)
|
||||
val wrap = MGUIGraphics(event.poseStack)
|
||||
|
||||
feature.renderIcon(wrap, x, y, iconSize, iconSize)
|
||||
|
||||
|
@ -155,7 +155,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
RenderSystem.setShaderColor(0f, 0f, 0f, 0.6f)
|
||||
|
||||
val size = minecraft.window.guiScaledHeight.coerceAtMost(minecraft.window.guiScaledWidth).toFloat() * 0.35f
|
||||
val wrap = MGUIGraphics(event.guiGraphics)
|
||||
val wrap = MGUIGraphics(event.poseStack)
|
||||
|
||||
wrap.drawArc(
|
||||
minecraft.window.guiScaledWidth / 2f,
|
||||
@ -241,7 +241,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
|
||||
val iconSize = size * 0.25f
|
||||
|
||||
val poseStack = event.guiGraphics.pose()
|
||||
val poseStack = event.poseStack
|
||||
poseStack.pushPose()
|
||||
poseStack.translate(minecraft.window.guiScaledWidth.toDouble() / 2f, minecraft.window.guiScaledHeight.toDouble() / 2f, 0.0)
|
||||
|
||||
@ -294,7 +294,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
|
||||
val y = minecraft.window.guiScaledHeight * 0.2f
|
||||
var x = minecraft.window.guiScaledWidth * 0.5f - (features.size.toFloat() * COOLDOWN_ICON_SIZE / 2f + (features.size - 1).toFloat() * (COOLDOWN_ICON_MARGIN / 2f))
|
||||
val wrap = MGUIGraphics(event.guiGraphics)
|
||||
val wrap = MGUIGraphics(event.poseStack)
|
||||
|
||||
for (feature in features) {
|
||||
feature.renderIcon(wrap, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE)
|
||||
|
@ -60,7 +60,7 @@ fun onMovementInputUpdate(event: MovementInputUpdateEvent) {
|
||||
cap.lastJumpTicks = 14
|
||||
} else {
|
||||
if (ply.isInWater) {
|
||||
if (ply.onGround()) {
|
||||
if (ply.isOnGround) {
|
||||
cap.lastJumpTicks = 14
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.Font
|
||||
|
||||
import net.minecraft.client.gui.components.Button
|
||||
@ -141,7 +142,7 @@ object MatteryGUI {
|
||||
return
|
||||
}
|
||||
|
||||
val guiGraphics = MGUIGraphics(event.guiGraphics)
|
||||
val guiGraphics = MGUIGraphics(event.poseStack)
|
||||
val stack = guiGraphics.pose
|
||||
val window = event.window
|
||||
|
||||
@ -253,7 +254,7 @@ object MatteryGUI {
|
||||
|
||||
val leftPadding = ceil(level * 80f - 0.5f)
|
||||
|
||||
val guiGraphics = MGUIGraphics(event.guiGraphics)
|
||||
val guiGraphics = MGUIGraphics(event.poseStack)
|
||||
|
||||
if (ply.hasEffect(MobEffects.HUNGER)) {
|
||||
CHARGE_HUNGER_BG.render(guiGraphics, left.toFloat(), top.toFloat())
|
||||
@ -323,7 +324,7 @@ object MatteryGUI {
|
||||
val top: Int = height - gui.leftHeight
|
||||
gui.leftHeight += 10
|
||||
|
||||
val guiGraphics = MGUIGraphics(event.guiGraphics)
|
||||
val guiGraphics = MGUIGraphics(event.poseStack)
|
||||
|
||||
HEALTH_BG.render(guiGraphics, left.toFloat(), top.toFloat())
|
||||
|
||||
@ -360,7 +361,7 @@ object MatteryGUI {
|
||||
}
|
||||
}
|
||||
|
||||
fun renderShieldCooldownOverlay(graphics: GuiGraphics, font: Font, stack: ItemStack, x: Int, y: Int): Boolean {
|
||||
fun renderShieldCooldownOverlay(pose: PoseStack, font: Font, stack: ItemStack, x: Int, y: Int): Boolean {
|
||||
if (!stack.isEmpty && stack.item is ShieldItem) {
|
||||
if (!stack.canPerformAction(ToolActions.SHIELD_BLOCK)) return false
|
||||
|
||||
@ -369,7 +370,7 @@ object MatteryGUI {
|
||||
|
||||
val percent = ((stack.item.getUseDuration(stack) - ply.useItemRemainingTicks + minecraft.partialTick) / 5f).coerceIn(0f, 1f)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f)
|
||||
drawArc(graphics.pose(), x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true)
|
||||
drawArc(pose, x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
|
||||
return true
|
||||
|
@ -1,9 +1,12 @@
|
||||
package ru.dbotthepony.mc.otm.client.render
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.blaze3d.vertex.Tesselator
|
||||
import net.minecraft.client.gui.Font
|
||||
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.RenderBuffers
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
@ -15,15 +18,14 @@ import kotlin.math.PI
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
// polyfill class for 1.19.4 and older
|
||||
class MGUIGraphics(val parent: GuiGraphics) {
|
||||
val pose: PoseStack get() = parent.pose()
|
||||
val bufferSource: MultiBufferSource.BufferSource get() = parent.bufferSource()
|
||||
val width get() = parent.guiWidth()
|
||||
val height get() = parent.guiHeight()
|
||||
class MGUIGraphics(val pose: PoseStack) {
|
||||
val bufferSource: MultiBufferSource.BufferSource get() = minecraft.renderBuffers().crumblingBufferSource()
|
||||
val width get() = minecraft.window.guiScaledWidth
|
||||
val height get() = minecraft.window.guiScaledHeight
|
||||
val font: Font get() = minecraft.font
|
||||
|
||||
fun setColor(red: Float, green: Float, blue: Float, alpha: Float) {
|
||||
parent.setColor(red, green, blue, alpha)
|
||||
RenderSystem.setShaderColor(red, green, blue, alpha)
|
||||
}
|
||||
|
||||
fun renderFakeItem(itemStack: ItemStack, x: Int, y: Int) {
|
||||
@ -83,7 +85,6 @@ class MGUIGraphics(val parent: GuiGraphics) {
|
||||
}
|
||||
|
||||
fun flush() {
|
||||
parent.flush()
|
||||
}
|
||||
|
||||
fun draw(
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectFunction
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
||||
import net.minecraft.ChatFormatting
|
||||
@ -610,7 +611,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
return super.keyPressed(key, scancode, mods)
|
||||
}
|
||||
|
||||
override fun renderBg(p_283065_: GuiGraphics, p_97788_: Float, p_97789_: Int, p_97790_: Int) {}
|
||||
override fun renderBg(p_283065_: PoseStack, p_97788_: Float, p_97789_: Int, p_97790_: Int) {}
|
||||
|
||||
var returnSlot: Slot? = null
|
||||
|
||||
@ -643,13 +644,13 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
return false
|
||||
}
|
||||
|
||||
override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
override fun render(poseStack: PoseStack, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
val wrap = MGUIGraphics(poseStack)
|
||||
val mouseXf = mouseX.toFloat()
|
||||
val mouseYf = mouseY.toFloat()
|
||||
|
||||
// dark background
|
||||
this.renderBackground(graphics)
|
||||
this.renderBackground(poseStack)
|
||||
|
||||
super.hoveredSlot = null
|
||||
var hovered = false
|
||||
@ -673,17 +674,17 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
}
|
||||
|
||||
RenderSystem.depthFunc(GL11.GL_LESS)
|
||||
MinecraftForge.EVENT_BUS.post(Background(this, graphics, mouseX, mouseY))
|
||||
MinecraftForge.EVENT_BUS.post(Background(this, poseStack, mouseX, mouseY))
|
||||
RenderSystem.disableDepthTest()
|
||||
|
||||
// Screen.super.render
|
||||
for (widget in renderables) {
|
||||
widget.render(graphics, mouseX, mouseY, partialTick)
|
||||
widget.render(poseStack, mouseX, mouseY, partialTick)
|
||||
}
|
||||
// /Screen.super.render
|
||||
|
||||
RenderSystem.disableDepthTest()
|
||||
MinecraftForge.EVENT_BUS.post(Foreground(this, graphics, mouseX, mouseY))
|
||||
MinecraftForge.EVENT_BUS.post(Foreground(this, poseStack, mouseX, mouseY))
|
||||
|
||||
var itemstack = if (draggingItem.isEmpty) menu.carried else draggingItem
|
||||
|
||||
@ -701,14 +702,14 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
}
|
||||
|
||||
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
|
||||
renderFloatingItem(graphics, itemstack, mouseX - 8, mouseY - i2, overrideCount)
|
||||
renderFloatingItem(poseStack, itemstack, mouseX - 8, mouseY - i2, overrideCount)
|
||||
}
|
||||
|
||||
if (menu.carried.isEmpty) {
|
||||
val hoveredSlot = super.hoveredSlot
|
||||
|
||||
if (hoveredSlot != null && hoveredSlot.hasItem()) {
|
||||
this.renderTooltip(graphics, mouseX, mouseY)
|
||||
this.renderTooltip(poseStack, mouseX, mouseY)
|
||||
} else {
|
||||
for (panel in panels) {
|
||||
RenderSystem.disableDepthTest()
|
||||
|
@ -156,7 +156,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) :
|
||||
set(value) {}
|
||||
|
||||
override fun innerRenderTooltips(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
||||
val list = getTooltipFromItem(minecraft!!, recipeOutput)
|
||||
val list = getTooltipFromItem(recipeOutput)
|
||||
|
||||
recipe.value.dyes.forEach {
|
||||
val (dye, amount) = it
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.components.Renderable
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
@ -14,13 +15,13 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
||||
require(panel.parent == null) { "Widget wrapped panels can't have a parent ($panel has parent ${panel.parent})" }
|
||||
}
|
||||
|
||||
override fun render(graphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
override fun render(stack: PoseStack, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
panel.tick()
|
||||
|
||||
val xFloat = mouseX.toFloat()
|
||||
val yFloat = mouseY.toFloat()
|
||||
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
panel.tickHover(xFloat, yFloat)
|
||||
panel.render(wrap, xFloat, yFloat, partialTick)
|
||||
|
@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.compat.jade.providers
|
||||
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.WorkerState
|
||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterBottlerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys
|
||||
@ -16,16 +19,14 @@ import snownee.jade.api.config.IPluginConfig
|
||||
import snownee.jade.api.ui.BoxStyle
|
||||
import snownee.jade.api.ui.IElementHelper
|
||||
|
||||
object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
object MatterBottlerProvider : IBlockComponentProvider, IServerDataProvider<BlockEntity> {
|
||||
override fun getUid(): ResourceLocation = JadeUids.MATTER_BOTTLER
|
||||
|
||||
override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) {
|
||||
if (accessor.blockEntity is MatterBottlerBlockEntity) {
|
||||
val bottler = accessor.blockEntity as MatterBottlerBlockEntity
|
||||
|
||||
override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, bottler: BlockEntity?, state: Boolean) {
|
||||
if (bottler is MatterBottlerBlockEntity) {
|
||||
val bottlerData = CompoundTag()
|
||||
bottlerData.putBoolean("isBottling", bottler.isBottling)
|
||||
bottlerData.putBoolean("isIdling", accessor.blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING)
|
||||
bottlerData.putBoolean("isIdling", bottler.blockState.getValue(WorkerState.SEMI_WORKER_STATE) !== WorkerState.WORKING)
|
||||
bottlerData.putFloat("workProgress", bottler.workProgress)
|
||||
data.put(JadeTagKeys.MATTER_BOTTLER_DATA, bottlerData)
|
||||
}
|
||||
|
@ -2,6 +2,9 @@ package ru.dbotthepony.mc.otm.compat.jade.providers
|
||||
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterReconstructorBlockEntity
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeUids
|
||||
@ -15,13 +18,11 @@ import snownee.jade.api.config.IPluginConfig
|
||||
import snownee.jade.api.ui.BoxStyle
|
||||
import snownee.jade.api.ui.IElementHelper
|
||||
|
||||
object MatterReconstructorProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
object MatterReconstructorProvider : IBlockComponentProvider, IServerDataProvider<BlockEntity> {
|
||||
override fun getUid(): ResourceLocation = JadeUids.MATTER_RECONSTRUCTOR
|
||||
|
||||
override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) {
|
||||
if (accessor.blockEntity is MatterReconstructorBlockEntity) {
|
||||
val reconstructor = accessor.blockEntity as MatterReconstructorBlockEntity
|
||||
|
||||
override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, reconstructor: BlockEntity?, state: Boolean) {
|
||||
if (reconstructor is MatterReconstructorBlockEntity) {
|
||||
val item = reconstructor.repairContainer.get(0)
|
||||
|
||||
if (!item.isEmpty && item.isDamageableItem && item.maxDamage != 0) {
|
||||
|
@ -4,6 +4,9 @@ import net.minecraft.ChatFormatting
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeColors
|
||||
@ -24,11 +27,11 @@ import snownee.jade.api.config.IPluginConfig
|
||||
import snownee.jade.api.ui.BoxStyle
|
||||
import snownee.jade.api.ui.IElementHelper
|
||||
|
||||
object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
object MatterStorageProvider : IBlockComponentProvider, IServerDataProvider<BlockEntity> {
|
||||
override fun getUid(): ResourceLocation = JadeUids.MATTER_STORAGE
|
||||
|
||||
override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) {
|
||||
accessor.blockEntity?.getCapability(MatteryCapability.MATTER)?.ifPresentK {
|
||||
override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, blockEntity: BlockEntity?, state: Boolean) {
|
||||
blockEntity?.getCapability(MatteryCapability.MATTER)?.ifPresentK {
|
||||
val matterData = CompoundTag()
|
||||
|
||||
matterData.putDecimal("storedMatter", it.storedMatter)
|
||||
|
@ -4,6 +4,9 @@ import net.minecraft.ChatFormatting
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import ru.dbotthepony.mc.otm.capability.AbstractProfiledStorage
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeColors
|
||||
@ -21,11 +24,11 @@ import snownee.jade.api.config.IPluginConfig
|
||||
import snownee.jade.api.ui.BoxStyle
|
||||
import snownee.jade.api.ui.IElementHelper
|
||||
|
||||
object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
object MatteryEnergyProvider : IBlockComponentProvider, IServerDataProvider<BlockEntity> {
|
||||
override fun getUid(): ResourceLocation = JadeUids.MATTERY_ENERGY
|
||||
|
||||
override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) {
|
||||
accessor.blockEntity?.getCapability(MatteryCapability.ENERGY)?.ifPresentK {
|
||||
override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, blockEntity: BlockEntity?, state: Boolean) {
|
||||
blockEntity?.getCapability(MatteryCapability.ENERGY)?.ifPresentK {
|
||||
val energyData = CompoundTag()
|
||||
|
||||
energyData.putDecimal("batteryLevel", it.batteryLevel)
|
||||
|
@ -3,6 +3,9 @@ package ru.dbotthepony.mc.otm.compat.jade.providers
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import net.minecraft.nbt.ListTag
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.ItemJob
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatteryWorkerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.compat.jade.JadeTagKeys
|
||||
@ -19,13 +22,11 @@ import snownee.jade.api.config.IPluginConfig
|
||||
import snownee.jade.api.ui.BoxStyle
|
||||
import snownee.jade.api.ui.IElementHelper
|
||||
|
||||
object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
object MatteryWorkerProvider : IBlockComponentProvider, IServerDataProvider<BlockEntity> {
|
||||
override fun getUid(): ResourceLocation = JadeUids.MATTERY_WORKER
|
||||
|
||||
override fun appendServerData(data: CompoundTag, accessor: BlockAccessor) {
|
||||
if (accessor.blockEntity is MatteryWorkerBlockEntity<*>) {
|
||||
val worker = accessor.blockEntity as MatteryWorkerBlockEntity<*>
|
||||
|
||||
override fun appendServerData(data: CompoundTag, player: ServerPlayer, level: Level, worker: BlockEntity?, state: Boolean) {
|
||||
if (worker is MatteryWorkerBlockEntity<*>) {
|
||||
val workerData = CompoundTag()
|
||||
|
||||
workerData["jobs"] = ListTag().also {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
|
||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||
@ -14,7 +15,7 @@ class IGUIRenderable2IDrawable(val parent: IGUIRenderable) : IDrawable {
|
||||
return parent.height.toInt()
|
||||
}
|
||||
|
||||
override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
parent.render(MGUIGraphics(guiGraphics), xOffset.toFloat(), yOffset.toFloat())
|
||||
override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) {
|
||||
parent.render(MGUIGraphics(stack), xOffset.toFloat(), yOffset.toFloat())
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView
|
||||
@ -61,8 +62,8 @@ object MatterEntanglerRecipeCategory : IRecipeCategory<IMatterEntanglerRecipe>,
|
||||
builder.addSlot(RecipeIngredientRole.OUTPUT, 116, 18 + 4).addItemStack(recipe.result)
|
||||
}
|
||||
|
||||
override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
val wrap = MGUIGraphics(guiGraphics)
|
||||
override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) {
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
for (x in 0 until 3) {
|
||||
for (y in 0 until 3) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView
|
||||
@ -14,7 +15,6 @@ import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
@ -45,14 +45,14 @@ object MicrowaveRecipeCategory : IRecipeCategory<MicrowaveRecipe>, IDrawable {
|
||||
return MItems.POWERED_SMOKER.description
|
||||
}
|
||||
|
||||
override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) {
|
||||
@Suppress("name_shadowing")
|
||||
val xOffset = xOffset.toFloat()
|
||||
|
||||
@Suppress("name_shadowing")
|
||||
val yOffset = yOffset.toFloat()
|
||||
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_INPUT + xOffset, Y_INPUT + yOffset)
|
||||
AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_OUTPUT + xOffset, Y_OUTPUT + yOffset)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.constants.VanillaTypes
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
@ -71,8 +72,8 @@ object PainterRecipeCategory : IRecipeCategory<PainterRecipe>, IDrawable {
|
||||
builder.addSlot(RecipeIngredientRole.OUTPUT, 100, 22).addIngredients(VanillaTypes.ITEM_STACK, listOf(recipe.output))
|
||||
}
|
||||
|
||||
override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
val wrap = MGUIGraphics(guiGraphics)
|
||||
override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) {
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
for (x in 0 .. 1) {
|
||||
for (y in 0 .. 2) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.compat.jei
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder
|
||||
import mezz.jei.api.gui.drawable.IDrawable
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView
|
||||
@ -14,7 +15,6 @@ import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.crafting.Ingredient
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
@ -45,14 +45,14 @@ object PlatePressRecipeCategory : IRecipeCategory<PlatePressRecipe>, IDrawable {
|
||||
return MItems.PLATE_PRESS.description
|
||||
}
|
||||
|
||||
override fun draw(graphics: GuiGraphics, xOffset: Int, yOffset: Int) {
|
||||
override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) {
|
||||
@Suppress("name_shadowing")
|
||||
val xOffset = xOffset.toFloat()
|
||||
|
||||
@Suppress("name_shadowing")
|
||||
val yOffset = yOffset.toFloat()
|
||||
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_INPUT + xOffset, Y_INPUT + yOffset)
|
||||
AbstractSlotPanel.SLOT_BACKGROUND.render(wrap, X_OUTPUT + xOffset, Y_OUTPUT + yOffset)
|
||||
@ -68,11 +68,11 @@ object PlatePressRecipeCategory : IRecipeCategory<PlatePressRecipe>, IDrawable {
|
||||
override fun draw(
|
||||
recipe: PlatePressRecipe,
|
||||
recipeSlotsView: IRecipeSlotsView,
|
||||
graphics: GuiGraphics,
|
||||
stack: PoseStack,
|
||||
mouseX: Double,
|
||||
mouseY: Double
|
||||
) {
|
||||
val wrap = MGUIGraphics(graphics)
|
||||
val wrap = MGUIGraphics(stack)
|
||||
|
||||
wrap.draw(TranslatableComponent("otm.gui.recipe.ticks", recipe.workTime), 40f, 30f, gravity = RenderGravity.TOP_CENTER, color = RGBAColor.BLACK)
|
||||
|
||||
|
@ -56,7 +56,7 @@ object CreativeMenuItemComparator : Comparator<Item> {
|
||||
if (item2index.isEmpty()) {
|
||||
val player = minecraft.player ?: return
|
||||
// creative tabs were not populated yet
|
||||
CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */, player.level().registryAccess())
|
||||
CreativeModeTabs.tryRebuildTabContents(player.connection.enabledFeatures(), false /* operator tabs */, player.level.registryAccess())
|
||||
|
||||
doRebuild()
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class MinecartCargoCrate(
|
||||
|
||||
if (interactingPlayers++ == 0) {
|
||||
if (!isRemoved) {
|
||||
level().playSound(null, this, MSoundEvents.CARGO_CRATE_OPEN, SoundSource.BLOCKS, 1f, 0.8f + level().random.nextFloat() * 0.2f)
|
||||
level.playSound(null, this, MSoundEvents.CARGO_CRATE_OPEN, SoundSource.BLOCKS, 1f, 0.8f + level.random.nextFloat() * 0.2f)
|
||||
this.gameEvent(GameEvent.CONTAINER_OPEN, player)
|
||||
PiglinAi.angerNearbyPiglins(player, true)
|
||||
}
|
||||
@ -102,7 +102,7 @@ class MinecartCargoCrate(
|
||||
|
||||
if (--interactingPlayers == 0) {
|
||||
if (!isRemoved) {
|
||||
level().gameEvent(GameEvent.CONTAINER_CLOSE, position, GameEvent.Context.of(this))
|
||||
level.gameEvent(GameEvent.CONTAINER_CLOSE, position, GameEvent.Context.of(this))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT
|
||||
override fun onHit(p_37260_: HitResult) {
|
||||
super.onHit(p_37260_)
|
||||
|
||||
if (!level().isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
discard()
|
||||
}
|
||||
}
|
||||
@ -37,8 +37,8 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT
|
||||
override fun onHitEntity(p_37259_: EntityHitResult) {
|
||||
super.onHitEntity(p_37259_)
|
||||
|
||||
if (!level().isClientSide) {
|
||||
p_37259_.entity.hurt(MatteryDamageSource(level().registryAccess().damageType(MDamageTypes.PLASMA), owner, inflictor), damage)
|
||||
if (!level.isClientSide) {
|
||||
p_37259_.entity.hurt(MatteryDamageSource(level.registryAccess().damageType(MDamageTypes.PLASMA), owner, inflictor), damage)
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,17 +54,17 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT
|
||||
|
||||
super.tick()
|
||||
|
||||
val trace = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity)
|
||||
val trace = ProjectileUtil.getHitResult(this, this::canHitEntity)
|
||||
|
||||
if (trace.type == HitResult.Type.BLOCK) {
|
||||
val pos = (trace as BlockHitResult).blockPos
|
||||
val state = level().getBlockState(pos)
|
||||
val state = level.getBlockState(pos)
|
||||
|
||||
if (state.`is`(Blocks.NETHER_PORTAL) || state.`is`(Blocks.END_GATEWAY)) {
|
||||
onHitBlock(trace)
|
||||
|
||||
// don't teleport plasma projectile
|
||||
if (!level().isClientSide)
|
||||
if (!level.isClientSide)
|
||||
discard()
|
||||
|
||||
return
|
||||
@ -85,7 +85,7 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT
|
||||
// extinguish
|
||||
|
||||
for (i in 0 .. 4) {
|
||||
level().addParticle(
|
||||
level.addParticle(
|
||||
ParticleTypes.BUBBLE,
|
||||
x - deltaMovement.x * 0.25,
|
||||
y - deltaMovement.y * 0.25,
|
||||
@ -96,9 +96,9 @@ class PlasmaProjectile(level: Level) : Projectile(MEntityTypes.PLASMA as EntityT
|
||||
)
|
||||
}
|
||||
|
||||
if (!level().isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
discard()
|
||||
level().levelEvent(LevelEvent.LAVA_FIZZ, blockPosition(), 0)
|
||||
level.levelEvent(LevelEvent.LAVA_FIZZ, blockPosition(), 0)
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -22,11 +22,11 @@ class EssenceServoItem : Item(Properties().stacksTo(64)) {
|
||||
}
|
||||
|
||||
fun useServo(player: Player, pos: BlockPos): InteractionResult {
|
||||
val block = player.level().getBlockEntity(pos) ?: return InteractionResult.FAIL
|
||||
val block = player.level.getBlockEntity(pos) ?: return InteractionResult.FAIL
|
||||
|
||||
// TODO: опыт как жидкость
|
||||
if (block is EssenceStorageBlockEntity) {
|
||||
if (player.level().isClientSide) return InteractionResult.SUCCESS
|
||||
if (player.level.isClientSide) return InteractionResult.SUCCESS
|
||||
if (player !is ServerPlayer) return InteractionResult.FAIL
|
||||
|
||||
if (player.isCrouching) { // выгружаем в блок
|
||||
|
@ -114,16 +114,16 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
|
||||
actionResult.result
|
||||
}
|
||||
|
||||
if (!player.abilities.instabuild && !player.level().isClientSide) {
|
||||
if (!player.abilities.instabuild && !player.level.isClientSide) {
|
||||
item.shrink(1)
|
||||
|
||||
if (item.isEmpty) return InteractionResultHolder.sidedSuccess(targetItem, player.level().isClientSide)
|
||||
if (item.isEmpty) return InteractionResultHolder.sidedSuccess(targetItem, player.level.isClientSide)
|
||||
if (!player.inventory.add(targetItem)) {
|
||||
player.spawnAtLocation(targetItem)
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(item, player.level().isClientSide)
|
||||
return InteractionResultHolder.sidedSuccess(item, player.level.isClientSide)
|
||||
}
|
||||
|
||||
return InteractionResultHolder.pass(item)
|
||||
@ -143,7 +143,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
|
||||
}
|
||||
|
||||
override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean {
|
||||
return player.level().getBlockState(context.blockPos).`is`(Blocks.CAULDRON)
|
||||
return player.level.getBlockState(context.blockPos).`is`(Blocks.CAULDRON)
|
||||
}
|
||||
|
||||
override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult {
|
||||
@ -158,12 +158,12 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
|
||||
val drained = cap.drain(toDrain, IFluidHandler.FluidAction.SIMULATE)
|
||||
|
||||
if (!drained.isEmpty && drained.amount == 1000) {
|
||||
player.level().playSound(player, context.blockPos, soundEvent, SoundSource.BLOCKS)
|
||||
val level = player.level() as? ServerLevel ?: return InteractionResult.SUCCESS
|
||||
player.level.playSound(player, context.blockPos, soundEvent, SoundSource.BLOCKS)
|
||||
val level = player.level as? ServerLevel ?: return InteractionResult.SUCCESS
|
||||
level.setBlock(context.blockPos, newState, Block.UPDATE_ALL)
|
||||
cap.drain(toDrain, IFluidHandler.FluidAction.EXECUTE)
|
||||
|
||||
if (item.count != 1 && !player.level().isClientSide) {
|
||||
if (item.count != 1 && !player.level.isClientSide) {
|
||||
item.count--
|
||||
|
||||
if (!player.inventory.add(targetItem)) {
|
||||
@ -186,7 +186,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
|
||||
}
|
||||
|
||||
override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean {
|
||||
return player.level().getBlockState(context.blockPos) in mapping
|
||||
return player.level.getBlockState(context.blockPos) in mapping
|
||||
}
|
||||
|
||||
override fun interact(item: ItemStack, player: Player, context: Context): InteractionResult {
|
||||
@ -202,13 +202,13 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
|
||||
val fill = cap.fill(toFill, IFluidHandler.FluidAction.SIMULATE)
|
||||
if (fill != 1000) return InteractionResult.FAIL
|
||||
|
||||
player.level().playSound(player, context.blockPos, mapped.second, SoundSource.BLOCKS)
|
||||
player.level.playSound(player, context.blockPos, mapped.second, SoundSource.BLOCKS)
|
||||
|
||||
val level = player.level() as? ServerLevel ?: return InteractionResult.SUCCESS
|
||||
val level = player.level as? ServerLevel ?: return InteractionResult.SUCCESS
|
||||
level.setBlock(context.blockPos, Blocks.CAULDRON.defaultBlockState(), Block.UPDATE_ALL)
|
||||
cap.fill(toFill, IFluidHandler.FluidAction.EXECUTE)
|
||||
|
||||
if (item.count != 1 && !player.level().isClientSide) {
|
||||
if (item.count != 1 && !player.level.isClientSide) {
|
||||
item.count--
|
||||
|
||||
if (!player.inventory.add(targetItem)) {
|
||||
@ -216,13 +216,13 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(player.level().isClientSide)
|
||||
return InteractionResult.sidedSuccess(player.level.isClientSide)
|
||||
}
|
||||
}
|
||||
|
||||
private object FillEmptyCapability : Interaction {
|
||||
override fun canInteract(item: ItemStack, player: Player, context: Context): Boolean {
|
||||
val target = player.level().getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return false
|
||||
val target = player.level.getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return false
|
||||
val cap = item.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return false
|
||||
return target.iterator().any { !it.isEmpty } || cap.iterator().any { !it.isEmpty }
|
||||
}
|
||||
@ -233,21 +233,21 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
|
||||
val targetItem = if (item.count == 1) item else item.copyWithCount(1)
|
||||
|
||||
val itemCap = targetItem.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).orNull() ?: return InteractionResult.FAIL
|
||||
val blockCap = player.level().getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return InteractionResult.FAIL
|
||||
val blockCap = player.level.getBlockEntity(context.blockPos)?.getCapability(ForgeCapabilities.FLUID_HANDLER, context.side)?.orNull() ?: return InteractionResult.FAIL
|
||||
val fluid = itemCap[0]
|
||||
|
||||
if (fluid.isEmpty) {
|
||||
// заполняем из блока
|
||||
val moveResult = moveFluid(source = blockCap, destination = itemCap, actuallyDrain = !player.level().isClientSide, actuallyFill = !player.level().isClientSide)
|
||||
val moveResult = moveFluid(source = blockCap, destination = itemCap, actuallyDrain = !player.level.isClientSide, actuallyFill = !player.level.isClientSide)
|
||||
|
||||
if (!moveResult.isEmpty) {
|
||||
val sound = moveResult.fluid.fluidType.getSound(moveResult, SoundActions.BUCKET_FILL)
|
||||
|
||||
if (sound != null) {
|
||||
player.level().playSound(player, context.blockPos, sound, SoundSource.BLOCKS)
|
||||
player.level.playSound(player, context.blockPos, sound, SoundSource.BLOCKS)
|
||||
}
|
||||
|
||||
if (item.count != 1 && !player.level().isClientSide) {
|
||||
if (item.count != 1 && !player.level.isClientSide) {
|
||||
item.count--
|
||||
|
||||
if (!player.inventory.add(targetItem)) {
|
||||
@ -255,21 +255,21 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(player.level().isClientSide)
|
||||
return InteractionResult.sidedSuccess(player.level.isClientSide)
|
||||
} else {
|
||||
return InteractionResult.FAIL
|
||||
}
|
||||
} else {
|
||||
val moveResult = moveFluid(source = itemCap, destination = blockCap, actuallyDrain = !player.level().isClientSide, actuallyFill = !player.level().isClientSide)
|
||||
val moveResult = moveFluid(source = itemCap, destination = blockCap, actuallyDrain = !player.level.isClientSide, actuallyFill = !player.level.isClientSide)
|
||||
|
||||
if (!moveResult.isEmpty) {
|
||||
val sound = moveResult.fluid.fluidType.getSound(moveResult, SoundActions.BUCKET_EMPTY)
|
||||
|
||||
if (sound != null) {
|
||||
player.level().playSound(player, context.blockPos, sound, SoundSource.BLOCKS)
|
||||
player.level.playSound(player, context.blockPos, sound, SoundSource.BLOCKS)
|
||||
}
|
||||
|
||||
if (item.count != 1 && !player.level().isClientSide) {
|
||||
if (item.count != 1 && !player.level.isClientSide) {
|
||||
item.count--
|
||||
|
||||
if (!player.inventory.add(targetItem)) {
|
||||
@ -277,7 +277,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(player.level().isClientSide)
|
||||
return InteractionResult.sidedSuccess(player.level.isClientSide)
|
||||
} else {
|
||||
return InteractionResult.FAIL
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem {
|
||||
val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true
|
||||
|
||||
val halfStack = pStack.copyWithCount(1)
|
||||
matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level().isClientSide()))
|
||||
matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide()))
|
||||
pSlot.set(halfStack)
|
||||
|
||||
if (getMatterValue(pStack)?.matter!! <= Decimal.ZERO) {
|
||||
@ -175,13 +175,13 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem {
|
||||
val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true
|
||||
|
||||
val halfStack = pStack.copyWithCount(1)
|
||||
matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level().isClientSide()))
|
||||
matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide()))
|
||||
pAccess.set(halfStack)
|
||||
|
||||
return true
|
||||
} else if (pOther.item is MatterDustItem && pOther.count == 1) {
|
||||
val matterOther = getMatterValue(pOther)?.matter ?: return true
|
||||
val diff = addMatterValue(pStack, matterOther, pPlayer.level().isClientSide())
|
||||
val diff = addMatterValue(pStack, matterOther, pPlayer.level.isClientSide())
|
||||
|
||||
if (matterOther - diff <= Decimal.ZERO) {
|
||||
pOther.shrink(1)
|
||||
|
@ -78,19 +78,19 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1)
|
||||
|
||||
override fun getCraftingRemainingItem(itemStack: ItemStack): ItemStack {
|
||||
val player = ForgeHooks.getCraftingPlayer() ?: return itemStack.copy()
|
||||
if (player.level().isClientSide) return itemStack.copy()
|
||||
if (player.level.isClientSide) return itemStack.copy()
|
||||
|
||||
if (!isPrimed(itemStack)) {
|
||||
itemStack.hurtAndBreak(1, player) {}
|
||||
} else {
|
||||
val level = player.level() as ServerLevel
|
||||
val level = player.level as ServerLevel
|
||||
|
||||
itemStack.hurtAndBreak(level.random.nextInt(1, 20), player) {}
|
||||
unprime(itemStack)
|
||||
|
||||
val (ex, ey, ez) = Vector.atCenterOf(player.blockPosition())
|
||||
|
||||
val exp = Explosion(player.level(), player, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY_WITH_DECAY else Explosion.BlockInteraction.KEEP)
|
||||
val exp = Explosion(player.level, player, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY_WITH_DECAY else Explosion.BlockInteraction.KEEP)
|
||||
exp.explode()
|
||||
exp.finalizeExplosion(true)
|
||||
|
||||
@ -150,20 +150,20 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1)
|
||||
}
|
||||
|
||||
fun attackAt(itemStack: ItemStack, attacker: LivingEntity, pos: Vec3, aim: Vec3, hand: InteractionHand) {
|
||||
if (!isPrimed(itemStack) || attacker.level().isClientSide || attacker is Player && attacker.getAttackStrengthScale(0.4f) < 0.98f)
|
||||
if (!isPrimed(itemStack) || attacker.level.isClientSide || attacker is Player && attacker.getAttackStrengthScale(0.4f) < 0.98f)
|
||||
return
|
||||
|
||||
val (ex, ey, ez) = pos
|
||||
|
||||
// взрыв в месте удара молотком
|
||||
val exp = Explosion(attacker.level(), attacker, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY_WITH_DECAY else Explosion.BlockInteraction.KEEP)
|
||||
val exp = Explosion(attacker.level, attacker, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY_WITH_DECAY else Explosion.BlockInteraction.KEEP)
|
||||
exp.explode()
|
||||
exp.finalizeExplosion(true)
|
||||
|
||||
if (!ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS)
|
||||
exp.clearToBlow()
|
||||
|
||||
val level = attacker.level() as ServerLevel
|
||||
val level = attacker.level as ServerLevel
|
||||
|
||||
val hitEntities = ObjectArraySet<LivingEntity>()
|
||||
hitEntities.add(attacker)
|
||||
|
@ -101,7 +101,7 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani
|
||||
victim.matteryPlayer?.let {
|
||||
if (it.isAndroid) {
|
||||
victim.invulnerableTime = 0
|
||||
victim.hurt(MatteryDamageSource(attacker.level().registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f)
|
||||
victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,11 +110,11 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani
|
||||
|
||||
itemStack.getCapability(MatteryCapability.ENERGY).ifPresentK {
|
||||
if (it.extractEnergyExact(ENERGY_PER_SWING, false)) {
|
||||
it.extractEnergy(attacker.level().random.nextVariance(ENERGY_PER_SWING_VARIANCE), false)
|
||||
it.extractEnergy(attacker.level.random.nextVariance(ENERGY_PER_SWING_VARIANCE), false)
|
||||
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(MatteryDamageSource(attacker.level().registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f)
|
||||
it.androidEnergy.extractEnergy(attacker.level.random.nextVariance(ENERGY_ZAP_VARIANCE), false)
|
||||
victim.hurt(MatteryDamageSource(attacker.level.registryAccess().damageType(MDamageTypes.EMP), attacker, itemStack), 8f)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,12 +163,12 @@ class EnergySwordItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)), Vani
|
||||
|
||||
if (blockState.`is`(BlockTags.SWORD_EFFICIENT)) {
|
||||
if (energy?.extractEnergyExact(PLANT_POWER_COST, false) == true)
|
||||
energy.extractEnergyExact(user.level().random.nextVariance(PLANT_POWER_COST_VARIANCE), false)
|
||||
energy.extractEnergyExact(user.level.random.nextVariance(PLANT_POWER_COST_VARIANCE), false)
|
||||
}
|
||||
|
||||
if (blockState.`is`(Blocks.COBWEB)) {
|
||||
if (energy?.extractEnergyExact(COBWEB_POWER_COST, false) == true)
|
||||
energy.extractEnergyExact(user.level().random.nextVariance(COBWEB_POWER_COST_VARIANCE), false)
|
||||
energy.extractEnergyExact(user.level.random.nextVariance(COBWEB_POWER_COST_VARIANCE), false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ class PlasmaRifleItem : PlasmaWeaponItem<PlasmaWeaponDataTable>(PlasmaWeaponData
|
||||
get() = Angle(-0.02, 0.0, 0.0)
|
||||
|
||||
override fun primaryFire(itemStack: ItemStack, player: Player, dt: PlasmaWeaponDataTable): Boolean {
|
||||
if (!player.level().isClientSide) {
|
||||
val arrow = PlasmaProjectile(player.level())
|
||||
if (!player.level.isClientSide) {
|
||||
val arrow = PlasmaProjectile(player.level)
|
||||
arrow.position = player.eyePosition
|
||||
|
||||
val calc = VelocityCalculation(player, force = 4.0, deviation = 0.3)
|
||||
@ -34,14 +34,14 @@ class PlasmaRifleItem : PlasmaWeaponItem<PlasmaWeaponDataTable>(PlasmaWeaponData
|
||||
|
||||
arrow.owner = player
|
||||
|
||||
player.level().addFreshEntity(arrow)
|
||||
player.level.addFreshEntity(arrow)
|
||||
} else {
|
||||
dt.doFireAnim(deviation = rotFireAnimDeviation)
|
||||
}
|
||||
|
||||
receiveHeat(itemStack, player, 10.0, dt)
|
||||
|
||||
player.level().playSound(
|
||||
player.level.playSound(
|
||||
player,
|
||||
player,
|
||||
MSoundEvents.RIFLE_SHOT,
|
||||
|
@ -280,7 +280,7 @@ abstract class PlasmaWeaponItem<D : PlasmaWeaponDataTable>(tables: KClass<D>, pr
|
||||
dt.heatCooldown = overheatCooldown
|
||||
|
||||
if (!before) {
|
||||
player.level().playSound(player, player, MSoundEvents.PLASMA_WEAPON_OVERHEAT, SoundSource.PLAYERS, 1f, 1f)
|
||||
player.level.playSound(player, player, MSoundEvents.PLASMA_WEAPON_OVERHEAT, SoundSource.PLAYERS, 1f, 1f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class VelocityCalculation(
|
||||
if (owner != null) {
|
||||
val ownerVel = owner.deltaMovement
|
||||
|
||||
if (owner.onGround()) {
|
||||
if (owner.isOnGround) {
|
||||
velocity += ownerVel
|
||||
} else {
|
||||
velocity += Vec3(ownerVel.x, 0.0, ownerVel.z)
|
||||
|
@ -84,10 +84,10 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
}
|
||||
|
||||
private fun popFurnaceExp() {
|
||||
if (capability.isExopackSmeltingInstalled && capability.exopackSmelterExperience >= 1f && !player.level().isClientSide) {
|
||||
if (capability.isExopackSmeltingInstalled && capability.exopackSmelterExperience >= 1f && !player.level.isClientSide) {
|
||||
val whole = capability.exopackSmelterExperience.toInt()
|
||||
capability.exopackSmelterExperience -= whole
|
||||
ExperienceOrb.award(player.level() as ServerLevel, player.position(), whole)
|
||||
ExperienceOrb.award(player.level as ServerLevel, player.position(), whole)
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
super.slotsChanged(container)
|
||||
|
||||
if (container == craftingGrid) {
|
||||
CraftingMenu.slotChangedCraftingGrid(this, capability.ply.level(), capability.ply, craftingGrid, craftingResultContainer)
|
||||
CraftingMenu.slotChangedCraftingGrid(this, capability.ply.level, capability.ply, craftingGrid, craftingResultContainer)
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ class ExopackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen
|
||||
|
||||
craftingResultContainer.clearContent()
|
||||
|
||||
if (!player.level().isClientSide) {
|
||||
if (!player.level.isClientSide) {
|
||||
for (slot in craftingGrid.slotIterator()) {
|
||||
val leftover = moveItemStackToSlots(slot.item, playerInventorySlots)
|
||||
|
||||
|
@ -406,7 +406,7 @@ abstract class MatteryMenu(
|
||||
override fun stillValid(player: Player): Boolean {
|
||||
if (tile == null) return true
|
||||
|
||||
if (player.level().getBlockEntity(tile.blockPos) !== tile) {
|
||||
if (player.level.getBlockEntity(tile.blockPos) !== tile) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class PainterMenu(
|
||||
return super.mayPlace(itemStack)
|
||||
}
|
||||
|
||||
return super.mayPlace(itemStack) && inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.any { it.value.matches(itemStack) }
|
||||
return super.mayPlace(itemStack) && inventory.player.level.recipeManager.byType(MRecipes.PAINTER).values.any { it.value.matches(itemStack) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ class PainterMenu(
|
||||
|
||||
private fun rescan() {
|
||||
possibleRecipes.clear()
|
||||
possibleRecipes.addAll(inventory.player.level().recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.value.matches(inputContainer[0]) })
|
||||
possibleRecipes.addAll(inventory.player.level.recipeManager.byType(MRecipes.PAINTER).values.iterator().filter { it.value.matches(inputContainer[0]) })
|
||||
|
||||
listeners.accept(Unit)
|
||||
if (tile !is PainterBlockEntity) return
|
||||
@ -136,12 +136,12 @@ class PainterMenu(
|
||||
if (inputContainer.isEmpty || selectedRecipe == null) {
|
||||
outputContainer.clearContent()
|
||||
} else {
|
||||
val recipe = inventory.player.level().recipeManager.byKey(selectedRecipe!!).get() as AbstractPainterRecipe?
|
||||
val recipe = inventory.player.level.recipeManager.byKey(selectedRecipe!!).get() as AbstractPainterRecipe?
|
||||
|
||||
if (recipe == null || !recipe.value.canCraft(dyeStoredDirect) || !recipe.value.matches(inputContainer, inventory.player.level())) {
|
||||
if (recipe == null || !recipe.value.canCraft(dyeStoredDirect) || !recipe.value.matches(inputContainer, inventory.player.level)) {
|
||||
outputContainer.clearContent()
|
||||
} else {
|
||||
outputContainer[0] = recipe.value.assemble(inputContainer, inventory.player.level().registryAccess())
|
||||
outputContainer[0] = recipe.value.assemble(inputContainer, inventory.player.level.registryAccess())
|
||||
lastRecipe = recipe
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class MatterEntanglerMenu(
|
||||
object : MatterySlot(it, i) {
|
||||
override fun mayPlace(itemStack: ItemStack): Boolean {
|
||||
val shadow = ShadowCraftingContainer.shadow(it, i, itemStack)
|
||||
val level = player.level()
|
||||
val level = player.level
|
||||
|
||||
return super.mayPlace(itemStack) && (level ?: return false)
|
||||
.recipeManager
|
||||
|
@ -324,7 +324,7 @@ class MatterPanelMenu(
|
||||
}
|
||||
|
||||
fun fullPatternBroadcast() {
|
||||
if (inventory.player.level().isClientSide) {
|
||||
if (inventory.player.level.isClientSide) {
|
||||
initialSend = true
|
||||
return
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class SmokeParticlesPacket(val x: Double, val y: Double, val z: Double) : Matter
|
||||
}
|
||||
|
||||
override fun play(context: MNetworkContext) {
|
||||
minecraft.player?.level()?.let {
|
||||
minecraft.player?.level?.let {
|
||||
makeSmoke(x, y, z, it.random, it)
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v
|
||||
}
|
||||
|
||||
private fun execute() {
|
||||
val level = minecraft.player?.level()
|
||||
val level = minecraft.player?.level
|
||||
|
||||
if (level == null) {
|
||||
LOGGER.error("Received BlockEntitySyncPacket before we are in valid level.")
|
||||
@ -127,7 +127,7 @@ object GenericNetworkChannel : MatteryNetworkChannel(
|
||||
}
|
||||
|
||||
fun makeSmoke(excluded: ServerPlayer, x: Double, y: Double, z: Double) {
|
||||
send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level().dimension()) }, SmokeParticlesPacket(x, y, z))
|
||||
send(PacketDistributor.NEAR.with { PacketDistributor.TargetPoint(excluded, x, y, z, 64.0, excluded.level.dimension()) }, SmokeParticlesPacket(x, y, z))
|
||||
}
|
||||
|
||||
fun register() {
|
||||
|
@ -523,9 +523,9 @@ data class ExopackSmokePacket(val player: UUID) : MatteryPacket {
|
||||
|
||||
override fun play(context: MNetworkContext) {
|
||||
context.packetHandled = true
|
||||
// minecraft.player?.level()?.getPlayerByUUID(player)?.matteryPlayer?.spawnExopackSmoke = true
|
||||
// minecraft.player?.level?.getPlayerByUUID(player)?.matteryPlayer?.spawnExopackSmoke = true
|
||||
|
||||
minecraft.player?.level()?.getPlayerByUUID(player)?.let { ply ->
|
||||
minecraft.player?.level?.getPlayerByUUID(player)?.let { ply ->
|
||||
if (ply != minecraft.player || minecraft.gameRenderer.mainCamera.isDetached) {
|
||||
var (x, y, z) = ply.position
|
||||
|
||||
@ -535,7 +535,7 @@ data class ExopackSmokePacket(val player: UUID) : MatteryPacket {
|
||||
x += kotlin.math.cos(deg) * -0.4
|
||||
z += kotlin.math.sin(deg) * -0.4
|
||||
|
||||
val level = ply.level()
|
||||
val level = ply.level
|
||||
val random = level.random
|
||||
|
||||
for (i in 0 .. random.nextInt(2, 4))
|
||||
|
@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
|
@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
|
@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
|
@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.advancements.critereon.DamagePredicate
|
||||
import net.minecraft.advancements.critereon.DamageSourcePredicate
|
||||
import net.minecraft.advancements.critereon.EntityPredicate
|
||||
|
@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.advancements.critereon.ItemPredicate
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
|
@ -14,7 +14,6 @@ import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap
|
||||
import net.minecraft.advancements.Criterion
|
||||
import net.minecraft.advancements.CriterionTrigger
|
||||
import net.minecraft.advancements.CriterionTriggerInstance
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.advancements.critereon.DeserializationContext
|
||||
import net.minecraft.advancements.critereon.EntityPredicate
|
||||
import net.minecraft.advancements.critereon.SerializationContext
|
||||
@ -28,6 +27,8 @@ import ru.dbotthepony.mc.otm.core.toJsonStrict
|
||||
import java.util.Optional
|
||||
import java.util.function.Predicate
|
||||
|
||||
typealias ContextAwarePredicate = EntityPredicate.Composite
|
||||
|
||||
// allows to support both 1.20.1 and 1.20.2 with ease
|
||||
// and has slightly less memory footprint than vanilla SimpleCriterionTrigger
|
||||
abstract class MCriterionTrigger<T : MCriterionTrigger<T>.AbstractInstance>(private val id: ResourceLocation) : CriterionTrigger<T> {
|
||||
@ -112,7 +113,7 @@ abstract class MCriterionTrigger<T : MCriterionTrigger<T>.AbstractInstance>(priv
|
||||
val context = deserializationContext.get().lastOrNull() ?: return DataResult.error { "Not current deserializing trigger instance" }
|
||||
|
||||
return try {
|
||||
DataResult.success(Pair.of(EntityPredicate.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context), ops.empty()))
|
||||
DataResult.success(Pair.of(EntityPredicate.Composite.fromJson(JsonObject().also { it["a"] = ops.convertTo(JsonOps.INSTANCE, input) }, "a", context), ops.empty()))
|
||||
} catch (err: Exception) {
|
||||
DataResult.error { "Failed to deserialize ContextAwarePredicate: " + err.message }
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.triggers
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds.Doubles
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
|
@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.triggers
|
||||
import com.mojang.serialization.Codec
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder
|
||||
import net.minecraft.advancements.Criterion
|
||||
import net.minecraft.advancements.critereon.ContextAwarePredicate
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import java.util.*
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user