Added BattleInfoComponent

This commit is contained in:
noil 2021-10-08 21:08:51 -04:00
parent bd13049b50
commit 82854ceb58
24 changed files with 395 additions and 188 deletions

View File

@ -10,16 +10,12 @@ import net.minecraft.block.BlockLiquid;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.IFluidBlock;
import org.apache.commons.lang3.CharUtils;
import org.apache.commons.lang3.math.NumberUtils;
@ -51,7 +47,7 @@ public final class BlocksComponent extends HudComponent {
if (block instanceof BlockAir)
continue;
if(!(block instanceof BlockLiquid || block instanceof IFluidBlock) && Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(new ItemStack(block)) == Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getMissingModel()) {
if (!(block instanceof BlockLiquid || block instanceof IFluidBlock) && Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(new ItemStack(block)) == Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getMissingModel()) {
continue;
}
@ -102,12 +98,12 @@ public final class BlocksComponent extends HudComponent {
final float rectX = renderPaddingX + this.getX() + xOffset;
final float rectY = renderPaddingY + this.getY() + yOffset;
RenderUtil.drawBorderedRect(rectX, rectY, rectX + 16, rectY + 16, 0.5f, color, borderColor);
if(block instanceof BlockLiquid || block instanceof IFluidBlock) {
if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
final Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
final ResourceLocation fluidStill = fluid.getStill();
final TextureAtlasSprite sprite;
if(fluidStill == null) {
if (fluidStill == null) {
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
} else {
// getTextureExtry (instead of getTextureEntry) is a forge typo, not a typo on our side

View File

@ -98,7 +98,7 @@ public final class CarouselComponent extends HudComponent {
protected String getValueAsOption() {
final Object wrappedValue = this.value.getValue();
if (wrappedValue instanceof Shader) {
return ((Shader)wrappedValue).getShaderID();
return ((Shader) wrappedValue).getShaderID();
} else {
return wrappedValue.toString().toLowerCase();
}
@ -109,7 +109,7 @@ public final class CarouselComponent extends HudComponent {
final ArrayList<String> options = new ArrayList<String>();
if (wrappedValue instanceof Shader) {
options.add(""); // always add an option for having no shader
for (Iterator<String> it = Seppuku.INSTANCE.getShaderManager().getShaderList(); it.hasNext();) {
for (Iterator<String> it = Seppuku.INSTANCE.getShaderManager().getShaderList(); it.hasNext(); ) {
options.add(it.next());
}
} else {
@ -124,7 +124,7 @@ public final class CarouselComponent extends HudComponent {
protected void pickOption(String option) {
final Object wrappedValue = this.value.getValue();
if (wrappedValue instanceof Shader) {
((Shader)wrappedValue).setShaderID(option);
((Shader) wrappedValue).setShaderID(option);
} else {
this.value.setEnumValue(option);
}

View File

@ -10,8 +10,8 @@ import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.util.logging.Level;
/**
@ -316,7 +316,7 @@ public class TextComponent extends HudComponent {
return "";
}
if(this.textCursor > this.selectCursor) {
if (this.textCursor > this.selectCursor) {
return this.displayValue.substring(this.selectCursor, this.textCursor);
} else {
return this.displayValue.substring(this.textCursor, this.selectCursor);
@ -332,7 +332,7 @@ public class TextComponent extends HudComponent {
public void setTextCursor(int pos, boolean shiftDown) {
if (pos <= 0) {
pos = 0;
} else if(pos > this.displayValue.length()) {
} else if (pos > this.displayValue.length()) {
pos = this.displayValue.length();
}
@ -365,7 +365,7 @@ public class TextComponent extends HudComponent {
end = Math.min(Math.max(end, 0), this.displayValue.length());
if (start == end) {
return;
} else if(start > end) {
} else if (start > end) {
final int temp = start;
start = end;
end = temp;

View File

@ -1,16 +1,12 @@
package me.rigamortis.seppuku.api.gui.menu;
import me.rigamortis.seppuku.api.util.NetworkUtil;
import me.rigamortis.seppuku.api.util.RenderUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.gui.GuiListExtended;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.ImageBufferDownload;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
/**
* @author noil
@ -46,7 +42,7 @@ public class GuiEntryAlt implements GuiListExtended.IGuiListEntry {
// load resource location & download skin from minotar's public api
if (this.resourceLocation == null) {
this.resourceLocation = AbstractClientPlayer.getLocationSkin(this.alt.getUsername());
this.getDownloadImageSkin(this.resourceLocation, this.alt.getUsername());
NetworkUtil.getDownloadImageSkin(this.resourceLocation, this.alt.getUsername());
} else { // render player head
Minecraft.getMinecraft().getTextureManager().bindTexture(this.resourceLocation);
GlStateManager.enableTexture2D();
@ -64,14 +60,6 @@ public class GuiEntryAlt implements GuiListExtended.IGuiListEntry {
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) {
}
private ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
textureManager.getTexture(resourceLocationIn);
ThreadDownloadImageData textureObject = new ThreadDownloadImageData(null, String.format("https://minotar.net/avatar/%s/64.png", StringUtils.stripControlCodes(username)), DefaultPlayerSkin.getDefaultSkin(AbstractClientPlayer.getOfflineUUID(username)), new ImageBufferDownload());
textureManager.loadTexture(resourceLocationIn, textureObject);
return textureObject;
}
public AltData getAlt() {
return this.alt;
}

View File

@ -1,5 +1,8 @@
package me.rigamortis.seppuku.api.util;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import java.awt.*;
/**
@ -25,4 +28,11 @@ public final class ColorUtil {
String hex = String.format("#%02x%02x%02x%02x", color.getAlpha(), color.getRed(), color.getGreen(), color.getBlue());
return hex;
}
public static int getHealthColor(Entity entity) {
int scale = (int) Math.round(255.0 - (double) ((EntityLivingBase) entity).getHealth() * 255.0 / (double) ((EntityLivingBase) entity).getMaxHealth());
int damageColor = 255 - scale << 8 | scale << 16;
return (255 << 24) | damageColor;
}
}

View File

@ -1,5 +1,13 @@
package me.rigamortis.seppuku.api.util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.ImageBufferDownload;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import org.apache.commons.io.IOUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@ -33,4 +41,12 @@ public final class NetworkUtil {
}
return null;
}
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
textureManager.getTexture(resourceLocationIn);
ThreadDownloadImageData textureObject = new ThreadDownloadImageData(null, String.format("https://minotar.net/avatar/%s/64.png", StringUtils.stripControlCodes(username)), DefaultPlayerSkin.getDefaultSkin(AbstractClientPlayer.getOfflineUUID(username)), new ImageBufferDownload());
textureManager.loadTexture(resourceLocationIn, textureObject);
return textureObject;
}
}

View File

@ -21,18 +21,19 @@ public final class ResourceUtil {
// note that this is kinda expensive for jar files since it lists ALL the
// resources and then filters them, so, if you need recursion, set recurse
// to true instead of doing it yourself or you will slow everything down
/**
* List directory contents for a resource folder.
* This is basically a brute-force implementation.
* Works for regular files and also JARs.
*
* @author Greg Briggs
* @param clazz Any java class that lives in the same place as the resources you want.
* @param path Should end with "/".
* @return The full path of each member item. Directories have a trailing slash.
* @throws URISyntaxException
* @throws IOException
*/
* List directory contents for a resource folder.
* This is basically a brute-force implementation.
* Works for regular files and also JARs.
*
* @param clazz Any java class that lives in the same place as the resources you want.
* @param path Should end with "/".
* @return The full path of each member item. Directories have a trailing slash.
* @throws URISyntaxException
* @throws IOException
* @author Greg Briggs
*/
public static Set<String> getResourceListing(Class clazz, String path, boolean recurse) throws URISyntaxException, IOException {
String classPath = clazz.getName().replace(".", "/");
@ -51,9 +52,9 @@ public final class ResourceUtil {
if (dirURL == null) {
/*
* In case of a jar file, we can't actually find a directory.
* Have to assume the same jar as clazz.
*/
* In case of a jar file, we can't actually find a directory.
* Have to assume the same jar as clazz.
*/
String me = classPath + ".class";
dirURL = clazz.getClassLoader().getResource(me);
// make absolute path from class' package if path doesnt have a leading slash, else, remove leading slash so patterns match
@ -73,7 +74,7 @@ public final class ResourceUtil {
JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
Set<String> result = new HashSet<String>(); //avoid duplicates in case it is a subdirectory
while(entries.hasMoreElements()) {
while (entries.hasMoreElements()) {
String name = entries.nextElement().getName();
if (name.startsWith(path) && !name.equals(path)) { //filter according to the path and ignore entry if it's the input path
// ignore part after next slash so that only subdirectories are kept instead of children of subdirectories (if not recursing)

View File

@ -121,16 +121,17 @@ public final class StringUtil {
/**
* Integer to Roman Numeral
* credits: Adilli Adil
*
* @param num
* @return
*/
public static String intToRoman(int num) {
StringBuilder sb = new StringBuilder();
int times = 0;
String[] romans = new String[] { "I", "IV", "V", "IX", "X", "XL", "L",
"XC", "C", "CD", "D", "CM", "M" };
int[] ints = new int[] { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500,
900, 1000 };
String[] romans = new String[]{"I", "IV", "V", "IX", "X", "XL", "L",
"XC", "C", "CD", "D", "CM", "M"};
int[] ints = new int[]{1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500,
900, 1000};
for (int i = ints.length - 1; i >= 0; i--) {
times = num / ints[i];
num %= ints[i];
@ -145,47 +146,50 @@ public final class StringUtil {
/**
* Insert a string inside another string at a given position. Does not check
* for bounds and therefore may throw.
* @param original The original string, where the insertion string will be put
*
* @param original The original string, where the insertion string will be put
* @param insertion The string to insert
* @param position Where to insert the string at
* @param position Where to insert the string at
* @returns the final string
*/
public static String insertAt(String original, String insertion, int position) {
return new StringBuilder(original.length() + insertion.length())
.append(original, 0, position)
.append(insertion)
.append(original,position, original.length())
.toString();
.append(original, 0, position)
.append(insertion)
.append(original, position, original.length())
.toString();
}
/**
* Insert a character inside another string at a given position. Does not
* check for bounds and therefore may throw.
* @param original The original string, where the insertion string will be put
*
* @param original The original string, where the insertion string will be put
* @param insertion The character to insert
* @param position Where to insert the character at
* @param position Where to insert the character at
* @returns the final string
*/
public static String insertAt(String original, char insertion, int position) {
return new StringBuilder(original.length() + 1)
.append(original, 0, position)
.append(insertion)
.append(original,position, original.length())
.toString();
.append(original, 0, position)
.append(insertion)
.append(original, position, original.length())
.toString();
}
/**
* Delete a range of characters in a string. Does not check for bounds and
* therefore may throw.
* @param s The string to manipulate
*
* @param s The string to manipulate
* @param start The start of the range
* @param end The end of the range (exclusive; character at this position not removed)
* @param end The end of the range (exclusive; character at this position not removed)
* @returns the final string
*/
public static String removeRange(String s, int start, int end) {
return new StringBuilder(s.length() + start - end)
.append(s, 0, start)
.append(s, end, s.length())
.toString();
.append(s, 0, start)
.append(s, end, s.length())
.toString();
}
}

View File

@ -2,36 +2,23 @@ package me.rigamortis.seppuku.api.util.shader;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.shader.Framebuffer;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.logging.Level;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL13.*;
import static org.lwjgl.opengl.GL11.glGetInteger;
import static org.lwjgl.opengl.GL13.GL_TEXTURE3;
import static org.lwjgl.opengl.GL20.*;
public class ShaderProgram {
@ -94,7 +81,7 @@ public class ShaderProgram {
}
public static ShaderProgram loadFromJSON(String filename) throws IOException, ParseException {
try(BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream(filename), StandardCharsets.UTF_8))) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream(filename), StandardCharsets.UTF_8))) {
final JSONParser parser = new JSONParser();
final Object objRaw = parser.parse(reader);
@ -102,7 +89,7 @@ public class ShaderProgram {
throw jsonTypeException("JSON root value", "a JSON object", objRaw);
}
final JSONObject obj = (JSONObject)objRaw;
final JSONObject obj = (JSONObject) objRaw;
// parse shader program name or default to its filename
ShaderProgram shader;
@ -110,7 +97,7 @@ public class ShaderProgram {
if (name == null) {
shader = new ShaderProgram(filename);
} else if (name instanceof String) {
shader = new ShaderProgram((String)name);
shader = new ShaderProgram((String) name);
} else {
throw jsonTypeException("name property", "a string or missing", name);
}
@ -120,9 +107,9 @@ public class ShaderProgram {
if (files == null) {
throw jsonException("files array missing");
} else if (files instanceof JSONArray) {
for (final Object file : (JSONArray)files) {
for (final Object file : (JSONArray) files) {
if (file instanceof String) {
shader.addShaderFile((String)file);
shader.addShaderFile((String) file);
} else {
throw jsonTypeException("a member of the files array", "a string", file);
}
@ -136,7 +123,7 @@ public class ShaderProgram {
// sanitisation for you
final Object uniforms = obj.get("uniforms");
if (uniforms instanceof JSONObject) {
for (HashMap.Entry<String, Object> entry : ((HashMap<String, Object>)uniforms).entrySet()) {
for (HashMap.Entry<String, Object> entry : ((HashMap<String, Object>) uniforms).entrySet()) {
final String uniform = entry.getKey();
if (isUniformReserved(uniform)) {
throw jsonException("the uniform name '" + uniform + "' is reserved");
@ -148,13 +135,13 @@ public class ShaderProgram {
throw jsonTypeException("a uniform entry", "JSON object", uniformObjRaw);
}
final JSONObject uniformObj = (JSONObject)uniformObjRaw;
final JSONObject uniformObj = (JSONObject) uniformObjRaw;
// get display name
String uName;
final Object displayName = uniformObj.get("displayname");
if (displayName instanceof String) {
uName = (String)displayName;
uName = (String) displayName;
} else if (displayName == null) {
uName = uniform;
} else {
@ -165,15 +152,15 @@ public class ShaderProgram {
String[] uAlias;
final Object aliases = uniformObj.get("alias");
if (aliases instanceof JSONArray) {
for (final Object alias : (JSONArray)aliases) {
for (final Object alias : (JSONArray) aliases) {
if (!(alias instanceof String)) {
throw jsonTypeException("a member of the uniform alias array", "a string", alias);
}
}
uAlias = ((ArrayList<String>)aliases).toArray(new String[((ArrayList<String>)aliases).size()]);
uAlias = ((ArrayList<String>) aliases).toArray(new String[((ArrayList<String>) aliases).size()]);
} else if (aliases == null) {
uAlias = new String[]{ uniform };
uAlias = new String[]{uniform};
} else {
throw jsonTypeException("uniform alias", "an array of strings or missing", aliases);
}
@ -182,7 +169,7 @@ public class ShaderProgram {
String uDesc;
final Object description = uniformObj.get("description");
if (description instanceof String) {
uDesc = (String)description;
uDesc = (String) description;
} else if (description == null) {
uDesc = null;
} else {
@ -207,7 +194,7 @@ public class ShaderProgram {
// make value object that can be used in the ui
Value finalValue;
switch ((String)uType) {
switch ((String) uType) {
case "int":
case "float":
if (uDefault == null) {
@ -227,7 +214,7 @@ public class ShaderProgram {
throw jsonTypeException("uniform default value type mismatched;", "a number or missing", uDefault);
}
if (((String)uType).equals("int")) {
if (((String) uType).equals("int")) {
// check that numbers are whole
// XXX org.json.simple stores whole numbers as Long (at least it seemed so in testing, if not, my bad -rafern)
if (!(uMin instanceof Long)) {
@ -240,17 +227,17 @@ public class ShaderProgram {
throw jsonException("uniform default value is an integer and must therefore be whole");
}
if (((Number)uMin).intValue() > ((Number)uMax).intValue()) {
if (((Number) uMin).intValue() > ((Number) uMax).intValue()) {
throw jsonException("uniform min must not be greater than max");
}
finalValue = new Value<Integer>(uName, uAlias, uDesc, ((Number)uDefault).intValue(), ((Number)uMin).intValue(), ((Number)uMax).intValue(), ((Number)uIncrements).intValue());
finalValue = new Value<Integer>(uName, uAlias, uDesc, ((Number) uDefault).intValue(), ((Number) uMin).intValue(), ((Number) uMax).intValue(), ((Number) uIncrements).intValue());
} else {
if (((Number)uMin).floatValue() > ((Number)uMax).floatValue()) {
if (((Number) uMin).floatValue() > ((Number) uMax).floatValue()) {
throw jsonException("uniform min must not be greater than max");
}
finalValue = new Value<Float>(uName, uAlias, uDesc, ((Number)uDefault).floatValue(), ((Number)uMin).floatValue(), ((Number)uMax).floatValue(), ((Number)uIncrements).floatValue());
finalValue = new Value<Float>(uName, uAlias, uDesc, ((Number) uDefault).floatValue(), ((Number) uMin).floatValue(), ((Number) uMax).floatValue(), ((Number) uIncrements).floatValue());
}
break;
case "bool":
@ -266,7 +253,7 @@ public class ShaderProgram {
throw jsonTypeException("uniform default value type mismatched;", "a boolean or missing", uDefault);
}
finalValue = new Value<Boolean>(uName, uAlias, uDesc, (Boolean)uDefault);
finalValue = new Value<Boolean>(uName, uAlias, uDesc, (Boolean) uDefault);
break;
default:
throw jsonException("unsupported uniform type '" + uType + "'");
@ -285,7 +272,7 @@ public class ShaderProgram {
public static ShaderProgram loadFromJSONNoThrow(String filename) {
try {
return loadFromJSON(filename);
} catch(Exception e) {
} catch (Exception e) {
Seppuku.INSTANCE.getLogger().log(Level.WARNING, "Failed to load shader program from json (see stack trace)");
e.printStackTrace();
return null;
@ -409,7 +396,7 @@ public class ShaderProgram {
public void destroy() {
if (this.valid) {
// release all, delete and invalidate program
while(this.release(true));
while (this.release(true)) ;
OpenGlHelper.glDeleteProgram(this.program);
this.program = 0;
this.valid = false;
@ -448,11 +435,11 @@ public class ShaderProgram {
final String uniformName = entry.getKey();
final Object val = entry.getValue().getValue();
if (val instanceof Integer) {
this.setUniform(uniformName, (Integer)val);
this.setUniform(uniformName, (Integer) val);
} else if (val instanceof Float) {
this.setUniform(uniformName, (Float)val);
this.setUniform(uniformName, (Float) val);
} else if (val instanceof Boolean) {
this.setUniform(uniformName, (Boolean)val);
this.setUniform(uniformName, (Boolean) val);
}
}
@ -491,7 +478,7 @@ public class ShaderProgram {
if (programStack.isEmpty()) {
OpenGlHelper.glUseProgram(programBeforeGrab);
} else if(programStack.size() == stackIndex) {
} else if (programStack.size() == stackIndex) {
ShaderProgram newProgram = programStack.peekLast();
OpenGlHelper.glUseProgram(newProgram.getProgram());
newProgram.flushUniformQueue();
@ -518,14 +505,14 @@ public class ShaderProgram {
locations.put(name, new Integer(fetched));
return fetched;
} else {
return (int)cached;
return (int) cached;
}
}
public void flushUniformQueue() {
if (this.make()) {
for (Map.Entry<Integer, UniformUtil.UValue> entry : this.uniformQueue.entrySet()) {
entry.getValue().set((int)entry.getKey());
entry.getValue().set((int) entry.getKey());
}
}
@ -665,11 +652,11 @@ public class ShaderProgram {
public void setColorUniform(int location, int color) {
this.setUniform(
location,
(float) (color >> 16 & 0xFF) * 0.003921569f,
(float) (color >> 8 & 0xFF) * 0.003921569f,
(float) (color & 0xFF) * 0.003921569f,
(float) (color >> 24 & 0xFF) * 0.003921569f
location,
(float) (color >> 16 & 0xFF) * 0.003921569f,
(float) (color >> 8 & 0xFF) * 0.003921569f,
(float) (color & 0xFF) * 0.003921569f,
(float) (color >> 24 & 0xFF) * 0.003921569f
);
}
@ -748,7 +735,7 @@ public class ShaderProgram {
public void setAnimateUniform() {
// not passing time directly or it will lead to floating point precision problems where the value never changes because of how big it is
this.setUniform(ANIMATE_UNIFORM, (float)(System.currentTimeMillis() % 1000) / 1000.0f);
this.setUniform(ANIMATE_UNIFORM, (float) (System.currentTimeMillis() % 1000) / 1000.0f);
}
public void setDepthUniformAndBindTexture() {
@ -765,7 +752,7 @@ public class ShaderProgram {
}
this.setUniform(depthUniform, 3);
this.setUniform(DEPTHDIMS_UNIFORM, (float)FramebufferUtil.getWidth(), (float)FramebufferUtil.getHeight());
this.setUniform(DEPTHDIMS_UNIFORM, (float) FramebufferUtil.getWidth(), (float) FramebufferUtil.getHeight());
if (this.depthTextureCounter == 1) {
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
@ -784,7 +771,7 @@ public class ShaderProgram {
if (this.depthTextureCounter < 0) {
throw new RuntimeException("Too many depth texture unbinds; there's a bug somewhere, report this");
} else if(this.depthTextureCounter == 0) {
} else if (this.depthTextureCounter == 0) {
GlStateManager.setActiveTexture(GL_TEXTURE3);
GlStateManager.bindTexture(0);
GlStateManager.disableTexture2D();

View File

@ -1,14 +1,10 @@
package me.rigamortis.seppuku.api.util.shader;
import me.rigamortis.seppuku.Seppuku;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.shader.Framebuffer;
import org.lwjgl.opengl.ContextCapabilities;
import org.lwjgl.opengl.GLContext;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.logging.Level;
@ -202,6 +198,7 @@ public final class UniformUtil {
}
private static Boolean arbShaders = null;
private static boolean usingArbShaders() {
if (arbShaders == null) {
// OpenGlHelper.arbShaders is private :(
@ -209,10 +206,11 @@ public final class UniformUtil {
arbShaders = new Boolean(contextcapabilities.OpenGL21);
}
return (boolean)arbShaders;
return (boolean) arbShaders;
}
private static boolean canWarn = true;
private static void showWarning(String message) {
if (canWarn) {
canWarn = false;
@ -303,7 +301,7 @@ public final class UniformUtil {
// methods for setting array uniforms. does no bounds checking; WILL crash on invalid data
public static void set(int loc, int vecSize, FloatBuffer val) {
switch(vecSize) {
switch (vecSize) {
case 1:
OpenGlHelper.glUniform1(loc, val);
break;
@ -322,7 +320,7 @@ public final class UniformUtil {
}
public static void set(int loc, int vecSize, IntBuffer val) {
switch(vecSize) {
switch (vecSize) {
case 1:
OpenGlHelper.glUniform1(loc, val);
break;
@ -342,7 +340,7 @@ public final class UniformUtil {
// methods for setting matrix uniforms. does no bounds checking; WILL crash on invalid data
public static void set(int loc, int matrixSize, boolean transpose, FloatBuffer val) {
switch(matrixSize) {
switch (matrixSize) {
case 2:
OpenGlHelper.glUniformMatrix2(loc, transpose, val);
break;

View File

@ -18,7 +18,7 @@ public class Regex {
public void setPatternString(String patternString) {
this.patternString = patternString;
if(patternString.equals("")) {
if (patternString.equals("")) {
this.pattern = null;
return;
}

View File

@ -94,7 +94,7 @@ public final class LocateFeatureCommand extends Command {
// I would use getDeclaredField("world") here, but it fails outside the dev environment
// I also tried using ObfuscationReflectionHelper but it wouldn't compile, so I gave up
Field worldField = null;
for(Field field : MapGenBase.class.getDeclaredFields()) {
for (Field field : MapGenBase.class.getDeclaredFields()) {
if (World.class.isAssignableFrom(field.getType())) {
worldField = field;
break;
@ -108,27 +108,25 @@ public final class LocateFeatureCommand extends Command {
worldField.setAccessible(true);
for(Field field : this.chunkGenerator.getClass().getDeclaredFields()) {
for (Field field : this.chunkGenerator.getClass().getDeclaredFields()) {
try {
if (MapGenStructure.class.isAssignableFrom(field.getType())) {
field.setAccessible(true);
MapGenBase structureGenerator = (MapGenBase) field.get(this.chunkGenerator);
worldField.set(structureGenerator, this);
}
} catch(IllegalAccessException e) {
} catch (IllegalAccessException e) {
Seppuku.INSTANCE.errorChat("Potential feature type skipped due to exception");
e.printStackTrace();
}
}
}
protected IChunkProvider createChunkProvider()
{
protected IChunkProvider createChunkProvider() {
return null;
}
protected boolean isChunkLoaded(int x, int z, boolean allowEmpty)
{
protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) {
return false;
}

View File

@ -0,0 +1,151 @@
package me.rigamortis.seppuku.impl.gui.hud.component;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.gui.hud.component.DraggableHudComponent;
import me.rigamortis.seppuku.api.util.ColorUtil;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor;
import me.rigamortis.seppuku.impl.module.combat.CrystalAuraModule;
import me.rigamortis.seppuku.impl.module.combat.KillAuraModule;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
public final class BattleInfoComponent extends DraggableHudComponent {
private CrystalAuraModule crystalAuraModule;
private KillAuraModule killAuraModule;
private AbstractClientPlayer currentOpponent;
public BattleInfoComponent() {
super("BattleInfo");
this.setW(117);
this.setH(48);
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
super.render(mouseX, mouseY, partialTicks);
if (mc.world != null && mc.player != null) {
if (this.crystalAuraModule == null)
this.crystalAuraModule = (CrystalAuraModule) Seppuku.INSTANCE.getModuleManager().find(CrystalAuraModule.class);
if (this.killAuraModule == null)
this.killAuraModule = (KillAuraModule) Seppuku.INSTANCE.getModuleManager().find(KillAuraModule.class);
// local vars
int itemSpacingOffset = 2;
String targetType = "target";
// grid
if (mc.currentScreen instanceof GuiHudEditor) {
for (float j = this.getX() + this.getW(); j > this.getX(); j -= 10) {
if (j <= this.getX())
continue;
if (j >= this.getX() + this.getW())
continue;
RenderUtil.drawLine(j, this.getY(), j, this.getY() + this.getH(), 2.0f, 0x75101010);
}
} else {
// background
RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0x75101010);
}
if (this.crystalAuraModule.getCurrentAttackEntity() != null) {
this.currentOpponent = (AbstractClientPlayer) this.crystalAuraModule.getCurrentAttackPlayer();
targetType = "crystal aura";
} else if (this.killAuraModule.getCurrentTarget() != null) {
if (this.killAuraModule.getCurrentTarget() instanceof AbstractClientPlayer) {
this.currentOpponent = (AbstractClientPlayer) this.killAuraModule.getCurrentTarget();
targetType = "kill aura";
}
} else if (mc.objectMouseOver != null) {
if (mc.objectMouseOver.entityHit != null) {
if (mc.objectMouseOver.entityHit instanceof AbstractClientPlayer && mc.objectMouseOver.entityHit.isEntityAlive()) {
this.currentOpponent = (AbstractClientPlayer) mc.objectMouseOver.entityHit;
targetType = "mouse over";
}
}
} else {
this.currentOpponent = null;
}
if (this.currentOpponent != null) {
if (this.currentOpponent.isEntityAlive()) {
// head bg
RenderUtil.drawRect(this.getX() + 1, this.getY() + 1, this.getX() + 27, this.getY() + 27, 0x75101010);
// head
mc.getTextureManager().bindTexture(this.currentOpponent.getLocationSkin());
RenderUtil.drawTexture(this.getX() + 2, this.getY() + 2, 24, 24, 8F / 64f, 8f / 64f, 16f / 64f, 16f / 64f);
// armor and items
GlStateManager.pushMatrix();
RenderHelper.enableGUIStandardItemLighting();
for (int i = 3; i >= 0; i--) {
final ItemStack stack = this.currentOpponent.inventoryContainer.getSlot(8 - i).getStack();
RenderUtil.drawRect((int) this.getX() + itemSpacingOffset, (int) this.getY() + 29, (int) this.getX() + itemSpacingOffset + 18, (int) this.getY() + 29 + 17, 0x75101010);
if (!stack.isEmpty()) {
mc.getRenderItem().renderItemAndEffectIntoGUI(stack, (int) this.getX() + itemSpacingOffset + 1, (int) this.getY() + 29);
mc.getRenderItem().renderItemOverlays(mc.fontRenderer, stack, (int) this.getX() + itemSpacingOffset + 1, (int) this.getY() + 29);
}
itemSpacingOffset += 19;
}
final ItemStack mainHandStack = this.currentOpponent.getHeldItem(EnumHand.MAIN_HAND);
RenderUtil.drawRect((int) this.getX() + itemSpacingOffset, (int) this.getY() + 29, (int) this.getX() + itemSpacingOffset + 18, (int) this.getY() + 29 + 17, 0x75101010);
if (!mainHandStack.isEmpty()) {
mc.getRenderItem().renderItemAndEffectIntoGUI(mainHandStack, (int) this.getX() + itemSpacingOffset + 1, (int) this.getY() + 29);
mc.getRenderItem().renderItemOverlays(mc.fontRenderer, mainHandStack, (int) this.getX() + itemSpacingOffset + 1, (int) this.getY() + 29);
}
itemSpacingOffset += 19;
final ItemStack offHandStack = this.currentOpponent.getHeldItem(EnumHand.OFF_HAND);
RenderUtil.drawRect((int) this.getX() + itemSpacingOffset, (int) this.getY() + 29, (int) this.getX() + itemSpacingOffset + 18, (int) this.getY() + 29 + 17, 0x75101010);
if (!offHandStack.isEmpty()) {
mc.getRenderItem().renderItemAndEffectIntoGUI(offHandStack, (int) this.getX() + itemSpacingOffset + 1, (int) this.getY() + 29);
mc.getRenderItem().renderItemOverlays(mc.fontRenderer, offHandStack, (int) this.getX() + itemSpacingOffset + 1, (int) this.getY() + 29);
}
RenderHelper.disableStandardItemLighting();
GlStateManager.popMatrix();
// hp bg
RenderUtil.drawRect(this.getX() + 28, this.getY() + 2 + mc.fontRenderer.FONT_HEIGHT * 2, this.getX() + this.getW() - 2, this.getY() + 2 + mc.fontRenderer.FONT_HEIGHT * 2 + 8, 0x75101010);
// hp
final float hpWidth = ((this.currentOpponent.getHealth() * ((this.getX() + this.getW() - 2 - 1) - (this.getX() + 29))) / this.currentOpponent.getMaxHealth());
RenderUtil.drawSideGradientRect(this.getX() + 29, this.getY() + 2 + mc.fontRenderer.FONT_HEIGHT * 2 + 1, this.getX() + this.getW() - 2 - 1, this.getY() + 2 + mc.fontRenderer.FONT_HEIGHT * 2 + 7, 0x3000FF00, 0x300000FF);
RenderUtil.drawRect(this.getX() + 29, this.getY() + 2 + mc.fontRenderer.FONT_HEIGHT * 2 + 1, ((this.getX() + 29) - (this.getX() + this.getW() - 2 - 1)) + (this.getX() + this.getW() - 2 - 1) + hpWidth, this.getY() + 2 + mc.fontRenderer.FONT_HEIGHT * 2 + 7, ColorUtil.getHealthColor(this.currentOpponent));
RenderUtil.drawGradientRect(this.getX() + 29, this.getY() + 2 + mc.fontRenderer.FONT_HEIGHT * 2 + 1, this.getX() + this.getW() - 2 - 1, this.getY() + 2 + mc.fontRenderer.FONT_HEIGHT * 2 + 7, 0x00000000, 0x50000000);
//if (this.currentOpponent instanceof AbstractClientPlayer) {
//final AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) this.currentOpponent;
//Minecraft.getMinecraft().getTextureManager().bindTexture(abstractClientPlayer.getLocationSkin());
//RenderUtil.drawTexture(this.getX(), this.getY(), 20, 20, 1, 0, 1, 1);
// }
} else {
this.currentOpponent = null;
}
// entity name
mc.fontRenderer.drawStringWithShadow(this.currentOpponent.getName(), this.getX() + 28, this.getY() + 2, 0xFFEEEEEE);
mc.fontRenderer.drawStringWithShadow("[" + targetType + "]", this.getX() + 28, this.getY() + 2 + mc.fontRenderer.FONT_HEIGHT, 0xFF999999);
} else {
mc.fontRenderer.drawStringWithShadow("Waiting for target...", this.getX() + 2, this.getY() + 2, 0xFFAAAAAA);
}
//if (this.isMouseInside(mouseX, mouseY)) { // mouse is inside
// draw extra info
//}
} else {
mc.fontRenderer.drawStringWithShadow("(battle info)", this.getX(), this.getY(), 0xFFAAAAAA);
}
}
}

View File

@ -642,7 +642,7 @@ public final class ModuleListComponent extends ResizableHudComponent {
public void onComponentEvent() {
final Regex regex = (Regex) value.getValue();
regex.setPatternString(valueText.getText());
if(regex.getPattern() == null)
if (regex.getPattern() == null)
Seppuku.INSTANCE.logfChat("%s - %s: Invalid or empty regular expression; no input will match with pattern.", module.getDisplayName(), value.getName());
Seppuku.INSTANCE.getConfigManager().save(ModuleConfig.class); // save configs
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventUIValueChanged(value));

View File

@ -105,6 +105,7 @@ public final class HudManager {
add(new TpsGraphComponent());
add(new MovementGraphComponent());
add(new ColorsComponent());
add(new BattleInfoComponent());
TrayComponent trayComponent = new TrayComponent();
trayComponent.setAnchorPoint(BOTTOM_CENTER);

View File

@ -1,13 +1,13 @@
package me.rigamortis.seppuku.impl.management;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.util.shader.ShaderProgram;
import me.rigamortis.seppuku.api.util.ResourceUtil;
import me.rigamortis.seppuku.api.util.shader.ShaderProgram;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
@ -43,7 +43,7 @@ public final class ShaderManager {
// TODO remove me
Seppuku.INSTANCE.getLogger().log(Level.INFO, "================= Loaded shaders =================");
for (Iterator<String> it = this.getShaderList(); it.hasNext();) {
for (Iterator<String> it = this.getShaderList(); it.hasNext(); ) {
Seppuku.INSTANCE.getLogger().log(Level.INFO, it.next());
}
Seppuku.INSTANCE.getLogger().log(Level.INFO, "==================================================");
@ -59,7 +59,7 @@ public final class ShaderManager {
}
private void destroyAll() {
for (Iterator<String> it = this.getShaderList(); it.hasNext();) {
for (Iterator<String> it = this.getShaderList(); it.hasNext(); ) {
this.getShader(it.next()).destroy();
}
@ -72,7 +72,7 @@ public final class ShaderManager {
for (File file : files) {
if (file.isDirectory()) {
this.loadShadersFilesystem(file);
} else if(file.getName().endsWith(".json")) {
} else if (file.getName().endsWith(".json")) {
// path is relative to shaders folder, remove prefix
final String path = file.getPath().substring(ShaderProgram.SHADER_FS_PATH.length());
final ShaderProgram shader = ShaderProgram.loadFromJSONNoThrow(path);
@ -88,14 +88,14 @@ public final class ShaderManager {
Set<String> listings;
try {
listings = ResourceUtil.getResourceListing(ShaderManager.class, path, true);
} catch(Exception e) {
} catch (Exception e) {
Seppuku.INSTANCE.getLogger().log(Level.WARNING, "Failed to recurse into resource path '" + path + "' when looking for shader files (see stack trace)");
e.printStackTrace();
return;
}
for (String listing : listings) {
if(listing.endsWith(".json")) {
if (listing.endsWith(".json")) {
String resourcePath = "resource://" + listing;
final ShaderProgram shader = ShaderProgram.loadFromJSONNoThrow(resourcePath);
if (shader != null) {

View File

@ -74,6 +74,7 @@ public final class CrystalAuraModule extends Module {
private BlockPos currentPlacePosition = null;
private BlockPos lastPlacePosition = null;
private Entity currentAttackEntity = null;
private Entity currentAttackPlayer = null;
public CrystalAuraModule() {
super("CrystalAura", new String[]{"AutoCrystal", "Crystal"}, "Automatically places crystals near enemies and detonates them", "NONE", -1, ModuleType.COMBAT);
@ -84,6 +85,8 @@ public final class CrystalAuraModule extends Module {
super.onDisable();
Seppuku.INSTANCE.getRotationManager().finishTask(this.placeRotationTask);
Seppuku.INSTANCE.getRotationManager().finishTask(this.attackRotationTask);
this.currentAttackEntity = null;
this.currentAttackPlayer = null;
}
@Listener
@ -279,6 +282,8 @@ public final class CrystalAuraModule extends Module {
}
if (targetPlayer != null) {
this.currentAttackPlayer = targetPlayer;
final float currentDamage = calculateExplosionDamage(targetPlayer, 6.0f, blockPos.getX() + 0.5f, blockPos.getY() + 1.0f, blockPos.getZ() + 0.5f) / 2.0f;
float localDamage = calculateExplosionDamage(mc.player, 6.0f, blockPos.getX() + 0.5f, blockPos.getY() + 1.0f, blockPos.getZ() + 0.5f) / 2.0f;
@ -393,4 +398,51 @@ public final class CrystalAuraModule extends Module {
}
}
public Timer getAttackTimer() {
return attackTimer;
}
public Timer getPlaceTimer() {
return placeTimer;
}
public List<PlaceLocation> getPlaceLocations() {
return placeLocations;
}
public RotationTask getPlaceRotationTask() {
return placeRotationTask;
}
public RotationTask getAttackRotationTask() {
return attackRotationTask;
}
public BlockPos getCurrentPlacePosition() {
return currentPlacePosition;
}
public void setCurrentPlacePosition(BlockPos currentPlacePosition) {
this.currentPlacePosition = currentPlacePosition;
}
public BlockPos getLastPlacePosition() {
return lastPlacePosition;
}
public void setLastPlacePosition(BlockPos lastPlacePosition) {
this.lastPlacePosition = lastPlacePosition;
}
public Entity getCurrentAttackEntity() {
return currentAttackEntity;
}
public Entity getCurrentAttackPlayer() {
return currentAttackPlayer;
}
public void setCurrentAttackEntity(Entity currentAttackEntity) {
this.currentAttackEntity = currentAttackEntity;
}
}

View File

@ -54,6 +54,7 @@ public final class KillAuraModule extends Module {
public void onDisable() {
super.onDisable();
Seppuku.INSTANCE.getRotationManager().finishTask(this.rotationTask);
this.currentTarget = null;
}
@Listener
@ -156,4 +157,15 @@ public final class KillAuraModule extends Module {
return ret;
}
public RotationTask getRotationTask() {
return rotationTask;
}
public Entity getCurrentTarget() {
return currentTarget;
}
public void setCurrentTarget(Entity currentTarget) {
this.currentTarget = currentTarget;
}
}

View File

@ -2,9 +2,9 @@ package me.rigamortis.seppuku.impl.module.render;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.render.EventDrawNameplate;
import me.rigamortis.seppuku.api.event.render.EventRender3D;
import me.rigamortis.seppuku.api.event.render.EventRenderEntity;
import me.rigamortis.seppuku.api.event.render.EventDrawNameplate;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.api.util.shader.ShaderProgram;
@ -27,9 +27,9 @@ import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.awt.*;
import static org.lwjgl.opengl.GL11.*;
@ -219,8 +219,7 @@ public final class ChamsModule extends Module {
final Entity entity = entry.getKey();
final QueuedEntity qEntity = entry.getValue();
if (qEntity.render != null)
{
if (qEntity.render != null) {
//OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)(15728880 % 65536), (float)(15728880 / 65536));
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f); // max brightness
qEntity.render.doRenderShadowAndFire(entity, qEntity.x, qEntity.y, qEntity.z, qEntity.yaw, qEntity.partialTicks);
@ -239,11 +238,10 @@ public final class ChamsModule extends Module {
final Entity entity = entry.getKey();
final QueuedEntity qEntity = entry.getValue();
if (qEntity.render != null)
{
if (qEntity.render != null) {
// set light level (from RenderManager.renderEntityStatic) and color
final int lightLevel = entity.isBurning() ? 15728880 : entity.getBrightnessForRender();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)(lightLevel % 65536), (float)(lightLevel / 65536));
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) (lightLevel % 65536), (float) (lightLevel / 65536));
GlStateManager.color(1.0f, 1.0f, 1.0f);
if (qEntity.entityType != lastEntityType && prog != null) {
@ -288,26 +286,26 @@ public final class ChamsModule extends Module {
private EntityType getEntityType(Entity entity) {
if (entity == Minecraft.getMinecraft().player ||
(entity instanceof EntityLivingBase && entity.ticksExisted <= 0) ||
Minecraft.getMinecraft().player.getRidingEntity() != null && entity == Minecraft.getMinecraft().player.getRidingEntity()) {
(entity instanceof EntityLivingBase && entity.ticksExisted <= 0) ||
Minecraft.getMinecraft().player.getRidingEntity() != null && entity == Minecraft.getMinecraft().player.getRidingEntity()) {
return EntityType.SKIP;
} else if(entity instanceof EntityPlayer) {
} else if (entity instanceof EntityPlayer) {
if (entity.isSneaking()) {
return EntityType.SNEAKING_PLAYER;
} else if(Seppuku.INSTANCE.getFriendManager().isFriend(entity) != null) {
} else if (Seppuku.INSTANCE.getFriendManager().isFriend(entity) != null) {
return EntityType.FRIENDLY_PLAYER;
} else {
return EntityType.NORMAL_PLAYER;
}
} else if(entity instanceof IAnimals && !(entity instanceof IMob)) {
} else if (entity instanceof IAnimals && !(entity instanceof IMob)) {
return EntityType.ANIMAL;
} else if(entity instanceof IMob) {
} else if (entity instanceof IMob) {
return EntityType.MOB;
} else if(entity instanceof EntityItem) {
} else if (entity instanceof EntityItem) {
return EntityType.ITEM;
} else if(entity instanceof EntityEnderCrystal) {
} else if (entity instanceof EntityEnderCrystal) {
return EntityType.CRYSTAL;
} else if(entity instanceof EntityBoat || entity instanceof EntityMinecart) {
} else if (entity instanceof EntityBoat || entity instanceof EntityMinecart) {
return EntityType.VEHICLE;
} else {
return EntityType.UNKNOWN;
@ -315,7 +313,7 @@ public final class ChamsModule extends Module {
}
private int getColor(EntityType entityType) {
switch(entityType) {
switch (entityType) {
case SNEAKING_PLAYER:
return this.sneakingColor.getValue().getRGB();
case FRIENDLY_PLAYER:
@ -340,7 +338,7 @@ public final class ChamsModule extends Module {
}
private boolean checkFilter(EntityType entityType) {
switch(entityType) {
switch (entityType) {
case SNEAKING_PLAYER:
case FRIENDLY_PLAYER:
case NORMAL_PLAYER:

View File

@ -45,7 +45,7 @@ public final class CrosshairModule extends Module {
final Minecraft mc = Minecraft.getMinecraft();
final ScaledResolution sr = new ScaledResolution(mc);
final float alpha = (float)this.alpha.getValue() / 255;
final float alpha = (float) this.alpha.getValue() / 255;
float size = this.size.getValue();
float thickness = this.thickness.getValue();
@ -57,8 +57,8 @@ public final class CrosshairModule extends Module {
thickness = temp;
}
final float xMid = (float)sr.getScaledWidth() / 2;
final float yMid = (float)sr.getScaledHeight() / 2;
final float xMid = (float) sr.getScaledWidth() / 2;
final float yMid = (float) sr.getScaledHeight() / 2;
final float halfSize = size / 2;
final float left = xMid - halfSize;
final float right = xMid + halfSize;
@ -81,9 +81,9 @@ public final class CrosshairModule extends Module {
// crosshair fill
if (this.fill.getValue()) {
final Color fillColor = this.fillColor.getValue();
final float red = (float)fillColor.getRed() / 255;
final float green = (float)fillColor.getGreen() / 255;
final float blue = (float)fillColor.getBlue() / 255;
final float red = (float) fillColor.getRed() / 255;
final float green = (float) fillColor.getGreen() / 255;
final float blue = (float) fillColor.getBlue() / 255;
if (this.fillInvert.getValue()) {
GlStateManager.tryBlendFuncSeparate(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR, 1, 0);
@ -123,9 +123,9 @@ public final class CrosshairModule extends Module {
// crosshair outline
if (this.outline.getValue()) {
final Color outlineColor = this.outlineColor.getValue();
final float ored = (float)outlineColor.getRed() / 255;
final float ogreen = (float)outlineColor.getGreen() / 255;
final float oblue = (float)outlineColor.getBlue() / 255;
final float ored = (float) outlineColor.getRed() / 255;
final float ogreen = (float) outlineColor.getGreen() / 255;
final float oblue = (float) outlineColor.getBlue() / 255;
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GlStateManager.shadeModel(GL_SMOOTH);

View File

@ -214,7 +214,7 @@ public final class NukerModule extends Module {
final double dist = mc.player.getDistance(pos.getX(), pos.getY(), pos.getZ());
if (pos.equals(SpeedMineModule.autoPos)) {
continue;
}
}
if (dist <= maxDist && (mc.world.getBlockState(pos).getBlock() != Blocks.AIR && !(mc.world.getBlockState(pos).getBlock() instanceof BlockLiquid)) && canBreak(pos)) {
if (selection) {
if ((this.selected == null) || !mc.world.getBlockState(pos).getBlock().equals(this.selected)) {

View File

@ -1,7 +1,5 @@
package me.rigamortis.seppuku.impl.module.world;
import java.awt.*;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.player.EventClickBlock;
import me.rigamortis.seppuku.api.event.player.EventPlayerDamageBlock;
@ -9,7 +7,6 @@ import me.rigamortis.seppuku.api.event.player.EventPlayerUpdate;
import me.rigamortis.seppuku.api.event.player.EventResetBlockRemoving;
import me.rigamortis.seppuku.api.event.render.EventRender3D;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.ColorUtil;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.block.Block;
@ -23,6 +20,8 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
import java.awt.*;
/**
* Author Seth
* 4/24/2019 @ 12:16 PM.
@ -91,19 +90,19 @@ public final class SpeedMineModule extends Module {
if (autoPos != null && mc.world.getBlockState(autoPos).getBlock() != Blocks.AIR) {
RenderUtil.begin3D();
final AxisAlignedBB bb = new AxisAlignedBB(
autoPos.getX() - mc.getRenderManager().viewerPosX,
autoPos.getY() - mc.getRenderManager().viewerPosY,
autoPos.getZ() - mc.getRenderManager().viewerPosZ,
autoPos.getX() + 1 - mc.getRenderManager().viewerPosX,
autoPos.getY() + 1 - mc.getRenderManager().viewerPosY,
autoPos.getZ() + 1 - mc.getRenderManager().viewerPosZ
autoPos.getX() - mc.getRenderManager().viewerPosX,
autoPos.getY() - mc.getRenderManager().viewerPosY,
autoPos.getZ() - mc.getRenderManager().viewerPosZ,
autoPos.getX() + 1 - mc.getRenderManager().viewerPosX,
autoPos.getY() + 1 - mc.getRenderManager().viewerPosY,
autoPos.getZ() + 1 - mc.getRenderManager().viewerPosZ
);
RenderUtil.drawBoundingBox(bb, 2f, new Color(255,255,255).getRGB());
RenderUtil.drawBoundingBox(bb, 2f, new Color(255, 255, 255).getRGB());
RenderUtil.end3D();
}
}
@Listener
public void damageBlock(EventPlayerDamageBlock event) {
if (canBreak(event.getPos())) {
@ -136,8 +135,7 @@ public final class SpeedMineModule extends Module {
if (auto.getValue()) {
if (autoPos == null) {
autoPos = event.getPos();
}
else if (mc.world.getBlockState(autoPos).getBlock() == Blocks.AIR) {
} else if (mc.world.getBlockState(autoPos).getBlock() == Blocks.AIR) {
autoPos = event.getPos();
}
@ -168,8 +166,6 @@ public final class SpeedMineModule extends Module {
}
private boolean canBreak(BlockPos pos) {
final IBlockState blockState = mc.world.getBlockState(pos);
final Block block = blockState.getBlock();

View File

@ -6,7 +6,6 @@ import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.player.EventFovModifier;
import me.rigamortis.seppuku.api.event.player.EventGetMouseOver;
import me.rigamortis.seppuku.api.event.player.EventPlayerReach;
import me.rigamortis.seppuku.api.event.render.EventDrawNameplate;
import me.rigamortis.seppuku.api.event.render.*;
import me.rigamortis.seppuku.api.patch.ClassPatch;
import me.rigamortis.seppuku.api.patch.MethodPatch;

View File

@ -108,8 +108,8 @@ public final class RenderLivingBasePatch extends ClassPatch {
* @return
*/
public static void setBrightnessHook(Buffer buf) {
FloatBuffer brightness = (FloatBuffer)buf;
for (Iterator<ShaderProgram> it = ShaderProgram.getProgramsInUse(); it.hasNext();) {
FloatBuffer brightness = (FloatBuffer) buf;
for (Iterator<ShaderProgram> it = ShaderProgram.getProgramsInUse(); it.hasNext(); ) {
it.next().setEntityBrightnessUniform(brightness.get(), brightness.get(), brightness.get(), brightness.get());
brightness.position(0);
}
@ -139,7 +139,7 @@ public final class RenderLivingBasePatch extends ClassPatch {
* @return
*/
public static void unsetBrightnessHook() {
for (Iterator<ShaderProgram> it = ShaderProgram.getProgramsInUse(); it.hasNext();) {
for (Iterator<ShaderProgram> it = ShaderProgram.getProgramsInUse(); it.hasNext(); ) {
it.next().setEntityBrightnessUniform(0.0f, 0.0f, 0.0f, 0.0f);
}
}