mirror of
https://github.com/Theaninova/new-frontiers.git
synced 2025-12-12 11:36:16 +00:00
Space Teleporter can teleport now.
This commit is contained in:
@@ -4,8 +4,13 @@ import de.wulkanat.www.new_frontiers.NewFrontiers
|
|||||||
import de.wulkanat.www.new_frontiers.proxy.registerItemRenderer
|
import de.wulkanat.www.new_frontiers.proxy.registerItemRenderer
|
||||||
import net.minecraft.block.Block
|
import net.minecraft.block.Block
|
||||||
import net.minecraft.block.material.Material
|
import net.minecraft.block.material.Material
|
||||||
|
import net.minecraft.block.state.IBlockState
|
||||||
import net.minecraft.creativetab.CreativeTabs
|
import net.minecraft.creativetab.CreativeTabs
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
import net.minecraft.item.Item
|
import net.minecraft.item.Item
|
||||||
|
import net.minecraft.util.EnumFacing
|
||||||
|
import net.minecraft.util.EnumHand
|
||||||
|
import net.minecraft.util.math.BlockPos
|
||||||
import net.minecraft.world.World
|
import net.minecraft.world.World
|
||||||
|
|
||||||
abstract class NFBlock(
|
abstract class NFBlock(
|
||||||
@@ -13,6 +18,7 @@ abstract class NFBlock(
|
|||||||
val collidable: Boolean = true,
|
val collidable: Boolean = true,
|
||||||
val tickRate: Int = 10,
|
val tickRate: Int = 10,
|
||||||
val hasCustomModel: Boolean = true,
|
val hasCustomModel: Boolean = true,
|
||||||
|
val onClick: (ClickParameters) -> Boolean = { false },
|
||||||
material: Material,
|
material: Material,
|
||||||
hardness: Float = 1.0F,
|
hardness: Float = 1.0F,
|
||||||
resistance: Float = 1.0F,
|
resistance: Float = 1.0F,
|
||||||
@@ -45,7 +51,25 @@ abstract class NFBlock(
|
|||||||
return tickRate
|
return tickRate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onBlockActivated(world: World, pos: BlockPos, state: IBlockState, playerIn: EntityPlayer, hand: EnumHand, sode: EnumFacing, x: Float, y: Float, z: Float): Boolean {
|
||||||
|
if (world.isRemote) return true
|
||||||
|
|
||||||
|
return onClick(ClickParameters(world, pos, state, playerIn, hand, sode, x, y, z))
|
||||||
|
}
|
||||||
|
|
||||||
fun registerModels() {
|
fun registerModels() {
|
||||||
registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory")
|
registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ClickParameters(
|
||||||
|
val world: World,
|
||||||
|
val pos: BlockPos,
|
||||||
|
val state: IBlockState,
|
||||||
|
val player: EntityPlayer,
|
||||||
|
val hand: EnumHand,
|
||||||
|
val sode: EnumFacing,
|
||||||
|
val x: Float,
|
||||||
|
val y: Float,
|
||||||
|
val z: Float
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ package de.wulkanat.www.new_frontiers.abstract_helpers
|
|||||||
import de.wulkanat.www.new_frontiers.NewFrontiers
|
import de.wulkanat.www.new_frontiers.NewFrontiers
|
||||||
import de.wulkanat.www.new_frontiers.proxy.registerItemRenderer
|
import de.wulkanat.www.new_frontiers.proxy.registerItemRenderer
|
||||||
import net.minecraft.creativetab.CreativeTabs
|
import net.minecraft.creativetab.CreativeTabs
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
import net.minecraft.item.Item
|
import net.minecraft.item.Item
|
||||||
|
import net.minecraft.item.ItemStack
|
||||||
|
import net.minecraft.util.ActionResult
|
||||||
|
import net.minecraft.util.EnumHand
|
||||||
|
import net.minecraft.world.World
|
||||||
|
|
||||||
abstract class NFItem(
|
abstract class NFItem(
|
||||||
name: String,
|
name: String,
|
||||||
|
|||||||
@@ -2,11 +2,22 @@ package de.wulkanat.www.new_frontiers.blocks
|
|||||||
|
|
||||||
import de.wulkanat.www.new_frontiers.abstract_helpers.NFBlock
|
import de.wulkanat.www.new_frontiers.abstract_helpers.NFBlock
|
||||||
import net.minecraft.block.material.Material
|
import net.minecraft.block.material.Material
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP
|
||||||
|
|
||||||
class BlockSpaceTeleporter : NFBlock(
|
class BlockSpaceTeleporter : NFBlock(
|
||||||
material = Material.GROUND,
|
material = Material.GROUND,
|
||||||
hardness = 1.5F,
|
hardness = 1.5F,
|
||||||
resistance = 2.5F,
|
resistance = 2.5F,
|
||||||
lightLevel = 15,
|
lightLevel = 15,
|
||||||
name = "space_teleporter"
|
name = "space_teleporter",
|
||||||
|
|
||||||
|
onClick = {
|
||||||
|
if (it.player is EntityPlayerMP) {
|
||||||
|
it.player.changeDimension(2)
|
||||||
|
it.player.setPositionAndUpdate(0.0, 0.0, 0.0)
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user