├── README.md ├── OBJ-Cosmetics ├── minecraft │ └── assets │ │ └── client │ │ └── cosmetics │ │ └── bandanas │ │ ├── 01 │ │ └── bandana_01.png │ │ └── models │ │ └── bandana.obj ├── cosmetics │ ├── CosmeticsManager.java │ ├── CosmeticsHandler.java │ ├── impl │ │ └── Bandana.java │ └── loader │ │ ├── Obj.java │ │ └── OBJLoader.java └── README.md ├── motionblur ├── README.md └── MotionBlur.java ├── Menu-Blur-Shader ├── assets │ └── minecraft │ │ └── shaders │ │ ├── program │ │ ├── menu_blur.fsh │ │ └── menu_blur.json │ │ └── post │ │ └── menu_blur.json └── README.md └── FontRenderer └── FontRenderer.java /README.md: -------------------------------------------------------------------------------- 1 | # MCP-Snippets 2 | 3 | You can skid all my snippets :3 4 | -------------------------------------------------------------------------------- /OBJ-Cosmetics/minecraft/assets/client/cosmetics/bandanas/01/bandana_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CuteNyami/MCP-Snippets/HEAD/OBJ-Cosmetics/minecraft/assets/client/cosmetics/bandanas/01/bandana_01.png -------------------------------------------------------------------------------- /motionblur/README.md: -------------------------------------------------------------------------------- 1 | # MotionBlur 2 | 3 | ### How to use: 4 | 5 | You need to paste this in the runGameLoop() method in the Minecraft class 6 | 7 | ````java 8 | MotionBlur.createAccumulation(); 9 | ```` 10 | -------------------------------------------------------------------------------- /OBJ-Cosmetics/cosmetics/CosmeticsManager.java: -------------------------------------------------------------------------------- 1 | package client.cosmetics; 2 | 3 | import net.minecraft.util.ResourceLocation; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | public class CosmeticsManager { 10 | 11 | public static List cosmetics = new ArrayList<>(); 12 | 13 | public static void registerCosmetics(CosmeticsHandler... handlers) { 14 | cosmetics.addAll(Arrays.asList(handlers)); 15 | } 16 | 17 | public static ResourceLocation getWingTexture() { 18 | return null; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Menu-Blur-Shader/assets/minecraft/shaders/program/menu_blur.fsh: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | uniform sampler2D DiffuseSampler; 4 | 5 | varying vec2 texCoord; 6 | varying vec2 oneTexel; 7 | 8 | uniform vec2 InSize; 9 | 10 | uniform vec2 BlurDir; 11 | uniform float Radius; 12 | 13 | void main() { 14 | vec4 blurred = vec4(0.0); 15 | float totalStrength = 0.0; 16 | for(float r = -Radius; r <= Radius; r += 1.0) { 17 | vec4 tex = texture2D(DiffuseSampler, texCoord + oneTexel * r * BlurDir); 18 | float strength = 1.0 - abs(r / Radius); 19 | totalStrength = totalStrength + strength; 20 | blurred = blurred + tex * strength; 21 | } 22 | gl_FragColor = vec4(blurred.rgb / totalStrength, 1.0); 23 | } -------------------------------------------------------------------------------- /Menu-Blur-Shader/README.md: -------------------------------------------------------------------------------- 1 | # Menu Blur Shader 2 | 3 | ### How can I load the shader? 4 | ```java 5 | Minecraft.getMinecraft().entityRenderer.loadShader(new ResourceLocation("shaders/post/menu_blur.json")); 6 | ``` 7 | 8 | ### How can I unload the shader? 9 | ```java 10 | Minecraft.getMinecraft().entityRenderer.stopUseShader(); 11 | ``` 12 | 13 | ### Example gui with the blur shader: 14 | ```java 15 | public class ExampleGui extends GuiScreen { 16 | 17 | private final Minecraft mc = Minecraft.getMinecraft(); 18 | 19 | @Override 20 | public void initGui() { 21 | mc.entityRenderer.loadShader(new ResourceLocation("shaders/post/menu_blur.json")); 22 | } 23 | 24 | @Override 25 | public void onGuiClosed() { 26 | mc.entityRenderer.stopUseShader(); 27 | } 28 | } 29 | ``` 30 | -------------------------------------------------------------------------------- /OBJ-Cosmetics/cosmetics/CosmeticsHandler.java: -------------------------------------------------------------------------------- 1 | package client.cosmetics; 2 | 3 | import net.minecraft.client.model.ModelRenderer; 4 | import net.minecraft.entity.Entity; 5 | 6 | public abstract class CosmeticsHandler { 7 | 8 | private final String name; 9 | private final CosmeticsType type; 10 | 11 | public CosmeticsHandler(String name, CosmeticsType type) { 12 | this.name = name; 13 | this.type = type; 14 | } 15 | 16 | public abstract void render(Entity entityIn, ModelRenderer modelRenderer); 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public CosmeticsType getType() { 23 | return type; 24 | } 25 | 26 | public enum CosmeticsType { 27 | 28 | HAT, 29 | BODY, 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Menu-Blur-Shader/assets/minecraft/shaders/post/menu_blur.json: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | "swap" 4 | ], 5 | "passes": [ 6 | { 7 | "name": "menu_blur", 8 | "intarget": "minecraft:main", 9 | "outtarget": "swap", 10 | "uniforms": [ 11 | { 12 | "name": "BlurDir", 13 | "values": [ 1.0, 0.0 ] 14 | }, 15 | { 16 | "name": "Radius", 17 | "values": [ 20.0 ] 18 | } 19 | ] 20 | }, 21 | { 22 | "name": "menu_blur", 23 | "intarget": "swap", 24 | "outtarget": "minecraft:main", 25 | "uniforms": [ 26 | { 27 | "name": "BlurDir", 28 | "values": [ 0.0, 1.0 ] 29 | }, 30 | { 31 | "name": "Radius", 32 | "values": [ 20.0 ] 33 | } 34 | ] 35 | } 36 | ] 37 | } -------------------------------------------------------------------------------- /Menu-Blur-Shader/assets/minecraft/shaders/program/menu_blur.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "blend": { 4 | "func": "add", 5 | "srcrgb": "one", 6 | "dstrgb": "zero" 7 | }, 8 | "vertex": "sobel", 9 | "fragment": "menu_blur", 10 | "attributes": [ "Position" ], 11 | "samplers": [ 12 | { "name": "DiffuseSampler" } 13 | ], 14 | "uniforms": [ 15 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 16 | { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 17 | { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 18 | { "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 19 | { "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] } 20 | ] 21 | } -------------------------------------------------------------------------------- /motionblur/MotionBlur.java: -------------------------------------------------------------------------------- 1 | package client.mod.impl; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import org.lwjgl.opengl.GL11; 5 | 6 | public class MotionBlur { 7 | public static float f; 8 | 9 | public static void createAccumulation() { 10 | float f = getAccumulationValue(); 11 | GL11.glAccum(GL11.GL_MULT, f); 12 | GL11.glAccum(GL11.GL_ACCUM, 1.0F - f); 13 | GL11.glAccum(GL11.GL_RETURN, 1.0F); 14 | } 15 | 16 | public static float getMultiplier() { 17 | return Minecraft.getDebugFPS() > 120 ? (Minecraft.getDebugFPS() > 200 ? 60.0F : 30.0F) : 0.0F; 18 | } 19 | 20 | public static float getAccumulationValue() { 21 | f = getMultiplier() * 10.0F; 22 | long lastTimestampInGame = System.currentTimeMillis(); 23 | 24 | if (f > 996.0F) { 25 | f = 996.0F; 26 | } 27 | 28 | if (f > 990.0F) { 29 | f = 990.0F; 30 | } 31 | 32 | long i = System.currentTimeMillis() - lastTimestampInGame; 33 | 34 | if (i > 10000L) { 35 | return 0.0F; 36 | } else { 37 | if (f < 0.0F) { 38 | f = 0.0F; 39 | } 40 | 41 | return f / 1000.0F; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /OBJ-Cosmetics/cosmetics/impl/Bandana.java: -------------------------------------------------------------------------------- 1 | package client.cosmetics.impl; 2 | 3 | import client.SimplexClient; 4 | import client.cosmetics.CosmeticsHandler; 5 | import client.cosmetics.loader.Obj; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.model.ModelRenderer; 8 | import net.minecraft.client.renderer.GlStateManager; 9 | import net.minecraft.entity.Entity; 10 | import net.minecraft.util.ResourceLocation; 11 | 12 | import java.io.IOException; 13 | 14 | public class Bandana extends CosmeticsHandler { 15 | 16 | private Obj model; 17 | 18 | public Bandana() { 19 | super("Bandana", CosmeticsType.HAT); 20 | try { 21 | model = SimplexClient.getInstance().getObjLoader().loadModel(Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("client/cosmetics/bandanas/models/bandana.obj")).getInputStream()); 22 | } catch (IOException e) { 23 | e.printStackTrace(); 24 | } 25 | } 26 | 27 | @Override 28 | public void render(Entity entityIn, ModelRenderer modelRenderer) { 29 | GlStateManager.pushMatrix(); 30 | if (entityIn.isSneaking()) { 31 | GlStateManager.translate(0.0, 0.06, 0.0); 32 | } 33 | 34 | if (modelRenderer.rotateAngleZ != 0.0F) { 35 | GlStateManager.rotate(modelRenderer.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F); 36 | } 37 | 38 | if (modelRenderer.rotateAngleY != 0.0F) { 39 | GlStateManager.rotate(modelRenderer.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); 40 | } 41 | 42 | if (modelRenderer.rotateAngleX != 0.0F) { 43 | GlStateManager.rotate(modelRenderer.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F); 44 | } 45 | 46 | GlStateManager.translate(-0f, 0.0f, 0.010); 47 | GlStateManager.rotate(180, 0, 0, 0); 48 | GlStateManager.scale(0.068F, 0.068F, 0.068F); 49 | GlStateManager.color(255, 255, 255, 255); 50 | Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("client/cosmetics/bandanas/01/bandana_01.png")); 51 | SimplexClient.getInstance().getObjLoader().render(model); 52 | GlStateManager.popMatrix(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /OBJ-Cosmetics/README.md: -------------------------------------------------------------------------------- 1 | # Obj Cosmetics 2 | 3 | ### The Original OBJ Loader: 4 | 5 | ### https://github.com/Blunderchips/LWJGL-OBJ-Loader 6 | 7 | ## How to use: 8 | 9 | ### first create a new instance of the OBJLoader class in your Main 10 | 11 | ````java 12 | private OBJLoader objLoader; 13 | 14 | public void startup() { 15 | objLoader = new OBJLoader(); 16 | } 17 | 18 | public OBJLoader getObjLoader() { 19 | return objLoader; 20 | } 21 | ```` 22 | 23 | ### then you need to register your Cosmetics 24 | 25 | ````java 26 | private OBJLoader objLoader; 27 | 28 | public void startup() { 29 | objLoader = new OBJLoader(); 30 | 31 | CosmeticsManager.registerCosmetics(new Bandana()); 32 | } 33 | 34 | public OBJLoader getObjLoader() { 35 | return objLoader; 36 | } 37 | ```` 38 | 39 | ### and now you need to go into the ModelPlayer class and replace the render method 40 | 41 | ````java 42 | public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale) { 43 | super.render(entityIn, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale); 44 | GlStateManager.pushMatrix(); 45 | 46 | if (this.isChild) { 47 | float f = 2.0F; 48 | GlStateManager.scale(1.0F / f, 1.0F / f, 1.0F / f); 49 | GlStateManager.translate(0.0F, 24.0F * scale, 0.0F); 50 | this.bipedLeftLegwear.render(scale); 51 | this.bipedRightLegwear.render(scale); 52 | this.bipedLeftArmwear.render(scale); 53 | this.bipedRightArmwear.render(scale); 54 | this.bipedBodyWear.render(scale); 55 | } else { 56 | if (entityIn.isSneaking()) { 57 | GlStateManager.translate(0.0F, 0.2F, 0.0F); 58 | } 59 | 60 | this.bipedLeftLegwear.render(scale); 61 | this.bipedRightLegwear.render(scale); 62 | this.bipedLeftArmwear.render(scale); 63 | this.bipedRightArmwear.render(scale); 64 | this.bipedBodyWear.render(scale); 65 | 66 | 67 | if (entityIn.getName().equals(Minecraft.getMinecraft().getSession().getProfile().getName())) { 68 | for (CosmeticsHandler handler : CosmeticsManager.cosmetics) { 69 | if (handler.getType() == CosmeticsHandler.CosmeticsType.HAT) { 70 | handler.render(entityIn, this.bipedHead); 71 | } else if (handler.getType() == CosmeticsHandler.CosmeticsType.BODY) { 72 | handler.render(entityIn, this.bipedBody); 73 | } 74 | } 75 | } 76 | } 77 | 78 | GlStateManager.popMatrix(); 79 | } 80 | ```` 81 | -------------------------------------------------------------------------------- /OBJ-Cosmetics/cosmetics/loader/Obj.java: -------------------------------------------------------------------------------- 1 | package client.cosmetics.loader; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | 7 | import org.lwjgl.opengl.GL11; 8 | import org.lwjgl.util.vector.Vector2f; 9 | import org.lwjgl.util.vector.Vector3f; 10 | 11 | import static org.lwjgl.opengl.GL11.GL_FLAT; 12 | import static org.lwjgl.opengl.GL11.GL_SMOOTH; 13 | 14 | public class Obj extends Object { 15 | 16 | private final List vertices; 17 | private final List textureCoords; 18 | private final List normals; 19 | private final List faces; 20 | private boolean enableSmoothShading; 21 | 22 | public Obj(List vertices, List textureCoords, 23 | List normals, List faces, boolean enableSmoothShading) { 24 | super(); 25 | 26 | this.vertices = vertices; 27 | this.textureCoords = textureCoords; 28 | this.normals = normals; 29 | this.faces = faces; 30 | this.enableSmoothShading = enableSmoothShading; 31 | } 32 | 33 | public Obj() { 34 | this(new ArrayList(), new ArrayList(), 35 | new ArrayList(), new ArrayList(), true); 36 | } 37 | 38 | public void enableStates() { 39 | if (this.isSmoothShadingEnabled()) { 40 | GL11.glShadeModel(GL_SMOOTH); 41 | } else { 42 | GL11.glShadeModel(GL_FLAT); 43 | } 44 | } 45 | 46 | public boolean hasTextureCoordinates() { 47 | return this.getTextureCoordinates().size() > 0; 48 | } 49 | 50 | public boolean hasNormals() { 51 | return this.getNormals().size() > 0; 52 | } 53 | 54 | public List getVertices() { 55 | return this.vertices; 56 | } 57 | 58 | public List getTextureCoordinates() { 59 | return this.textureCoords; 60 | } 61 | 62 | public List getNormals() { 63 | return this.normals; 64 | } 65 | 66 | public List getFaces() { 67 | return this.faces; 68 | } 69 | 70 | public boolean isSmoothShadingEnabled() { 71 | return this.enableSmoothShading; 72 | } 73 | 74 | public void setSmoothShadingEnabled(boolean isSmoothShadingEnabled) { 75 | this.enableSmoothShading = isSmoothShadingEnabled; 76 | } 77 | 78 | public static class Face extends Object { 79 | 80 | private final int[] vertexIndices; 81 | private final int[] normalIndices; 82 | private final int[] textureCoordinateIndices; 83 | 84 | public boolean hasNormals() { 85 | return this.normalIndices != null; 86 | } 87 | 88 | public boolean hasTextureCoords() { 89 | return this.textureCoordinateIndices != null; 90 | } 91 | 92 | public int[] getVertices() { 93 | return this.vertexIndices; 94 | } 95 | 96 | public int[] getTextureCoords() { 97 | return this.textureCoordinateIndices; 98 | } 99 | 100 | public int[] getNormals() { 101 | return this.normalIndices; 102 | } 103 | 104 | public Face(int[] vertexIndices, int[] textureCoordinateIndices, 105 | int[] normalIndices) { 106 | super(); 107 | 108 | this.vertexIndices = vertexIndices; 109 | this.normalIndices = normalIndices; 110 | this.textureCoordinateIndices = textureCoordinateIndices; 111 | } 112 | 113 | @Override 114 | public String toString() { 115 | return String.format("Face[vertexIndices%s normalIndices%s textureCoordinateIndices%s]", 116 | Arrays.toString(vertexIndices), Arrays.toString(normalIndices), Arrays.toString(textureCoordinateIndices)); 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /OBJ-Cosmetics/cosmetics/loader/OBJLoader.java: -------------------------------------------------------------------------------- 1 | package client.cosmetics.loader; 2 | 3 | import java.io.File; 4 | import java.io.InputStream; 5 | import java.io.FileNotFoundException; 6 | import java.util.Scanner; 7 | import java.util.concurrent.Executors; 8 | import java.util.concurrent.ScheduledExecutorService; 9 | 10 | import org.lwjgl.opengl.GL11; 11 | import org.lwjgl.util.vector.Vector2f; 12 | import org.lwjgl.util.vector.Vector3f; 13 | 14 | import static org.lwjgl.opengl.GL11.GL_FRONT; 15 | import static org.lwjgl.opengl.GL11.GL_COMPILE; 16 | import static org.lwjgl.opengl.GL11.GL_SHININESS; 17 | import static org.lwjgl.opengl.GL11.GL_TRIANGLES; 18 | 19 | /** 20 | * OBJloader class. Loads in Wavefront .obj file in to the program. 21 | * 22 | * @author Matthew Van der Bijl 23 | */ 24 | public class OBJLoader extends Object { 25 | 26 | /** 27 | * Constructs a new OBJLoader. 28 | */ 29 | public OBJLoader() { 30 | super(); 31 | } 32 | 33 | public int createDisplayList(Obj model) { 34 | int displayList = GL11.glGenLists(1); 35 | GL11.glNewList(displayList, GL_COMPILE); 36 | { 37 | this.render(model); 38 | } 39 | GL11.glEndList(); 40 | return displayList; 41 | } 42 | 43 | /** 44 | * Renders a given Obj file. 45 | * 46 | * @param model the Obj file to be rendered 47 | */ 48 | public void render(Obj model) { 49 | GL11.glMaterialf(GL_FRONT, GL_SHININESS, 120); 50 | GL11.glBegin(GL_TRIANGLES); 51 | { 52 | for (Obj.Face face : model.getFaces()) { 53 | Vector3f[] normals = { 54 | model.getNormals().get(face.getNormals()[0] - 1), 55 | model.getNormals().get(face.getNormals()[1] - 1), 56 | model.getNormals().get(face.getNormals()[2] - 1) 57 | }; 58 | Vector2f[] texCoords = { 59 | model.getTextureCoordinates().get(face.getTextureCoords()[0] - 1), 60 | model.getTextureCoordinates().get(face.getTextureCoords()[1] - 1), 61 | model.getTextureCoordinates().get(face.getTextureCoords()[2] - 1) 62 | }; 63 | Vector3f[] vertices = { 64 | model.getVertices().get(face.getVertices()[0] - 1), 65 | model.getVertices().get(face.getVertices()[1] - 1), 66 | model.getVertices().get(face.getVertices()[2] - 1) 67 | }; 68 | { 69 | GL11.glNormal3f(normals[0].getX(), normals[0].getY(), normals[0].getZ()); 70 | GL11.glTexCoord2f(texCoords[0].getX(), texCoords[0].getY()); 71 | GL11.glVertex3f(vertices[0].getX(), vertices[0].getY(), vertices[0].getZ()); 72 | GL11.glNormal3f(normals[1].getX(), normals[1].getY(), normals[1].getZ()); 73 | GL11.glTexCoord2f(texCoords[1].getX(), texCoords[1].getY()); 74 | GL11.glVertex3f(vertices[1].getX(), vertices[1].getY(), vertices[1].getZ()); 75 | GL11.glNormal3f(normals[2].getX(), normals[2].getY(), normals[2].getZ()); 76 | GL11.glTexCoord2f(texCoords[2].getX(), texCoords[2].getY()); 77 | GL11.glVertex3f(vertices[2].getX(), vertices[2].getY(), vertices[2].getZ()); 78 | } 79 | } 80 | } 81 | GL11.glEnd(); 82 | } 83 | 84 | /** 85 | * @param file the file to be loaded 86 | * @return the loaded Obj 87 | * @throws java.io.FileNotFoundException thrown if the Obj file is not found 88 | */ 89 | public Obj loadModel(File file) throws FileNotFoundException { 90 | return this.loadModel(new Scanner(file)); 91 | } 92 | 93 | /** 94 | * @param stream the stream to be loaded 95 | * @return the loaded Obj 96 | */ 97 | public Obj loadModel(InputStream stream) { 98 | return this.loadModel(new Scanner(stream)); 99 | } 100 | 101 | /** 102 | * @param sc the Obj to be loaded 103 | * @return the loaded Obj 104 | */ 105 | public Obj loadModel(Scanner sc) { 106 | Obj model = new Obj(); 107 | while (sc.hasNextLine()) { 108 | String ln = sc.nextLine(); 109 | if (ln == null || ln.equals("") || ln.startsWith("#")) { 110 | } else { 111 | String[] split = ln.split(" "); 112 | switch (split[0]) { 113 | case "v": 114 | model.getVertices().add(new Vector3f( 115 | Float.parseFloat(split[1]), 116 | Float.parseFloat(split[2]), 117 | Float.parseFloat(split[3]) 118 | )); 119 | break; 120 | case "vn": 121 | model.getNormals().add(new Vector3f( 122 | Float.parseFloat(split[1]), 123 | Float.parseFloat(split[2]), 124 | Float.parseFloat(split[3]) 125 | )); 126 | break; 127 | case "vt": 128 | model.getTextureCoordinates().add(new Vector2f( 129 | Float.parseFloat(split[1]), 130 | Float.parseFloat(split[2]) 131 | )); 132 | break; 133 | case "f": 134 | model.getFaces().add(new Obj.Face( 135 | new int[]{ 136 | Integer.parseInt(split[1].split("/")[0]), 137 | Integer.parseInt(split[2].split("/")[0]), 138 | Integer.parseInt(split[3].split("/")[0]) 139 | }, 140 | new int[]{ 141 | Integer.parseInt(split[1].split("/")[1]), 142 | Integer.parseInt(split[2].split("/")[1]), 143 | Integer.parseInt(split[3].split("/")[1]) 144 | }, 145 | new int[]{ 146 | Integer.parseInt(split[1].split("/")[2]), 147 | Integer.parseInt(split[2].split("/")[2]), 148 | Integer.parseInt(split[3].split("/")[2]) 149 | } 150 | )); 151 | break; 152 | case "s": 153 | model.setSmoothShadingEnabled(!ln.contains("off")); 154 | break; 155 | default: 156 | System.err.println("[OBJ] Unknown Line: " + ln); 157 | } 158 | } 159 | } 160 | sc.close(); 161 | return model; 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /FontRenderer/FontRenderer.java: -------------------------------------------------------------------------------- 1 | import net.minecraft.client.Minecraft; 2 | import net.minecraft.client.gui.ScaledResolution; 3 | import net.minecraft.client.renderer.GlStateManager; 4 | import org.lwjgl.opengl.GL11; 5 | import org.newdawn.slick.SlickException; 6 | import org.newdawn.slick.UnicodeFont; 7 | import org.newdawn.slick.font.effects.ColorEffect; 8 | 9 | import java.awt.*; 10 | import java.io.IOException; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | import java.util.Objects; 14 | import java.util.regex.Pattern; 15 | 16 | public class FontRenderer { 17 | 18 | private final String path; 19 | 20 | private final float size; 21 | 22 | public final int FONT_HEIGHT = 9; 23 | 24 | private final Map cachedStringWidth; 25 | 26 | private float antiAliasingFactor; 27 | 28 | private UnicodeFont unicodeFont; 29 | 30 | private int prevScaleFactor; 31 | 32 | private final ColorEffect colorEffect = new ColorEffect(Color.WHITE); 33 | 34 | private final Pattern pattern = Pattern.compile("§[0123456789abcdefklmnor]"); 35 | 36 | public FontRenderer(String path, float size) { 37 | this.path = path; 38 | this.size = size; 39 | 40 | this.cachedStringWidth = new HashMap<>(); 41 | this.prevScaleFactor = new ScaledResolution(Minecraft.getMinecraft()).getScaleFactor(); 42 | 43 | ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft()); 44 | 45 | try { 46 | this.prevScaleFactor = resolution.getScaleFactor(); 47 | this.unicodeFont = new UnicodeFont(this.getFontFromInput(path).deriveFont(this.size * this.prevScaleFactor / 2.0F)); 48 | this.unicodeFont.addAsciiGlyphs(); 49 | this.unicodeFont.getEffects().add(new ColorEffect(Color.WHITE)); 50 | this.unicodeFont.loadGlyphs(); 51 | this.antiAliasingFactor = resolution.getScaleFactor(); 52 | } catch (SlickException | IOException | FontFormatException e) { 53 | e.printStackTrace(); 54 | } 55 | } 56 | 57 | public void drawStringShadow(String text, float x, float y, Color color) { 58 | drawString(text, x + 1.0F, y + 1.0F, Color.BLACK); 59 | drawString(text, x, y, color); 60 | } 61 | 62 | public void drawCenteredString(String text, float x, float y, Color color) { 63 | drawString(text, x - ((int) getWidth(text) >> 1), y, color); 64 | } 65 | 66 | public void drawCenteredStringShadow(String text, float x, float y, Color color) { 67 | drawString(text, x + 1.0F, y + 1.0F, Color.BLACK); 68 | drawString(text, x - ((int) getWidth(text) >> 1), y, color); 69 | } 70 | 71 | public void drawString(String text, float x, float y, Color color) { 72 | ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft()); 73 | 74 | if (text == null) return; 75 | if (resolution.getScaleFactor() != this.prevScaleFactor) { 76 | try { 77 | this.prevScaleFactor = resolution.getScaleFactor(); 78 | this.unicodeFont = new UnicodeFont(this.getFontFromInput(path).deriveFont(this.size * this.prevScaleFactor / 2.0f)); 79 | this.unicodeFont.addAsciiGlyphs(); 80 | this.unicodeFont.getEffects().add(colorEffect); 81 | this.unicodeFont.loadGlyphs(); 82 | } catch (SlickException | IOException | FontFormatException e) { 83 | throw new RuntimeException(e); 84 | } 85 | } 86 | 87 | this.antiAliasingFactor = resolution.getScaleFactor(); 88 | 89 | GL11.glPushMatrix(); 90 | GL11.glScalef(1.0F / this.antiAliasingFactor, 1.0F / this.antiAliasingFactor, 1.0F / this.antiAliasingFactor); 91 | 92 | x *= this.antiAliasingFactor; 93 | y *= this.antiAliasingFactor; 94 | 95 | float originalX = x; 96 | 97 | float red = color.getRed() / 255.0f; 98 | float green = color.getGreen() / 255.0f; 99 | float blue = color.getBlue() / 255.0f; 100 | float alpha = color.getAlpha() / 255.0f; 101 | 102 | char[] characters = text.toCharArray(); 103 | int index = 0; 104 | 105 | GL11.glColor4f(red, green, blue, alpha); 106 | 107 | GlStateManager.enableBlend(); 108 | GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 109 | 110 | String[] parts = pattern.split(text); 111 | int[] colorCodes = new int[]{0, 170, 43520, 43690, 11141120, 11141290, 16755200, 11184810, 5592405, 5592575, 5635925, 5636095, 16733525, 16733695, 16777045, 16777215}; 112 | 113 | Color currentColor = color; 114 | 115 | for (final String s : parts) { 116 | for (final String s2 : s.split("\n")) { 117 | for (final String s3 : s2.split("\r")) { 118 | this.unicodeFont.drawString(x, y, s3, new org.newdawn.slick.Color(currentColor.getRGB())); 119 | x += this.unicodeFont.getWidth(s3); 120 | index += s3.length(); 121 | 122 | if (index < characters.length && characters[index] == '\r') { 123 | x = originalX; 124 | ++index; 125 | } 126 | } 127 | if (index < characters.length && characters[index] == '\n') { 128 | x = originalX; 129 | y += this.getHeight(s2) * 2.0f; 130 | ++index; 131 | } 132 | } 133 | if (index < characters.length) { 134 | final char colorCode = characters[index]; 135 | if (colorCode == '§') { 136 | final char colorChar = characters[index + 1]; 137 | final int codeIndex = "0123456789abcdef".indexOf(colorChar); 138 | if (codeIndex < 0) { 139 | if (colorChar == 'r') { 140 | currentColor = color; 141 | } 142 | } else { 143 | currentColor = new Color(colorCodes[codeIndex]); 144 | } 145 | 146 | index += 2; 147 | } 148 | } 149 | } 150 | 151 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 152 | GlStateManager.disableBlend(); 153 | 154 | GL11.glPopMatrix(); 155 | } 156 | 157 | public float getWidth(final String text) { 158 | // bad code but idc 159 | String textWithOutColorCodes = text 160 | .replace("§0", "") 161 | .replace("§1", "") 162 | .replace("§2", "") 163 | .replace("§3", "") 164 | .replace("§4", "") 165 | .replace("§5", "") 166 | .replace("§6", "") 167 | .replace("§7", "") 168 | .replace("§8", "") 169 | .replace("§9", "") 170 | .replace("§a", "") 171 | .replace("§b", "") 172 | .replace("§c", "") 173 | .replace("§d", "") 174 | .replace("§e", "") 175 | .replace("§f", "") 176 | .replace("§k", "") 177 | .replace("§l", "") 178 | .replace("§m", "") 179 | .replace("§n", "") 180 | .replace("§o", "") 181 | .replace("§r", ""); 182 | 183 | if (this.cachedStringWidth.size() > 1000) { 184 | this.cachedStringWidth.clear(); 185 | } 186 | return this.cachedStringWidth.computeIfAbsent(text, e -> this.unicodeFont.getWidth(textWithOutColorCodes) / this.antiAliasingFactor); 187 | } 188 | 189 | public String getPath() { 190 | return path; 191 | } 192 | 193 | public float getSize() { 194 | return size; 195 | } 196 | 197 | private Font getFontFromInput(String path) throws IOException, FontFormatException { 198 | return Font.createFont(0, Objects.requireNonNull(FontRenderer.class.getClassLoader().getResourceAsStream(path))); 199 | } 200 | 201 | public float getHeight(final String s) { 202 | return this.unicodeFont.getHeight(s) / 2.0f; 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /OBJ-Cosmetics/minecraft/assets/client/cosmetics/bandanas/models/bandana.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.93.2 OBJ File: 'untitled.blend' 2 | # www.blender.org 3 | v -1.499930 6.240478 4.472800 4 | v -1.499931 6.240479 3.347806 5 | v -3.374928 5.806554 3.347805 6 | v -4.499927 5.806448 3.347804 7 | v -4.499926 5.806448 4.472797 8 | v -4.499932 4.717674 -4.490095 9 | v -4.499932 4.895155 -3.347999 10 | v -3.374933 4.895097 -3.347999 11 | v -1.499936 4.895097 -3.347999 12 | v -1.499937 4.717674 -4.490093 13 | v 1.500059 4.886526 -3.347999 14 | v 1.500059 4.705146 -4.490133 15 | v 1.500065 6.240478 4.472802 16 | v 1.500064 6.240479 3.347808 17 | v 4.500055 4.895097 -3.347999 18 | v 4.500054 4.717674 -4.490088 19 | v 4.500061 5.806448 4.472804 20 | v 4.500060 5.806448 3.347811 21 | v 3.375062 5.806554 3.347810 22 | v -4.499929 5.430408 -0.078509 23 | v 4.500057 5.430408 -0.078502 24 | v 3.375059 5.430408 -0.078503 25 | v 3.375057 5.088665 -2.223955 26 | v 3.375057 4.891936 -3.347999 27 | v -3.374931 5.430408 -0.078508 28 | v -4.499926 3.556559 4.472796 29 | v 4.500061 3.556559 4.472804 30 | v 4.500054 2.449498 -4.497754 31 | v -4.499932 2.449498 -4.497759 32 | v -4.499927 3.556560 3.347802 33 | v -4.499932 2.637624 -3.348000 34 | v -4.499929 3.184609 0.024508 35 | v -3.374931 3.184609 0.024509 36 | v -3.374933 2.637624 -3.348000 37 | v 3.375058 2.995750 -1.181144 38 | v 3.375057 2.640884 -3.348000 39 | v 4.500058 3.184609 0.024515 40 | v -1.499937 2.449498 -4.497757 41 | v -1.499936 2.637624 -3.348000 42 | v -3.374928 3.719281 3.347805 43 | v 1.500065 3.990483 4.472802 44 | v 1.500064 3.990484 3.347808 45 | v -1.499930 3.990483 4.472798 46 | v 1.500059 2.462025 -4.497714 47 | v 1.500059 2.646319 -3.348000 48 | v 4.500055 2.637624 -3.348000 49 | v -1.499931 3.990484 3.347806 50 | v 3.375062 3.719281 3.347810 51 | v 4.500060 3.556560 3.347810 52 | v 3.375059 3.184609 0.024514 53 | v 1.125056 4.694294 -4.475805 54 | v -1.124935 4.694294 -4.475807 55 | v -1.124935 2.444270 -4.475808 56 | v 1.125056 2.444270 -4.475806 57 | vt 0.111118 0.999989 58 | vt 0.111118 0.875319 59 | vt 0.041677 0.875319 60 | vt 0.000041 0.875319 61 | vt 0.000041 0.999989 62 | vt 0.000041 0.000119 63 | vt 0.000041 0.124880 64 | vt 0.041677 0.124880 65 | vt 0.111118 0.124880 66 | vt 0.111118 0.000119 67 | vt 0.222229 0.124880 68 | vt 0.222229 0.000119 69 | vt 0.222229 0.999989 70 | vt 0.222229 0.875319 71 | vt 0.333344 0.124880 72 | vt 0.333344 0.000119 73 | vt 0.333344 0.999989 74 | vt 0.333344 0.875319 75 | vt 0.291672 0.875319 76 | vt 0.000041 0.500369 77 | vt 0.333344 0.500369 78 | vt 0.291672 0.500369 79 | vt 0.291672 0.259548 80 | vt 0.291672 0.124880 81 | vt 0.041677 0.500369 82 | vt 0.459326 0.187596 83 | vt 0.333292 0.187596 84 | vt 0.333292 0.375104 85 | vt 0.374963 0.375104 86 | vt 0.333292 0.375104 87 | vt 0.333351 0.562624 88 | vt 0.666672 0.562624 89 | vt 0.666731 0.375104 90 | vt 0.625044 0.375104 91 | vt 0.666672 0.750054 92 | vt 0.666672 0.562624 93 | vt 0.555542 0.562624 94 | vt 0.374969 0.000081 95 | vt 0.333351 0.000081 96 | vt 0.333292 0.187577 97 | vt 0.666731 0.187577 98 | vt 0.666672 0.000081 99 | vt 0.625000 0.000081 100 | vt 0.499985 0.000081 101 | vt 0.625044 0.187577 102 | vt 0.374925 0.187577 103 | vt 0.499989 0.187577 104 | vt 0.708344 0.500369 105 | vt 0.666687 0.500369 106 | vt 0.708344 0.875319 107 | vt 0.958344 0.640903 108 | vt 0.958344 0.875319 109 | vt 1.000000 0.500369 110 | vt 0.777786 0.999989 111 | vt 0.777786 0.875319 112 | vt 0.666687 0.875319 113 | vt 0.666687 0.999989 114 | vt 0.708344 0.124880 115 | vt 0.666687 0.000119 116 | vt 0.666687 0.124880 117 | vt 0.540674 0.375104 118 | vt 0.540674 0.187596 119 | vt 0.888886 0.124880 120 | vt 0.888886 0.000119 121 | vt 0.777786 0.000119 122 | vt 0.888886 0.999989 123 | vt 0.888886 0.875319 124 | vt 0.444443 0.562624 125 | vt 0.444443 0.750054 126 | vt 0.555542 0.750054 127 | vt 0.500000 0.375104 128 | vt 0.625000 0.562624 129 | vt 0.444443 0.562624 130 | vt 0.555542 0.750054 131 | vt 0.555542 0.562624 132 | vt 0.666731 0.375104 133 | vt 0.666731 0.187596 134 | vt 0.958344 0.124880 135 | vt 1.000000 0.124880 136 | vt 1.000000 0.000119 137 | vt 1.000000 0.999989 138 | vt 1.000000 0.875319 139 | vt 0.333351 0.562624 140 | vt 0.333351 0.750054 141 | vt 0.375008 0.750054 142 | vt 0.444443 0.750054 143 | vt 0.375008 0.562624 144 | vt 0.499985 0.000081 145 | vt 0.499989 0.187577 146 | vt 0.625000 0.000081 147 | vt 0.465666 0.187577 148 | vt 0.419884 0.000081 149 | vt 0.374925 0.187577 150 | vt 0.625044 0.187596 151 | vt 0.540674 0.187596 152 | vt 0.625044 0.375104 153 | vt 0.500000 0.562624 154 | vt 0.958344 0.500369 155 | vt 0.540674 0.375104 156 | vt 0.459326 0.187596 157 | vt 0.459326 0.375104 158 | vt 0.500000 0.375104 159 | vt 0.500000 0.562624 160 | vt 0.625044 0.375104 161 | vt 0.374963 0.375104 162 | vt 0.375008 0.562624 163 | vt 0.625000 0.750054 164 | vt 0.625000 0.562624 165 | vt 0.625044 0.187577 166 | vt 0.374969 0.000081 167 | vt 0.374963 0.187596 168 | vt 0.374963 0.375104 169 | vt 0.625000 0.562624 170 | vt 0.777786 0.124880 171 | vt 0.125011 0.375104 172 | vt 0.062513 0.375104 173 | vt 0.062513 0.187541 174 | vt 0.459326 0.375104 175 | vt 0.375008 0.562624 176 | vt 0.125011 0.187541 177 | vn -0.0749 0.9945 -0.0731 178 | vn -0.1135 0.9935 0.0000 179 | vn -0.0572 0.9876 -0.1465 180 | vn -0.0485 0.9862 -0.1585 181 | vn -0.1432 0.9897 0.0000 182 | vn 0.0000 0.9881 -0.1535 183 | vn 0.0000 0.9873 -0.1587 184 | vn 0.0000 0.9877 -0.1562 185 | vn 0.0008 0.9881 -0.1535 186 | vn 0.0019 0.9880 -0.1542 187 | vn 0.0015 0.9878 -0.1557 188 | vn -0.0009 0.9878 -0.1557 189 | vn 0.0718 0.9974 0.0000 190 | vn 0.0916 0.9942 -0.0555 191 | vn -0.0035 0.9879 -0.1551 192 | vn -0.0041 0.9881 -0.1535 193 | vn 0.1223 0.9897 -0.0740 194 | vn 0.0001 0.9973 -0.0728 195 | vn 0.0741 0.9911 -0.1107 196 | vn -0.0000 0.9919 -0.1266 197 | vn 0.0000 0.9908 -0.1354 198 | vn 0.0031 0.9909 -0.1344 199 | vn 0.0032 0.9865 -0.1639 200 | vn 0.0050 0.9863 -0.1648 201 | vn -0.0028 0.9850 -0.1724 202 | vn 0.0000 0.9896 -0.1441 203 | vn -0.0000 -0.0000 1.0000 204 | vn 1.0000 0.0000 -0.0000 205 | vn 0.0000 0.0034 -1.0000 206 | vn -1.0000 -0.0000 0.0000 207 | vn 0.0472 -0.9886 0.1432 208 | vn 0.0000 -0.9896 0.1439 209 | vn -0.0000 -0.9870 0.1610 210 | vn -0.0038 -0.9874 0.1582 211 | vn -0.0041 -0.9872 0.1596 212 | vn -0.0306 -0.9883 0.1493 213 | vn 0.0016 -0.9869 0.1611 214 | vn 0.0014 -0.9869 0.1615 215 | vn -0.0000 -0.9870 0.1608 216 | vn -0.0000 -0.9869 0.1615 217 | vn 0.1430 -0.9884 0.0521 218 | vn 0.1432 -0.9897 -0.0000 219 | vn 0.0953 -0.9914 0.0899 220 | vn -0.0478 -0.9989 -0.0000 221 | vn -0.0957 -0.9954 -0.0000 222 | vn 0.0478 -0.9989 -0.0000 223 | vn -0.0012 -0.9873 0.1591 224 | vn 0.0012 -0.9872 0.1592 225 | vn 0.0000 0.0000 -1.0000 226 | vn -0.1148 -0.9919 0.0540 227 | vn -0.1429 -0.9882 0.0544 228 | vn -0.1432 -0.9897 0.0000 229 | vn -0.0041 -0.9869 0.1615 230 | vn -0.0033 -0.9870 0.1604 231 | vn -0.0000 -0.9876 0.1568 232 | vn 0.0957 -0.9954 -0.0000 233 | s 1 234 | f 1/1/1 2/2/2 3/3/3 235 | f 4/4/4 5/5/5 1/1/1 236 | f 6/6/6 7/7/7 8/8/8 237 | f 9/9/9 10/10/10 6/6/6 238 | f 11/11/11 12/12/12 10/10/10 239 | f 1/1/1 13/13/13 14/14/14 240 | f 15/15/15 16/16/16 12/12/12 241 | f 17/17/17 18/18/18 19/19/19 242 | f 14/14/14 13/13/13 17/17/17 243 | f 20/20/20 4/4/4 3/3/3 244 | f 18/18/18 21/21/21 22/22/22 245 | f 22/22/22 21/21/21 15/15/23 246 | f 23/23/24 15/15/23 24/24/25 247 | f 7/7/7 20/20/20 25/25/26 248 | f 3/3/3 4/4/4 1/1/1 249 | f 8/8/8 9/9/9 6/6/6 250 | f 9/9/9 11/11/11 10/10/10 251 | f 2/2/2 1/1/1 14/14/14 252 | f 11/11/11 15/15/15 12/12/12 253 | f 19/19/19 14/14/14 17/17/17 254 | f 25/25/26 20/20/20 3/3/3 255 | f 19/19/19 18/18/18 22/22/22 256 | f 23/23/24 22/22/22 15/15/23 257 | f 8/8/8 7/7/7 25/25/26 258 | f 1/26/27 5/27/27 26/28/27 259 | f 18/29/28 17/30/28 27/31/28 260 | f 28/32/28 16/33/28 15/34/28 261 | f 29/35/29 6/36/29 10/37/29 262 | f 7/38/30 6/39/30 29/40/30 263 | f 26/41/30 5/42/30 4/43/30 264 | f 4/43/30 20/44/30 30/45/30 265 | f 31/46/30 32/47/30 7/38/30 266 | f 33/48/31 32/49/32 34/50/33 267 | f 35/51/34 36/52/35 37/53/36 268 | f 38/54/37 39/55/38 34/50/33 269 | f 31/56/39 29/57/40 38/54/37 270 | f 40/58/41 26/59/42 30/60/43 271 | f 41/61/27 13/62/27 1/26/27 272 | f 42/63/44 41/64/45 43/65/46 273 | f 38/54/37 44/66/47 45/67/48 274 | f 12/68/29 44/69/29 38/70/29 275 | f 15/34/28 21/71/28 46/72/28 276 | f 14/73/49 47/74/49 2/75/49 277 | f 27/76/27 17/77/27 13/62/27 278 | f 48/78/50 49/79/51 27/80/52 279 | f 44/66/47 28/81/53 46/82/54 280 | f 36/52/35 45/67/48 44/66/47 281 | f 44/66/47 46/82/54 36/52/35 282 | f 16/83/29 28/84/29 44/69/29 283 | f 48/85/49 42/86/49 19/87/49 284 | f 22/88/30 50/89/30 19/90/30 285 | f 35/91/30 23/92/30 36/93/30 286 | f 35/91/30 50/89/30 23/92/30 287 | f 24/94/27 11/95/27 36/96/27 288 | f 37/97/28 21/71/28 18/29/28 289 | f 37/53/36 49/79/51 48/78/50 290 | f 30/60/43 32/49/32 33/48/31 291 | f 20/44/30 32/47/30 30/45/30 292 | f 32/47/30 20/44/30 7/38/30 293 | f 32/49/32 31/56/39 34/50/33 294 | f 35/51/34 37/53/36 50/98/55 295 | f 36/52/35 46/82/54 37/53/36 296 | f 21/71/28 37/97/28 46/72/28 297 | f 45/99/27 9/100/27 39/101/27 298 | f 25/102/28 33/103/28 8/104/28 299 | f 3/105/28 40/106/28 25/102/28 300 | f 2/75/49 40/107/49 3/108/49 301 | f 47/74/49 40/107/49 2/75/49 302 | f 42/86/49 14/73/49 19/87/49 303 | f 47/74/49 14/73/49 42/86/49 304 | f 50/89/30 48/109/30 19/90/30 305 | f 23/92/30 24/110/30 36/93/30 306 | f 50/89/30 22/88/30 23/92/30 307 | f 39/101/27 8/111/27 34/112/27 308 | f 11/95/27 45/99/27 36/96/27 309 | f 45/99/27 11/95/27 9/100/27 310 | f 9/100/27 8/111/27 39/101/27 311 | f 33/103/28 34/113/28 8/104/28 312 | f 40/106/28 33/103/28 25/102/28 313 | f 47/114/56 43/65/46 26/59/42 314 | f 41/64/45 42/63/44 48/78/50 315 | f 51/115/27 52/116/27 53/117/27 316 | f 43/118/27 1/26/27 26/28/27 317 | f 49/119/28 18/29/28 27/31/28 318 | f 46/72/28 28/32/28 15/34/28 319 | f 38/70/29 29/35/29 10/37/29 320 | f 31/46/30 7/38/30 29/40/30 321 | f 30/45/30 26/41/30 4/43/30 322 | f 40/58/41 47/114/56 26/59/42 323 | f 27/80/52 41/64/45 48/78/50 324 | f 34/50/33 31/56/39 38/54/37 325 | f 43/118/27 41/61/27 1/26/27 326 | f 47/114/56 42/63/44 43/65/46 327 | f 39/55/38 38/54/37 45/67/48 328 | f 10/37/29 12/68/29 38/70/29 329 | f 54/120/27 51/115/27 53/117/27 330 | f 41/61/27 27/76/27 13/62/27 331 | f 12/68/29 16/83/29 44/69/29 332 | f 49/119/28 37/97/28 18/29/28 333 | f 50/98/55 37/53/36 48/78/50 334 | f 40/58/41 30/60/43 33/48/31 335 | --------------------------------------------------------------------------------