Merge remote-tracking branch 'origin/1.21' into 1.21
This commit is contained in:
commit
46d04a4217
@ -10,6 +10,7 @@ import net.minecraft.world.item.Items
|
|||||||
import net.minecraft.world.item.crafting.Ingredient
|
import net.minecraft.world.item.crafting.Ingredient
|
||||||
import net.neoforged.neoforge.common.Tags
|
import net.neoforged.neoforge.common.Tags
|
||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||||
|
import ru.dbotthepony.mc.otm.config.CablesConfig
|
||||||
import ru.dbotthepony.mc.otm.registry.MBlocks
|
import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||||
import ru.dbotthepony.mc.otm.registry.MItemTags
|
import ru.dbotthepony.mc.otm.registry.MItemTags
|
||||||
import ru.dbotthepony.mc.otm.registry.MItems
|
import ru.dbotthepony.mc.otm.registry.MItems
|
||||||
@ -460,4 +461,36 @@ fun addCraftingTableRecipes(consumer: RecipeOutput) {
|
|||||||
.row(MItemTags.IRON_PLATES, MItemTags.CRAFTING_TABLES, MItemTags.IRON_PLATES)
|
.row(MItemTags.IRON_PLATES, MItemTags.CRAFTING_TABLES, MItemTags.IRON_PLATES)
|
||||||
.unlockedBy(Tags.Items.DYES)
|
.unlockedBy(Tags.Items.DYES)
|
||||||
.build(consumer)
|
.build(consumer)
|
||||||
|
|
||||||
|
MatteryRecipe(MItems.CHEST_UPGRADER, category = RecipeCategory.TOOLS)
|
||||||
|
.rowAC(Items.REDSTONE, Items.REDSTONE)
|
||||||
|
.row(MItemTags.TRITANIUM_PLATES, Items.ENDER_PEARL, MItemTags.TRITANIUM_PLATES)
|
||||||
|
.rowB(ItemTags.STONE_BUTTONS)
|
||||||
|
.unlockedBy(Tags.Items.CHESTS_WOODEN)
|
||||||
|
.unlockedBy(Tags.Items.BARRELS_WOODEN)
|
||||||
|
.unlockedBy(MItemTags.CARGO_CRATES)
|
||||||
|
.build(consumer)
|
||||||
|
|
||||||
|
MatteryRecipe(MItems.ENERGY_CABLES[CablesConfig.E.CRUDE]!!.asItem(), category = machinesCategory, count = 8)
|
||||||
|
.row(MItemTags.IRON_PLATES, Items.REDSTONE, MItemTags.IRON_PLATES)
|
||||||
|
.unlockedBy(Items.REDSTONE)
|
||||||
|
.build(consumer)
|
||||||
|
|
||||||
|
MatteryRecipe(MItems.ENERGY_CABLES[CablesConfig.E.REGULAR]!!.asItem(), category = machinesCategory, count = 16)
|
||||||
|
.row(MItemTags.IRON_PLATES, MItemTags.IRON_PLATES, MItemTags.IRON_PLATES)
|
||||||
|
.row(MItemTags.COPPER_WIRES, Items.REDSTONE, MItemTags.COPPER_WIRES)
|
||||||
|
.row(MItemTags.IRON_PLATES, MItemTags.IRON_PLATES, MItemTags.IRON_PLATES)
|
||||||
|
.build(consumer)
|
||||||
|
|
||||||
|
MatteryRecipe(MItems.ENERGY_CABLES[CablesConfig.E.ADVANCED]!!.asItem(), category = machinesCategory, count = 16)
|
||||||
|
.row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES)
|
||||||
|
.row(MItemTags.GOLD_WIRES, Items.REDSTONE, MItemTags.GOLD_WIRES)
|
||||||
|
.row(MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES, MItemTags.TRITANIUM_PLATES)
|
||||||
|
.build(consumer)
|
||||||
|
|
||||||
|
MatteryRecipe(MItems.ENERGY_CABLES[CablesConfig.E.SUPERCONDUCTOR]!!.asItem(), category = machinesCategory)
|
||||||
|
.row(MItemTags.REINFORCED_TRITANIUM_PLATES, MItems.ELECTROMAGNET, MItemTags.REINFORCED_TRITANIUM_PLATES)
|
||||||
|
.row(Tags.Items.INGOTS_GOLD, Tags.Items.INGOTS_GOLD, Tags.Items.INGOTS_GOLD)
|
||||||
|
.row(MItemTags.REINFORCED_TRITANIUM_PLATES, Items.BLUE_ICE, MItemTags.REINFORCED_TRITANIUM_PLATES)
|
||||||
|
.build(consumer)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class FluidTankBlockEntity(blockPos: BlockPos, blockState: BlockState) : Mattery
|
|||||||
if (level is ServerLevel) {
|
if (level is ServerLevel) {
|
||||||
markDirtyFast()
|
markDirtyFast()
|
||||||
}
|
}
|
||||||
}), FluidStack.STREAM_CODEC.wrap()))
|
}), FluidStack.OPTIONAL_STREAM_CODEC.wrap()))
|
||||||
|
|
||||||
val fillInput = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer)
|
val fillInput = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer)
|
||||||
val drainInput = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer)
|
val drainInput = MatteryContainer(::markDirtyFast, 1).also(::addDroppableContainer)
|
||||||
|
@ -26,7 +26,7 @@ open class BlockMatteryFluidHandler(private val _capacity: IntSupplier, field: D
|
|||||||
get() = _capacity.asInt
|
get() = _capacity.asInt
|
||||||
|
|
||||||
override fun serializeNBT(registry: HolderLookup.Provider): Tag {
|
override fun serializeNBT(registry: HolderLookup.Provider): Tag {
|
||||||
return fluid.save(registry)
|
return fluid.saveOptional(registry)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun deserializeNBT(registry: HolderLookup.Provider, nbt: Tag?) {
|
override fun deserializeNBT(registry: HolderLookup.Provider, nbt: Tag?) {
|
||||||
|
@ -4,9 +4,15 @@ import io.wispforest.condensed_creative.entry.impl.CondensedItemEntry
|
|||||||
import io.wispforest.condensed_creative.registry.CondensedCreativeInitializer
|
import io.wispforest.condensed_creative.registry.CondensedCreativeInitializer
|
||||||
import io.wispforest.condensed_creative.registry.CondensedEntryRegistry
|
import io.wispforest.condensed_creative.registry.CondensedEntryRegistry
|
||||||
import net.minecraft.core.RegistryAccess
|
import net.minecraft.core.RegistryAccess
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries
|
||||||
import net.minecraft.world.item.CreativeModeTab
|
import net.minecraft.world.item.CreativeModeTab
|
||||||
import net.minecraft.world.item.DyeColor
|
import net.minecraft.world.item.DyeColor
|
||||||
import net.minecraft.world.item.Item
|
import net.minecraft.world.item.Item
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
import net.minecraft.world.level.material.Fluids
|
||||||
|
import net.neoforged.neoforge.capabilities.Capabilities
|
||||||
|
import net.neoforged.neoforge.fluids.FluidStack
|
||||||
|
import net.neoforged.neoforge.fluids.capability.IFluidHandler
|
||||||
import ru.dbotthepony.mc.otm.core.registryName
|
import ru.dbotthepony.mc.otm.core.registryName
|
||||||
import ru.dbotthepony.mc.otm.registry.MCreativeTabs
|
import ru.dbotthepony.mc.otm.registry.MCreativeTabs
|
||||||
import ru.dbotthepony.mc.otm.registry.MItems
|
import ru.dbotthepony.mc.otm.registry.MItems
|
||||||
@ -48,6 +54,9 @@ class CondensedCreativeCompat : CondensedCreativeInitializer {
|
|||||||
addByBase(MItems.ITEM_MONITOR, MCreativeTabs.MAIN)
|
addByBase(MItems.ITEM_MONITOR, MCreativeTabs.MAIN)
|
||||||
addByBase(MItems.STORAGE_POWER_SUPPLIER, MCreativeTabs.MAIN)
|
addByBase(MItems.STORAGE_POWER_SUPPLIER, MCreativeTabs.MAIN)
|
||||||
|
|
||||||
|
addByFluids(MItems.FLUID_CAPSULE, MCreativeTabs.MAIN)
|
||||||
|
addByFluids(MItems.FLUID_TANK, MCreativeTabs.MAIN)
|
||||||
|
|
||||||
addByBase(MItems.TRITANIUM_DOOR, MCreativeTabs.DECORATIVE)
|
addByBase(MItems.TRITANIUM_DOOR, MCreativeTabs.DECORATIVE)
|
||||||
addByBase(MItems.TRITANIUM_TRAPDOOR, MCreativeTabs.DECORATIVE)
|
addByBase(MItems.TRITANIUM_TRAPDOOR, MCreativeTabs.DECORATIVE)
|
||||||
addByBase(MRegistry.TRITANIUM_PRESSURE_PLATE.allItems, MCreativeTabs.DECORATIVE)
|
addByBase(MRegistry.TRITANIUM_PRESSURE_PLATE.allItems, MCreativeTabs.DECORATIVE)
|
||||||
@ -111,4 +120,23 @@ class CondensedCreativeCompat : CondensedCreativeInitializer {
|
|||||||
tabs.forEach { builder.addToItemGroup(it) }
|
tabs.forEach { builder.addToItemGroup(it) }
|
||||||
return builder
|
return builder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addByFluids(item: Item, vararg tabs: CreativeModeTab): CondensedItemEntry.Builder? {
|
||||||
|
val base = ItemStack(item, 1)
|
||||||
|
|
||||||
|
val list = arrayListOf(base)
|
||||||
|
for (fluid in BuiltInRegistries.FLUID) {
|
||||||
|
if (fluid != Fluids.EMPTY && fluid.isSource(fluid.defaultFluidState())) {
|
||||||
|
list.add(base.copy().also {
|
||||||
|
it.getCapability(Capabilities.FluidHandler.ITEM)?.let {
|
||||||
|
it.fill(FluidStack(fluid, it.getTankCapacity(0)), IFluidHandler.FluidAction.EXECUTE)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val builder = CondensedEntryRegistry.fromItemStacks(item.registryName, base, list)
|
||||||
|
tabs.forEach { builder.addToItemGroup(it) }
|
||||||
|
return builder
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.item.block
|
||||||
|
|
||||||
|
import net.minecraft.ChatFormatting
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
|
import net.minecraft.world.item.BlockItem
|
||||||
|
import net.minecraft.world.item.ItemStack
|
||||||
|
import net.minecraft.world.item.TooltipFlag
|
||||||
|
import ru.dbotthepony.mc.otm.config.CablesConfig
|
||||||
|
import ru.dbotthepony.mc.otm.core.util.formatPower
|
||||||
|
import ru.dbotthepony.mc.otm.registry.MBlocks
|
||||||
|
|
||||||
|
class EnergyCableItem(val conf: CablesConfig.E, properties: Properties) : BlockItem(MBlocks.ENERGY_CABLES[conf]!!, properties) {
|
||||||
|
override fun appendHoverText(
|
||||||
|
stack: ItemStack,
|
||||||
|
context: TooltipContext,
|
||||||
|
tooltip: MutableList<Component>,
|
||||||
|
flag: TooltipFlag
|
||||||
|
) {
|
||||||
|
super.appendHoverText(stack, context, tooltip, flag)
|
||||||
|
|
||||||
|
tooltip.add(
|
||||||
|
Component.translatable("otm.item.power.throughput_mono", conf.throughput.formatPower())
|
||||||
|
.withStyle(ChatFormatting.GRAY))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.dbotthepony.mc.otm.item
|
package ru.dbotthepony.mc.otm.item.block
|
||||||
|
|
||||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer
|
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.capability.fluid.BlockMatteryFluidHandler
|
|||||||
import ru.dbotthepony.mc.otm.client.render.blockentity.FluidTankRenderer
|
import ru.dbotthepony.mc.otm.client.render.blockentity.FluidTankRenderer
|
||||||
import ru.dbotthepony.mc.otm.core.TooltipList
|
import ru.dbotthepony.mc.otm.core.TooltipList
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
|
import ru.dbotthepony.mc.otm.item.FluidCapsuleItem
|
||||||
import ru.dbotthepony.mc.otm.registry.CapabilitiesRegisterListener
|
import ru.dbotthepony.mc.otm.registry.CapabilitiesRegisterListener
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
import java.util.function.IntSupplier
|
import java.util.function.IntSupplier
|
||||||
@ -36,9 +37,18 @@ class FluidTankItem(block: FluidTankBlock, properties: Properties, val capacity:
|
|||||||
if (pContext.player?.isCrouching == true)
|
if (pContext.player?.isCrouching == true)
|
||||||
return InteractionResult.PASS
|
return InteractionResult.PASS
|
||||||
|
|
||||||
val context = FluidCapsuleItem.Context(pContext.clickedPos, pContext.level.getBlockState(pContext.clickedPos), pContext.clickedFace)
|
val context = FluidCapsuleItem.Context(
|
||||||
|
pContext.clickedPos,
|
||||||
|
pContext.level.getBlockState(pContext.clickedPos),
|
||||||
|
pContext.clickedFace
|
||||||
|
)
|
||||||
|
|
||||||
if (FluidCapsuleItem.canInteract(pContext.itemInHand, pContext.player ?: return InteractionResult.FAIL, context))
|
if (FluidCapsuleItem.canInteract(
|
||||||
|
pContext.itemInHand,
|
||||||
|
pContext.player ?: return InteractionResult.FAIL,
|
||||||
|
context
|
||||||
|
)
|
||||||
|
)
|
||||||
return FluidCapsuleItem.interact(pContext.itemInHand, pContext.player!!, context)
|
return FluidCapsuleItem.interact(pContext.itemInHand, pContext.player!!, context)
|
||||||
|
|
||||||
return super.onItemUseFirst(stack, pContext)
|
return super.onItemUseFirst(stack, pContext)
|
@ -17,7 +17,7 @@ class FluidGaugeWidget(synchronizer: SynchableGroup) {
|
|||||||
var fluidSupplier = Supplier { FluidStack.EMPTY }
|
var fluidSupplier = Supplier { FluidStack.EMPTY }
|
||||||
|
|
||||||
val maxCapacity by synchronizer.computedInt(IntSupplier { maxCapacitySupplier.asInt })
|
val maxCapacity by synchronizer.computedInt(IntSupplier { maxCapacitySupplier.asInt })
|
||||||
val fluid by synchronizer.computed({ fluidSupplier.get() }, FluidStack.STREAM_CODEC.wrap())
|
val fluid by synchronizer.computed({ fluidSupplier.get() }, FluidStack.OPTIONAL_STREAM_CODEC.wrap())
|
||||||
|
|
||||||
val percentage: Float get() {
|
val percentage: Float get() {
|
||||||
if (maxCapacity <= 0 || fluid.isEmpty) {
|
if (maxCapacity <= 0 || fluid.isEmpty) {
|
||||||
|
@ -25,7 +25,6 @@ import net.minecraft.world.item.Tiers
|
|||||||
import net.minecraft.world.item.crafting.Ingredient
|
import net.minecraft.world.item.crafting.Ingredient
|
||||||
import net.minecraft.world.level.block.Block
|
import net.minecraft.world.level.block.Block
|
||||||
import net.neoforged.bus.api.IEventBus
|
import net.neoforged.bus.api.IEventBus
|
||||||
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent
|
|
||||||
import net.neoforged.neoforge.common.SimpleTier
|
import net.neoforged.neoforge.common.SimpleTier
|
||||||
import ru.dbotthepony.mc.otm.capability.ITieredUpgradeSet
|
import ru.dbotthepony.mc.otm.capability.ITieredUpgradeSet
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
@ -43,7 +42,7 @@ import ru.dbotthepony.mc.otm.item.CrudeBatteryItem
|
|||||||
import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem
|
import ru.dbotthepony.mc.otm.item.EssenceCapsuleItem
|
||||||
import ru.dbotthepony.mc.otm.item.EssenceServoItem
|
import ru.dbotthepony.mc.otm.item.EssenceServoItem
|
||||||
import ru.dbotthepony.mc.otm.item.FluidCapsuleItem
|
import ru.dbotthepony.mc.otm.item.FluidCapsuleItem
|
||||||
import ru.dbotthepony.mc.otm.item.FluidTankItem
|
import ru.dbotthepony.mc.otm.item.block.FluidTankItem
|
||||||
import ru.dbotthepony.mc.otm.item.GravitationalDisruptorItem
|
import ru.dbotthepony.mc.otm.item.GravitationalDisruptorItem
|
||||||
import ru.dbotthepony.mc.otm.item.HealPillItem
|
import ru.dbotthepony.mc.otm.item.HealPillItem
|
||||||
import ru.dbotthepony.mc.otm.item.MatteryItem
|
import ru.dbotthepony.mc.otm.item.MatteryItem
|
||||||
@ -58,6 +57,7 @@ import ru.dbotthepony.mc.otm.item.ZPMItem
|
|||||||
import ru.dbotthepony.mc.otm.item.addSimpleDescription
|
import ru.dbotthepony.mc.otm.item.addSimpleDescription
|
||||||
import ru.dbotthepony.mc.otm.item.armor.PortableGravitationStabilizerItem
|
import ru.dbotthepony.mc.otm.item.armor.PortableGravitationStabilizerItem
|
||||||
import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem
|
import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem
|
||||||
|
import ru.dbotthepony.mc.otm.item.block.EnergyCableItem
|
||||||
import ru.dbotthepony.mc.otm.item.exopack.ExopackProbeItem
|
import ru.dbotthepony.mc.otm.item.exopack.ExopackProbeItem
|
||||||
import ru.dbotthepony.mc.otm.item.exopack.ExopackSlotUpgradeItem
|
import ru.dbotthepony.mc.otm.item.exopack.ExopackSlotUpgradeItem
|
||||||
import ru.dbotthepony.mc.otm.item.exopack.ExopackUpgradeItem
|
import ru.dbotthepony.mc.otm.item.exopack.ExopackUpgradeItem
|
||||||
@ -84,7 +84,7 @@ object MItems {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val ENERGY_CABLES: Map<CablesConfig.E, BlockItem> = SupplierMap(CablesConfig.E.entries.map { conf ->
|
val ENERGY_CABLES: Map<CablesConfig.E, BlockItem> = SupplierMap(CablesConfig.E.entries.map { conf ->
|
||||||
conf to registry.register("${conf.name.lowercase()}_energy_cable") { BlockItem(MBlocks.ENERGY_CABLES[conf]!!, DEFAULT_PROPERTIES) }
|
conf to registry.register("${conf.name.lowercase()}_energy_cable") { EnergyCableItem(conf, DEFAULT_PROPERTIES) }
|
||||||
})
|
})
|
||||||
|
|
||||||
val ANDROID_STATION = register(MNames.ANDROID_STATION, MBlocks.ANDROID_STATION)
|
val ANDROID_STATION = register(MNames.ANDROID_STATION, MBlocks.ANDROID_STATION)
|
||||||
@ -323,7 +323,7 @@ object MItems {
|
|||||||
val ESSENCE_DRIVE: EssenceCapsuleItem by registry.register("essence_drive") { EssenceCapsuleItem(true) }
|
val ESSENCE_DRIVE: EssenceCapsuleItem by registry.register("essence_drive") { EssenceCapsuleItem(true) }
|
||||||
|
|
||||||
val FLUID_CAPSULE: FluidCapsuleItem by registry.register("fluid_capsule") { FluidCapsuleItem(ItemsConfig::FLUID_CAPSULE_CAPACITY) }
|
val FLUID_CAPSULE: FluidCapsuleItem by registry.register("fluid_capsule") { FluidCapsuleItem(ItemsConfig::FLUID_CAPSULE_CAPACITY) }
|
||||||
val FLUID_TANK: FluidTankItem by registry.register(MNames.FLUID_TANK) { FluidTankItem(MBlocks.FLUID_TANK, Item.Properties().stacksTo(1), ItemsConfig::FLUID_TANK_CAPACITY) }
|
val FLUID_TANK: FluidTankItem by registry.register(MNames.FLUID_TANK) { FluidTankItem(MBlocks.FLUID_TANK, Properties().stacksTo(1), ItemsConfig::FLUID_TANK_CAPACITY) }
|
||||||
val LIQUID_XP_BUCKET: BucketItem by registry.register("liquid_xp_bucket") { BucketItem(MFluids.LIQUID_XP, Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON)) }
|
val LIQUID_XP_BUCKET: BucketItem by registry.register("liquid_xp_bucket") { BucketItem(MFluids.LIQUID_XP, Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON)) }
|
||||||
|
|
||||||
val TRITANIUM_COMPONENT: SimpleTier = SimpleTier(
|
val TRITANIUM_COMPONENT: SimpleTier = SimpleTier(
|
||||||
|
Loading…
Reference in New Issue
Block a user