From 4703cac0e9b8dcc3728987023fe164d8a0f7c3f1 Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:13:01 -0400 Subject: [PATCH] Armor GUI, CPS, Potion Effects GUI --- .../java/net/minecraft/client/Minecraft.java | 4 + .../net/minecraft/client/gui/GuiIngame.java | 5 +- .../client/settings/GameSettings.java | 78 +++++++- .../minecraft/client/settings/KeyBinding.java | 4 +- .../net/PeytonPlayz585/shadow/ArmorGui.java | 178 ++++++++++++++++++ .../net/PeytonPlayz585/shadow/FuncUtils.java | 34 ++++ .../net/PeytonPlayz585/shadow/GuiShadow.java | 2 +- .../eaglercraft/v1_8/opengl/ImageData.java | 167 +++++++--------- .../server/EaglerIntegratedServerWorker.java | 17 +- .../client/renderer/RenderGlobal.java | 4 +- .../java/net/minecraft/client/Minecraft.java | 4 + .../net/minecraft/client/gui/GuiIngame.java | 6 +- .../client/settings/GameSettings.java | 80 +++++++- .../minecraft/client/settings/KeyBinding.java | 4 +- 14 files changed, 472 insertions(+), 115 deletions(-) create mode 100644 src/main/java/net/PeytonPlayz585/shadow/ArmorGui.java create mode 100644 src/main/java/net/PeytonPlayz585/shadow/FuncUtils.java diff --git a/src/lwjgl/java/net/minecraft/client/Minecraft.java b/src/lwjgl/java/net/minecraft/client/Minecraft.java index 538f496..c23b144 100644 --- a/src/lwjgl/java/net/minecraft/client/Minecraft.java +++ b/src/lwjgl/java/net/minecraft/client/Minecraft.java @@ -2338,4 +2338,8 @@ public class Minecraft implements IThreadListener { } return ret; } + + public float getPartialTicks() { + return this.timer.renderPartialTicks; + } } \ No newline at end of file diff --git a/src/lwjgl/java/net/minecraft/client/gui/GuiIngame.java b/src/lwjgl/java/net/minecraft/client/gui/GuiIngame.java index 1f3c13a..df639f6 100644 --- a/src/lwjgl/java/net/minecraft/client/gui/GuiIngame.java +++ b/src/lwjgl/java/net/minecraft/client/gui/GuiIngame.java @@ -5,6 +5,7 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*; import java.util.ArrayList; import java.util.Collection; +import net.PeytonPlayz585.shadow.ArmorGui; import net.PeytonPlayz585.shadow.Config; import net.PeytonPlayz585.shadow.CustomColors; import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; @@ -77,7 +78,7 @@ public class GuiIngame extends Gui { private static final ResourceLocation pumpkinBlurTexPath = new ResourceLocation("textures/misc/pumpkinblur.png"); private final EaglercraftRandom rand = new EaglercraftRandom(); private final Minecraft mc; - private final RenderItem itemRenderer; + public final RenderItem itemRenderer; private final GuiNewChat persistantChatGUI; private int updateCounter; /**+ @@ -312,6 +313,8 @@ public class GuiIngame extends Gui { this.overlayPlayerList.updatePlayerList(true); this.overlayPlayerList.renderPlayerlist(i, scoreboard, scoreobjective1); } + + ArmorGui.draw(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableLighting(); diff --git a/src/lwjgl/java/net/minecraft/client/settings/GameSettings.java b/src/lwjgl/java/net/minecraft/client/settings/GameSettings.java index 1261885..d2a7a26 100644 --- a/src/lwjgl/java/net/minecraft/client/settings/GameSettings.java +++ b/src/lwjgl/java/net/minecraft/client/settings/GameSettings.java @@ -269,6 +269,12 @@ public class GameSettings { public boolean hidePassword = true; public boolean fullBright = false; public boolean leftHand = false; + public boolean entityCulling = true; + public boolean particleCulling = true; + public boolean armorgui = false; + public boolean cps = false; + public boolean keyStrokes = false; + public boolean potionGUI = false; public boolean enableFNAWSkins = true; public int voiceListenRadius = 16; @@ -928,6 +934,30 @@ public class GameSettings { this.leftHand = !this.leftHand; } + if(parOptions == GameSettings.Options.ENTITY_CULLING) { + this.entityCulling = !this.entityCulling; + } + + if(parOptions == GameSettings.Options.PARTICLE_CULLING) { + this.particleCulling = !this.particleCulling; + } + + if(parOptions == GameSettings.Options.ARMOR_GUI) { + this.armorgui = !this.armorgui; + } + + if(parOptions == GameSettings.Options.CPS) { + this.cps = !this.cps; + } + + if(parOptions == GameSettings.Options.KEYSTROKES) { + this.keyStrokes = !this.keyStrokes; + } + + if(parOptions == GameSettings.Options.POTION_GUI) { + this.potionGUI = !this.potionGUI; + } + this.saveOptions(); } @@ -1058,6 +1088,16 @@ public class GameSettings { return this.fullBright; case LEFT_HAND: return this.leftHand; + case ENTITY_CULLING: + return this.entityCulling; + case PARTICLE_CULLING: + return this.particleCulling; + case ARMOR_GUI: + return this.armorgui; + case CPS: + return this.cps; + case POTION_GUI: + return this.potionGUI; default: return false; } @@ -1935,6 +1975,30 @@ public class GameSettings { if (astring[0].equals("leftHand") && astring.length >= 2) { leftHand = Boolean.valueOf(astring[1]).booleanValue(); } + + if(astring[0].equals("particleCulling") && astring.length >= 2) { + particleCulling = Boolean.valueOf(astring[1]).booleanValue(); + } + + if(astring[0].equals("entityCulling") && astring.length >= 2) { + entityCulling = Boolean.valueOf(astring[1]).booleanValue(); + } + + if(astring[0].equals("armorgui") && astring.length >= 2) { + armorgui = Boolean.valueOf(astring[1]).booleanValue(); + } + + if(astring[0].equals("cps") && astring.length >= 2) { + cps = Boolean.valueOf(astring[1]).booleanValue(); + } + + if(astring[0].equals("keyStrokes") && astring.length >= 2) { + keyStrokes = Boolean.valueOf(astring[1]).booleanValue(); + } + + if(astring[0].equals("potionGUI") && astring.length >= 2) { + potionGUI = Boolean.valueOf(astring[1]).booleanValue(); + } for (SoundCategory soundcategory : SoundCategory._VALUES) { if (astring[0].equals("soundCategory_" + soundcategory.getCategoryName())) { @@ -2131,6 +2195,12 @@ public class GameSettings { printwriter.println("enableFNAWSkins:" + this.enableFNAWSkins); printwriter.println("fullbright:" + this.fullBright); printwriter.println("leftHand:" + this.leftHand); + printwriter.println("entityCulling:" + this.entityCulling); + printwriter.println("particleCulling:" + this.particleCulling); + printwriter.println("armorgui:" + this.armorgui); + printwriter.println("cps:" + this.cps); + printwriter.println("keyStrokes:" + this.keyStrokes); + printwriter.println("potionGUI:" + this.potionGUI); for (KeyBinding keybinding : this.keyBindings) { printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode()); @@ -2344,7 +2414,13 @@ public class GameSettings { FNAW_SKINS("options.skinCustomisation.enableFNAWSkins", false, true), EAGLER_VSYNC("options.vsync", false, true), FULLBRIGHT("Fullbright", false, true), - LEFT_HAND("Main Hand", false, true); + LEFT_HAND("Main Hand", false, true), + ENTITY_CULLING("Entity Culling", false, true), + PARTICLE_CULLING("Particle Culling", false, true), + ARMOR_GUI("Armor GUI", false, true), + CPS("CPS", false, true), + KEYSTROKES("Keystrokes", false, true), + POTION_GUI("Potion Effects GUI", false, true); private final boolean enumFloat; private final boolean enumBoolean; diff --git a/src/lwjgl/java/net/minecraft/client/settings/KeyBinding.java b/src/lwjgl/java/net/minecraft/client/settings/KeyBinding.java index 7cc8b72..11cacf3 100644 --- a/src/lwjgl/java/net/minecraft/client/settings/KeyBinding.java +++ b/src/lwjgl/java/net/minecraft/client/settings/KeyBinding.java @@ -36,8 +36,8 @@ public class KeyBinding implements Comparable { private final String keyDescription; private final int keyCodeDefault; private final String keyCategory; - private int keyCode; - private boolean pressed; + public int keyCode; + public boolean pressed; private int pressTime; public static void onTick(int keyCode) { diff --git a/src/main/java/net/PeytonPlayz585/shadow/ArmorGui.java b/src/main/java/net/PeytonPlayz585/shadow/ArmorGui.java new file mode 100644 index 0000000..d68291b --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/ArmorGui.java @@ -0,0 +1,178 @@ +package net.PeytonPlayz585.shadow; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.lax1dude.eaglercraft.v1_8.Mouse; +import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiIngame; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ResourceLocation; + +public class ArmorGui { + public static void draw() { + if(Minecraft.getMinecraft().gameSettings.potionGUI) { + renderPotEffects(); + } + if(Minecraft.getMinecraft().gameSettings.armorgui) { + renderArmorDura(); + } + if(Minecraft.getMinecraft().gameSettings.cps) { + renderCPS(); + } + if(Minecraft.getMinecraft().gameSettings.keyStrokes) { + renderKeyStrokes(); + } + } + + public static void renderArmorDura() { + GlStateManager.enableLighting(); + ItemStack boots = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[0]; + ItemStack legs = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[1]; + ItemStack chest = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[2]; + ItemStack helmet = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[3]; + ItemStack hand = Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem(); + + if (helmet != null) { + ItemStack displayhelmet = helmet.copy(); + displayhelmet.stackSize = 1; + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemAndEffectIntoGUI(displayhelmet, 5 + 3, 15 + 2); + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, displayhelmet, 5 + 3, 15 + 2, ""); + } + + if (chest != null) { + ItemStack displaychest = chest.copy(); + displaychest.stackSize = 1; + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemAndEffectIntoGUI(displaychest, 5 + 3, 15 + 18); + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, displaychest, 5 + 3, 15 + 18, ""); + } + + if (legs != null) { + ItemStack displaylegs = legs.copy(); + displaylegs.stackSize = 1; + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemAndEffectIntoGUI(displaylegs, 5 + 3, 10 + 38); + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, displaylegs, 5 + 3, 15 + 38, ""); + } + + if (boots != null) { + ItemStack displayboots = boots.copy(); + displayboots.stackSize = 1; + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemAndEffectIntoGUI(displayboots, 5 + 3, 15 + 50); + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, displayboots, 5 + 3, 15 + 50, ""); + } + + RenderHelper.enableGUIStandardItemLighting(); + + if (hand != null) { + ItemStack displayhand = hand.copy(); + float f = (float) displayhand.animationsToGo - Minecraft.getMinecraft().getPartialTicks(); + if (f > 0.0F) { + GlStateManager.pushMatrix(); + float f1 = 1.0F + f / 5.0F; + GlStateManager.translate((float) ((5 + 3) + 8), (float) ((15 + 66) + 12), 0.0F); + GlStateManager.scale(1.0F / f1, (f1 + 1.0F) / 2.0F, 1.0F); + GlStateManager.translate((float) (-((5 + 3) + 8)), (float) (-((15 + 66) + 12)), 0.0F); + } + + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemAndEffectIntoGUI(displayhand, 5 + 3, 15 + 66); + if (f > 0.0F) { + GlStateManager.popMatrix(); + } + + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemOverlays(Minecraft.getMinecraft().fontRendererObj, displayhand, 5 + 3, 15 + 66); + } + + RenderHelper.disableStandardItemLighting(); + } + + public static void renderPotEffects() { + int i = 80; + int i2 = 16; + Collection collection = Minecraft.getMinecraft().thePlayer.getActivePotionEffects(); + if (!collection.isEmpty()) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.disableLighting(); + GlStateManager.enableAlpha(); + int l = 33; + if (collection.size() > 5) l = 132 / (collection.size() - 1); + for (PotionEffect potioneffect: Minecraft.getMinecraft().thePlayer.getActivePotionEffects()) { + Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + if (potion.hasStatusIcon()) { + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/inventory.png")); + int i3 = potion.getStatusIconIndex(); + GuiIngame guiIngame = new GuiIngame(Minecraft.getMinecraft()); + guiIngame.drawTexturedModalRect(4 + 21 - 20, 110 + i2 - 14, 0 + i3 % 8 * 18, 198 + i3 / 8 * 18, 18, 18); + } + String s1 = I18n.format(potion.getName(), new Object[0]); + if (potioneffect.getAmplifier() == 1) { + s1 = String.valueOf(String.valueOf(s1)) + " " + I18n.format("enchantment.level.2", new Object[0]); + } else if (potioneffect.getAmplifier() == 2) { + s1 = String.valueOf(String.valueOf(s1)) + " " + I18n.format("enchantment.level.3", new Object[0]); + } else if (potioneffect.getAmplifier() == 3) { + s1 = String.valueOf(String.valueOf(s1)) + " " + I18n.format("enchantment.level.4", new Object[0]); + } + Minecraft.getMinecraft().fontRendererObj.drawString(s1, (4 + 21), (110 + i2 - 14), -1); + String s2 = Potion.getDurationString(potioneffect); + Minecraft.getMinecraft().fontRendererObj.drawString(s2, (4 + 21), (110 + i2 + 10 - 14), -1); + i2 += l; + } + } + } + + public static boolean wasPressed; + public static long lastPressed; + private static List clicks = new ArrayList < > (); + + public static void renderCPS() { + boolean pressed = Mouse.isButtonDown(0) || Mouse.isButtonDown(1); + + if (pressed != wasPressed) { + lastPressed = System.currentTimeMillis(); + wasPressed = pressed; + if (pressed) { + clicks.add(lastPressed); + } + } + + final long time = System.currentTimeMillis(); + FuncUtils.removeIf(clicks, sinceLast -> sinceLast + 1000 < time); + + ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft()); + Minecraft.getMinecraft().fontRendererObj.drawString("[CPS: " + clicks.size() + "]", res.getScaledWidth() / 2 - 17, 5 + 2, -1); + } + + public static void renderKeyStrokes() { + } + + private static void renderHotbarItem(int xPos, int yPos, float partialTicks, ItemStack stack) { + ItemStack itemstack = stack; + if (itemstack != null) { + float f = (float) itemstack.animationsToGo - partialTicks; + if (f > 0.0F) { + GlStateManager.pushMatrix(); + float f1 = 1.0F + f / 5.0F; + GlStateManager.translate((float) (xPos + 8), (float) (yPos + 12), 0.0F); + GlStateManager.scale(1.0F / f1, (f1 + 1.0F) / 2.0F, 1.0F); + GlStateManager.translate((float) (-(xPos + 8)), (float) (-(yPos + 12)), 0.0F); + } + + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemAndEffectIntoGUI(itemstack, xPos, yPos); + if (f > 0.0F) { + GlStateManager.popMatrix(); + } + + Minecraft.getMinecraft().ingameGUI.itemRenderer.renderItemOverlays(Minecraft.getMinecraft().fontRendererObj, itemstack, xPos, yPos); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/FuncUtils.java b/src/main/java/net/PeytonPlayz585/shadow/FuncUtils.java new file mode 100644 index 0000000..f043aac --- /dev/null +++ b/src/main/java/net/PeytonPlayz585/shadow/FuncUtils.java @@ -0,0 +1,34 @@ +package net.PeytonPlayz585.shadow; + +import java.util.Collection; +import java.util.Iterator; +import java.util.function.Predicate; +import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; + +public class FuncUtils { + + public static boolean removeIf(Collection collection, Predicate pre) { + boolean ret = false; + Iterator itr = collection.iterator(); + while (itr.hasNext()) { + if (pre.test(itr.next())) { + itr.remove(); + ret = true; + } + } + return ret; + } + + public static boolean isInside(int mouseX, int mouseY, double x, double y, double width, double height) { + return (mouseX > x && mouseX < (x + width)) && (mouseY > y && mouseY < (y + height)); + } + + public static void setColor(int color) { + float f3 = (float) (color >> 24 & 255) / 255.0F; + float f = (float) (color >> 16 & 255) / 255.0F; + float f1 = (float) (color >> 8 & 255) / 255.0F; + float f2 = (float) (color & 255) / 255.0F; + + GlStateManager.color(f, f1, f2, f3); + } +} \ No newline at end of file diff --git a/src/main/java/net/PeytonPlayz585/shadow/GuiShadow.java b/src/main/java/net/PeytonPlayz585/shadow/GuiShadow.java index e1ad573..bf6b385 100644 --- a/src/main/java/net/PeytonPlayz585/shadow/GuiShadow.java +++ b/src/main/java/net/PeytonPlayz585/shadow/GuiShadow.java @@ -9,7 +9,7 @@ import net.minecraft.client.settings.GameSettings; public class GuiShadow extends GuiScreen { - private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.TOGGLE_SPRINT, GameSettings.Options.CHUNK_BORDERS, GameSettings.Options.HIDE_PASSWORD, GameSettings.Options.FULLBRIGHT, GameSettings.Options.LEFT_HAND}; + private static GameSettings.Options[] enumOptions = new GameSettings.Options[] {GameSettings.Options.TOGGLE_SPRINT, GameSettings.Options.CHUNK_BORDERS, GameSettings.Options.HIDE_PASSWORD, GameSettings.Options.FULLBRIGHT, GameSettings.Options.LEFT_HAND, GameSettings.Options.ENTITY_CULLING, GameSettings.Options.PARTICLE_CULLING, GameSettings.Options.ARMOR_GUI, GameSettings.Options.CPS, GameSettings.Options.POTION_GUI}; private GuiScreen parentScreen; protected String title; diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ImageData.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ImageData.java index 71eb24d..cf7ebe8 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ImageData.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/opengl/ImageData.java @@ -43,109 +43,86 @@ public class ImageData { public ImageData fillAlpha() { for(int i = 0; i < pixels.length; ++i) { - pixels[i] = pixels[i] | 0xFF000000; + pixels[i] |= 0xFF000000; } return this; } public ImageData getSubImage(int x, int y, int pw, int ph) { - int[] img = new int[pw * ph]; - for(int i = 0; i < ph; ++i) { - System.arraycopy(pixels, (i + y) * this.width + x, img, i * pw, pw); - } - return new ImageData(pw, ph, img, alpha); - } + int[] img = new int[pw * ph]; + for (int i = 0; i < ph; ++i) { + System.arraycopy(pixels, (i + y) * this.width + x, img, i * pw, pw); + } + return new ImageData(pw, ph, img, alpha); + } - public static final ImageData loadImageFile(String path) { - byte[] fileData = EagRuntime.getResourceBytes(path); - if(fileData != null) { - return loadImageFile(fileData); - }else { - return null; - } - } + public static final ImageData loadImageFile(String path) { + byte[] fileData = EagRuntime.getResourceBytes(path); + return (fileData != null) ? loadImageFile(fileData) : null; + } - public static final ImageData loadImageFile(InputStream data) { - return PlatformAssets.loadImageFile(data); - } + public static final ImageData loadImageFile(InputStream data) { + return PlatformAssets.loadImageFile(data); + } - public static final ImageData loadImageFile(byte[] data) { - return PlatformAssets.loadImageFile(data); - } + public static final ImageData loadImageFile(byte[] data) { + return PlatformAssets.loadImageFile(data); + } - public void getRGB(int startX, int startY, int w, int h, - int[] rgbArray, int offset, int scansize) { - for(int y = 0; y < h; ++y) { - System.arraycopy(pixels, offset + (y + startY) * scansize + startX, rgbArray, y * w, w); - } - } - - public void copyPixelsFrom(ImageData input, int dx1, int dy1, int dx2, int dy2, - int sx1, int sy1, int sx2, int sy2) { - if(sx2 - sx1 != dx2 - dx1) { - throw new IllegalArgumentException("Width of the copied region must match the" - + "width of the pasted region"); - } - int cw = sx2 - sx1; - if(sy2 - sy1 != dy2 - dy1) { - throw new IllegalArgumentException("Height of the copied region must match the" - + "height of the pasted region"); - } - int ch = sy2 - sy1; - for(int y = 0; y < ch; ++y) { - System.arraycopy(input.pixels, sx1 + (sy1 + y) * cw, pixels, dx1 + (dy1 + y) * cw, cw); - } - } - - public void drawLayer(ImageData input, int dx1, int dy1, int dx2, int dy2, - int sx1, int sy1, int sx2, int sy2) { - if(sx2 - sx1 != dx2 - dx1) { - throw new IllegalArgumentException("Width of the copied region must match the" - + "width of the pasted region"); - } - int cw = sx2 - sx1; - if(sy2 - sy1 != dy2 - dy1) { - throw new IllegalArgumentException("Height of the copied region must match the" - + "height of the pasted region"); - } - int ch = sy2 - sy1; - for(int y = 0; y < ch; ++y) { - for(int x = 0; x < cw; ++x) { - int si = (sy1 + y) * cw + sx1 + x; - int di = (dy1 + y) * cw + dx1 + x; - int spx = input.pixels[si]; - int dpx = pixels[di]; - if((spx & 0xFF000000) == 0xFF000000 || (dpx & 0xFF000000) == 0) { - pixels[di] = spx; - }else { - int sa = (spx >> 24) & 0xFF; - int da = (dpx >> 24) & 0xFF; - int r = ((spx >> 16) & 0xFF) * sa / 255; - int g = ((spx >> 8) & 0xFF) * sa / 255; - int b = (spx & 0xFF) * sa / 255; - int aa = (255 - sa) * da; - r += ((dpx >> 16) & 0xFF) * aa / 65025; - g += ((dpx >> 8) & 0xFF) * aa / 65025; - b += (dpx & 0xFF) * aa / 65025; - sa += da; - if(sa > 0xFF) sa = 0xFF; - pixels[di] = ((sa) << 24) | (r << 16) | (g << 8) | b; - } - } - } - } - - public ImageData swapRB() { - for(int i = 0; i < pixels.length; ++i) { - int j = pixels[i]; - pixels[i] = (j & 0xFF00FF00) | ((j & 0x00FF0000) >> 16) | - ((j & 0x000000FF) << 16); - } - return this; - } - - public static int swapRB(int c) { - return (c & 0xFF00FF00) | ((c & 0x00FF0000) >> 16) | ((c & 0x000000FF) << 16); - } + public void getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) { + for (int y = 0; y < h; ++y) { + System.arraycopy(pixels, offset + (y + startY) * scansize + startX, rgbArray, y * w, w); + } + } + + public void copyPixelsFrom(ImageData input, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) { + int cw = sx2 - sx1; + int ch = sy2 - sy1; + for (int y = 0; y < ch; ++y) { + System.arraycopy(input.pixels, sx1 + (sy1 + y) * cw, pixels, dx1 + (dy1 + y) * cw, cw); + } + } + + public void drawLayer(ImageData input, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) { + int cw = sx2 - sx1; + int ch = sy2 - sy1; + for (int y = 0; y < ch; ++y) { + for (int x = 0; x < cw; ++x) { + int si = (sy1 + y) * cw + sx1 + x; + int di = (dy1 + y) * cw + dx1 + x; + int spx = input.pixels[si]; + int dpx = pixels[di]; + + if ((spx & 0xFF000000) == 0xFF000000 || (dpx & 0xFF000000) == 0) { + pixels[di] = spx; + } else { + int sa = (spx >> 24) & 0xFF; + int da = (dpx >> 24) & 0xFF; + int r = ((spx >> 16) & 0xFF) * sa >> 8; + int g = ((spx >> 8) & 0xFF) * sa >> 8; + int b = (spx & 0xFF) * sa >> 8; + int aa = (255 - sa) * da >> 8; + r += ((dpx >> 16) & 0xFF) * aa >> 8; + g += ((dpx >> 8) & 0xFF) * aa >> 8; + b += (dpx & 0xFF) * aa >> 8; + sa += da; + if (sa > 0xFF) sa = 0xFF; + pixels[di] = (sa << 24) | (r << 16) | (g << 8) | b; + } + } + } + } + + public ImageData swapRB() { + for (int i = 0; i < pixels.length; ++i) { + int j = pixels[i]; + pixels[i] = (j & 0xFF00FF00) | ((j & 0x00FF0000) >> 16) | ((j & 0x000000FF) << 16); + } + return this; + } + + public static int swapRB(int c) { + return (c & 0xFF00FF00) | ((c & 0x00FF0000) >> 16) | ((c & 0x000000FF) << 16); + } } diff --git a/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/server/EaglerIntegratedServerWorker.java b/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/server/EaglerIntegratedServerWorker.java index c5d87ee..e4544c3 100644 --- a/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/server/EaglerIntegratedServerWorker.java +++ b/src/main/java/net/lax1dude/eaglercraft/v1_8/sp/server/EaglerIntegratedServerWorker.java @@ -64,22 +64,21 @@ public class EaglerIntegratedServerWorker { List pktList = ServerPlatformSingleplayer.recieveAllPacket(); if(pktList != null) { IPCPacketData packetData; - for(int i = 0, l = pktList.size(); i < l; ++i) { - packetData = pktList.get(i); - if(packetData.channel.equals(SingleplayerServerController.IPC_CHANNEL)) { + for(IPCPacketData pkt : pktList) { + if(pkt.channel.equals(SingleplayerServerController.IPC_CHANNEL)) { IPCPacketBase ipc; try { - ipc = IPCPacketManager.IPCDeserialize(packetData.contents); + ipc = IPCPacketManager.IPCDeserialize(pkt.contents); }catch(IOException ex) { throw new RuntimeException("Failed to deserialize IPC packet", ex); } handleIPCPacket(ipc); }else { - IntegratedServerPlayerNetworkManager netHandler = openChannels.get(packetData.channel); + IntegratedServerPlayerNetworkManager netHandler = openChannels.get(pkt.channel); if(netHandler != null) { - netHandler.addRecievedPacket(packetData.contents); + netHandler.addRecievedPacket(pkt.contents); }else { - logger.error("Recieved packet on channel that does not exist: \"{}\"", packetData.channel); + logger.error("Recieved packet on channel that does not exist: \"{}\"", pkt.channel); } } } @@ -88,8 +87,8 @@ public class EaglerIntegratedServerWorker { public static void tick() { List ocs = new ArrayList<>(openChannels.values()); - for(int i = 0, l = ocs.size(); i < l; ++i) { - ocs.get(i).tick(); + for(IntegratedServerPlayerNetworkManager netHandler : ocs) { + netHandler.tick(); } } diff --git a/src/main/java/net/minecraft/client/renderer/RenderGlobal.java b/src/main/java/net/minecraft/client/renderer/RenderGlobal.java index c0b0351..496c99f 100644 --- a/src/main/java/net/minecraft/client/renderer/RenderGlobal.java +++ b/src/main/java/net/minecraft/client/renderer/RenderGlobal.java @@ -506,7 +506,7 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene public void renderEntities(Entity renderViewEntity, ICamera camera, float partialTicks) { boolean b = true; - if(entityCantBeSeen(renderViewEntity)) { + if(this.mc.gameSettings.entityCulling && entityCantBeSeen(renderViewEntity)) { return; } if (this.renderEntitiesStartupCounter > 0) { @@ -2293,7 +2293,7 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene private EntityFX spawnEntityFX(int p_174974_1_, boolean ignoreRange, double p_174974_3_, double p_174974_5_, double p_174974_7_, double p_174974_9_, double p_174974_11_, double p_174974_13_, int... p_174974_15_) { if (this.mc != null && this.mc.getRenderViewEntity() != null && this.mc.effectRenderer != null) { - if(isBehindPlayer(new BlockPos(p_174974_3_, p_174974_5_, p_174974_7_))) { + if(this.mc.gameSettings.particleCulling && isBehindPlayer(new BlockPos(p_174974_3_, p_174974_5_, p_174974_7_))) { return null; } diff --git a/src/teavm/java/net/minecraft/client/Minecraft.java b/src/teavm/java/net/minecraft/client/Minecraft.java index a9f411d..5682211 100644 --- a/src/teavm/java/net/minecraft/client/Minecraft.java +++ b/src/teavm/java/net/minecraft/client/Minecraft.java @@ -2368,4 +2368,8 @@ public class Minecraft extends ModData implements IThreadListener { } return ret; } + + public float getPartialTicks() { + return this.timer.renderPartialTicks; + } } \ No newline at end of file diff --git a/src/teavm/java/net/minecraft/client/gui/GuiIngame.java b/src/teavm/java/net/minecraft/client/gui/GuiIngame.java index c8aef88..7a6284d 100644 --- a/src/teavm/java/net/minecraft/client/gui/GuiIngame.java +++ b/src/teavm/java/net/minecraft/client/gui/GuiIngame.java @@ -5,6 +5,7 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*; import java.util.ArrayList; import java.util.Collection; +import net.PeytonPlayz585.shadow.ArmorGui; import net.PeytonPlayz585.shadow.Config; import net.PeytonPlayz585.shadow.CustomColors; import net.eaglerforge.api.ModAPI; @@ -79,7 +80,7 @@ public class GuiIngame extends Gui { private static final ResourceLocation pumpkinBlurTexPath = new ResourceLocation("textures/misc/pumpkinblur.png"); private final EaglercraftRandom rand = new EaglercraftRandom(); private final Minecraft mc; - private final RenderItem itemRenderer; + public final RenderItem itemRenderer; private final GuiNewChat persistantChatGUI; private int updateCounter; /**+ @@ -315,6 +316,9 @@ public class GuiIngame extends Gui { this.overlayPlayerList.renderPlayerlist(i, scoreboard, scoreobjective1); } + if(this.mc.gameSettings.armorgui) { + ArmorGui.draw(); + } ModAPI.callEvent("drawhud", new ModData()); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/teavm/java/net/minecraft/client/settings/GameSettings.java b/src/teavm/java/net/minecraft/client/settings/GameSettings.java index f5966b4..141a850 100644 --- a/src/teavm/java/net/minecraft/client/settings/GameSettings.java +++ b/src/teavm/java/net/minecraft/client/settings/GameSettings.java @@ -272,6 +272,12 @@ public class GameSettings extends ModData { public boolean enableFNAWSkins = true; public boolean fullBright = false; public boolean leftHand = false; + public boolean entityCulling = true; + public boolean particleCulling = true; + public boolean armorgui = false; + public boolean cps = false; + public boolean keyStrokes = false; + public boolean potionGUI = false; public int voiceListenRadius = 16; public float voiceListenVolume = 0.5f; @@ -1091,6 +1097,30 @@ public class GameSettings extends ModData { if(parOptions == GameSettings.Options.LEFT_HAND) { this.leftHand = !this.leftHand; } + + if(parOptions == GameSettings.Options.ENTITY_CULLING) { + this.entityCulling = !this.entityCulling; + } + + if(parOptions == GameSettings.Options.PARTICLE_CULLING) { + this.particleCulling = !this.particleCulling; + } + + if(parOptions == GameSettings.Options.ARMOR_GUI) { + this.armorgui = !this.armorgui; + } + + if(parOptions == GameSettings.Options.CPS) { + this.cps = !this.cps; + } + + if(parOptions == GameSettings.Options.KEYSTROKES) { + this.keyStrokes = !this.keyStrokes; + } + + if(parOptions == GameSettings.Options.POTION_GUI) { + this.potionGUI = !this.potionGUI; + } this.saveOptions(); } @@ -1220,6 +1250,18 @@ public class GameSettings extends ModData { return this.fullBright; case LEFT_HAND: return this.leftHand; + case ENTITY_CULLING: + return this.entityCulling; + case PARTICLE_CULLING: + return this.particleCulling; + case ARMOR_GUI: + return this.armorgui; + case CPS: + return this.cps; + case POTION_GUI: + return this.potionGUI; + case KEYSTROKES: + return this.keyStrokes; default: return false; } @@ -2097,6 +2139,30 @@ public class GameSettings extends ModData { if (astring[0].equals("leftHand") && astring.length >= 2) { leftHand = Boolean.valueOf(astring[1]).booleanValue(); } + + if(astring[0].equals("particleCulling") && astring.length >= 2) { + particleCulling = Boolean.valueOf(astring[1]).booleanValue(); + } + + if(astring[0].equals("entityCulling") && astring.length >= 2) { + entityCulling = Boolean.valueOf(astring[1]).booleanValue(); + } + + if(astring[0].equals("armorgui") && astring.length >= 2) { + armorgui = Boolean.valueOf(astring[1]).booleanValue(); + } + + if(astring[0].equals("cps") && astring.length >= 2) { + cps = Boolean.valueOf(astring[1]).booleanValue(); + } + + if(astring[0].equals("keyStrokes") && astring.length >= 2) { + keyStrokes = Boolean.valueOf(astring[1]).booleanValue(); + } + + if(astring[0].equals("potionGUI") && astring.length >= 2) { + potionGUI = Boolean.valueOf(astring[1]).booleanValue(); + } for (SoundCategory soundcategory : SoundCategory._VALUES) { if (astring[0].equals("soundCategory_" + soundcategory.getCategoryName())) { @@ -2293,6 +2359,12 @@ public class GameSettings extends ModData { printwriter.println("enableFNAWSkins:" + this.enableFNAWSkins); printwriter.println("fullbright:" + this.fullBright); printwriter.println("leftHand:" + this.leftHand); + printwriter.println("entityCulling:" + this.entityCulling); + printwriter.println("particleCulling:" + this.particleCulling); + printwriter.println("armorgui:" + this.armorgui); + printwriter.println("cps:" + this.cps); + printwriter.println("keyStrokes:" + this.keyStrokes); + printwriter.println("potionGUI:" + this.potionGUI); for (KeyBinding keybinding : this.keyBindings) { printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode()); @@ -2506,7 +2578,13 @@ public class GameSettings extends ModData { FNAW_SKINS("options.skinCustomisation.enableFNAWSkins", false, true), EAGLER_VSYNC("options.vsync", false, true), FULLBRIGHT("Fullbright", false, true), - LEFT_HAND("Main Hand", false, true); + LEFT_HAND("Main Hand", false, true), + ENTITY_CULLING("Entity Culling", false, true), + PARTICLE_CULLING("Particle Culling", false, true), + ARMOR_GUI("Armor GUI", false, true), + CPS("CPS", false, true), + KEYSTROKES("Keystrokes", false, true), + POTION_GUI("Potion Effects GUI", false, true); private final boolean enumFloat; private final boolean enumBoolean; diff --git a/src/teavm/java/net/minecraft/client/settings/KeyBinding.java b/src/teavm/java/net/minecraft/client/settings/KeyBinding.java index c096876..ba2b77c 100644 --- a/src/teavm/java/net/minecraft/client/settings/KeyBinding.java +++ b/src/teavm/java/net/minecraft/client/settings/KeyBinding.java @@ -38,8 +38,8 @@ public class KeyBinding extends ModData implements Comparable { private final String keyDescription; private final int keyCodeDefault; private final String keyCategory; - private int keyCode; - private boolean pressed; + public int keyCode; + public boolean pressed; private int pressTime; public static void onTick(int keyCode) {