All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.chestmc.block.BlockControllerBase.kt Maven / Gradle / Ivy

The newest version!
package net.chestmc.block

import net.chestmc.common.extensions.applyTag
import net.chestmc.common.extensions.newData
import net.chestmc.common.extensions.newItem
import net.minecraft.server.NBTTagCompound
import org.bukkit.Location
import org.bukkit.World
import org.bukkit.block.Block
import org.bukkit.block.BlockFace
import org.bukkit.entity.Entity
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import java.util.*

/**
 * A abstract skeletal implementation of [IBlockController].
 */
abstract class BlockControllerBase(override val block: Block) : IBlockController {
  override val location: Location = block.location
  override val world: World = block.world

  override fun startup() {
  }

  override fun shutdown() {
  }

  override fun onAttack(player: Player, face: BlockFace): Boolean {
    return true
  }

  override fun onInteract(player: Player, face: BlockFace): Boolean {
    return true
  }

  override fun onBreak(player: Player): Boolean {
    return true
  }

  override fun onPlace(player: Player, item: ItemStack, face: BlockFace): Boolean {
    return true
  }

  override fun canTick(): Boolean {
    return false
  }

  override fun onTick(random: Random) {
  }

  override fun onCollide(entity: Entity) {
  }

  override fun onJump(entity: Entity): Boolean {
    return true
  }

  override fun onPostJump(entity: Entity) {
  }

  override fun onFall(entity: Entity, height: Float) {
  }

  override fun onStep(entity: Entity) {
  }

  override fun doPhysics() {
  }

  override fun persistOnBreak(beforeBreak: Boolean): Boolean {
    return false
  }

  override fun getItem(): ItemStack = newItem(newData(block.type, block.data)).applyTag {
    setClass(CONTROLLER_KEY, [email protected])
  }

  override fun save(tag: NBTTagCompound) {
  }

  override fun load(tag: NBTTagCompound) {
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy