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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
bin
.settings

.idea
*.iml
.gradle/
build.number
build/
run/
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.3-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.12"
mappings = "snapshot_20170614"
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.19-SNAPSHOT'
snakeyaml 'org.yaml:snakeyaml:1.19-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.12"
//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
34 changes: 17 additions & 17 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.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;

import org.lwjgl.opengl.GL11;

import watson.chat.Chat;
import watson.cli.AnnoCommand;
import watson.cli.CalcCommand;
Expand Down Expand Up @@ -246,7 +246,7 @@ public BlockEditSet getBlockEditSet()
idBuilder.append(serverIP);
}
idBuilder.append('/');
idBuilder.append(mc.thePlayer.dimension);
idBuilder.append(mc.player.dimension);
String id = idBuilder.toString();

// Lookup BlockEditSet or create new mapping if not found.
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);
BufferBuilder 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
32 changes: 17 additions & 15 deletions src/watson/LiteModWatson.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.renderer.GlStateManager;
Expand All @@ -20,9 +21,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 +166,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 @@ -180,21 +182,21 @@ public void onJoinGame(INetHandler netHandler, S01PacketJoinGame joinGamePacket,
// should retain the previous display state.
Minecraft mc = Minecraft.getMinecraft();
Controller.instance.getDisplaySettings().configure(Controller.instance.getServerIP(),
mc.theWorld.getWorldInfo().getGameType());
mc.world.getWorldInfo().getGameType());
}
}

// --------------------------------------------------------------------------
/**
* @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 @@ -313,23 +315,23 @@ public void onPostRender(float partialTicks)

private double getPlayerX(float partialTicks)
{
EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
EntityPlayerSP p = Minecraft.getMinecraft().player;
return p.prevPosX + (p.posX - p.prevPosX) * partialTicks;
}

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

private double getPlayerY(float partialTicks)
{
EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
EntityPlayerSP p = Minecraft.getMinecraft().player;
return p.prevPosY + (p.posY - p.prevPosY) * partialTicks;
}

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

private double getPlayerZ(float partialTicks)
{
EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
EntityPlayerSP p = Minecraft.getMinecraft().player;
return p.prevPosZ + (p.posZ - p.prevPosZ) * partialTicks;
}

Expand Down Expand Up @@ -357,7 +359,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 @@ -466,13 +468,13 @@ public static void onInventoryPlayerChangeCurrentItem(EventInfo<InventoryPlayer>

// --------------------------------------------------------------------------
/**
* Play a button press sound and call the {@link ActionHandler} for a
* Play a button press sound and call the {@link SoundHandler} for a
* {@link ModifiedKeyBinding}.
*/
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
Loading