Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantum64 committed Dec 21, 2019
1 parent 3074ec5 commit 2212e67
Show file tree
Hide file tree
Showing 46 changed files with 1,418 additions and 153 deletions.
11 changes: 10 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ buildscript {
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath "org.jetbrains.kotlin:kotlin-serialization:1.3.61"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
}
}

plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.61"
id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.60'
id 'com.github.johnrengelman.shadow' version '4.0.4'
//id "net.ltgt.apt" version "0.21"
//id "net.ltgt.apt-idea" version "0.21"
}

apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

Expand All @@ -28,6 +29,12 @@ archivesBaseName = 'stars'

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}

minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
Expand Down Expand Up @@ -101,6 +108,7 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/dependency_management.html

compile "org.jetbrains.kotlin:kotlin-stdlib"
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0"

// Dev environment
compileOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.26:api")
Expand Down Expand Up @@ -128,6 +136,7 @@ shadowJar {
}

relocate('kotlin', 'co.q64.library.kotlin')
relocate('kotlinx', 'co.q64.library.kotlinx')
}

jar.dependsOn 'shadowJar'
Expand Down
9 changes: 7 additions & 2 deletions src/main/kotlin/co/q64/stars/block/BaseBlock.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package co.q64.stars.block

import co.q64.stars.id
import net.minecraft.block.Block
import net.minecraft.block.SoundType
import net.minecraft.block.material.Material

abstract class BaseBlock(id: String, properties: Properties = Properties.create(Material.IRON)) : Block(properties) {
val earth = Block.Properties.create(Material.EARTH).sound(SoundType.GROUND).hardnessAndResistance(0f, 0f)
val hard = Block.Properties.create(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(-1f, 3600000f)

abstract class BaseBlock(blockId: String, properties: Properties = Properties.create(Material.IRON)) : Block(properties) {
init {
setRegistryName(id)
id = blockId
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/kotlin/co/q64/stars/block/DarknessBlock.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package co.q64.stars.block

import net.minecraft.state.BooleanProperty

object DarknessBlock : BaseBlock("darkness", hard) {
val active: BooleanProperty = BooleanProperty.create("active")
}
2 changes: 0 additions & 2 deletions src/main/kotlin/co/q64/stars/block/DecayingBlock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import net.minecraft.tileentity.TileEntity
import net.minecraft.util.BlockRenderLayer
import net.minecraft.world.IBlockReader

private val earth = Block.Properties.create(Material.EARTH).sound(SoundType.GROUND).hardnessAndResistance(0f, 0f)

object DecayingBlock : BaseBlock("decaying", earth) {
override fun getRenderLayer() = BlockRenderLayer.CUTOUT
override fun hasTileEntity(state: BlockState) = true
Expand Down
7 changes: 0 additions & 7 deletions src/main/kotlin/co/q64/stars/block/FormedBlocks.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package co.q64.stars.block

import net.minecraft.block.Block
import net.minecraft.block.SoundType
import net.minecraft.block.material.Material

private val earth = Block.Properties.create(Material.EARTH).sound(SoundType.GROUND).hardnessAndResistance(0f, 0f)
private val hard = Block.Properties.create(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(-1f, 3600000f)

sealed class FormedBlock(id: String, properties: Properties = earth) : BaseBlock(id, properties)
object BlueFormedBlock : FormedBlock("blue_formed")
object BrownFormedBlock : FormedBlock("brown_formed")
Expand Down
16 changes: 16 additions & 0 deletions src/main/kotlin/co/q64/stars/block/GatewayBlock.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package co.q64.stars.block

import co.q64.stars.type.Level
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.state.BooleanProperty
import net.minecraft.state.EnumProperty
import net.minecraft.state.StateContainer

object GatewayBlock : BaseBlock("gateway", hard) {
val type = EnumProperty.create("type", Level::class.java)
val complete = BooleanProperty.create("complete")

override fun fillStateContainer(builder: StateContainer.Builder<Block, BlockState>) =
super.fillStateContainer(builder.add(type).add(complete))
}
3 changes: 0 additions & 3 deletions src/main/kotlin/co/q64/stars/block/SeedBlocks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import net.minecraft.tileentity.TileEntity
import net.minecraft.util.BlockRenderLayer
import net.minecraft.world.IBlockReader

private val earth = Block.Properties.create(Material.EARTH).sound(SoundType.GROUND).hardnessAndResistance(0f, 0f)
private val hard = Block.Properties.create(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(-1f, 3600000f)

sealed class BaseSeedBlock(id: String, properties: Properties = earth) : BaseBlock(id, properties) {
override fun getRenderLayer() = BlockRenderLayer.CUTOUT
override fun hasTileEntity(state: BlockState) = true
Expand Down
12 changes: 11 additions & 1 deletion src/main/kotlin/co/q64/stars/block/StarsBlocks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ val blocks: List<Block> by lazy {
BrownFormedBlock,
CyanFormedBlock,
GreenFormedBlock,
GreenFruitBlock,
OrangeFormedBlock,
PinkFormedBlock,
PurpleFormedBlock,
Expand All @@ -24,10 +25,19 @@ val blocks: List<Block> by lazy {
BrownFormedBlockHard,
CyanFormedBlockHard,
GreenFormedBlockHard,
GreenFruitBlockHard,
OrangeFormedBlockHard,
PurpleFormedBlockHard,
RedFormedBlockHard,
RedPrimedBlockHard,
YellowFormedBlockHard
YellowFormedBlockHard,

DecayBlock,
DecaySolidBlock,
AirDecayBlock,
SpecialDecayBlock,
SpecialDecaySolidBlock,
DarknessBlock,
GatewayBlock
)
}
36 changes: 24 additions & 12 deletions src/main/kotlin/co/q64/stars/capability/Gardener.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
@file:UseSerializers(BlockPosSerializer::class, ResourceLocationSerializer::class, SoundEventSerializer::class)

package co.q64.stars.capability

import co.q64.stars.type.FleetingStage
import co.q64.stars.type.FormingBlockType
import co.q64.stars.type.Level
import co.q64.stars.type.*
import co.q64.stars.util.BlockPosSerializer
import co.q64.stars.util.ResourceLocationSerializer
import co.q64.stars.util.SoundEventSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers
import net.minecraft.util.ResourceLocation
import net.minecraft.util.SoundEvent
import net.minecraft.util.math.BlockPos
import java.util.*

@Serializable
data class Gardener(
var seeds: Int = 0,
var keys: Int = 0,
Expand All @@ -23,13 +29,19 @@ data class Gardener(
var completeChallenge: Boolean = false,
var tutorialMode: Boolean = false,
var fleetingStage: FleetingStage = FleetingStage.NONE,
var level: Level,
var hubSpawn: BlockPos,
var hubEntryPosition: BlockPos,
var hubEntryDimension: ResourceLocation,
var tutorialEntryPosition: BlockPos,
var tutorialEntryDimension: ResourceLocation,
var nextSeeds: Deque<FormingBlockType> = ArrayDeque(),
var lastSeed: FormingBlockType = BlueFormingBlockType,
var level: Level = RedLevel, // TODO
var hubSpawn: BlockPos = BlockPos.ZERO,
var hubEntryPosition: BlockPos = BlockPos.ZERO,
var hubEntryDimension: ResourceLocation? = null,
var tutorialEntryPosition: BlockPos = BlockPos.ZERO,
var tutorialEntryDimension: ResourceLocation? = null,
var nextSeeds: MutableList<FormingBlockType> = mutableListOf(),
var lastSounds: Set<SoundEvent> = mutableSetOf(),
var lastPlayed: Map<SoundEvent, Long> = mutableMapOf()
)
var lastPlayed: MutableMap<SoundEvent, Long> = mutableMapOf()
) {
//fun getLastPlayed(event: SoundEvent) = lastPlayed.getOrDefault(event, 0L)
//fun updatePlayed(event: SoundEvent, time: Long) {
//lastPlayed[event] = time
// }
}
6 changes: 6 additions & 0 deletions src/main/kotlin/co/q64/stars/capability/Hub.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package co.q64.stars.capability

import kotlinx.serialization.Serializable

@Serializable
data class Hub(var next: Int = 0)
4 changes: 3 additions & 1 deletion src/main/kotlin/co/q64/stars/client/ClientLoader.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package co.q64.stars.client

fun startClient() {
import co.q64.stars.client.render.initializeRendering

fun startClient() {
initializeRendering()
}
10 changes: 10 additions & 0 deletions src/main/kotlin/co/q64/stars/client/render/RenderSetup.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package co.q64.stars.client.render

import co.q64.stars.client.render.tile.tesrs
import net.minecraftforge.fml.client.registry.ClientRegistry

fun initializeRendering() {
tesrs.forEach { (type, render) ->
ClientRegistry.bindTileEntitySpecialRenderer(type.java, render)
}
}
Loading

0 comments on commit 2212e67

Please sign in to comment.