Compare commits

...

7 Commits

8 changed files with 53 additions and 40 deletions

View File

@ -1,6 +1,7 @@
package ru.dbotthepony.mc.otm.datagen.recipes
import net.minecraft.data.recipes.*
import net.minecraft.tags.ItemTags
import net.minecraft.world.item.DyeColor
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
@ -435,4 +436,12 @@ fun addDecorativesRecipes(provider: MatteryRecipeProvider, consumer: RecipeOutpu
builder.build(consumer)
}
for ((color, item) in MRegistry.STAR_CHAIR.allItems) {
MatteryRecipe(item, category = RecipeCategory.DECORATIONS)
.rowB(color?.tag)
.row(MItemTags.TRITANIUM_PLATES, ItemTags.WOOL, MItemTags.TRITANIUM_PLATES)
.row(MItemTags.TRITANIUM_PLATES, MItemTags.CARBON_PLATES, MItemTags.TRITANIUM_PLATES)
.build(consumer)
}
}

View File

@ -1384,6 +1384,9 @@ open class EditablePanel<out S : Screen>(
parent?.updateBounds()
}
open val ignoreWhenSizingToContents: Boolean
get() = false
/**
* Attempts to tightly fit dimensions to all children
*/
@ -1405,8 +1408,10 @@ open class EditablePanel<out S : Screen>(
for (child in visibleChildrenInternal) {
when (child.dock) {
Dock.NONE -> {
width = maxOf(width, child.x + child.width)
height = maxOf(height, child.y + child.height)
if (!child.ignoreWhenSizingToContents) {
width = maxOf(width, child.x + child.width)
height = maxOf(height, child.y + child.height)
}
}
Dock.FILL -> {

View File

@ -34,6 +34,9 @@ open class FramePanel<out S : Screen>(
var isActive = tabs.isEmpty()
protected set
override val ignoreWhenSizingToContents: Boolean
get() = true
init {
tabs.add(this)
}
@ -197,6 +200,9 @@ open class FramePanel<out S : Screen>(
close()
}
override val ignoreWhenSizingToContents: Boolean
get() = true
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (isPressed) {
CLOSE_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height)
@ -223,6 +229,9 @@ open class FramePanel<out S : Screen>(
isActive = !isActive
}*/
override val ignoreWhenSizingToContents: Boolean
get() = true
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
/*if (isPressed) {
HELP_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height)

View File

@ -339,6 +339,9 @@ class DeviceControls<out S : MatteryScreen<*>>(
private var upgradeWindow: FramePanel<S>? = null
override val ignoreWhenSizingToContents: Boolean
get() = true
private val buttons = ArrayList<EditablePanel<S>>()
private fun alignButtons() {
@ -350,8 +353,10 @@ class DeviceControls<out S : MatteryScreen<*>>(
var totalWidth = 0f
var totalHeight = 0f
val parent = parent!!
for (button in buttons) {
if (y != 0f && button.height + y > parent!!.height) {
if (y != 0f && button.height + y > parent.height && (parent.dock == Dock.NONE || !parent.layoutInvalidated)) {
totalHeight = totalHeight.coerceAtLeast(y - 2f)
y = 0f
x += currentWidth + 2f

View File

@ -320,13 +320,13 @@ object MachinesConfig : AbstractConfig("machines") {
val PASSIVE_LOSS: Decimal by builder
.comment("Amount of energy lost per tick in % of energy stored")
.defineDecimal("PASSIVE_LOSS", Decimal("0.000001"), Decimal.ZERO)
.defineDecimal("PASSIVE_LOSS", Decimal("0.0000004"), Decimal.ZERO)
val ACTIVE_LOSS: Decimal by builder
.comment("Amount of energy lost per tick in % of energy stored if Flywheel configuration is invalid")
.comment("Keep in mind that all stored energy is instantly lost when controller is broken by any means")
.comment("unless using mod which fully preserve blockentity metadata such as Mekanism cardboard box or Carry On")
.defineDecimal("ACTIVE_LOSS", Decimal("0.0004"), Decimal.ZERO)
.defineDecimal("ACTIVE_LOSS", Decimal("0.00004"), Decimal.ZERO)
init {
builder.pop()

View File

@ -295,31 +295,7 @@ operator fun CraftingContainer.get(column: Int, row: Int, flop: Boolean): ItemSt
}
fun Container.sort(comparator: Comparator<ItemStack> = ItemStackSorter.DEFAULT) {
if (isEmpty)
return
val slots = slotIterator().filter { !it.isForbiddenForAutomation && it.getMaxStackSize() >= it.item.count }.toList()
if (slots.isEmpty())
return
val items = Object2ObjectOpenCustomHashMap<ItemStack, ItemStack>(ItemStackHashStrategy)
slots.forEach {
val get = items[it.item]
if (get == null) {
items[it.item] = it.item.copy()
} else {
get.count += it.item.count
}
}
val sortedItems = ObjectArrayList(items.values)
sortedItems.sortWith(comparator)
slots.forEach { it.remove() }
sortedItems.forEach { addItem(it, false) }
sortWithIndices(computeSortedIndices(comparator))
}
fun Container.sortWithIndices(sortedSlots: IntCollection) {
@ -337,7 +313,12 @@ fun Container.sortWithIndices(sortedSlots: IntCollection) {
if (value in 0 until containerSize && seen.add(value)) {
val slot = containerSlot(value)
if (slot.isNotEmpty && !slot.isForbiddenForAutomation && slot.item.count <= slot.getMaxStackSize()) {
if (
slot.isNotEmpty &&
!slot.isForbiddenForAutomation &&
slot.item.count <= slot.getMaxStackSize() &&
(!slot.hasFilter || slot.getFilter() != slot.item.item || slot.getMaxStackSize() > 1)
) {
valid.add(slot)
}
}

View File

@ -63,7 +63,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1)
}
fun canPrime(player: Player): Boolean {
return player.inventory.clearOrCountMatchingItems(GUNPOWDER_PREDICATE, 0, player.inventoryMenu.craftSlots) > 0 &&
return player.hasInfiniteMaterials() || player.inventory.clearOrCountMatchingItems(GUNPOWDER_PREDICATE, 0, player.inventoryMenu.craftSlots) > 0 &&
player.inventory.clearOrCountMatchingItems(IRON_NUGGET_PREDICATE, 0, player.inventoryMenu.craftSlots) > 0
}
@ -142,7 +142,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1)
}
fun attackAt(itemStack: ItemStack, attacker: LivingEntity, pos: Vec3, aim: Vec3, hand: InteractionHand) {
if (!isPrimed(itemStack) || attacker.level().isClientSide || attacker is Player && attacker.getAttackStrengthScale(0.4f) < 0.98f)
if (!isPrimed(itemStack) || attacker.level().isClientSide || attacker is Player && !attacker.isCreative && attacker.getAttackStrengthScale(0.4f) < 0.98f)
return
val (ex, ey, ez) = pos
@ -221,7 +221,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1)
it.connection.send(ClientboundExplodePacket(ex, ey, ez, 1f, exp.toBlow, exp.hitPlayers[it], Explosion.BlockInteraction.DESTROY, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE))
}
if (attacker !is Player || !attacker.isCreative) {
if (!attacker.hasInfiniteMaterials()) {
unprime(itemStack)
val copy = itemStack.copy()
@ -303,8 +303,10 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1)
override fun finishUsingItem(stack: ItemStack, level: Level, entity: LivingEntity): ItemStack {
if (entity is Player && canPrime(entity)) {
if (level is ServerLevel) {
entity.inventory.clearOrCountMatchingItems(GUNPOWDER_PREDICATE, 1, entity.inventoryMenu.craftSlots)
entity.inventory.clearOrCountMatchingItems(IRON_NUGGET_PREDICATE, 1, entity.inventoryMenu.craftSlots)
if (!entity.hasInfiniteMaterials()) {
entity.inventory.clearOrCountMatchingItems(GUNPOWDER_PREDICATE, 1, entity.inventoryMenu.craftSlots)
entity.inventory.clearOrCountMatchingItems(IRON_NUGGET_PREDICATE, 1, entity.inventoryMenu.craftSlots)
}
prime(stack)
}

View File

@ -244,10 +244,12 @@ abstract class MatteryMenu(
)
}
chargeFlag = Delegate.Of(
getter = { slotIndex in mattery.slotsChargeFlag },
setter = booleanInput(true) { if (mattery.hasExopack) { if (it) mattery.slotsChargeFlag.add(slotIndex) else mattery.slotsChargeFlag.remove(slotIndex) } }::accept
)
if (mattery.hasExopack) {
chargeFlag = Delegate.Of(
getter = { slotIndex in mattery.slotsChargeFlag },
setter = booleanInput(true) { if (mattery.hasExopack) { if (it) mattery.slotsChargeFlag.add(slotIndex) else mattery.slotsChargeFlag.remove(slotIndex) } }::accept
)
}
}
}