Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from Utility-Client/crosshair-recode
New Crosshairs
- Loading branch information
Showing
16 changed files
with
142 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
38 changes: 21 additions & 17 deletions
38
src/main/java/de/gamingcraft/crosshair/CrosshairManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
package de.gamingcraft.crosshair; | ||
|
||
import de.gamingcraft.config.ConfigManager; | ||
import de.gamingcraft.crosshair.crosshairs.*; | ||
import de.gamingcraft.utils.SerializationUtils; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.Gui; | ||
import net.minecraft.client.gui.ScaledResolution; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
public class CrosshairManager extends Thread { | ||
public ArrayList<Crosshair> crosshairs = new ArrayList<Crosshair>(); | ||
public class CrosshairManager { | ||
|
||
@Override | ||
public void run() { | ||
crosshairs.add(new DefaultCrosshair()); | ||
crosshairs.add(new PointCross()); | ||
crosshairs.add(new PointCrosshair()); | ||
super.run(); | ||
} | ||
|
||
public void loop(int offsetY) { | ||
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); | ||
int centerX = sr.getScaledWidth() / 2; | ||
int centerY = sr.getScaledHeight() / 2 + offsetY; | ||
public static void loop(ScaledResolution sr) throws Exception { | ||
GlStateManager.disableDepth(); | ||
GlStateManager.disableAlpha(); | ||
HashMap<Integer, Boolean> pixels = (HashMap<Integer, Boolean>) SerializationUtils.deserialize(ConfigManager.config.getCrosshair()); | ||
int size = ConfigManager.config.getCrosshairSize(); | ||
|
||
crosshairs.get(ConfigManager.config.getCrosshair()).updateRender(sr, centerX, centerY, sr.getScaleFactor()); | ||
int f = 0; | ||
for (int i = 0; i < size; i++) { | ||
for (int e = 0; e < size; e++) { | ||
int x = sr.getScaledWidth() / 2 + i * 2 - size; | ||
int y = sr.getScaledHeight() / 2 + e * 2 - size; | ||
if(!pixels.getOrDefault(f, true)) Gui.drawRect(x, y, x + 2, y + 2, 2164260863L); | ||
f++; | ||
} | ||
} | ||
GlStateManager.enableDepth(); | ||
GlStateManager.enableAlpha(); | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
src/main/java/de/gamingcraft/crosshair/crosshairs/DefaultCrosshair.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
src/main/java/de/gamingcraft/crosshair/crosshairs/PointCross.java
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/main/java/de/gamingcraft/crosshair/crosshairs/PointCrosshair.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/de/gamingcraft/utils/SerializationUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package de.gamingcraft.utils; | ||
|
||
import java.io.*; | ||
import java.util.Base64; | ||
|
||
public class SerializationUtils { | ||
public static String serialize(Serializable o) throws IOException { | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
ObjectOutputStream oos = new ObjectOutputStream(baos); | ||
oos.writeObject(o); | ||
oos.close(); | ||
return Base64.getEncoder().encodeToString(baos.toByteArray()); | ||
} | ||
|
||
public static Object deserialize(String s) throws IOException, | ||
ClassNotFoundException { | ||
byte[] data = Base64.getDecoder().decode(s); | ||
ObjectInputStream ois = new ObjectInputStream( | ||
new ByteArrayInputStream(data)); | ||
Object o = ois.readObject(); | ||
ois.close(); | ||
return o; | ||
} | ||
} |
Oops, something went wrong.