c3
This commit is contained in:
parent
6c61b330d1
commit
bc920a5d1e
15 changed files with 217 additions and 197 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue