iron shulker boxes
This commit is contained in:
parent
85950c6a90
commit
cc372ed871
@ -272,6 +272,7 @@ minecraft {
|
||||
mixin {
|
||||
config("$mod_id.mixins.json")
|
||||
config("$mod_id.ironchest.mixins.json")
|
||||
config("$mod_id.ironshulkerbox.mixins.json")
|
||||
// config("$mod_id.ad_astra.mixins.json")
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
package ru.dbotthepony.mc.otm.mixin.ironshulkerbox;
|
||||
|
||||
import com.progwml6.ironshulkerbox.common.block.entity.CopperShulkerBoxBlockEntity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import ru.dbotthepony.mc.otm.compat.ironshulkerbox.MatteryIronShulkerBoxMenu;
|
||||
|
||||
@Mixin(CopperShulkerBoxBlockEntity.class)
|
||||
public abstract class CopperShulkerBoxBlockEntityMixin {
|
||||
@Overwrite(remap = false)
|
||||
public AbstractContainerMenu createMenu(int containerId, Inventory inventory) {
|
||||
return MatteryIronShulkerBoxMenu.copper(containerId, inventory, ((CopperShulkerBoxBlockEntity)(Object) this));
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package ru.dbotthepony.mc.otm.mixin.ironshulkerbox;
|
||||
|
||||
import com.progwml6.ironshulkerbox.common.block.entity.CrystalShulkerBoxBlockEntity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import ru.dbotthepony.mc.otm.compat.ironshulkerbox.MatteryIronShulkerBoxMenu;
|
||||
|
||||
@Mixin(CrystalShulkerBoxBlockEntity.class)
|
||||
public abstract class CrystalShulkerBoxBlockEntityMixin {
|
||||
@Overwrite(remap = false)
|
||||
public AbstractContainerMenu createMenu(int containerId, Inventory inventory) {
|
||||
return MatteryIronShulkerBoxMenu.crystal(containerId, inventory, ((CrystalShulkerBoxBlockEntity)(Object) this));
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package ru.dbotthepony.mc.otm.mixin.ironshulkerbox;
|
||||
|
||||
import com.progwml6.ironshulkerbox.common.block.entity.DiamondShulkerBoxBlockEntity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import ru.dbotthepony.mc.otm.compat.ironshulkerbox.MatteryIronShulkerBoxMenu;
|
||||
|
||||
@Mixin(DiamondShulkerBoxBlockEntity.class)
|
||||
public abstract class DiamondShulkerBoxBlockEntityMixin {
|
||||
@Overwrite(remap = false)
|
||||
public AbstractContainerMenu createMenu(int containerId, Inventory inventory) {
|
||||
return MatteryIronShulkerBoxMenu.diamond(containerId, inventory, ((DiamondShulkerBoxBlockEntity)(Object) this));
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package ru.dbotthepony.mc.otm.mixin.ironshulkerbox;
|
||||
|
||||
import com.progwml6.ironshulkerbox.common.block.entity.GoldShulkerBoxBlockEntity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import ru.dbotthepony.mc.otm.compat.ironshulkerbox.MatteryIronShulkerBoxMenu;
|
||||
|
||||
@Mixin(GoldShulkerBoxBlockEntity.class)
|
||||
public abstract class GoldShulkerBoxBlockEntityMixin {
|
||||
@Overwrite(remap = false)
|
||||
public AbstractContainerMenu createMenu(int containerId, Inventory inventory) {
|
||||
return MatteryIronShulkerBoxMenu.gold(containerId, inventory, ((GoldShulkerBoxBlockEntity)(Object) this));
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package ru.dbotthepony.mc.otm.mixin.ironshulkerbox;
|
||||
|
||||
import com.progwml6.ironshulkerbox.common.block.entity.IronShulkerBoxBlockEntity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import ru.dbotthepony.mc.otm.compat.ironshulkerbox.MatteryIronShulkerBoxMenu;
|
||||
|
||||
@Mixin(IronShulkerBoxBlockEntity.class)
|
||||
public abstract class IronShulkerBoxBlockEntityMixin {
|
||||
@Overwrite(remap = false)
|
||||
public AbstractContainerMenu createMenu(int containerId, Inventory inventory) {
|
||||
return MatteryIronShulkerBoxMenu.iron(containerId, inventory, ((IronShulkerBoxBlockEntity)(Object) this));
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package ru.dbotthepony.mc.otm.mixin.ironshulkerbox;
|
||||
|
||||
import com.progwml6.ironshulkerbox.common.block.entity.ObsidianShulkerBoxBlockEntity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import ru.dbotthepony.mc.otm.compat.ironshulkerbox.MatteryIronShulkerBoxMenu;
|
||||
|
||||
@Mixin(ObsidianShulkerBoxBlockEntity.class)
|
||||
public abstract class ObsidianShulkerBoxBlockEntityMixin {
|
||||
@Overwrite(remap = false)
|
||||
public AbstractContainerMenu createMenu(int containerId, Inventory inventory) {
|
||||
return MatteryIronShulkerBoxMenu.obsidian(containerId, inventory, ((ObsidianShulkerBoxBlockEntity)(Object) this));
|
||||
}
|
||||
}
|
@ -46,6 +46,8 @@ import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded
|
||||
import ru.dbotthepony.mc.otm.compat.curios.onCuriosSlotModifiersUpdated
|
||||
import ru.dbotthepony.mc.otm.compat.ironchest.IronChestMenuTypes
|
||||
import ru.dbotthepony.mc.otm.compat.ironchest.isIronChestLoaded
|
||||
import ru.dbotthepony.mc.otm.compat.ironshulkerbox.IronShulkersMenuTypes
|
||||
import ru.dbotthepony.mc.otm.compat.ironshulkerbox.isIronShulkersLoaded
|
||||
import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu
|
||||
import ru.dbotthepony.mc.otm.compat.vanilla.VanillaMenuTypes
|
||||
import ru.dbotthepony.mc.otm.config.PlayerConfig
|
||||
@ -140,6 +142,10 @@ object OverdriveThatMatters {
|
||||
IronChestMenuTypes.register(MOD_BUS)
|
||||
}
|
||||
|
||||
if (isIronShulkersLoaded) {
|
||||
IronShulkersMenuTypes.register(MOD_BUS)
|
||||
}
|
||||
|
||||
MCreativeTabs.initialize(MOD_BUS)
|
||||
|
||||
MOD_BUS.addListener(::registerNetworkPackets)
|
||||
|
@ -0,0 +1,68 @@
|
||||
package ru.dbotthepony.mc.otm.compat.ironshulkerbox
|
||||
|
||||
import com.progwml6.ironshulkerbox.IronShulkerBoxes
|
||||
import com.progwml6.ironshulkerbox.common.block.IronShulkerBoxesTypes
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.world.Container
|
||||
import net.minecraft.world.flag.FeatureFlags
|
||||
import net.minecraft.world.inventory.MenuType
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.level.Level
|
||||
import net.minecraft.world.level.block.entity.BlockEntity
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import net.neoforged.bus.api.IEventBus
|
||||
import net.neoforged.fml.ModList
|
||||
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent
|
||||
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||
import ru.dbotthepony.mc.otm.capability.IQuickStackContainer
|
||||
import ru.dbotthepony.mc.otm.capability.MatteryCapability
|
||||
import ru.dbotthepony.mc.otm.compat.ironshulkerbox.MatteryIronShulkerBoxMenu.Slot
|
||||
import ru.dbotthepony.mc.otm.compat.vanilla.VanillaChestScreen
|
||||
import ru.dbotthepony.mc.otm.menu.makeSlots
|
||||
import ru.dbotthepony.mc.otm.registry.MDeferredRegister
|
||||
import kotlin.collections.toTypedArray
|
||||
|
||||
val isIronShulkersLoaded by lazy {
|
||||
ModList.get().isLoaded(IronShulkerBoxes.MODID)
|
||||
}
|
||||
|
||||
object IronShulkersMenuTypes {
|
||||
private val registrar = MDeferredRegister(Registries.MENU, OverdriveThatMatters.MOD_ID)
|
||||
|
||||
val IRON by registrar.register("ironshulkerbox_iron") { MenuType(MatteryIronShulkerBoxMenu::iron, FeatureFlags.VANILLA_SET) }
|
||||
val GOLD by registrar.register("ironshulkerbox_gold") { MenuType(MatteryIronShulkerBoxMenu::gold, FeatureFlags.VANILLA_SET) }
|
||||
val DIAMOND by registrar.register("ironshulkerbox_diamond") { MenuType(MatteryIronShulkerBoxMenu::diamond, FeatureFlags.VANILLA_SET) }
|
||||
val COPPER by registrar.register("ironshulkerbox_copper") { MenuType(MatteryIronShulkerBoxMenu::copper, FeatureFlags.VANILLA_SET) }
|
||||
val CRYSTAL by registrar.register("ironshulkerbox_crystal") { MenuType(MatteryIronShulkerBoxMenu::crystal, FeatureFlags.VANILLA_SET) }
|
||||
val OBSIDIAN by registrar.register("ironshulkerbox_obsidian") { MenuType(MatteryIronShulkerBoxMenu::obsidian, FeatureFlags.VANILLA_SET) }
|
||||
|
||||
private fun provider(level: Level, pos: BlockPos, state: BlockState, blockEntity: BlockEntity?, context: Void?): IQuickStackContainer? {
|
||||
val container = blockEntity as? Container ?: return null
|
||||
return IQuickStackContainer.Simple(makeSlots(container, ::Slot))
|
||||
}
|
||||
|
||||
fun registerCapabilities(event: RegisterCapabilitiesEvent) {
|
||||
val colors = DyeColor.entries.toMutableList<DyeColor?>().also { it.add(0, null) }
|
||||
|
||||
IronShulkerBoxesTypes.entries.forEach { type ->
|
||||
event.registerBlock(MatteryCapability.QUICK_STACK_CONTAINER, ::provider, *colors.map { IronShulkerBoxesTypes.get(type, it) }.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
internal fun register(bus: IEventBus) {
|
||||
registrar.register(bus)
|
||||
bus.addListener(this::registerScreens)
|
||||
bus.addListener(this::registerCapabilities)
|
||||
}
|
||||
|
||||
private fun registerScreens(event: RegisterMenuScreensEvent) {
|
||||
event.register(IRON, ::VanillaChestScreen)
|
||||
event.register(GOLD, ::VanillaChestScreen)
|
||||
event.register(DIAMOND, ::VanillaChestScreen)
|
||||
event.register(COPPER, ::VanillaChestScreen)
|
||||
event.register(CRYSTAL, ::VanillaChestScreen)
|
||||
event.register(OBSIDIAN, ::VanillaChestScreen)
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package ru.dbotthepony.mc.otm.compat.ironshulkerbox
|
||||
|
||||
import com.progwml6.ironshulkerbox.common.block.IronShulkerBoxesTypes
|
||||
import net.minecraft.world.Container
|
||||
import net.minecraft.world.SimpleContainer
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.inventory.MenuType
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.compat.vanilla.AbstractVanillaChestMenu
|
||||
import ru.dbotthepony.mc.otm.container.EnhancedContainer
|
||||
import ru.dbotthepony.mc.otm.menu.MatteryMenuSlot
|
||||
import ru.dbotthepony.mc.otm.menu.QuickMoveInput
|
||||
import ru.dbotthepony.mc.otm.menu.makeSlots
|
||||
|
||||
class MatteryIronShulkerBoxMenu(
|
||||
type: MenuType<*>, containerId: Int,
|
||||
inventory: Inventory, boxType: IronShulkerBoxesTypes,
|
||||
container: Container = EnhancedContainer.Simple(boxType.size)
|
||||
) : AbstractVanillaChestMenu(type, containerId, inventory, container) {
|
||||
override val rows: Int = boxType.size / boxType.rowLength
|
||||
override val columns: Int = boxType.rowLength
|
||||
|
||||
override val containerSlots = makeSlots(container, ::Slot)
|
||||
|
||||
init {
|
||||
container.startOpen(player)
|
||||
addStorageSlot(containerSlots)
|
||||
addInventorySlots()
|
||||
}
|
||||
|
||||
override val quickMoveToStorage = QuickMoveInput.create(this, playerCombinedInventorySlots, containerSlots)
|
||||
override val quickMoveFromStorage = QuickMoveInput.create(this, containerSlots, playerInventorySlots, false)
|
||||
|
||||
class Slot(container: Container, slot: Int) : MatteryMenuSlot(container, slot) {
|
||||
override fun mayPlace(stack: ItemStack): Boolean {
|
||||
return super.mayPlace(stack) && stack.item.canFitInsideContainerItems()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun iron(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(IronShulkerBoxesTypes.IRON.size), boxType: IronShulkerBoxesTypes = IronShulkerBoxesTypes.IRON): MatteryIronShulkerBoxMenu {
|
||||
return MatteryIronShulkerBoxMenu(IronShulkersMenuTypes.IRON, containerId, inventory, boxType, container)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun gold(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(IronShulkerBoxesTypes.GOLD.size), boxType: IronShulkerBoxesTypes = IronShulkerBoxesTypes.GOLD): MatteryIronShulkerBoxMenu {
|
||||
return MatteryIronShulkerBoxMenu(IronShulkersMenuTypes.GOLD, containerId, inventory, boxType, container)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun diamond(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(IronShulkerBoxesTypes.DIAMOND.size), boxType: IronShulkerBoxesTypes = IronShulkerBoxesTypes.DIAMOND): MatteryIronShulkerBoxMenu {
|
||||
return MatteryIronShulkerBoxMenu(IronShulkersMenuTypes.DIAMOND, containerId, inventory, boxType, container)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun copper(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(IronShulkerBoxesTypes.COPPER.size), boxType: IronShulkerBoxesTypes = IronShulkerBoxesTypes.COPPER): MatteryIronShulkerBoxMenu {
|
||||
return MatteryIronShulkerBoxMenu(IronShulkersMenuTypes.COPPER, containerId, inventory, boxType, container)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun crystal(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(IronShulkerBoxesTypes.CRYSTAL.size), boxType: IronShulkerBoxesTypes = IronShulkerBoxesTypes.CRYSTAL): MatteryIronShulkerBoxMenu {
|
||||
return MatteryIronShulkerBoxMenu(IronShulkersMenuTypes.CRYSTAL, containerId, inventory, boxType, container)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun obsidian(containerId: Int, inventory: Inventory, container: Container = SimpleContainer(IronShulkerBoxesTypes.OBSIDIAN.size), boxType: IronShulkerBoxesTypes = IronShulkerBoxesTypes.OBSIDIAN): MatteryIronShulkerBoxMenu {
|
||||
return MatteryIronShulkerBoxMenu(IronShulkersMenuTypes.OBSIDIAN, containerId, inventory, boxType, container)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"required": false,
|
||||
"package": "ru.dbotthepony.mc.otm.mixin.ironshulkerbox",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"minVersion": "0.8",
|
||||
"mixins": [
|
||||
"IronShulkerBoxBlockEntityMixin",
|
||||
"GoldShulkerBoxBlockEntityMixin",
|
||||
"DiamondShulkerBoxBlockEntityMixin",
|
||||
"CopperShulkerBoxBlockEntityMixin",
|
||||
"CrystalShulkerBoxBlockEntityMixin",
|
||||
"ObsidianShulkerBoxBlockEntityMixin"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user