Compare commits

..

No commits in common. "f375d157b070dfc148229af22c4310b10f147e58" and "47ff975449e9d318e65dd8891070ccdb362e80aa" have entirely different histories.

10 changed files with 4 additions and 193 deletions

View File

@ -2,6 +2,7 @@ plugins {
id "fabric-loom" version "0.6.49" id "fabric-loom" version "0.6.49"
id "maven-publish" id "maven-publish"
id "org.jetbrains.kotlin.jvm" version "1.4.30" id "org.jetbrains.kotlin.jvm" version "1.4.30"
id "com.github.johnrengelman.shadow" version "4.0.4"
} }
archivesBaseName = project.archives_base_name archivesBaseName = project.archives_base_name
@ -79,10 +80,8 @@ dependencies {
include "alexiil.mc.lib:libblockattributes-items:${project.libblockattributes_version}" include "alexiil.mc.lib:libblockattributes-items:${project.libblockattributes_version}"
compile project(":kiwi-java") compile project(":kiwi-java")
include project(":kiwi-java") shadow project(":kiwi-java")
runtimeOnly project(":plugin:mousewheelie")
include project(":plugin:mousewheelie")
runtimeOnly project(":plugin:rei") runtimeOnly project(":plugin:rei")
include project(":plugin:rei") include project(":plugin:rei")

View File

@ -1,27 +0,0 @@
plugins {
id "fabric-loom"
id "org.jetbrains.kotlin.jvm"
}
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories {
maven {
url = "https://maven.siphalor.de/"
}
jcenter()
}
dependencies {
implementation project(":")
modImplementation("de.siphalor:mousewheelie-1.16:${project.mousewheelie_version}") {
exclude group: "net.fabricmc"
exclude group: "net.fabricmc.fabric-api"
exclude module: "modmenu"
exclude group: "me.shedaniel.cloth"
}
}

View File

@ -1,4 +0,0 @@
archives_base_name=PhyCon-Plugin-MouseWheelie
mousewheelie_version=1.6.4+mc1.16.4

View File

@ -1,41 +0,0 @@
package net.shadowfacts.phycon.plugin.mousewheelie.mixin;
import de.siphalor.mousewheelie.client.util.ScrollAction;
import de.siphalor.mousewheelie.client.util.accessors.IContainerScreen;
import de.siphalor.mousewheelie.client.util.accessors.ISpecialScrollableScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.Text;
import net.shadowfacts.phycon.block.terminal.TerminalScreen;
import net.shadowfacts.phycon.block.terminal.TerminalScreenHandler;
import org.spongepowered.asm.mixin.Mixin;
/**
* @author shadowfacts
*/
@Mixin(TerminalScreen.class)
public abstract class MixinTerminalScreen extends HandledScreen<TerminalScreenHandler> implements ISpecialScrollableScreen, IContainerScreen {
private MixinTerminalScreen(TerminalScreenHandler screenHandler, PlayerInventory playerInventory, Text text) {
super(screenHandler, playerInventory, text);
}
@Override
public ScrollAction mouseWheelie_onMouseScrolledSpecial(double mouseX, double mouseY, double scrollAmount) {
Slot slot = mouseWheelie_getSlotAt(mouseX, mouseY);
if (slot == null) {
return ScrollAction.PASS;
}
if (slot.id < handler.getBufferSlotsEnd()) {
// scrolling in the network inventory is never allowed
// scrolling out of the buffer is theoretically possible, but there isn't a straightforward way
// of telling the server not to mark the buffer slot as TO_NETWORK after mouse wheelie's song and dance
return ScrollAction.ABORT;
} else {
return ScrollAction.PASS;
}
}
}

View File

@ -1,36 +0,0 @@
{
"schemaVersion": 1,
"id": "phycon_mousewheelie",
"version": "${version}",
"name": "PhyCon Mouse Wheelie Integration",
"description": "",
"authors": [
"Shadowfacts"
],
"contact": {
"homepage": "https://git.shadowfacts.net/minecraft/PhysicalConnectivity"
},
"license": "LGPL-3.0",
"environment": "client",
"entrypoints": {
},
"mixins": [
{
"config": "phycon-mousewheelie-client.mixins.json",
"environment": "client"
}
],
"depends": {
"fabricloader": ">=0.4.0",
"fabric": "*",
"fabric-language-kotlin": ">=1.3.50",
"phycon": "*",
"mousewheelie": "*"
},
"custom": {
"modmenu:parent": "phycon"
}
}

View File

@ -1,11 +0,0 @@
{
"required": true,
"package": "net.shadowfacts.phycon.plugin.mousewheelie.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinTerminalScreen"
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -10,5 +10,4 @@ pluginManagement {
} }
include("kiwi-java") include("kiwi-java")
include("plugin:mousewheelie")
include("plugin:rei") include("plugin:rei")

View File

@ -1,18 +1,12 @@
package net.shadowfacts.phycon.mixin.client; package net.shadowfacts.phycon.mixin.client;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
import net.shadowfacts.phycon.block.terminal.TerminalScreen; import net.shadowfacts.phycon.block.terminal.TerminalScreen;
import net.shadowfacts.phycon.block.terminal.TerminalScreenHandler;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/** /**
@ -21,31 +15,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(HandledScreen.class) @Mixin(HandledScreen.class)
public class MixinHandledScreen { public class MixinHandledScreen {
@Inject( @Inject(method = "drawSlot(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/screen/slot/Slot;)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;enableDepthTest()V"))
method = "drawSlot(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/screen/slot/Slot;)V", private void drawSlot(MatrixStack matrixStack, Slot slot, CallbackInfo ci) {
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;enableDepthTest()V")
)
private void drawSlotUnderlay(MatrixStack matrixStack, Slot slot, CallbackInfo ci) {
if ((Object)this instanceof TerminalScreen) { if ((Object)this instanceof TerminalScreen) {
TerminalScreen self = (TerminalScreen)(Object)this; TerminalScreen self = (TerminalScreen)(Object)this;
self.drawSlotUnderlay(matrixStack, slot); self.drawSlotUnderlay(matrixStack, slot);
} }
} }
@Redirect(
method = "drawSlot(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/screen/slot/Slot;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/ItemRenderer;renderGuiItemOverlay(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V")
)
private void drawSlotAmount(ItemRenderer itemRenderer, TextRenderer textRenderer, ItemStack stack, int x, int y, @Nullable String countLabel, MatrixStack matrixStack, Slot slot) {
if ((Object)this instanceof TerminalScreen) {
TerminalScreen self = (TerminalScreen)(Object)this;
TerminalScreenHandler handler = self.getScreenHandler();
if (slot.id < handler.getNetworkSlotsEnd() && stack.getCount() > 1) {
self.drawNetworkSlotAmount(stack, x, y, slot, matrixStack);
return;
}
}
itemRenderer.renderGuiItemOverlay(textRenderer, stack, x, y, countLabel);
}
} }

View File

@ -8,8 +8,6 @@ import net.minecraft.client.gui.widget.AbstractButtonWidget
import net.minecraft.client.gui.widget.AbstractPressableButtonWidget import net.minecraft.client.gui.widget.AbstractPressableButtonWidget
import net.minecraft.client.gui.widget.ButtonWidget import net.minecraft.client.gui.widget.ButtonWidget
import net.minecraft.client.gui.widget.TextFieldWidget import net.minecraft.client.gui.widget.TextFieldWidget
import net.minecraft.client.render.Tessellator
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.util.math.MatrixStack import net.minecraft.client.util.math.MatrixStack
import net.minecraft.entity.player.PlayerInventory import net.minecraft.entity.player.PlayerInventory
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
@ -28,8 +26,6 @@ import net.shadowfacts.phycon.util.next
import net.shadowfacts.phycon.util.prev import net.shadowfacts.phycon.util.prev
import org.lwjgl.glfw.GLFW import org.lwjgl.glfw.GLFW
import java.lang.NumberFormatException import java.lang.NumberFormatException
import java.math.RoundingMode
import java.text.DecimalFormat
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.math.floor import kotlin.math.floor
import kotlin.math.min import kotlin.math.min
@ -263,42 +259,6 @@ class TerminalScreen(handler: TerminalScreenHandler, playerInv: PlayerInventory,
DrawableHelper.fill(matrixStack, slot.x, slot.y, slot.x + 16, slot.y + 16, color.toInt()) DrawableHelper.fill(matrixStack, slot.x, slot.y, slot.x + 16, slot.y + 16, color.toInt())
} }
private val DECIMAL_FORMAT = DecimalFormat("#.#").apply { roundingMode = RoundingMode.HALF_UP }
private val FORMAT = DecimalFormat("##").apply { roundingMode = RoundingMode.HALF_UP }
fun drawNetworkSlotAmount(stack: ItemStack, x: Int, y: Int, slot: Slot, matrixStack: MatrixStack) {
val amount = stack.count
val s = when {
amount < 1_000 -> amount.toString()
amount < 1_000_000 -> {
val format = if (amount < 10_000) DECIMAL_FORMAT else FORMAT
format.format(amount / 1_000.0) + "K"
}
amount < 1_000_000_000 -> {
val format = if (amount < 10_000_000) DECIMAL_FORMAT else FORMAT
format.format(amount / 1_000_000.0) + "M"
}
else -> {
DECIMAL_FORMAT.format(amount / 1000000000.0).toString() + "B"
}
}
// draw damage bar
// empty string for label because vanilla renders the count behind the damage bar
itemRenderer.renderGuiItemOverlay(textRenderer, stack, x, y, "")
matrixStack.push()
matrixStack.translate(x.toDouble(), y.toDouble(), itemRenderer.zOffset + 200.0)
val scale = 2 / 3f
matrixStack.scale(scale, scale, 1.0f)
val immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().buffer)
val textX = (1 / scale * 18) - textRenderer.getWidth(s).toFloat() - 3
val textY = (1 / scale * 18) - 11
textRenderer.draw(s, textX, textY, 0xffffff, true, matrixStack.peek().model, immediate, false, 0, 0xF000F0)
immediate.draw()
matrixStack.pop()
}
private fun isPointInsScrollThumb(mouseX: Double, mouseY: Double): Boolean { private fun isPointInsScrollThumb(mouseX: Double, mouseY: Double): Boolean {
val x = (width - backgroundWidth) / 2 val x = (width - backgroundWidth) / 2
val y = (height - backgroundHeight) / 2 val y = (height - backgroundHeight) / 2

View File

@ -236,10 +236,7 @@ class TerminalScreenHandler(syncId: Int, val playerInv: PlayerInventory, val ter
return slotsInsertedInto return slotsInsertedInto
} }
val networkSlotsStart = 0
val networkSlotsEnd = 54
val bufferSlotsStart = 54 val bufferSlotsStart = 54
val bufferSlotsEnd = 72
val playerSlotsStart = 72 val playerSlotsStart = 72
val playerSlotsEnd = 72 + 36 val playerSlotsEnd = 72 + 36
fun isNetworkSlot(id: Int) = id in 0 until bufferSlotsStart fun isNetworkSlot(id: Int) = id in 0 until bufferSlotsStart