aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt40
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt16
2 files changed, 41 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index ad2df542c..8a909f15e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -22,12 +22,14 @@ import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.client.Minecraft
+import net.minecraft.client.renderer.GLAllocation
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.RenderHelper
import net.minecraft.init.Blocks
import net.minecraft.init.Items
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
+import org.lwjgl.opengl.GL11
import java.util.regex.Pattern
object NEUItems {
@@ -192,8 +194,8 @@ object NEUItems {
ErrorManager.logError(
IllegalStateException("Something went wrong!"),
"Encountered an error getting the item for §7$this§c. " +
- "This may be because your NEU repo is outdated. Please ask in the SkyHanni " +
- "Discord if this is the case"
+ "This may be because your NEU repo is outdated. Please ask in the SkyHanni " +
+ "Discord if this is the case"
)
fallbackItem
}
@@ -201,6 +203,7 @@ object NEUItems {
fun isVanillaItem(item: ItemStack): Boolean =
manager.auctionManager.isVanillaItem(item.getInternalName().asString())
+
fun ItemStack.renderOnScreen(x: Float, y: Float, scaleMultiplier: Double = 1.0) {
val item = checkBlinkItem()
val isSkull = item.item === Items.skull
@@ -221,16 +224,39 @@ object NEUItems {
GlStateManager.pushMatrix()
- GlStateManager.translate(translateX, translateY, 1F)
- GlStateManager.scale(finalScale, finalScale, 1.0)
+ GlStateManager.translate(translateX, translateY, -19f)
+ GlStateManager.scale(finalScale, finalScale, 0.2)
+ GL11.glNormal3f(0f, 0f, 1f / 0.2f) // Compensate for z scaling
RenderHelper.enableGUIStandardItemLighting()
+
+ AdjustStandardItemLighting.adjust() // Compensate for z scaling
+
Minecraft.getMinecraft().renderItem.renderItemIntoGUI(item, 0, 0)
RenderHelper.disableStandardItemLighting()
GlStateManager.popMatrix()
}
+ private object AdjustStandardItemLighting {
+
+ private const val lightScaling = 2.47f // Adjust as needed
+ private const val g = 0.6f // Original Value taken from RenderHelper
+ private const val lightIntensity = lightScaling * g
+ private val itemLightBuffer = GLAllocation.createDirectFloatBuffer(16);
+
+ init {
+ itemLightBuffer.clear()
+ itemLightBuffer.put(lightIntensity).put(lightIntensity).put(lightIntensity).put(1.0f)
+ itemLightBuffer.flip()
+ }
+
+ fun adjust() {
+ GL11.glLight(16384, 4609, itemLightBuffer)
+ GL11.glLight(16385, 4609, itemLightBuffer)
+ }
+ }
+
fun allNeuRepoItems(): Map<String, JsonObject> = NotEnoughUpdates.INSTANCE.manager.itemInformation
fun getMultiplier(internalName: NEUInternalName, tryCount: Int = 0): Pair<NEUInternalName, Int> {
@@ -326,11 +352,11 @@ object NEUItems {
val name = group("name").trim { it <= ' ' }
val ultimate = group("format").lowercase().contains("§l")
((if (ultimate && name != "Ultimate Wise") "ULTIMATE_" else "")
- + turboCheck(name).replace(" ", "_").replace("-", "_").uppercase()
- + ";" + group("level").romanToDecimal())
+ + turboCheck(name).replace(" ", "_").replace("-", "_").uppercase()
+ + ";" + group("level").romanToDecimal())
}
- //Uses NEU
+ // Uses NEU
fun saveNBTData(item: ItemStack, removeLore: Boolean = true): String {
val jsonObject = manager.getJsonForItem(item)
if (!jsonObject.has("internalname")) {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt
index 9367e5ee1..01f9941aa 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt
@@ -62,7 +62,7 @@ interface Renderable {
text: String,
onClick: () -> Unit,
bypassChecks: Boolean = false,
- condition: () -> Boolean = { true }
+ condition: () -> Boolean = { true },
): Renderable =
link(string(text), onClick, bypassChecks, condition)
@@ -70,7 +70,7 @@ interface Renderable {
renderable: Renderable,
onClick: () -> Unit,
bypassChecks: Boolean = false,
- condition: () -> Boolean = { true }
+ condition: () -> Boolean = { true },
): Renderable {
return clickable(
hoverable(underlined(renderable), renderable, bypassChecks, condition = condition),
@@ -85,7 +85,7 @@ interface Renderable {
text: String,
tips: List<String>,
bypassChecks: Boolean = false,
- onClick: () -> Unit
+ onClick: () -> Unit,
): Renderable {
return clickable(hoverTips(text, tips, bypassChecks = bypassChecks), onClick, bypassChecks = bypassChecks)
}
@@ -95,7 +95,7 @@ interface Renderable {
onClick: () -> Unit,
button: Int = 0,
bypassChecks: Boolean = false,
- condition: () -> Boolean = { true }
+ condition: () -> Boolean = { true },
) =
object : Renderable {
override val width: Int
@@ -124,7 +124,7 @@ interface Renderable {
indexes: List<Int> = listOf(),
stack: ItemStack? = null,
bypassChecks: Boolean = false,
- condition: () -> Boolean = { true }
+ condition: () -> Boolean = { true },
): Renderable {
val render = string(text)
@@ -211,7 +211,7 @@ interface Renderable {
hovered: Renderable,
unhovered: Renderable,
bypassChecks: Boolean = false,
- condition: () -> Boolean = { true }
+ condition: () -> Boolean = { true },
) =
object : Renderable {
override val width: Int
@@ -233,8 +233,8 @@ interface Renderable {
override fun render(posX: Int, posY: Int) {
GlStateManager.pushMatrix()
- if (Minecraft.getMinecraft().currentScreen == null || Minecraft.getMinecraft().currentScreen is GuiChat)
- GlStateManager.translate(0F, 0F, -145F)
+ if (Minecraft.getMinecraft().currentScreen is GuiChat)
+ GlStateManager.translate(0F, 0F, -3F)
any.renderOnScreen(0F, 0F, scaleMultiplier = scale)
GlStateManager.popMatrix()
}