Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.the9grounds.aeadditions.api

import appeng.api.stacks.AEItemKey
import appeng.api.stacks.AEKey
import appeng.api.stacks.AEKeyType
import appeng.api.storage.cells.IBasicCellItem
import appeng.api.storage.cells.ICellWorkbenchItem
import appeng.api.storage.cells.ISaveProvider
import appeng.me.cells.BasicCellHandler
import appeng.util.ConfigInventory
import com.google.common.base.Preconditions
import com.the9grounds.aeadditions.me.storage.ExtendedDiskCellHandler
import io.github.projectet.ae2things.storage.DISKCellHandler
import net.minecraft.network.chat.Component
import net.minecraft.world.item.ItemStack

interface IAEAdditionsDiskCell : ICellWorkbenchItem {
open fun getKeyType(): AEKeyType?

open fun getBytes(var1: ItemStack?): Int

open fun isBlackListed(cellItem: ItemStack?, requestedAddition: AEKey): Boolean {
return if ((requestedAddition as AEItemKey).item is IBasicCellItem) {
BasicCellHandler.INSTANCE.getCellInventory(
(requestedAddition as AEItemKey).toStack(),
null as ISaveProvider?
)!!
.usedBytes > 0L
} else {
false
}
}

fun storableInStorageCell(): Boolean {
return false
}

fun isStorageCell(i: ItemStack?): Boolean {
return true
}

open fun getIdleDrain(): Double

override fun getConfigInventory(var1: ItemStack?): ConfigInventory?

fun addCellInformationToTooltip(`is`: ItemStack, lines: MutableList<Component?>) {
Preconditions.checkArgument(`is`.item === this)
ExtendedDiskCellHandler.addCellInformationToTooltip(`is`, lines)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppEng {
StorageCells.addCellHandler(AEAdditionsCellHandler)
StorageCells.addCellHandler(SuperCellHandler)
if (Mods.AE2THINGS.isEnabled) {
StorageCells.addCellHandler(ExtendedDiskCellHandler())
StorageCells.addCellHandler(ExtendedDiskCellHandler)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import appeng.hooks.AEToolItem
import appeng.items.contents.CellConfig
import appeng.util.ConfigInventory
import appeng.util.InteractionUtil
import com.the9grounds.aeadditions.api.IAEAdditionsDiskCell
import io.github.projectet.ae2things.item.AETItems
import io.github.projectet.ae2things.storage.DISKCellHandler
import io.github.projectet.ae2things.storage.IDISKCellItem
Expand All @@ -32,12 +33,12 @@ import net.minecraft.world.level.Level
/**
* Need to overwrite as the original one puts it into the ae2things creative tab
*/
class DiskCell(properties: Item.Properties, private val _keyType: AEKeyType, val component: ItemLike, val housing: ItemLike?, val kilobytes: Int, val _idleDrain: Double) : DiskCellWithoutMod(properties), IDISKCellItem, AEToolItem {
class DiskCell(properties: Item.Properties, private val keyType: AEKeyType, val component: ItemLike, val housing: ItemLike?, val kilobytes: Int, val _idleDrain: Double) : DiskCellWithoutMod(properties), IAEAdditionsDiskCell, AEToolItem {
override fun getKeyType(): AEKeyType {
return _keyType
return keyType
}

override fun isBlackListed(cellItem: ItemStack?, requestedAddition: AEKey?): Boolean {
override fun isBlackListed(cellItem: ItemStack?, requestedAddition: AEKey): Boolean {
if (requestedAddition is AEItemKey) {
return super.isBlackListed(cellItem, requestedAddition)
}
Expand Down Expand Up @@ -132,6 +133,9 @@ class DiskCell(properties: Item.Properties, private val _keyType: AEKeyType, val
tooltip: MutableList<Component?>,
context: TooltipFlag?
) {
if (stack === null) {
return
}
tooltip.add(
Component.literal("Deep Item Storage disK - Storage for dummies").withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.ITALIC)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,49 @@
package com.the9grounds.aeadditions.me.storage

import appeng.api.config.IncludeExclude
import appeng.api.storage.cells.ICellHandler
import appeng.api.storage.cells.ISaveProvider
import appeng.core.localization.GuiText
import appeng.core.localization.Tooltips
import com.the9grounds.aeadditions.item.storage.DiskCell
import io.github.projectet.ae2things.storage.DISKCellHandler
import net.minecraft.ChatFormatting
import net.minecraft.network.chat.Component
import net.minecraft.world.item.ItemStack

class ExtendedDiskCellHandler : DISKCellHandler() {
object ExtendedDiskCellHandler : ICellHandler {
override fun isCell(`is`: ItemStack?): Boolean {
return `is`!!.item is DiskCell
}

override fun getCellInventory(`is`: ItemStack?, container: ISaveProvider?): ExtendedDiskCellInventory? {
if (`is` == null) return null
return ExtendedDiskCellInventory.createInventory(`is`, container)
}

fun addCellInformationToTooltip(stack: ItemStack, lines: MutableList<Component?>) {
val handler: ExtendedDiskCellInventory? = this.getCellInventory(stack, null as ISaveProvider?)
if (handler != null) {
if (handler.hasDiskUUID()) {
lines.add(
Component.literal("Disk UUID: ").withStyle(ChatFormatting.GRAY)
.append(Component.literal(handler.diskUUID.toString()).withStyle(ChatFormatting.AQUA))
)
lines.add(Tooltips.bytesUsed(handler.usedSpace, handler.totalBytes))
}

if (handler.isPreformatted) {
val list =
(if (handler.partitionListMode == IncludeExclude.WHITELIST) GuiText.Included else GuiText.Excluded).text()
if (handler.isFuzzy) {
lines.add(
GuiText.Partitioned.withSuffix(" - ").append(list).append(" ").append(GuiText.Fuzzy.text())
)
} else {
lines.add(
GuiText.Partitioned.withSuffix(" - ").append(list).append(" ").append(GuiText.Precise.text())
)
}
}
}
}
}
Loading
Loading