mirror of
https://github.com/Theaninova/new-frontiers.git
synced 2025-12-11 02:56:16 +00:00
Space Teleporter can teleport now.
This commit is contained in:
@@ -5,6 +5,7 @@ import de.wulkanat.www.new_frontiers.init.Items
|
||||
import de.wulkanat.www.new_frontiers.init.registerBiomes
|
||||
import de.wulkanat.www.new_frontiers.init.registerDimensions
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.client.main.Main
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemBlock
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent
|
||||
@@ -26,6 +27,9 @@ object NewFrontiers {
|
||||
const val MOD_NAME = "New Frontiers"
|
||||
const val VERSION = "1.0-SNAPSHOT"
|
||||
|
||||
@Mod.Instance
|
||||
lateinit var instance: Main
|
||||
|
||||
@Mod.EventHandler
|
||||
fun preinit(event: FMLPreInitializationEvent) {
|
||||
// TODO: register world generator
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
package de.wulkanat.www.new_frontiers.abstract_helpers
|
||||
|
||||
import net.minecraft.block.state.IBlockState
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.biome.Biome
|
||||
import net.minecraft.world.chunk.ChunkPrimer
|
||||
import net.minecraftforge.common.BiomeDictionary
|
||||
import net.minecraftforge.common.BiomeManager
|
||||
import net.minecraftforge.fml.relauncher.Side
|
||||
import net.minecraftforge.fml.relauncher.SideOnly
|
||||
import java.util.*
|
||||
|
||||
abstract class NFBiome(
|
||||
val name: String,
|
||||
@@ -21,7 +27,13 @@ abstract class NFBiome(
|
||||
spawnableCaveCreatureList: List<SpawnListEntry> = arrayListOf(),
|
||||
spawnableCreatureList: List<SpawnListEntry> = arrayListOf(),
|
||||
spawnableMonsterList: List<SpawnListEntry> = arrayListOf(),
|
||||
spawnableWaterCreatureList: List<SpawnListEntry> = arrayListOf()
|
||||
spawnableWaterCreatureList: List<SpawnListEntry> = arrayListOf(),
|
||||
|
||||
val decorate: (decorateParams: DecorateParams) -> Unit = {},
|
||||
val genTerrainBlocks: (genTerrainBlocksParams: GenTerrainBlocksParams) -> Unit = {},
|
||||
val skyColorByTemp: (currentTemperature: Float) -> Int = { 0x000000 },
|
||||
val grassColorAtPos: (pos: BlockPos) -> Int = { 0x000000 },
|
||||
val foliageColorAtPos: (pos: BlockPos) -> Int = { 0x000000 }
|
||||
) : Biome(setRainAndSnow(BiomeProperties(name)
|
||||
.setBaseHeight(baseHeight)
|
||||
.setHeightVariation(heightVariation)
|
||||
@@ -36,8 +48,6 @@ abstract class NFBiome(
|
||||
this.spawnableCreatureList = spawnableCreatureList
|
||||
this.spawnableMonsterList = spawnableMonsterList
|
||||
this.spawnableWaterCreatureList = spawnableWaterCreatureList
|
||||
|
||||
// TODO: decorator
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -50,4 +60,43 @@ abstract class NFBiome(
|
||||
return properties
|
||||
}
|
||||
}
|
||||
|
||||
override fun decorate(world: World, rand: Random, pos: BlockPos) {
|
||||
decorate(DecorateParams(world, rand, pos, this))
|
||||
}
|
||||
|
||||
override fun genTerrainBlocks(world: World, rand: Random, chunkPrimer: ChunkPrimer, x: Int, z: Int, noiseVal: Double) {
|
||||
genTerrainBlocks(GenTerrainBlocksParams(world, rand, chunkPrimer, x, z, noiseVal))
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override fun getSkyColorByTemp(temp: Float): Int {
|
||||
return skyColorByTemp(temp)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override fun getGrassColorAtPos(pos: BlockPos): Int {
|
||||
return grassColorAtPos(pos)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override fun getFoliageColorAtPos(pos: BlockPos): Int {
|
||||
return foliageColorAtPos(pos)
|
||||
}
|
||||
|
||||
class GenTerrainBlocksParams(
|
||||
val world: World,
|
||||
val rand: Random,
|
||||
val chunkPrimer: ChunkPrimer,
|
||||
val x: Int,
|
||||
val z: Int,
|
||||
val noiseVal: Double
|
||||
)
|
||||
|
||||
class DecorateParams(
|
||||
val world: World,
|
||||
val rand: Random,
|
||||
val pos: BlockPos,
|
||||
val biomeInstance: NFBiome
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@ package de.wulkanat.www.new_frontiers.abstract_helpers
|
||||
import de.wulkanat.www.new_frontiers.NewFrontiers
|
||||
import de.wulkanat.www.new_frontiers.proxy.registerItemRenderer
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.BlockHorizontal
|
||||
import net.minecraft.block.SoundType
|
||||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.block.properties.PropertyDirection
|
||||
import net.minecraft.block.state.IBlockState
|
||||
import net.minecraft.creativetab.CreativeTabs
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
@@ -19,14 +22,16 @@ abstract class NFBlock(
|
||||
val tickRate: Int = 10,
|
||||
val hasCustomModel: Boolean = true,
|
||||
val onClick: (ClickParameters) -> Boolean = { false },
|
||||
val facingDirections: PropertyDirection? = null,
|
||||
material: Material,
|
||||
hardness: Float = 1.0F,
|
||||
resistance: Float = 1.0F,
|
||||
lightLevel: Int = 0,
|
||||
lightOpacity: Int = 0,
|
||||
soundType: SoundType = SoundType.METAL,
|
||||
name: String,
|
||||
creativeTab: CreativeTabs = de.wulkanat.www.new_frontiers.init.CreativeTabs.NF_BLOCKS.value
|
||||
) : Block(material) {
|
||||
) : Block(material) {
|
||||
init {
|
||||
// The Java code is a lot of hot garbage, so most of this is copied from the setter functions
|
||||
blockResistance = resistance * 3.0f
|
||||
@@ -41,6 +46,27 @@ abstract class NFBlock(
|
||||
this.lightValue = lightLevel
|
||||
this.lightOpacity = lightOpacity
|
||||
this.creativeTab = creativeTab
|
||||
|
||||
this.blockSoundType = soundType
|
||||
}
|
||||
|
||||
override fun onBlockAdded(world: World, pos: BlockPos, state: IBlockState) {
|
||||
if (this.facingDirections != null && !world.isRemote) {
|
||||
val north = world.getBlockState(pos.north())
|
||||
val south = world.getBlockState(pos.south())
|
||||
val west = world.getBlockState(pos.west())
|
||||
val east = world.getBlockState(pos.east())
|
||||
var face = state.getValue(facingDirections) as EnumFacing
|
||||
|
||||
when {
|
||||
face == EnumFacing.NORTH && north.isFullBlock && south.isFullBlock -> face = EnumFacing.SOUTH
|
||||
face == EnumFacing.SOUTH && north.isFullBlock && south.isFullBlock -> face = EnumFacing.NORTH
|
||||
face == EnumFacing.EAST && west.isFullBlock && east.isFullBlock -> face = EnumFacing.WEST
|
||||
face == EnumFacing.WEST && west.isFullBlock && east.isFullBlock -> face = EnumFacing.EAST
|
||||
}
|
||||
|
||||
world.setBlockState(pos, state.withProperty(facingDirections, face), 2)
|
||||
}
|
||||
}
|
||||
|
||||
override fun isCollidable(): Boolean {
|
||||
@@ -51,10 +77,10 @@ abstract class NFBlock(
|
||||
return tickRate
|
||||
}
|
||||
|
||||
override fun onBlockActivated(world: World, pos: BlockPos, state: IBlockState, playerIn: EntityPlayer, hand: EnumHand, sode: EnumFacing, x: Float, y: Float, z: Float): Boolean {
|
||||
override fun onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, face: 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))
|
||||
return onClick(ClickParameters(world, pos, state, player, hand, face, x, y, z))
|
||||
}
|
||||
|
||||
fun registerModels() {
|
||||
@@ -67,7 +93,7 @@ abstract class NFBlock(
|
||||
val state: IBlockState,
|
||||
val player: EntityPlayer,
|
||||
val hand: EnumHand,
|
||||
val sode: EnumFacing,
|
||||
val face: EnumFacing,
|
||||
val x: Float,
|
||||
val y: Float,
|
||||
val z: Float
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package de.wulkanat.www.new_frontiers.abstract_helpers
|
||||
|
||||
interface NFStatefulBlock {
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class BlockSpaceTeleporter : NFBlock(
|
||||
|
||||
onClick = {
|
||||
if (it.player is EntityPlayerMP) {
|
||||
it.player.changeDimension(2)
|
||||
it.player.changeDimension(40000)
|
||||
it.player.setPositionAndUpdate(0.0, 0.0, 0.0)
|
||||
true
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package de.wulkanat.www.new_frontiers.blocks
|
||||
|
||||
import de.wulkanat.www.new_frontiers.NewFrontiers
|
||||
import de.wulkanat.www.new_frontiers.abstract_helpers.NFBlock
|
||||
import net.minecraft.block.BlockHorizontal
|
||||
import net.minecraft.block.material.Material
|
||||
|
||||
class SpaceshipController : NFBlock(
|
||||
name = "spaceship_controller",
|
||||
material = Material.GROUND,
|
||||
facingDirections = BlockHorizontal.FACING,
|
||||
|
||||
onClick = {
|
||||
it.player.openGui(NewFrontiers.instance, 0, it.world, it.pos.x, it.pos.y, it.pos.z)
|
||||
true
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
package de.wulkanat.www.new_frontiers.dimensions
|
||||
|
||||
import de.wulkanat.www.new_frontiers.abstract_helpers.NFDimension
|
||||
import net.minecraft.world.biome.Biome
|
||||
import net.minecraft.world.biome.BiomeProviderSingle
|
||||
import net.minecraft.world.gen.ChunkGeneratorOverworld
|
||||
import net.minecraft.world.gen.IChunkGenerator
|
||||
|
||||
class DimensionBody(id: Int, name: String) : NFDimension(
|
||||
name = "planetary_body",
|
||||
id = 40001,
|
||||
canRespawn = true,
|
||||
surfaceDimension = true,
|
||||
biomeProvider = BiomeProviderSingle(Biome.getBiomeForId(29) as Biome)
|
||||
) {
|
||||
override fun createChunkGenerator(): IChunkGenerator {
|
||||
return ChunkGeneratorOverworld(this.world, 19203, false, name)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.world.gen.IChunkGenerator
|
||||
|
||||
class DimensionSpace : NFDimension(
|
||||
name = "space",
|
||||
id = 2,
|
||||
id = 40000,
|
||||
canRespawn = true,
|
||||
surfaceDimension = false,
|
||||
biomeProvider = BiomeProviderSingle(Biomes.DEEP_SPACE.value)
|
||||
|
||||
@@ -3,8 +3,10 @@ package de.wulkanat.www.new_frontiers.init
|
||||
import de.wulkanat.www.new_frontiers.blocks.BlockFTLDrive
|
||||
import de.wulkanat.www.new_frontiers.abstract_helpers.NFBlock
|
||||
import de.wulkanat.www.new_frontiers.blocks.BlockSpaceTeleporter
|
||||
import de.wulkanat.www.new_frontiers.blocks.SpaceshipController
|
||||
|
||||
enum class Blocks(val value: NFBlock) {
|
||||
SPACE_TELEPORTER(BlockSpaceTeleporter()),
|
||||
FTL_DRIVE(BlockFTLDrive());
|
||||
FTL_DRIVE(BlockFTLDrive()),
|
||||
SPACESHIP_CONTROLLER(SpaceshipController())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:block/cube_all",
|
||||
"textures": {
|
||||
"all": "new_frontiers:blocks/space_teleporter"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "new_frontiers:block/spaceship_controller"
|
||||
}
|
||||
Reference in New Issue
Block a user