This commit is contained in:
Cilly Leang 2025-03-08 15:13:29 +11:00
parent 6c61b330d1
commit bc920a5d1e
Signed by: cilly
GPG key ID: 6500251E087653C9
15 changed files with 217 additions and 197 deletions

View file

@ -1,4 +1,42 @@
package moe.lava.cartloader.impl
import moe.lava.cartloader.accessor.AccessorAbstractMinecartEntity
import net.minecraft.entity.Entity
import net.minecraft.entity.ItemEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.entity.vehicle.AbstractMinecartEntity
import net.minecraft.item.Items
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
class MixinPlayerEntityImpl {
private var linking: AbstractMinecartEntity? = null
fun interact(minecart: Entity, player: PlayerEntity, hand: Hand): ActionResult? {
if (minecart !is AbstractMinecartEntity)
return null
if (minecart !is AccessorAbstractMinecartEntity)
return null;
if (!player.getStackInHand(hand).isOf(Items.CHAIN))
return null
val target = linking
if (target == null) {
linking = minecart
return ActionResult.SUCCESS
}
if (target !is AccessorAbstractMinecartEntity)
return null
linking = null
if (!target.isAlive)
return ActionResult.FAIL
if (!minecart.boundingBox.expand(0.1).intersects(target.boundingBox))
return ActionResult.FAIL
target.`cartloader$getImpl`().linkTo(minecart)
return ActionResult.SUCCESS
}
}