Skip to content

Commit

Permalink
1.1.1
Browse files Browse the repository at this point in the history
* hopefully fixed DataManager failing to read config-file on first load.
* added MP-Module: renderLines (toggle drawing of lines in MP)
* configurable hitBox-radii
* refactored SingleTickMoveData render-algorithm
  • Loading branch information
BlazingTwist committed Mar 25, 2021
1 parent a105fd3 commit 30a09c6
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 87 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.1.0'
version = '1.1.1'
group = 'blazingtwist.cannontracer' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'cannontracer'

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/the_dark_jumper/cannontracer/Update.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Update {
public static final String OUTDATED_MSG = "is outdated, please update using the button on the config screen!";
public static final String MOD_NAME = "CannonTracer ";

public static final String VERSION = "1.1.0";
public static final String VERSION = "1.1.1";

public static void sendUpdateMessageIfNeeded() {
if(checkUpdateAvailable()) {
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/the_dark_jumper/cannontracer/configsaving/Color.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,23 @@ public Color setAlpha(int alpha) {
this.alpha = alpha;
return this;
}

/**
* Inverts `this` color and returns `this`
*
* @return this Color Object
*/
public Color invert() {
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
return this;
}

/**
* @return a new instance of {@link the_dark_jumper.cannontracer.configsaving.Color} with the same Property-Values
*/
public Color copy() {
return new Color(red, green, blue, alpha);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,8 @@ public void load() {
updatePathGNS.set(prefs.get("TracerUpdatePath", ""));

try {
List<String> lines = Files.readAllLines(Paths.get(configPathGNS.get()));
System.err.println("Found " + lines.size() + " lines at configPath: " + configPathGNS.get());

StringBuilder jsonBuilder = new StringBuilder();
lines.forEach(line -> jsonBuilder.append(line).append("\n"));
String json = jsonBuilder.toString();
System.err.println("Collected lines to String: " + json);

ObjectMapper mapper = getObjectMapper();
this.tracerConfig = mapper.readValue(json, TracerConfig.class);
this.tracerConfig = mapper.readValue(new File(configPathGNS.get()), TracerConfig.class);
} catch (Exception e) {
System.err.println("Unable to parse config, resetting to default");
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,37 @@

public class MultiPlayerKeybinds {
@JsonProperty("XRayTracesMP")
private KeybindEntry xRayTracesMP = new KeybindEntry().addTrigger(45, 42);
private KeybindEntry xRayTracesMP = new KeybindEntry().addTrigger(45, 42); // X + LeftShift

@JsonProperty("RenderLinesMP")
private KeybindEntry renderLinesMP = new KeybindEntry().addTrigger(38, 42); // L + LeftShift

@JsonProperty("MenuMP")
private KeybindEntry menuMP = new KeybindEntry().addTrigger(46, 42);
private KeybindEntry menuMP = new KeybindEntry().addTrigger(46, 42); // C + LeftShift

@JsonProperty("PullDataMP")
private KeybindEntry pullDataMP = new KeybindEntry().addTrigger(19).addExclude(42);
private KeybindEntry pullDataMP = new KeybindEntry().addTrigger(19).addExclude(42); // R + !LeftShift

@JsonProperty("ClearDataMP")
private KeybindEntry clearDataMP = new KeybindEntry().addTrigger(19, 42);
private KeybindEntry clearDataMP = new KeybindEntry().addTrigger(19, 42); // R + LeftShift

@JsonProperty("DisplayTickMP+")
private KeybindEntry displayTickMPAdd = new KeybindEntry().addTrigger(333);
private KeybindEntry displayTickMPAdd = new KeybindEntry().addTrigger(333); // ArrowRight

@JsonProperty("DisplayTickMP-")
private KeybindEntry displayTickMPSub = new KeybindEntry().addTrigger(331);
private KeybindEntry displayTickMPSub = new KeybindEntry().addTrigger(331); // ArrowLeft

@JsonProperty("DisplayDespawnTickMP")
private KeybindEntry displayDespawnTickMP = new KeybindEntry().addTrigger(42, 333);
private KeybindEntry displayDespawnTickMP = new KeybindEntry().addTrigger(42, 333); // LeftShift + ArrowRight

@JsonProperty("DisplayPrevDespawnTickMP")
private KeybindEntry displayPreviousDespawnTickMP = new KeybindEntry().addTrigger(42, 331);
private KeybindEntry displayPreviousDespawnTickMP = new KeybindEntry().addTrigger(42, 331); // LeftShift + ArrowLeft

@JsonProperty("ShowFirstTickMP")
private KeybindEntry showFirstTickMP = new KeybindEntry().addTrigger(328);
private KeybindEntry showFirstTickMP = new KeybindEntry().addTrigger(328); // ArrowUP

@JsonProperty("ShowLastTickMP")
private KeybindEntry showLastTickMP = new KeybindEntry().addTrigger(336);
private KeybindEntry showLastTickMP = new KeybindEntry().addTrigger(336); // ArrowDown

public MultiPlayerKeybinds() {
}
Expand All @@ -45,6 +48,15 @@ public MultiPlayerKeybinds setxRayTracesMP(KeybindEntry xRayTracesMP) {
return this;
}

public KeybindEntry getRenderLinesMP() {
return renderLinesMP;
}

public MultiPlayerKeybinds setRenderLinesMP(KeybindEntry renderLinesMP) {
this.renderLinesMP = renderLinesMP;
return this;
}

public KeybindEntry getMenuMP() {
return menuMP;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class TrackingDataEntry {
@JsonProperty("color")
private Color color = new Color(0, 0, 0, 255);

@JsonProperty("hitBoxRadius")
private double hitBoxRadius = 0.5;

public TrackingDataEntry() {
}

Expand Down Expand Up @@ -60,4 +63,13 @@ public TrackingDataEntry setColor(Color color) {
this.color = color;
return this;
}

public double getHitBoxRadius() {
return hitBoxRadius;
}

public TrackingDataEntry setHitBoxRadius(double hitBoxRadius) {
this.hitBoxRadius = hitBoxRadius;
return this;
}
}
15 changes: 8 additions & 7 deletions src/main/java/the_dark_jumper/cannontracer/gui/ConfigGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ private void generateTrackingRow(ScrollableTable table, TrackingIDChangeHandler
new ValueFrame<>(this, null, table.colors, "id", new GetterAndSetter<>(idHandler::getID, idHandler::setID), String.class, true),
new ValueFrame<>(this, null, table.colors, "time", new GetterAndSetter<>(trackingData::getTime, trackingData::setTime), Float.class, false),
new ValueFrame<>(this, null, table.colors, "thickness", new GetterAndSetter<>(trackingData::getThickness, trackingData::setThickness), Float.class, false),
new ValueFrame<>(this, null, table.colors, "hitBoxRadius", new GetterAndSetter<>(trackingData::getHitBoxRadius, trackingData::setHitBoxRadius), Double.class, false),
new ValueFrame<>(this, null, table.colors, "red", new GetterAndSetter<>(trackingData.getColor()::getRed, trackingData.getColor()::setRed), Integer.class, false),
new ValueFrame<>(this, null, table.colors, "green", new GetterAndSetter<>(trackingData.getColor()::getGreen, trackingData.getColor()::setGreen), Integer.class, false),
new ValueFrame<>(this, null, table.colors, "blue", new GetterAndSetter<>(trackingData.getColor()::getBlue, trackingData.getColor()::setBlue), Integer.class, false),
Expand Down Expand Up @@ -401,18 +402,18 @@ public void mousePressEvent(boolean leftDown) {
@Override
@ParametersAreNonnullByDefault
public void drawCenteredString(FontRenderer fontRenderer, String text, int xPos, int height, int color) {
double configFontHeight = guiManager.getGuiConfig().getFontHeight();
if (configFontHeight == 0) {
double configFontSize = guiManager.getGuiConfig().getFontHeight();
if (configFontSize == 0) {
return;
}
height -= (fontRenderer.FONT_HEIGHT * configFontHeight) / 2;
xPos /= configFontHeight;
height /= configFontHeight;
height -= (fontRenderer.FONT_HEIGHT * configFontSize) / 2;
xPos /= configFontSize;
height /= configFontSize;

GL11.glPushMatrix();
//GlStateManager.pushMatrix();
GL11.glScaled(configFontHeight, configFontHeight, configFontHeight);
//GlStateManager.scaled(configFontHeight, configFontHeight, configFontHeight);
GL11.glScaled(configFontSize, configFontSize, configFontSize);
//GlStateManager.scaled(configFontSize, configFontSize, configFontSize);
super.drawCenteredString(fontRenderer, text, xPos, height, color);
GL11.glPopMatrix();
//GlStateManager.popMatrix();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class ModuleManager {
public ModuleBasic showLastTickSP;

public ModuleBasic xRayTracesMP;
public ModuleBasic renderLinesMP;
public ModuleBasic menuMP;
public ModuleBasic pullDataMP;
public ModuleBasic clearDataMP;
Expand Down Expand Up @@ -120,6 +121,10 @@ public void generateMultiPlayerModules() {
xRayTracesMP.setBehaviour(new ToggleBehaviour(xRayTracesMP, false, main.multiPlayerSettings.xRayTraceGNS));
multiPlayerModules.add(xRayTracesMP);

renderLinesMP = new ModuleBasic("RenderLinesMP", true, false);
renderLinesMP.setBehaviour(new ToggleBehaviour(renderLinesMP, true, main.multiPlayerSettings.renderLinesGNS));
multiPlayerModules.add(renderLinesMP);

menuMP = new ModuleBasic("MenuMP", false, true);
menuMP.setBehaviour(new ToggleBehaviour(menuMP, false, main.multiPlayerSettings.renderMenuGNS));
multiPlayerModules.add(menuMP);
Expand Down Expand Up @@ -171,6 +176,7 @@ public void reloadConfig() {

MultiPlayerKeybinds keysMP = main.dataManager.getTracerConfig().getMultiPlayerConfig().getKeybinds();
xRayTracesMP.setKeybind(keysMP.getxRayTracesMP());
renderLinesMP.setKeybind(keysMP.getRenderLinesMP());
menuMP.setKeybind(keysMP.getMenuMP());
pullDataMP.setKeybind(keysMP.getPullDataMP());
clearDataMP.setKeybind(keysMP.getClearDataMP());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class MultiPlayerSettings {
public final Main main;

public GetterAndSetter<Boolean> renderLinesGNS = new GetterAndSetter<>(true);
public GetterAndSetter<Integer> renderTickGNS = new GetterAndSetter<>(0);
public GetterAndSetter<Boolean> xRayTraceGNS = new GetterAndSetter<>(false);
private boolean renderMenu = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,12 @@ public void onWorldRender(RenderWorldLastEvent event) {
final BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);

boolean renderLines = isSinglePlayer || main.multiPlayerSettings.renderLinesGNS.get();
for (SingleTickMoveData moveData : tracingHistory) {
for (String key : moveData.tickData.keySet()) {
TrackingDataEntry trackData = isSinglePlayer ? main.dataManager.getTrackingDataSP().get(key) : main.dataManager.getTrackingDataMP().get(key);
if (trackData != null && trackData.isRender()) {
moveData.setupDrawingBuffer(bufferBuilder, trackData, key);
moveData.setupDrawingBuffer(bufferBuilder, trackData, key, renderLines);

// TODO check axis rendering
//moveData.renderAxisText(rendererManager, matrixStack, bufferSource);
Expand Down
Loading

0 comments on commit 30a09c6

Please sign in to comment.