Skip to content

Commit

Permalink
checkpack should only work in valid slot
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Aug 18, 2022
1 parent 14952fe commit 53c8c6a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.possible_triangle.create_jetpack.item.BronzeJetpack.ControlType
import com.possible_triangle.create_jetpack.network.ControlManager
import net.minecraft.world.entity.EquipmentSlot
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.Level
import net.minecraft.world.phys.Vec3
Expand Down Expand Up @@ -54,6 +53,7 @@ interface IJetpack {

fun swimModifier(context: Context): Double

fun isValid(context: Context): Boolean
fun isUsable(context: Context): Boolean

fun onUse(context: Context) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import com.possible_triangle.create_jetpack.CreateJetpackMod
import com.possible_triangle.create_jetpack.capability.IJetpack.Context
import com.possible_triangle.create_jetpack.item.BronzeJetpack.ControlType
import com.possible_triangle.create_jetpack.item.BronzeJetpack.ControlType.*
import com.possible_triangle.create_jetpack.network.ControlManager
import com.possible_triangle.create_jetpack.network.ControlManager.Key
import com.simibubi.create.content.contraptions.particle.AirParticleData
import net.minecraft.core.particles.ParticleTypes
import net.minecraft.server.level.ServerLevel
import net.minecraft.server.level.ServerPlayer
import net.minecraft.sounds.SoundEvents
import net.minecraft.sounds.SoundSource
Expand Down Expand Up @@ -69,10 +67,11 @@ object JetpackLogic {
).flatten()

return sources.asSequence()
.map { it.first to it.second.getCapability(JETPACK_CAPABILITY) }
.filter { it.second.isPresent }
.map { it.first to it.second.resolve().get() }
.map { it.first(it.second) }
.map { (builder, source) -> builder to source.getCapability(JETPACK_CAPABILITY) }
.filter { (_, capability) -> capability.isPresent }
.map { (builder, capability) -> builder to capability.resolve().get() }
.map { (builder, capability) -> builder(capability) }
.filter { it.jetpack.isValid(it) }
.firstOrNull()
}

Expand Down Expand Up @@ -233,7 +232,7 @@ object JetpackLogic {
val thrusters = context.jetpack.getThrusters(context) ?: return
val yaw = (context.entity.yBodyRot / 180 * -Math.PI).toFloat()
val pitch = (context.entity.xRot / 180 * -Math.PI).toFloat()
val xRot = when(context.pose) {
val xRot = when (context.pose) {
FlyingPose.SUPERMAN -> pitch
FlyingPose.UPRIGHT -> 0F
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.simibubi.create.content.curiosities.armor.BackTankUtil
import com.simibubi.create.content.curiosities.armor.CopperBacktankItem
import com.tterrag.registrate.util.entry.ItemEntry
import net.minecraft.core.Direction
import net.minecraft.world.entity.EquipmentSlot
import net.minecraft.world.item.Rarity
import net.minecraft.world.phys.Vec3
import net.minecraftforge.common.capabilities.Capability
Expand Down Expand Up @@ -62,6 +63,10 @@ class BronzeJetpack(properties: Properties, blockItem: ItemEntry<CopperBacktankB
else Configs.SERVER.USES_PER_TANK.get()
}

override fun isValid(context: Context): Boolean {
return context.slot == EquipmentSlot.CHEST
}

override fun isUsable(context: Context): Boolean {
val tank = BackTankUtil.get(context.entity)
if (tank.isEmpty) return false
Expand Down

0 comments on commit 53c8c6a

Please sign in to comment.