Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = 'sponge'
url = 'http://repo.spongepowered.org/maven'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.4-SNAPSHOT'
}
}

apply plugin: 'net.minecraftforge.gradle.liteloader'
apply plugin: 'org.spongepowered.mixin'

version = "0.13.0.134"
group = "me.totemo.watson" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "watson"

minecraft {
version = "1.10.2"
mappings = "snapshot_20160629"
runDir = "run"
}

sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'res'
}
}
}

repositories {
mavenLocal()
mavenCentral()
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}

configurations {
snakeyaml
}

dependencies {
compile 'org.yaml:snakeyaml:1.18-SNAPSHOT'
snakeyaml 'org.yaml:snakeyaml:1.18-SNAPSHOT'
// It's ugly but it works which is all a gradle newbie needs
}

mixin {
defaultObfuscationEnv notch
}

litemod {
name = "Watson"
json {
name = "Watson"
mcversion = "1.10.2"
//mixinConfigs += "mixins.watson.json"
author = "totemo"
description = "A 3-D log visualisation tool."
classTransformerClasses += "watson.transformer.WatsonTransformer"
}
}

jar {
from { configurations.snakeyaml.collect { it.isDirectory() ? it : zipTree(it) } }
from litemod.outputs
}
36 changes: 36 additions & 0 deletions src/watson/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public void message(String text)
_recolourQueryResults = (Boolean) dom.get("recolour_query_results");
_timeOrderedDeposits = (Boolean) dom.get("time_ordered_deposits");
_vectorLength = ((Double) dom.get("vector_length")).floatValue();
_useChatHighlights = ((Boolean) dom.get("chat_highlights"));

for (Entry<String, ModifiedKeyBinding> entry : getKeyBindingsMap().entrySet())
{
Expand Down Expand Up @@ -198,6 +199,7 @@ public void save()
dom.put("recolour_query_results", _recolourQueryResults);
dom.put("time_ordered_deposits", _timeOrderedDeposits);
dom.put("vector_length", (double) _vectorLength);
dom.put("chat_highlights", _useChatHighlights);

for (Entry<String, ModifiedKeyBinding> entry : getKeyBindingsMap().entrySet())
{
Expand Down Expand Up @@ -852,6 +854,33 @@ public float getVectorLength()
return _vectorLength;
}

// --------------------------------------------------------------------------
/**
* Enable or disable chat highlights
*
* @param enabled whether or not chat highlights should be used
*/
public void useChatHighlights(boolean enabled)
{
_useChatHighlights = enabled;
Chat.localOutput(_useChatHighlights
? "Custom highlights in chat are now enabled."
: "Custom highlights in chat are now disabled."
);
save();
}

// --------------------------------------------------------------------------
/**
* Return true if chat highlights are enabled
*
* @return true if chat highlights should be used
*/
public boolean useChatHighlights()
{
return _useChatHighlights;
}

// --------------------------------------------------------------------------
/**
* Return all {@link ModifiedKeyBindings} in the order they should be listed
Expand Down Expand Up @@ -902,6 +931,8 @@ protected void configureValidator()
root.addChild("time_ordered_deposits", new TypeValidatorNode(Boolean.class, true, false));
root.addChild("vector_length", new TypeValidatorNode(Double.class, true, 4.0));

root.addChild("chat_highlights", new TypeValidatorNode(Boolean.class, true, false));

for (Entry<String, ModifiedKeyBinding> entry : getKeyBindingsMap().entrySet())
{
root.addChild(entry.getKey(), new TypeValidatorNode(String.class, true, entry.getValue().toString()));
Expand Down Expand Up @@ -1098,6 +1129,11 @@ private static HashMap<String, ModifiedKeyBinding> getKeyBindingsMap()
*/
protected float _vectorLength = 4.0f;

/**
* If true, the chat higlighter will be enabled.
*/
protected boolean _useChatHighlights = false;

/**
* All {@link ModifiedKeyBindings} in the order they should be listed in the
* configuration panel.
Expand Down
32 changes: 16 additions & 16 deletions src/watson/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.mumfrey.liteloader.gl.GL;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.VertexBuffer;

import org.lwjgl.opengl.GL11;

import watson.chat.Chat;
import watson.cli.AnnoCommand;
import watson.cli.CalcCommand;
Expand Down Expand Up @@ -713,21 +713,21 @@ public void drawSelection()
if (_selection != null && getDisplaySettings().isSelectionShown())
{
Tessellator tess = Tessellator.getInstance();
WorldRenderer wr = tess.getWorldRenderer();
wr.startDrawing(GL11.GL_LINES);
wr.setColorRGBA(255, 0, 255, 128);
GL11.glLineWidth(4.0f);
VertexBuffer vb = tess.getBuffer();
vb.begin(GL.GL_LINES, GL.VF_POSITION);
GL.glColor4f(255 / 255f, 0 / 255f, 255 / 255f, 128);
GL.glLineWidth(4.0f);

final float halfSize = 0.3f;
float x = _selection.x + 0.5f;
float y = _selection.y + 0.5f;
float z = _selection.z + 0.5f;
wr.addVertex(x - halfSize, y, z);
wr.addVertex(x + halfSize, y, z);
wr.addVertex(x, y - halfSize, z);
wr.addVertex(x, y + halfSize, z);
wr.addVertex(x, y, z - halfSize);
wr.addVertex(x, y, z + halfSize);
vb.pos(x - halfSize, y, z).endVertex();
vb.pos(x + halfSize, y, z).endVertex();
vb.pos(x, y - halfSize, z).endVertex();
vb.pos(x, y + halfSize, z).endVertex();
vb.pos(x, y, z - halfSize).endVertex();
vb.pos(x, y, z + halfSize).endVertex();
tess.draw();

if (_selection.playerEditSet != null)
Expand All @@ -736,13 +736,13 @@ public void drawSelection()
BlockEdit predecessor = _selection.playerEditSet.getEditBefore(_selection);
if (predecessor != null)
{
wr.startDrawing(GL11.GL_LINES);
wr.setColorRGBA(255, 0, 255, 128);
vb.begin(GL.GL_LINES, GL.VF_POSITION);
GL.glColor4f(255 / 255f, 0 / 255f, 255 / 255f, 128);
GL11.glEnable(GL11.GL_LINE_STIPPLE);
GL11.glLineStipple(8, (short) 0xAAAA);
GL11.glLineWidth(3.0f);
wr.addVertex(predecessor.x + 0.5f, predecessor.y + 0.5f, predecessor.z + 0.5f);
wr.addVertex(x, y, z);
vb.pos(predecessor.x + 0.5f, predecessor.y + 0.5f, predecessor.z + 0.5f).endVertex();
vb.pos(x, y, z).endVertex();
tess.draw();
GL11.glDisable(GL11.GL_LINE_STIPPLE);
}
Expand Down
4 changes: 2 additions & 2 deletions src/watson/DisplaySettings.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package watson;

import net.minecraft.world.WorldSettings;
import net.minecraft.world.GameType;
import watson.chat.Chat;

// ----------------------------------------------------------------------------
Expand All @@ -14,7 +14,7 @@ public class DisplaySettings
* This method configures the initial display settings based on the server
* being connected to and the game type.
*/
public void configure(@SuppressWarnings("unused") String serverIP, WorldSettings.GameType gameType)
public void configure(@SuppressWarnings("unused") String serverIP, GameType gameType)
{
// The Watson display defaults to on. On survival servers, assume the
// presence of ModMode and its associated notifications to turn on or off
Expand Down
21 changes: 11 additions & 10 deletions src/watson/LiteModWatson.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.network.INetHandler;
import net.minecraft.network.play.client.C01PacketChatMessage;
import net.minecraft.network.play.server.S01PacketJoinGame;
import net.minecraft.util.IChatComponent;
import net.minecraft.network.play.client.CPacketChatMessage;
import net.minecraft.network.play.server.SPacketJoinGame;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.LWJGLException;
Expand Down Expand Up @@ -164,12 +165,12 @@ public void upgradeSettings(String version, File configPath, File oldConfigPath)
* Perform actions triggered on initial join.
*
* @see com.mumfrey.liteloader.JoinGameListener#onJoinGame(net.minecraft.network.INetHandler,
* net.minecraft.network.play.server.S01PacketJoinGame,
* net.minecraft.network.play.server.SPacketJoinGame,
* net.minecraft.client.multiplayer.ServerData,
* com.mojang.realmsclient.dto.RealmsServer)
*/
@Override
public void onJoinGame(INetHandler netHandler, S01PacketJoinGame joinGamePacket, ServerData serverData,
public void onJoinGame(INetHandler netHandler, SPacketJoinGame joinGamePacket, ServerData serverData,
RealmsServer realmsServer)
{
if (Configuration.instance.isEnabled())
Expand All @@ -186,15 +187,15 @@ public void onJoinGame(INetHandler netHandler, S01PacketJoinGame joinGamePacket,

// --------------------------------------------------------------------------
/**
* @see com.mumfrey.liteloader.ChatFilter#onChat(net.minecraft.util.IChatComponent,
* @see com.mumfrey.liteloader.ChatFilter#onChat(net.minecraft.util.text.ITextComponent,
* java.lang.String,
* com.mumfrey.liteloader.core.LiteLoaderEventBroker.ReturnValue)
*/
@Override
public boolean onChat(IChatComponent chat, String message, LiteLoaderEventBroker.ReturnValue<IChatComponent> newMessage)
public boolean onChat(ITextComponent chat, String message, LiteLoaderEventBroker.ReturnValue<ITextComponent> newMessage)
{
boolean allowChat = ChatProcessor.instance.onChat(chat);
if (allowChat)
if (allowChat && Configuration.instance.useChatHighlights())
{
newMessage.set(Chat.getChatHighlighter().highlight(chat));
}
Expand Down Expand Up @@ -357,7 +358,7 @@ public static void sendChatMessage(EntityPlayerSP player, String chat)
{
if (!ClientCommandManager.instance.handleClientCommand(chat))
{
player.sendQueue.addToSendQueue(new C01PacketChatMessage(chat));
player.connection.sendPacket(new CPacketChatMessage(chat));
}
}

Expand Down Expand Up @@ -472,7 +473,7 @@ public static void onInventoryPlayerChangeCurrentItem(EventInfo<InventoryPlayer>
protected static void performKeyBinding(ModifiedKeyBinding binding)
{
Minecraft mc = Minecraft.getMinecraft();
mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(new SoundEvent(new ResourceLocation("gui.button.press")), 1.0F));
binding.perform();
}

Expand Down
8 changes: 4 additions & 4 deletions src/watson/PrivateFieldsWatson.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.mumfrey.liteloader.core.runtime.Obf;
import com.mumfrey.liteloader.util.PrivateFields;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.text.TextFormatting;

// ----------------------------------------------------------------------------
/**
Expand All @@ -27,9 +27,9 @@ protected PrivateFieldsWatson(Class<P> owner, Obf obf)

// --------------------------------------------------------------------------

public static final PrivateFieldsWatson<EnumChatFormatting, Character> formattingCode = new PrivateFieldsWatson<EnumChatFormatting, Character>(
EnumChatFormatting.class,
WatsonObf.EnumChatFormatting_formattingCode);
public static final PrivateFieldsWatson<TextFormatting, Character> formattingCode = new PrivateFieldsWatson<TextFormatting, Character>(
TextFormatting.class,
WatsonObf.TextFormatting_formattingCode);
public static final PrivateFieldsWatson<RenderManager, Double> renderPosX = new PrivateFieldsWatson<RenderManager, Double>(
RenderManager.class,
WatsonObf.RenderManager_renderPosX);
Expand Down
20 changes: 10 additions & 10 deletions src/watson/Screenshot.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import javax.imageio.ImageIO;

import net.minecraft.event.ClickEvent;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.ITextComponent;

import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
Expand All @@ -31,7 +31,7 @@ public class Screenshot
* @param width the screen width.
* @param height the screen height.
*/
public static IChatComponent save(File file, int width, int height)
public static ITextComponent save(File file, int width, int height)
{
try
{
Expand All @@ -57,14 +57,14 @@ public static IChatComponent save(File file, int width, int height)
}

ImageIO.write(image, "png", file);
ChatComponentText text = new ChatComponentText(file.getName());
text.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file.getAbsolutePath()));
text.getChatStyle().setUnderlined(Boolean.valueOf(true));
return new ChatComponentTranslation("screenshot.success", new Object[]{text});
TextComponentString text = new TextComponentString(file.getName());
text.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file.getAbsolutePath()));
text.getStyle().setUnderlined(Boolean.valueOf(true));
return new TextComponentTranslation("screenshot.success", new Object[]{text});
}
catch (Exception ex)
{
return new ChatComponentTranslation("screenshot.failure", new Object[]{ex.getMessage()});
return new TextComponentTranslation("screenshot.failure", new Object[]{ex.getMessage()});
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/watson/WatsonObf.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public WatsonObf(String seargeName, String obfName)
// and methods thereof.

public static WatsonObf KeyBinding = new WatsonObf("net.minecraft.client.settings.KeyBinding",
"bsr");
"bcu");
public static WatsonObf KeyBinding_onTick = new WatsonObf("func_74507_a", "a", "onTick");
public static WatsonObf KeyBinding_setKeyBindState = new WatsonObf("func_74510_a", "a", "setKeyBindState");

Expand All @@ -57,13 +57,13 @@ public WatsonObf(String seargeName, String obfName)
// and methods thereof.

public static WatsonObf InventoryPlayer = new WatsonObf("net.minecraft.entity.player.InventoryPlayer",
"ahb");
public static WatsonObf InventoryPlayer_changeCurrentItem = new WatsonObf("func_70453_c", "d", "changeCurrentItem");
"zr");
public static WatsonObf InventoryPlayer_changeCurrentItem = new WatsonObf("func_70453_c", "f", "changeCurrentItem");

// --------------------------------------------------------------------------
// Private fields accessed by reflection.

protected static WatsonObf EnumChatFormatting_formattingCode = new WatsonObf("field_96329_z", "z", "formattingCode");
protected static WatsonObf TextFormatting_formattingCode = new WatsonObf("field_96329_z", "z", "formattingCode");
protected static WatsonObf RenderManager_renderPosX = new WatsonObf("field_78725_b", "o", "renderPosX");
protected static WatsonObf RenderManager_renderPosY = new WatsonObf("field_78726_c", "p", "renderPosY");
protected static WatsonObf RenderManager_renderPosZ = new WatsonObf("field_78723_d", "q", "renderPosZ");
Expand Down
Loading