Skip to content

Commit

Permalink
Fixed code for detecting snitch on place + WIP GUI stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLittleKitty committed Feb 3, 2017
1 parent 8aabc51 commit 242c486
Show file tree
Hide file tree
Showing 19 changed files with 137 additions and 90 deletions.
2 changes: 1 addition & 1 deletion SnitchLists.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Snitch list is one of the main objects used in Snitch Master. It is a very useful tool that you can use to group together Snitches that meet certain criteria.

Snitches are then displayed in the world and io JourneyMap with the color of their top Snitch list.
Snitches are then displayed in the world and in JourneyMap with the color of their top Snitch list.

This tutorial will help you with learning to use Snitch list qualifier language so you can group your Snitches together however you like.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gmail.nuclearcat1337.snitch_master.gui;

import com.gmail.nuclearcat1337.snitch_master.gui.screens.SettingsGui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.client.IModGuiFactory;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.gmail.nuclearcat1337.snitch_master.gui.controls;

import com.gmail.nuclearcat1337.snitch_master.SnitchMaster;
import com.gmail.nuclearcat1337.snitch_master.util.GeneralUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;

/**
* Created by Mr_Little_Kitty on 1/20/2017.
*/
public class DropMenu extends GuiButton
{
public static final ResourceLocation MENU_BUTTON = new ResourceLocation(SnitchMaster.MODID,"snitchMasterMain.png");

public DropMenu(int buttonId, int x, int y)
{
super(buttonId, x, y, 16, 16, "");
}



@Override
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
if(super.mousePressed(mc,mouseX,mouseY))
{

return true;
}
return false;
}

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY)
{
if(this.visible)
{
//GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
int i = this.getHoverState(this.hovered);

GlStateManager.color(1.0f,1.0f,1.0f,1.0f);

GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);

mc.getTextureManager().bindTexture(BUTTON_TEXTURES);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);

// if(i == 2) //They are hovering over the button
// {
// float f3 = (float)(16777120 >> 24 & 255) / 255.0F;
// float f = (float)(16777120 >> 16 & 255) / 255.0F;
// float f1 = (float)(16777120 >> 8 & 255) / 255.0F;
// float f2 = (float)(16777120 & 255) / 255.0F;
// GlStateManager.color(f, f1, f2, f3);
// }

mc.getTextureManager().bindTexture(MENU_BUTTON);
this.drawTexturedModalRect(this.xPosition+4,this.yPosition+4,0,0,8,8);

this.mouseDragged(mc, mouseX, mouseY);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gmail.nuclearcat1337.snitch_master.gui;
package com.gmail.nuclearcat1337.snitch_master.gui.screens;

import com.gmail.nuclearcat1337.snitch_master.gui.GuiConstants;
import com.gmail.nuclearcat1337.snitch_master.gui.controls.TextBox;
import com.gmail.nuclearcat1337.snitch_master.snitches.SnitchList;
import com.gmail.nuclearcat1337.snitch_master.util.Acceptor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gmail.nuclearcat1337.snitch_master.gui;
package com.gmail.nuclearcat1337.snitch_master.gui.screens;

import net.minecraft.client.gui.GuiScreen;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gmail.nuclearcat1337.snitch_master.gui;
package com.gmail.nuclearcat1337.snitch_master.gui.screens;

import com.gmail.nuclearcat1337.snitch_master.gui.GuiConstants;
import com.gmail.nuclearcat1337.snitch_master.gui.controls.TextBox;
import com.gmail.nuclearcat1337.snitch_master.util.Acceptor;
import net.minecraft.client.Minecraft;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gmail.nuclearcat1337.snitch_master.gui;
package com.gmail.nuclearcat1337.snitch_master.gui.screens;

import com.gmail.nuclearcat1337.snitch_master.SnitchMaster;
import com.gmail.nuclearcat1337.snitch_master.gui.GuiConstants;
import com.gmail.nuclearcat1337.snitch_master.gui.snitchliststable.SnitchListRemoveColumn;
import com.gmail.nuclearcat1337.snitch_master.gui.snitchliststable.SnitchListsTable;
import com.gmail.nuclearcat1337.snitch_master.gui.snitchtable.SnitchRemoveColumn;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.gmail.nuclearcat1337.snitch_master.gui;
package com.gmail.nuclearcat1337.snitch_master.gui.screens;

import com.gmail.nuclearcat1337.snitch_master.SnitchMaster;
import com.gmail.nuclearcat1337.snitch_master.api.SnitchListQualifier;
import com.gmail.nuclearcat1337.snitch_master.gui.GuiConstants;
import com.gmail.nuclearcat1337.snitch_master.gui.controls.TextBox;
import com.gmail.nuclearcat1337.snitch_master.gui.snitchliststable.SnitchListsTable;
import com.gmail.nuclearcat1337.snitch_master.snitches.SnitchList;
Expand Down Expand Up @@ -54,7 +55,7 @@ public void initGui()
rgbBoxWidth = nameBoxWidth/3;
qualifierStringWidth = mc.fontRendererObj.getStringWidth("Qualifier");
createNewListStringWidth = mc.fontRendererObj.getStringWidth(CREATE_NEW_LIST_STRING);
buttonWidth = (qualifierBoxWidth-GuiConstants.STANDARD_SEPARATION_DISTANCE)/3;
buttonWidth = (qualifierBoxWidth- GuiConstants.STANDARD_SEPARATION_DISTANCE)/3;

int yPos = (this.height / 2) - (GuiConstants.STANDARD_BUTTON_HEIGHT*3) - (GuiConstants.STANDARD_SEPARATION_DISTANCE) ;
int xPos = (this.width/2) - (nameBoxWidth/2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.gmail.nuclearcat1337.snitch_master.gui;
package com.gmail.nuclearcat1337.snitch_master.gui.screens;

import com.gmail.nuclearcat1337.snitch_master.Settings;
import com.gmail.nuclearcat1337.snitch_master.SnitchMaster;
import com.gmail.nuclearcat1337.snitch_master.gui.GuiConstants;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gmail.nuclearcat1337.snitch_master.gui;
package com.gmail.nuclearcat1337.snitch_master.gui.screens;

import com.gmail.nuclearcat1337.snitch_master.gui.GuiConstants;
import com.gmail.nuclearcat1337.snitch_master.gui.controls.TextBox;
import com.gmail.nuclearcat1337.snitch_master.handlers.ChatSnitchParser;
import net.minecraft.client.Minecraft;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.gmail.nuclearcat1337.snitch_master.gui.snitchliststable;

import com.gmail.nuclearcat1337.snitch_master.gui.EditStringGui;
import com.gmail.nuclearcat1337.snitch_master.gui.screens.EditStringGui;
import com.gmail.nuclearcat1337.snitch_master.gui.tables.TableColumn;
import com.gmail.nuclearcat1337.snitch_master.snitches.SnitchList;
import com.gmail.nuclearcat1337.snitch_master.snitches.SnitchLists;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.gmail.nuclearcat1337.snitch_master.Settings;
import com.gmail.nuclearcat1337.snitch_master.SnitchMaster;
import com.gmail.nuclearcat1337.snitch_master.api.SnitchListQualifier;
import com.gmail.nuclearcat1337.snitch_master.gui.EditColorGui;
import com.gmail.nuclearcat1337.snitch_master.gui.EditStringGui;
import com.gmail.nuclearcat1337.snitch_master.gui.screens.EditColorGui;
import com.gmail.nuclearcat1337.snitch_master.gui.screens.EditStringGui;
import com.gmail.nuclearcat1337.snitch_master.gui.GuiConstants;
import com.gmail.nuclearcat1337.snitch_master.gui.NewSnitchListGui;
import com.gmail.nuclearcat1337.snitch_master.gui.screens.NewSnitchListGui;
import com.gmail.nuclearcat1337.snitch_master.gui.snitchtable.*;
import com.gmail.nuclearcat1337.snitch_master.gui.tables.TableButtonColumn;
import com.gmail.nuclearcat1337.snitch_master.gui.tables.TableColumn;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gmail.nuclearcat1337.snitch_master.gui.tables;

import com.gmail.nuclearcat1337.snitch_master.gui.GuiConstants;
import com.gmail.nuclearcat1337.snitch_master.gui.controls.DropMenu;
import com.gmail.nuclearcat1337.snitch_master.util.Pair;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
Expand Down Expand Up @@ -91,7 +92,9 @@ public void initGui()
buttonList.add(doneButton);
buttonList.add(columnsButton);

initializeButtons(2);
//buttonList.add(new DropMenu(2,20,20));

initializeButtons(3);

super.initGui();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ private boolean tryParsePlaceMessage(ITextComponent msg)
return false;

ITextComponent hoverComponent = siblings.get(0);

HoverEvent hover = hoverComponent.getStyle().getHoverEvent();
if(hover != null)
{
Expand All @@ -161,9 +162,9 @@ private Snitch parseSnitchFromChat(String text)
String[] groupArgs = args[2].split(" ");

int x, y, z;
x = Integer.parseInt(locationArgs[0].substring(2));
y = Integer.parseInt(locationArgs[1]);
z = Integer.parseInt(locationArgs[2].substring(0, locationArgs[2].length() - 1));
x = Integer.parseInt(locationArgs[1].substring(1));
y = Integer.parseInt(locationArgs[2]);
z = Integer.parseInt(locationArgs[3].substring(0, locationArgs[3].length() - 1));
String world = worldArgs.length > 1 ? worldArgs[1] : snitchMaster.getCurrentWorld();

Location loc = new Location(x, y, z, world);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.gmail.nuclearcat1337.snitch_master.handlers;

import com.gmail.nuclearcat1337.snitch_master.SnitchMaster;
import com.gmail.nuclearcat1337.snitch_master.gui.MainGui;
import com.gmail.nuclearcat1337.snitch_master.gui.screens.MainGui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.fml.client.registry.ClientRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
public class QuietTimeHandler implements IAlertRecipient
{
private static final String QUIET_TIME_CONFIG_KEY = "quiet-time-config";
private final Settings settings;

public QuietTimeHandler(Settings settings)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.gmail.nuclearcat1337.snitch_master.util;

import org.lwjgl.util.*;
import org.lwjgl.util.Color;

import java.nio.ByteBuffer;

/**
* Created by Mr_Little_Kitty on 7/16/2016.
*/
Expand All @@ -14,4 +19,36 @@ public static double DistanceSquared(int x1, int z1, int y1, int x2, int z2, int
{
return Math.pow(x2 - x1,2) + Math.pow(z2 - z1,2) + Math.pow(y2 - y1,2);
}

// public static int ToColor(float red, float green, float blue, float alpha)
// {
// int returnVal = (Normalize(alpha) << 24);
// returnVal = returnVal | (Normalize(blue) << 16);
// returnVal = returnVal | (Normalize(green) << 8);
// returnVal = returnVal | (Normalize(green));
// return returnVal;
// }
//
// private static final int RANGE = 127;
//
// private static int Normalize(float value)
// {
// int b;
// if(Float.isNaN(value))
// b = 0;
// else if(value > 1)
// b = 1;
// else if (value < -1)
// b = -1;
// else
// {
// value = value * (RANGE);
// if(value >= 0)
// value += 0.5f;
// else
// value -= 0.5f;
// b = (int)value;
// }
// return b;
// }
}

0 comments on commit 242c486

Please sign in to comment.