Merge remote-tracking branch 'origin/master' into master
This commit is contained in:
commit
3aaa595d7b
@ -258,6 +258,9 @@ private fun misc(provider: MatteryLanguageProvider) {
|
||||
misc("item.pattern.infinite.stored", "Stored patterns: %s")
|
||||
misc("item.pattern.line", "%s [%s%%]")
|
||||
misc("item.pattern.research", "Researched: %s%%")
|
||||
misc("item.pattern.research.item_count", "Items: %s / %s")
|
||||
misc("item.pattern.research.advance", "Progress per item: %s%%")
|
||||
|
||||
|
||||
misc("item.matter.infinite", "Stored matter: ∞ / ∞")
|
||||
misc("item.matter.normal", "Stored matter: %s / %s")
|
||||
@ -797,6 +800,8 @@ private fun gui(provider: MatteryLanguageProvider) {
|
||||
gui("slot_filter.filtered", "This slot is filtered for automation")
|
||||
gui("slot_filter.forbidden", "This slot is forbidden for automation mechanisms")
|
||||
gui("slot_filter.hint", "To remove slot filter press Ctrl + LMB")
|
||||
|
||||
gui("tooltip.enum.active", "> %s")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,6 +264,8 @@ private fun misc(provider: MatteryLanguageProvider) {
|
||||
misc("item.pattern.stored", "Хранимые шаблоны: %s / %s")
|
||||
misc("item.pattern.infinite.stored", "Хранимые шаблоны: %s")
|
||||
misc("item.pattern.research", "Исследовано: %s%%")
|
||||
misc("item.pattern.research.item_count", "Предметы: %s / %s")
|
||||
misc("item.pattern.research.advance", "Исследование за предмет: %s%%")
|
||||
|
||||
misc("item.matter.infinite", "Хранимая материя неиссякаема")
|
||||
misc("item.matter.normal", "Хранимая материя: %s / %s")
|
||||
|
@ -162,6 +162,32 @@ class MatterScannerBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) :
|
||||
matterNode.discover(this)
|
||||
}
|
||||
|
||||
|
||||
override fun jobUpdated(new: MachineItemJob?, old: MachineItemJob?, id: Int) {
|
||||
visualItemStack = new?.itemStack ?: ItemStack.EMPTY
|
||||
visualProgress = 0f
|
||||
}
|
||||
|
||||
var visualItemStack by synchronizer.item(observe = false)
|
||||
private set
|
||||
|
||||
var visualProgress by synchronizer.float().property
|
||||
private set
|
||||
|
||||
override fun onWorkTick(
|
||||
requiredPower: Decimal,
|
||||
extractedPower: Decimal,
|
||||
ticksAdvanced: Double,
|
||||
job: MachineItemJob,
|
||||
id: Int
|
||||
): JobStatus {
|
||||
val result = super.onWorkTick(requiredPower, extractedPower, ticksAdvanced, job, id)
|
||||
|
||||
visualProgress = jobEventLoops[0].workProgress
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val BASE_CONSUMPTION get() = _BASE_CONSUMPTION.get()
|
||||
|
||||
|
@ -88,7 +88,6 @@ private fun Font.drawScaledDuckTyped(poseStack: PoseStack, buffer: MultiBufferSo
|
||||
poseStack.translate(-translation)
|
||||
poseStack.scale(scale, scale, scale)
|
||||
val inv = 1f / scale
|
||||
poseStack.translate(translation * inv)
|
||||
val size = drawDuckTyped(poseStack, buffer, text, x * inv, y * inv, color, drawShadow, displayMode, packedLightCoords, effectColor)
|
||||
poseStack.popPose()
|
||||
|
||||
|
@ -0,0 +1,71 @@
|
||||
package ru.dbotthepony.mc.otm.client.render.blockentity
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.math.Axis
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||
import net.minecraft.world.item.ItemDisplayContext
|
||||
import ru.dbotthepony.mc.otm.block.entity.matter.MatterScannerBlockEntity
|
||||
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||
import ru.dbotthepony.mc.otm.client.render.lockBlendFunc
|
||||
|
||||
class MatterScannerRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<MatterScannerBlockEntity> {
|
||||
companion object {
|
||||
private val source = DynamicBufferSource(maximalInitialBufferSize = 2 shl 10)
|
||||
}
|
||||
|
||||
override fun render(
|
||||
tile: MatterScannerBlockEntity,
|
||||
partialTick: Float,
|
||||
pose: PoseStack,
|
||||
bufferSource: MultiBufferSource,
|
||||
packedLight: Int,
|
||||
packedOverlay: Int
|
||||
) {
|
||||
val item = tile.visualItemStack
|
||||
|
||||
if (item.isEmpty) {
|
||||
return
|
||||
}
|
||||
|
||||
pose.pushPose()
|
||||
|
||||
pose.translate(0.5, 0.5, 0.5)
|
||||
pose.scale(0.5f, 0.5f, 0.5f)
|
||||
|
||||
pose.mulPose(Axis.XP.rotationDegrees(90f))
|
||||
pose.mulPose(Axis.ZP.rotationDegrees(tile.blockRotation.back.toYRot()))
|
||||
|
||||
context.itemRenderer.renderStatic(
|
||||
item,
|
||||
ItemDisplayContext.FIXED,
|
||||
packedLight,
|
||||
packedOverlay,
|
||||
pose,
|
||||
source,
|
||||
tile.level,
|
||||
tile.blockPos.asLong().toInt()
|
||||
)
|
||||
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f - tile.visualProgress)
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA)
|
||||
|
||||
lockBlendFunc = true
|
||||
|
||||
try {
|
||||
source.endBatch()
|
||||
} finally {
|
||||
lockBlendFunc = false
|
||||
}
|
||||
|
||||
RenderSystem.disableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
|
||||
pose.popPose()
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.matter
|
||||
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.components.EditBox
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
@ -8,8 +9,7 @@ import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.capability.matter.IPatternState
|
||||
import ru.dbotthepony.mc.otm.capability.matter.IReplicationTask
|
||||
import ru.dbotthepony.mc.otm.client.ShiftPressedCond
|
||||
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
|
||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||
import ru.dbotthepony.mc.otm.client.render.*
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.*
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel
|
||||
@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
||||
import ru.dbotthepony.mc.otm.core.math.integerDivisionDown
|
||||
import ru.dbotthepony.mc.otm.core.util.ItemSorter
|
||||
import ru.dbotthepony.mc.otm.core.util.formatMatter
|
||||
@ -33,6 +34,7 @@ import ru.dbotthepony.mc.otm.menu.matter.ReplicationRequestPacket
|
||||
import ru.dbotthepony.mc.otm.network.MenuNetworkChannel
|
||||
import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak
|
||||
import java.util.function.Predicate
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@MouseTweaksDisableWheelTweak
|
||||
@ -164,7 +166,24 @@ class MatterPanelScreen(
|
||||
list.add(TranslatableComponent(
|
||||
"otm.item.pattern.research",
|
||||
String.format("%.2f", it.researchPercent * 100.0)
|
||||
).withStyle(ChatFormatting.AQUA)) }
|
||||
).withStyle(ChatFormatting.AQUA))
|
||||
|
||||
if (ru.dbotthepony.mc.otm.client.minecraft.options.advancedItemTooltips) {
|
||||
val researchAdvance = MatterManager.getResearchAdvance(it.item)
|
||||
val required = ceil(1.0 / researchAdvance).toInt()
|
||||
val researched = (required.toDouble() * it.researchPercent).toInt()
|
||||
|
||||
list.add(TranslatableComponent(
|
||||
"otm.item.pattern.research.item_count",
|
||||
researched,
|
||||
required
|
||||
).withStyle(ChatFormatting.DARK_GRAY))
|
||||
list.add(TranslatableComponent(
|
||||
"otm.item.pattern.research.advance",
|
||||
String.format("%.2f", researchAdvance * 100.0)
|
||||
).withStyle(ChatFormatting.DARK_GRAY))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
menu.tasksFiltered.getOrNull(index)?.let {
|
||||
list.add(TranslatableComponent("otm.gui.matter_task.total", it.total).withStyle(ChatFormatting.GRAY))
|
||||
@ -177,6 +196,35 @@ class MatterPanelScreen(
|
||||
return list
|
||||
}
|
||||
|
||||
override fun renderRegular(graphics: GuiGraphics, itemstack: ItemStack, countOverride: String?) {
|
||||
if (isPatternView) {
|
||||
super.renderRegular(graphics, itemstack, "")
|
||||
|
||||
menu.patternsFiltered.getOrNull(index)?.let {
|
||||
if (it.researchPercent < 1f) {
|
||||
font.drawScaledAligned(graphics.pose(), graphics.bufferSource(), (it.researchPercent * 100.0).toInt().toString() + "%", .5f, RenderGravity.BOTTOM_RIGHT, width - 1f, height - 1f, true, color = RGBAColor.WHITE)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.renderRegular(graphics, itemstack, countOverride)
|
||||
|
||||
menu.tasksFiltered.getOrNull(index)?.let {
|
||||
val progress = it.finished.toFloat() / it.total.toFloat()
|
||||
val processing = it.inProgress.toFloat() / it.total.toFloat()
|
||||
|
||||
val barLeft = 2f
|
||||
val barTop = 2f
|
||||
val barWidth = width - 4f
|
||||
val barHeight = 1f
|
||||
|
||||
graphics.renderRect(barLeft - .5f, barTop - .5f, barWidth + 1f, barHeight + 1f, color = RGBAColor.WHITE)
|
||||
graphics.renderRect(barLeft, barTop, barWidth, barHeight, color = RGBAColor.BLACK)
|
||||
graphics.renderRect(barLeft, barTop, barWidth * progress, barHeight, color = RGBAColor.GREEN)
|
||||
graphics.renderRect(barLeft + barWidth * progress, barTop, barWidth * processing, barHeight, color = RGBAColor.YELLOW)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
if (isPatternView) {
|
||||
if (minecraft?.player?.isSpectator != true)
|
||||
|
@ -11,12 +11,8 @@ import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
|
||||
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
|
||||
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.core.GetterSetter
|
||||
import ru.dbotthepony.mc.otm.core.TextComponent
|
||||
import ru.dbotthepony.mc.otm.core.next
|
||||
import ru.dbotthepony.mc.otm.core.prev
|
||||
import ru.dbotthepony.mc.otm.core.*
|
||||
import ru.dbotthepony.mc.otm.core.util.EnumValueCodec
|
||||
import ru.dbotthepony.mc.otm.core.value
|
||||
import ru.dbotthepony.mc.otm.menu.input.IPlayerInputWithFeedback
|
||||
import java.util.*
|
||||
import java.util.function.Predicate
|
||||
@ -164,7 +160,9 @@ abstract class EnumRectangleButtonPanel<out S : Screen, T : Enum<T>>(
|
||||
|
||||
for ((k, entry) in enumMapping) {
|
||||
if (entry.tooltip != null && predicate.test(k)) {
|
||||
listing.add(entry.tooltip.copy().withStyle(if (entry.key == prop.get()) ChatFormatting.WHITE else ChatFormatting.GRAY))
|
||||
val active = entry.key == prop.get()
|
||||
val tooltip = entry.tooltip.copy().withStyle(if (active) ChatFormatting.WHITE else ChatFormatting.GRAY)
|
||||
listing.add(if (active) TranslatableComponent("otm.gui.tooltip.enum.active", tooltip) else tooltip)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,7 @@ object MBlockEntities {
|
||||
BlockEntityRenderers.register(MATTER_CAPACITOR_BANK, ::MatterBatteryBankRenderer)
|
||||
BlockEntityRenderers.register(MATTER_RECONSTRUCTOR, ::MatterReconstructorRenderer)
|
||||
BlockEntityRenderers.register(MATTER_REPLICATOR, ::MatterReplicatorRenderer)
|
||||
BlockEntityRenderers.register(MATTER_SCANNER, ::MatterScannerRenderer)
|
||||
BlockEntityRenderers.register(HOLO_SIGN, ::HoloSignRenderer)
|
||||
BlockEntityRenderers.register(FLUID_TANK, ::FluidTankRenderer)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user