Add dev chest
This commit is contained in:
parent
a86d30dae4
commit
22cac9d7a0
@ -405,6 +405,8 @@ private fun blocks(provider: MatteryLanguageProvider) {
|
||||
add(MBlocks.ESSENCE_STORAGE, "desc", "Allows to store and retrieve experience levels")
|
||||
add(MBlocks.MATTER_RECONSTRUCTOR, "Matter Reconstructor")
|
||||
add(MBlocks.MATTER_RECONSTRUCTOR, "desc", "Repairs tools using matter")
|
||||
add(MBlocks.DEV_CHEST, "Dev Chest")
|
||||
add(MBlocks.DEV_CHEST, "desc", "Contains all items present in game")
|
||||
|
||||
add(MBlocks.FLUID_TANK, "Fluid Tank")
|
||||
add(MBlocks.FLUID_TANK, "named", "Fluid Tank (%s)")
|
||||
|
@ -408,6 +408,8 @@ private fun blocks(provider: MatteryLanguageProvider) {
|
||||
add(MBlocks.ESSENCE_STORAGE, "desc", "Позволяет хранить очки опыта")
|
||||
add(MBlocks.MATTER_RECONSTRUCTOR, "Материальный реконструктор")
|
||||
add(MBlocks.MATTER_RECONSTRUCTOR, "desc", "Чинит инструменты используя материю")
|
||||
add(MBlocks.DEV_CHEST, "Сундук разработчика")
|
||||
add(MBlocks.DEV_CHEST, "desc", "Хранит все предметы, которые есть в игре")
|
||||
|
||||
add(MBlocks.FLUID_TANK, "Жидкостный бак")
|
||||
add(MBlocks.FLUID_TANK, "named", "Жидкостный бак (%s)")
|
||||
|
@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.android.AndroidResearchManager;
|
||||
import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature;
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity;
|
||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.ExplosionQueue;
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity;
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability;
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability;
|
||||
import ru.dbotthepony.mc.otm.capability.drive.DrivePool;
|
||||
@ -198,6 +199,8 @@ public final class OverdriveThatMatters {
|
||||
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, ExplosiveHammerItem.Companion::onLeftClickBlock);
|
||||
|
||||
EVENT_BUS.addListener(EventPriority.NORMAL, DevChestBlockEntity.Companion::mappingsChanged);
|
||||
|
||||
MatteryPlayerNetworkChannel.INSTANCE.register();
|
||||
MenuNetworkChannel.INSTANCE.register();
|
||||
WeaponNetworkChannel.INSTANCE.register();
|
||||
|
@ -0,0 +1,14 @@
|
||||
package ru.dbotthepony.mc.otm.block.decorative
|
||||
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.level.block.EntityBlock
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity
|
||||
|
||||
class DevChestBlock : RotatableMatteryBlock(Properties.of().destroyTime(-1f).explosionResistance(360000f)), EntityBlock {
|
||||
override fun newBlockEntity(p_153215_: BlockPos, p_153216_: BlockState): BlockEntity {
|
||||
return DevChestBlockEntity(p_153215_, p_153216_)
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package ru.dbotthepony.mc.otm.block.entity.decorative
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities
|
||||
import net.minecraftforge.items.IItemHandler
|
||||
import net.minecraftforge.registries.ForgeRegistries
|
||||
import net.minecraftforge.registries.IdMappingEvent
|
||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||
import ru.dbotthepony.mc.otm.core.getID
|
||||
import ru.dbotthepony.mc.otm.registry.MBlockEntities
|
||||
|
||||
class DevChestBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryBlockEntity(MBlockEntities.DEV_CHEST, blockPos, blockState), IItemHandler {
|
||||
override fun getSlots(): Int {
|
||||
return cache().size
|
||||
}
|
||||
|
||||
override fun getStackInSlot(slot: Int): ItemStack {
|
||||
return cache().getOrNull(slot) ?: ItemStack.EMPTY
|
||||
}
|
||||
|
||||
override fun insertItem(slot: Int, stack: ItemStack, simulate: Boolean): ItemStack {
|
||||
return stack
|
||||
}
|
||||
|
||||
override fun extractItem(slot: Int, amount: Int, simulate: Boolean): ItemStack {
|
||||
return getStackInSlot(slot).copyWithCount(amount)
|
||||
}
|
||||
|
||||
override fun getSlotLimit(slot: Int): Int {
|
||||
return getStackInSlot(slot).maxStackSize
|
||||
}
|
||||
|
||||
override fun isItemValid(slot: Int, stack: ItemStack): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
init {
|
||||
exposeGlobally(ForgeCapabilities.ITEM_HANDLER, this)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val cache = ArrayList<ItemStack>()
|
||||
|
||||
@Suppress("SameReturnValue")
|
||||
private fun cache(): List<ItemStack> {
|
||||
if (cache.isNotEmpty()) {
|
||||
return cache
|
||||
}
|
||||
|
||||
val sorted = Int2ObjectAVLTreeMap<ItemStack>()
|
||||
|
||||
for (item in ForgeRegistries.ITEMS.values) {
|
||||
check(sorted.put(ForgeRegistries.ITEMS.getID(item), ItemStack(item, 1).also { it.count = item.getMaxStackSize(it) }) == null)
|
||||
}
|
||||
|
||||
cache.addAll(sorted.values)
|
||||
return cache
|
||||
}
|
||||
|
||||
fun mappingsChanged(event: IdMappingEvent) {
|
||||
cache.clear()
|
||||
}
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import ru.dbotthepony.mc.otm.block.entity.blackhole.BlackHoleBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntityExplosionDebugger
|
||||
import ru.dbotthepony.mc.otm.block.entity.blackhole.BlockEntitySphereDebugger
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.CargoCrateBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.HoloSignBlockEntity
|
||||
import ru.dbotthepony.mc.otm.block.entity.decorative.InfiniteWaterSourceBlockEntity
|
||||
@ -60,6 +61,7 @@ object MBlockEntities {
|
||||
val ANDROID_CHARGER_MIDDLE: BlockEntityType<AndroidChargerMiddleBlockEntity> by registry.register(MNames.ANDROID_CHARGER + "_middle") { BlockEntityType.Builder.of(::AndroidChargerMiddleBlockEntity, MBlocks.ANDROID_CHARGER).build(null) }
|
||||
val ANDROID_CHARGER_TOP: BlockEntityType<AndroidChargerTopBlockEntity> by registry.register(MNames.ANDROID_CHARGER + "_top") { BlockEntityType.Builder.of(::AndroidChargerTopBlockEntity, MBlocks.ANDROID_CHARGER).build(null) }
|
||||
val INFINITE_WATER_SOURCE: BlockEntityType<InfiniteWaterSourceBlockEntity> by registry.register(MNames.INFINITE_WATER_SOURCE) { BlockEntityType.Builder.of(::InfiniteWaterSourceBlockEntity, MBlocks.INFINITE_WATER_SOURCE).build(null) }
|
||||
val DEV_CHEST: BlockEntityType<DevChestBlockEntity> by registry.register(MNames.DEV_CHEST) { BlockEntityType.Builder.of(::DevChestBlockEntity, MBlocks.DEV_CHEST).build(null) }
|
||||
|
||||
val POWERED_FURNACE: BlockEntityType<PoweredFurnaceBlockEntity> by registry.register(MNames.POWERED_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_FURNACE).build(null) }
|
||||
val POWERED_BLAST_FURNACE: BlockEntityType<PoweredFurnaceBlockEntity> by registry.register(MNames.POWERED_BLAST_FURNACE) { BlockEntityType.Builder.of({ a, b -> MBlocks.POWERED_BLAST_FURNACE.newBlockEntity(a, b) }, MBlocks.POWERED_BLAST_FURNACE).build(null) }
|
||||
|
@ -39,6 +39,7 @@ import ru.dbotthepony.mc.otm.block.MatterCableBlock
|
||||
import ru.dbotthepony.mc.otm.block.tech.PhantomAttractorBlock
|
||||
import ru.dbotthepony.mc.otm.block.tech.PlatePressBlock
|
||||
import ru.dbotthepony.mc.otm.block.StorageCableBlock
|
||||
import ru.dbotthepony.mc.otm.block.decorative.DevChestBlock
|
||||
import ru.dbotthepony.mc.otm.block.decorative.EngineBlock
|
||||
import ru.dbotthepony.mc.otm.block.decorative.FluidTankBlock
|
||||
import ru.dbotthepony.mc.otm.block.decorative.HoloSignBlock
|
||||
@ -119,6 +120,7 @@ object MBlocks {
|
||||
|
||||
val PHANTOM_ATTRACTOR: Block by registry.register(MNames.PHANTOM_ATTRACTOR) { PhantomAttractorBlock() }
|
||||
val FLUID_TANK: FluidTankBlock by registry.register(MNames.FLUID_TANK) { FluidTankBlock() }
|
||||
val DEV_CHEST: DevChestBlock by registry.register(MNames.DEV_CHEST) { DevChestBlock() }
|
||||
|
||||
val TRITANIUM_ORE: Block by registry.register(MNames.TRITANIUM_ORE) { DropExperienceBlock(
|
||||
BlockBehaviour.Properties.of()
|
||||
|
@ -133,6 +133,7 @@ private fun addMainCreativeTabItems(consumer: CreativeModeTab.Output) {
|
||||
accept(MItems.CreativeUpgrades.LIST)
|
||||
|
||||
accept(MRegistry.CARGO_CRATES.item)
|
||||
accept(MItems.DEV_CHEST)
|
||||
accept(MItems.HOLO_SIGN)
|
||||
|
||||
base(MItems.TRITANIUM_DOOR)
|
||||
|
@ -142,6 +142,15 @@ object MItems {
|
||||
}
|
||||
}
|
||||
|
||||
val DEV_CHEST: BlockItem by registry.register(MNames.DEV_CHEST) {
|
||||
object : BlockItem(MBlocks.DEV_CHEST, DEFAULT_PROPERTIES) {
|
||||
override fun appendHoverText(p_40572_: ItemStack, p_40573_: Level?, p_40574_: MutableList<Component>, p_40575_: TooltipFlag) {
|
||||
super.appendHoverText(p_40572_, p_40573_, p_40574_, p_40575_)
|
||||
p_40574_.add(TranslatableComponent("$descriptionId.desc").withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val MACHINES = SupplierList(
|
||||
::ANDROID_STATION, ::ANDROID_CHARGER, ::BATTERY_BANK, ::MATTER_DECOMPOSER, ::MATTER_CAPACITOR_BANK, ::MATTER_CABLE, ::PATTERN_STORAGE,
|
||||
::MATTER_SCANNER, ::MATTER_PANEL, ::MATTER_REPLICATOR, ::MATTER_BOTTLER, ::ENERGY_COUNTER, ::CHEMICAL_GENERATOR,
|
||||
|
@ -14,6 +14,7 @@ object MNames {
|
||||
const val FLUID_TANK = "fluid_tank"
|
||||
const val ANDROID_CHARGER = "android_charger"
|
||||
const val INFINITE_WATER_SOURCE = "infinite_water_source"
|
||||
const val DEV_CHEST = "dev_chest"
|
||||
|
||||
// blocks
|
||||
const val ANDROID_STATION = "android_station"
|
||||
|
Loading…
Reference in New Issue
Block a user