Browse Source

Update cardinal stuff

tags/v0.1.1-mc1.14-fabric
Colin Reeder 1 year ago
parent
commit
e127f6b635
4 changed files with 28 additions and 16 deletions
  1. +4
    -3
      build.gradle
  2. +1
    -1
      src/main/kotlin/click/vpzom/mods/japta2/block/util/BlockJPT.kt
  3. +10
    -4
      src/main/kotlin/click/vpzom/mods/japta2/block/util/EnergyHelper.kt
  4. +13
    -8
      src/main/kotlin/click/vpzom/mods/japta2/block/util/TileEntityJPTBase.kt

+ 4
- 3
build.gradle View File

@@ -26,11 +26,12 @@ dependencies {

modCompile (group: "net.fabricmc", name: "fabric-language-kotlin", version: "1.3.40+build.1")

modCompile "com.github.NerdHubMC:Cardinal-Components-API:1.2.1-SNAPSHOT"
modCompile "com.github.NerdHubMC:Cardinal-Energy:1.2.0"
modCompile "com.github.NerdHubMC.Cardinal-Components-API:cardinal-components-base:2.0.1-SNAPSHOT"
modCompile "com.github.NerdHubMC.Cardinal-Components-API:cardinal-components-block:2.0.1-SNAPSHOT"
modCompile "com.github.NerdHubMC:Cardinal-Energy:1.3.0"
}

version = "0.1.0"
version = "0.1.1"
archivesBaseName = "JAPTA2-mc1.14-fabric"

processResources {


+ 1
- 1
src/main/kotlin/click/vpzom/mods/japta2/block/util/BlockJPT.kt View File

@@ -1,7 +1,7 @@
package click.vpzom.mods.japta2.block.util

import nerdhub.cardinal.components.api.BlockComponentProvider
import nerdhub.cardinal.components.api.ComponentType
import nerdhub.cardinal.components.api.component.BlockComponentProvider
import nerdhub.cardinal.components.api.component.Component
import nerdhub.cardinalenergy.DefaultTypes
import nerdhub.cardinalenergy.api.IEnergyHandler


+ 10
- 4
src/main/kotlin/click/vpzom/mods/japta2/block/util/EnergyHelper.kt View File

@@ -2,7 +2,7 @@ package click.vpzom.mods.japta2.block.util

import click.vpzom.mods.japta2.block.util.TileEntityJPTBase
import click.vpzom.mods.japta2.item.util.ItemJPT
import nerdhub.cardinal.components.api.BlockComponentProvider
import nerdhub.cardinal.components.api.component.BlockComponentProvider
import nerdhub.cardinalenergy.DefaultTypes
import net.minecraft.item.ItemStack
import net.minecraft.util.math.Direction
@@ -20,7 +20,9 @@ object EnergyHelper {
if(block is BlockComponentProvider) {
if(block.hasComponent(world, pos, DefaultTypes.CARDINAL_ENERGY, side)) {
val storage = block.getComponent(world, pos, DefaultTypes.CARDINAL_ENERGY, side)
return Pair(storage.energyStored.toLong(), storage.capacity.toLong())
if(storage != null) {
return Pair(storage.energyStored.toLong(), storage.capacity.toLong())
}
}
}

@@ -37,7 +39,9 @@ object EnergyHelper {
if(block is BlockComponentProvider) {
if(block.hasComponent(world, pos, DefaultTypes.CARDINAL_ENERGY, side)) {
val storage = block.getComponent(world, pos, DefaultTypes.CARDINAL_ENERGY, side)
return storage.extractEnergy(maxExtract.toInt()).toLong()
if(storage != null) {
return storage.extractEnergy(maxExtract.toInt()).toLong()
}
}
}

@@ -54,7 +58,9 @@ object EnergyHelper {
if(block is BlockComponentProvider) {
if(block.hasComponent(world, pos, DefaultTypes.CARDINAL_ENERGY, side)) {
val storage = block.getComponent(world, pos, DefaultTypes.CARDINAL_ENERGY, side)
return storage.receiveEnergy(maxInsert.toInt()).toLong()
if(storage != null) {
return storage.receiveEnergy(maxInsert.toInt()).toLong()
}
}
}



+ 13
- 8
src/main/kotlin/click/vpzom/mods/japta2/block/util/TileEntityJPTBase.kt View File

@@ -1,5 +1,6 @@
package click.vpzom.mods.japta2.block.util

import nerdhub.cardinal.components.api.component.extension.CloneableComponent;
import nerdhub.cardinalenergy.api.IEnergyHandler
import nerdhub.cardinalenergy.api.IEnergyStorage
import net.minecraft.block.entity.BlockEntity
@@ -16,10 +17,6 @@ abstract class TileEntityJPTBase(type: BlockEntityType<out TileEntityJPTBase>):
abstract fun attemptExtractEnergy(side: Direction?, maxExtract: Long, simulate: Boolean): Long

inner class CardinalAdapter(val side: Direction?): IEnergyHandler, IEnergyStorage {
override fun readEnergyFromTag(p0: CompoundTag?) {
throw UnsupportedOperationException()
}

override fun setCapacity(p0: Int) {
throw UnsupportedOperationException()
}
@@ -40,10 +37,6 @@ abstract class TileEntityJPTBase(type: BlockEntityType<out TileEntityJPTBase>):
return attemptExtractEnergy(side, p0.toLong(), false).toInt()
}

override fun writeEnergyToTag(p0: CompoundTag?): CompoundTag {
throw UnsupportedOperationException()
}

override fun setEnergyStored(p0: Int) {
throw UnsupportedOperationException()
}
@@ -61,5 +54,17 @@ abstract class TileEntityJPTBase(type: BlockEntityType<out TileEntityJPTBase>):
val amount = p0.toLong()
return attemptExtractEnergy(side, amount, true) >= amount
}

override fun newInstance(): CloneableComponent {
throw UnsupportedOperationException()
}

override fun toTag(p0: CompoundTag): CompoundTag {
throw UnsupportedOperationException()
}

override fun fromTag(p0: CompoundTag) {
throw UnsupportedOperationException()
}
}
}

Loading…
Cancel
Save