diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..672dce0 --- /dev/null +++ b/build.gradle @@ -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 +} diff --git a/src/watson/Configuration.java b/src/watson/Configuration.java index d052754..63da1ba 100644 --- a/src/watson/Configuration.java +++ b/src/watson/Configuration.java @@ -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 entry : getKeyBindingsMap().entrySet()) { @@ -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 entry : getKeyBindingsMap().entrySet()) { @@ -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 @@ -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 entry : getKeyBindingsMap().entrySet()) { root.addChild(entry.getKey(), new TypeValidatorNode(String.class, true, entry.getValue().toString())); @@ -1098,6 +1129,11 @@ private static HashMap 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. diff --git a/src/watson/Controller.java b/src/watson/Controller.java index 8fcad16..449cca1 100644 --- a/src/watson/Controller.java +++ b/src/watson/Controller.java @@ -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; @@ -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) @@ -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); } diff --git a/src/watson/DisplaySettings.java b/src/watson/DisplaySettings.java index 57575a5..5b06eec 100644 --- a/src/watson/DisplaySettings.java +++ b/src/watson/DisplaySettings.java @@ -1,6 +1,6 @@ package watson; -import net.minecraft.world.WorldSettings; +import net.minecraft.world.GameType; import watson.chat.Chat; // ---------------------------------------------------------------------------- @@ -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 diff --git a/src/watson/LiteModWatson.java b/src/watson/LiteModWatson.java index 878e1dc..9dabfa0 100644 --- a/src/watson/LiteModWatson.java +++ b/src/watson/LiteModWatson.java @@ -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; @@ -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()) @@ -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 newMessage) + public boolean onChat(ITextComponent chat, String message, LiteLoaderEventBroker.ReturnValue newMessage) { boolean allowChat = ChatProcessor.instance.onChat(chat); - if (allowChat) + if (allowChat && Configuration.instance.useChatHighlights()) { newMessage.set(Chat.getChatHighlighter().highlight(chat)); } @@ -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)); } } @@ -472,7 +473,7 @@ public static void onInventoryPlayerChangeCurrentItem(EventInfo 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(); } diff --git a/src/watson/PrivateFieldsWatson.java b/src/watson/PrivateFieldsWatson.java index 5efaf1e..78eb948 100644 --- a/src/watson/PrivateFieldsWatson.java +++ b/src/watson/PrivateFieldsWatson.java @@ -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; // ---------------------------------------------------------------------------- /** @@ -27,9 +27,9 @@ protected PrivateFieldsWatson(Class

owner, Obf obf) // -------------------------------------------------------------------------- - public static final PrivateFieldsWatson formattingCode = new PrivateFieldsWatson( - EnumChatFormatting.class, - WatsonObf.EnumChatFormatting_formattingCode); + public static final PrivateFieldsWatson formattingCode = new PrivateFieldsWatson( + TextFormatting.class, + WatsonObf.TextFormatting_formattingCode); public static final PrivateFieldsWatson renderPosX = new PrivateFieldsWatson( RenderManager.class, WatsonObf.RenderManager_renderPosX); diff --git a/src/watson/Screenshot.java b/src/watson/Screenshot.java index 27737ab..b391a11 100644 --- a/src/watson/Screenshot.java +++ b/src/watson/Screenshot.java @@ -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; @@ -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 { @@ -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()}); } } diff --git a/src/watson/WatsonObf.java b/src/watson/WatsonObf.java index 6dd4a5e..b8d3b74 100644 --- a/src/watson/WatsonObf.java +++ b/src/watson/WatsonObf.java @@ -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"); @@ -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"); diff --git a/src/watson/analysis/Analysis.java b/src/watson/analysis/Analysis.java index f6ffb04..e25f65e 100644 --- a/src/watson/analysis/Analysis.java +++ b/src/watson/analysis/Analysis.java @@ -5,7 +5,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.chat.IChatHandler; import watson.chat.IMatchedChatHandler; @@ -29,7 +29,7 @@ public class Analysis implements IChatHandler * true if none were called. The chat is added to the client's chat * GUI if true was returned. */ - public boolean dispatchMatchedChat(IChatComponent chat) + public boolean dispatchMatchedChat(ITextComponent chat) { String unformatted = chat.getUnformattedText(); for (Entry entry : _handlers.entrySet()) @@ -58,10 +58,10 @@ public void addMatchedChatHandler(Pattern pattern, IMatchedChatHandler handler) // -------------------------------------------------------------------------- /** - * @see watson.chat.IChatHandler#onChat(net.minecraft.util.IChatComponent) + * @see watson.chat.IChatHandler#onChat(net.minecraft.util.text.ITextComponent) */ @Override - public boolean onChat(IChatComponent chat) + public boolean onChat(ITextComponent chat) { return dispatchMatchedChat(chat); } // onChat diff --git a/src/watson/analysis/CoreProtectAnalysis.java b/src/watson/analysis/CoreProtectAnalysis.java index dcf38a8..6748425 100644 --- a/src/watson/analysis/CoreProtectAnalysis.java +++ b/src/watson/analysis/CoreProtectAnalysis.java @@ -8,7 +8,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.Controller; import watson.SyncTaskQueue; import watson.analysis.task.AddBlockEditTask; @@ -52,7 +52,7 @@ public CoreProtectAnalysis() addMatchedChatHandler(INSPECTOR_COORDS, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { inspectorCoords(chat, m); return true; @@ -61,7 +61,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(DETAILS, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { details(chat, m); return true; @@ -70,7 +70,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LOOKUP_COORDS, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lookupCoords(chat, m); return true; @@ -79,7 +79,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LOOKUP_HEADER, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lookupHeader(chat, m); return true; @@ -93,7 +93,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) * inspector coordinates line. */ @SuppressWarnings("unused") - void inspectorCoords(IChatComponent chat, Matcher m) + void inspectorCoords(ITextComponent chat, Matcher m) { _isLookup = false; _x = Integer.parseInt(m.group(1)); @@ -109,7 +109,7 @@ void inspectorCoords(IChatComponent chat, Matcher m) * inspector or lookup details line. */ @SuppressWarnings("unused") - void details(IChatComponent chat, Matcher m) + void details(ITextComponent chat, Matcher m) { _lookupDetails = false; if (m.group(3).equals("placed") || m.group(3).equals("removed")) @@ -163,7 +163,7 @@ else if (type.equals("389")) * lookup header line. */ @SuppressWarnings("unused") - void lookupHeader(IChatComponent chat, Matcher m) + void lookupHeader(ITextComponent chat, Matcher m) { _isLookup = true; } @@ -174,7 +174,7 @@ void lookupHeader(IChatComponent chat, Matcher m) * lookup coordinates line. */ @SuppressWarnings("unused") - void lookupCoords(IChatComponent chat, Matcher m) + void lookupCoords(ITextComponent chat, Matcher m) { _isLookup = true; if (_lookupDetails) diff --git a/src/watson/analysis/LbCoordsAnalysis.java b/src/watson/analysis/LbCoordsAnalysis.java index bd02b63..3611bbc 100644 --- a/src/watson/analysis/LbCoordsAnalysis.java +++ b/src/watson/analysis/LbCoordsAnalysis.java @@ -19,7 +19,7 @@ import java.util.logging.Level; import java.util.regex.Matcher; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.Configuration; import watson.Controller; import watson.SyncTaskQueue; @@ -50,7 +50,7 @@ public LbCoordsAnalysis() addMatchedChatHandler(LB_COORD, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbCoord(chat, m); // Don't echo in GUI. @@ -60,7 +60,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LB_COORD_KILLS, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbCoordKills(chat, m); // Don't echo in GUI. @@ -70,7 +70,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LB_COORD_REPLACED, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbCoordReplaced(chat, m); // Don't echo in GUI. @@ -80,7 +80,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LB_PAGE, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbPage(chat, m); return true; @@ -90,7 +90,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) IMatchedChatHandler headerHandler = new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbHeader(chat, m); return true; @@ -113,7 +113,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) /** * Parse creation and destruction coords results. */ - void lbCoord(IChatComponent chat, Matcher m) + void lbCoord(ITextComponent chat, Matcher m) { try { @@ -187,7 +187,7 @@ void lbCoord(IChatComponent chat, Matcher m) // No reformatting of query results. Recolour? if (Configuration.instance.getRecolourQueryResults()) { - Chat.localChat(ChatComponents.getEnumChatFormatting(colourCode), chat.getUnformattedText()); + Chat.localChat(ChatComponents.getTextFormatting(colourCode), chat.getUnformattedText()); } else { @@ -207,7 +207,7 @@ void lbCoord(IChatComponent chat, Matcher m) /** * Parse kill coords results. */ - void lbCoordKills(IChatComponent chat, Matcher m) + void lbCoordKills(ITextComponent chat, Matcher m) { try { @@ -267,7 +267,7 @@ void lbCoordKills(IChatComponent chat, Matcher m) // No reformatting of query results. Recolour? if (Configuration.instance.getRecolourQueryResults()) { - Chat.localChat(ChatComponents.getEnumChatFormatting(colourCode), chat.getUnformattedText()); + Chat.localChat(ChatComponents.getTextFormatting(colourCode), chat.getUnformattedText()); } else { @@ -288,7 +288,7 @@ void lbCoordKills(IChatComponent chat, Matcher m) * Parse /lb coords results where the edit was replacement of one block with * another. */ - void lbCoordReplaced(IChatComponent chat, Matcher m) + void lbCoordReplaced(ITextComponent chat, Matcher m) { try { @@ -335,7 +335,7 @@ void lbCoordReplaced(IChatComponent chat, Matcher m) // No reformatting of query results. Recolour? if (Configuration.instance.getRecolourQueryResults()) { - Chat.localChat(ChatComponents.getEnumChatFormatting(colourCode), chat.getUnformattedText()); + Chat.localChat(ChatComponents.getTextFormatting(colourCode), chat.getUnformattedText()); } else { @@ -359,7 +359,7 @@ void lbCoordReplaced(IChatComponent chat, Matcher m) * configuration setting. */ @SuppressWarnings("unused") - void lbPage(IChatComponent chat, Matcher m) + void lbPage(ITextComponent chat, Matcher m) { int currentPage = Integer.parseInt(m.group(1)); int pageCount = Integer.parseInt(m.group(2)); @@ -386,7 +386,7 @@ void lbPage(IChatComponent chat, Matcher m) * we look for the various headers in /lb results and clear the counters. */ @SuppressWarnings("unused") - void lbHeader(IChatComponent chat, Matcher m) + void lbHeader(ITextComponent chat, Matcher m) { _currentPage = _pageCount = 0; } diff --git a/src/watson/analysis/LbToolBlockAnalysis.java b/src/watson/analysis/LbToolBlockAnalysis.java index 9e33d5b..46f024f 100644 --- a/src/watson/analysis/LbToolBlockAnalysis.java +++ b/src/watson/analysis/LbToolBlockAnalysis.java @@ -6,7 +6,7 @@ import java.util.regex.Matcher; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.Controller; import watson.SyncTaskQueue; import watson.analysis.task.AddBlockEditTask; @@ -33,7 +33,7 @@ public LbToolBlockAnalysis() addMatchedChatHandler(LB_POSITION, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbPosition(chat, m); return true; @@ -42,7 +42,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LB_EDIT, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbEdit(chat, m); return true; @@ -51,7 +51,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LB_EDIT_REPLACED, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbEditReplaced(chat, m); return true; @@ -64,7 +64,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) * Parse the result header when checking the logs for a single block using * coal ore. */ - void lbPosition(@SuppressWarnings("unused") IChatComponent chat, Matcher m) + void lbPosition(@SuppressWarnings("unused") ITextComponent chat, Matcher m) { _x = Integer.parseInt(m.group(1)); _y = Integer.parseInt(m.group(2)); @@ -80,7 +80,7 @@ void lbPosition(@SuppressWarnings("unused") IChatComponent chat, Matcher m) * Parse "created" or "destroyed" result in the logs for a single block using * coal ore. */ - void lbEdit(@SuppressWarnings("unused") IChatComponent chat, Matcher m) + void lbEdit(@SuppressWarnings("unused") ITextComponent chat, Matcher m) { if ((System.currentTimeMillis() - _lbPositionTime) < POSITION_TIMEOUT_MILLIS) { @@ -102,7 +102,7 @@ void lbEdit(@SuppressWarnings("unused") IChatComponent chat, Matcher m) /** * Parse results where the player replaced one block with another. */ - void lbEditReplaced(@SuppressWarnings("unused") IChatComponent chat, Matcher m) + void lbEditReplaced(@SuppressWarnings("unused") ITextComponent chat, Matcher m) { if ((System.currentTimeMillis() - _lbPositionTime) < POSITION_TIMEOUT_MILLIS) { diff --git a/src/watson/analysis/ModModeAnalysis.java b/src/watson/analysis/ModModeAnalysis.java index 80faa0b..b191f1b 100644 --- a/src/watson/analysis/ModModeAnalysis.java +++ b/src/watson/analysis/ModModeAnalysis.java @@ -7,7 +7,7 @@ import java.util.regex.Matcher; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.Controller; import watson.chat.IMatchedChatHandler; @@ -28,7 +28,7 @@ public ModModeAnalysis() IMatchedChatHandler modmodeHandler = new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { changeModMode(chat, m); return true; @@ -41,7 +41,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) IMatchedChatHandler dutiesHandler = new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { changeDutyMode(chat, m); return true; @@ -58,7 +58,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) * assigned the "mod.entermodmode" or "mod.leavemodmode" category. */ @SuppressWarnings("unused") - void changeModMode(IChatComponent chat, Matcher m) + void changeModMode(ITextComponent chat, Matcher m) { Controller.instance.getDisplaySettings().setDisplayed(m.pattern() == MODMODE_ENABLE); } @@ -69,7 +69,7 @@ void changeModMode(IChatComponent chat, Matcher m) * assigned the "mod.enabledutymode" or "mod.disabledutymode" category. */ @SuppressWarnings("unused") - void changeDutyMode(IChatComponent chat, Matcher m) + void changeDutyMode(ITextComponent chat, Matcher m) { Controller.instance.getDisplaySettings().setDisplayed(m.pattern() == DUTYMODE_ENABLE); } diff --git a/src/watson/analysis/PrismAnalysis.java b/src/watson/analysis/PrismAnalysis.java index df01a54..7ec9dfb 100644 --- a/src/watson/analysis/PrismAnalysis.java +++ b/src/watson/analysis/PrismAnalysis.java @@ -8,7 +8,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.Controller; import watson.SyncTaskQueue; import watson.analysis.task.AddBlockEditTask; @@ -77,7 +77,7 @@ public PrismAnalysis() addMatchedChatHandler(PLACE_BREAK, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { placeBreak(chat, m); return true; @@ -86,7 +86,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(DATE_TIME_WORLD_COORDS, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { dateTimeWorldCoords(chat, m); return true; @@ -95,7 +95,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LOOKUP_DEFAULTS, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lookupDefaults(chat, m); return true; @@ -104,7 +104,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(INSPECTOR_HEADER, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { inspectorHeader(chat, m); return true; @@ -118,7 +118,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) * block type and action. */ @SuppressWarnings("unused") - void placeBreak(IChatComponent chat, Matcher m) + void placeBreak(ITextComponent chat, Matcher m) { _player = m.group(1); String blockAndCount = m.group(2); @@ -169,7 +169,7 @@ void placeBreak(IChatComponent chat, Matcher m) * Parse date, time, world name and coords from Prism reports in chat. */ @SuppressWarnings("unused") - void dateTimeWorldCoords(IChatComponent chat, Matcher m) + void dateTimeWorldCoords(ITextComponent chat, Matcher m) { if (_expectingDateTimeCoords) { @@ -216,7 +216,7 @@ void dateTimeWorldCoords(IChatComponent chat, Matcher m) * lookup (/prism l) rather than inspector results (/prism i). */ @SuppressWarnings("unused") - void lookupDefaults(IChatComponent chat, Matcher m) + void lookupDefaults(ITextComponent chat, Matcher m) { _inspectorResult = false; } @@ -227,7 +227,7 @@ void lookupDefaults(IChatComponent chat, Matcher m) * inspector results (/prism i). */ @SuppressWarnings("unused") - void inspectorHeader(IChatComponent chat, Matcher m) + void inspectorHeader(ITextComponent chat, Matcher m) { _inspectorResult = true; _awaitingFirstResult = true; diff --git a/src/watson/analysis/RatioAnalysis.java b/src/watson/analysis/RatioAnalysis.java index e87a6c2..ff5be19 100644 --- a/src/watson/analysis/RatioAnalysis.java +++ b/src/watson/analysis/RatioAnalysis.java @@ -14,7 +14,7 @@ import java.util.Locale; import java.util.regex.Matcher; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.chat.Chat; import watson.chat.IMatchedChatHandler; import watson.db.TimeStamp; @@ -42,7 +42,7 @@ public RatioAnalysis() addMatchedChatHandler(LB_HEADER_RATIO, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbHeaderRatio(chat, m); return true; @@ -51,7 +51,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LB_HEADER_RATIO_CURRENT, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbHeaderRatioCurrent(chat, m); return true; @@ -61,7 +61,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) IMatchedChatHandler headerHandler = new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbHeader(chat, m); return true; @@ -78,7 +78,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LB_SUM, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { return lbSum(chat, m); } @@ -93,7 +93,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) * until we see an lb.header.ratio line. */ @SuppressWarnings("unused") - void lbHeader(IChatComponent chat, Matcher m) + void lbHeader(ITextComponent chat, Matcher m) { reset(); } @@ -103,7 +103,7 @@ void lbHeader(IChatComponent chat, Matcher m) * Parse lines matching LogBlockPatterns.LB_HEADER_RATIO. */ @SuppressWarnings("unused") - void lbHeaderRatio(IChatComponent chat, Matcher m) + void lbHeaderRatio(ITextComponent chat, Matcher m) { reset(); _parsing = true; @@ -116,7 +116,7 @@ void lbHeaderRatio(IChatComponent chat, Matcher m) * Parse lines matching LogBlockPatterns.LB_HEADER_RATIO_CURRENT. */ @SuppressWarnings("unused") - void lbHeaderRatioCurrent(IChatComponent chat, Matcher m) + void lbHeaderRatioCurrent(ITextComponent chat, Matcher m) { reset(); _parsing = true; @@ -129,7 +129,7 @@ void lbHeaderRatioCurrent(IChatComponent chat, Matcher m) * Parse lines containing sums of creations and destructions of stone and * diamond. */ - boolean lbSum(IChatComponent chat, Matcher m) + boolean lbSum(ITextComponent chat, Matcher m) { if (_parsing) { diff --git a/src/watson/analysis/RegionInfoAnalysis.java b/src/watson/analysis/RegionInfoAnalysis.java index 58efe76..0cbca1f 100644 --- a/src/watson/analysis/RegionInfoAnalysis.java +++ b/src/watson/analysis/RegionInfoAnalysis.java @@ -5,7 +5,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.Configuration; import watson.Controller; import watson.chat.IMatchedChatHandler; @@ -29,7 +29,7 @@ public RegionInfoAnalysis() addMatchedChatHandler(WG_REGIONS, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { wgRegions(chat, m); return true; @@ -42,7 +42,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) * Respond to wg.regions by issuing the corresponding /region info commands. */ @SuppressWarnings("unused") - void wgRegions(IChatComponent chat, Matcher m) + void wgRegions(ITextComponent chat, Matcher m) { long now = System.currentTimeMillis(); if (now - _lastCommandTime > (long) (Configuration.instance.getRegionInfoTimeoutSeconds() * 1000)) diff --git a/src/watson/analysis/ServerTime.java b/src/watson/analysis/ServerTime.java index 30ca1a4..dcba376 100644 --- a/src/watson/analysis/ServerTime.java +++ b/src/watson/analysis/ServerTime.java @@ -8,7 +8,7 @@ import java.util.Locale; import java.util.regex.Matcher; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.Controller; import watson.chat.Chat; import watson.chat.IMatchedChatHandler; @@ -111,7 +111,7 @@ public ServerTime() addMatchedChatHandler(LB_HEADER_TIME_CHECK, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbHeaderTimeCheck(chat, m); // Don't echo time check result header in GUI. @@ -121,7 +121,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) addMatchedChatHandler(LB_HEADER_NO_RESULTS, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { // Called method controls whether chat is echoed. return lbHeaderNoResults(chat, m); @@ -134,7 +134,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) * Handle the results of the time checking query. */ @SuppressWarnings("unused") - void lbHeaderTimeCheck(IChatComponent chat, Matcher m) + void lbHeaderTimeCheck(ITextComponent chat, Matcher m) { String serverIP = Controller.instance.getServerIP(); if (serverIP != null && _localMinusServerMinutes.get(serverIP) == null) @@ -174,7 +174,7 @@ void lbHeaderTimeCheck(IChatComponent chat, Matcher m) * GUI when it was triggered by the time checking query, only. */ @SuppressWarnings("unused") - boolean lbHeaderNoResults(IChatComponent chat, Matcher m) + boolean lbHeaderNoResults(ITextComponent chat, Matcher m) { boolean echo = _echoNextNoResults; _echoNextNoResults = true; diff --git a/src/watson/analysis/TeleportAnalysis.java b/src/watson/analysis/TeleportAnalysis.java index c8483e4..588f903 100644 --- a/src/watson/analysis/TeleportAnalysis.java +++ b/src/watson/analysis/TeleportAnalysis.java @@ -4,7 +4,7 @@ import java.util.regex.Matcher; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.Controller; import watson.chat.IMatchedChatHandler; import watson.db.BlockEdit; @@ -27,7 +27,7 @@ public TeleportAnalysis() addMatchedChatHandler(LB_TP, new IMatchedChatHandler() { @Override - public boolean onMatchedChat(IChatComponent chat, Matcher m) + public boolean onMatchedChat(ITextComponent chat, Matcher m) { lbTp(chat, m); return true; @@ -41,7 +41,7 @@ public boolean onMatchedChat(IChatComponent chat, Matcher m) * corresponding edit so that /w pre works. */ @SuppressWarnings("unused") - void lbTp(IChatComponent chat, Matcher m) + void lbTp(ITextComponent chat, Matcher m) { try { diff --git a/src/watson/analysis/task/AddBlockEditTask.java b/src/watson/analysis/task/AddBlockEditTask.java index c2108e0..958d69e 100644 --- a/src/watson/analysis/task/AddBlockEditTask.java +++ b/src/watson/analysis/task/AddBlockEditTask.java @@ -14,7 +14,7 @@ public class AddBlockEditTask implements Runnable * Constructor. * * @param edit the edit to add when the task is run. - * @param true if true, the state variables signifying the selected edit are + * @param updateVariables if true, the state variables signifying the selected edit are * updated. */ public AddBlockEditTask(BlockEdit edit, boolean updateVariables) diff --git a/src/watson/chat/Chat.java b/src/watson/chat/Chat.java index 2fb56a7..263b19a 100644 --- a/src/watson/chat/Chat.java +++ b/src/watson/chat/Chat.java @@ -3,10 +3,11 @@ import java.util.logging.Level; import net.minecraft.client.Minecraft; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import watson.Configuration; import watson.debug.Log; // ---------------------------------------------------------------------------- @@ -67,7 +68,7 @@ public static boolean isChatGuiReady() */ public static void localChat(String message) { - localChat(new ChatComponentText(message)); + localChat(new TextComponentString(message)); } // -------------------------------------------------------------------------- @@ -77,26 +78,26 @@ public static void localChat(String message) * @param colour the colour to format the text as. * @param message the text to display. */ - public static void localChat(EnumChatFormatting colour, String message) + public static void localChat(TextFormatting colour, String message) { - ChatComponentText chat = new ChatComponentText(message); - ChatStyle style = new ChatStyle(); + TextComponentString chat = new TextComponentString(message); + Style style = new Style(); style.setColor(colour); - chat.setChatStyle(style); + chat.setStyle(style); localChat(chat); } // -------------------------------------------------------------------------- /** * Display the chat locally. - * + * * @param chat the chat component. */ - public static void localChat(IChatComponent chat) + public static void localChat(ITextComponent chat) { if (isChatGuiReady()) { - IChatComponent highlighted = getChatHighlighter().highlight(chat); + ITextComponent highlighted = Configuration.instance.useChatHighlights() ? getChatHighlighter().highlight(chat) : chat; Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(highlighted); } } @@ -109,7 +110,7 @@ public static void localChat(IChatComponent chat) */ public static void localOutput(String message) { - localChat(EnumChatFormatting.AQUA, message); + localChat(TextFormatting.AQUA, message); } // -------------------------------------------------------------------------- @@ -120,7 +121,7 @@ public static void localOutput(String message) */ public static void localError(String message) { - localChat(EnumChatFormatting.DARK_RED, message); + localChat(TextFormatting.DARK_RED, message); } // -------------------------------------------------------------------------- diff --git a/src/watson/chat/ChatComponents.java b/src/watson/chat/ChatComponents.java index 0e9ca1d..0094931 100644 --- a/src/watson/chat/ChatComponents.java +++ b/src/watson/chat/ChatComponents.java @@ -3,14 +3,14 @@ import java.util.ArrayList; import java.util.HashMap; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.ITextComponent; import watson.PrivateFieldsWatson; // ---------------------------------------------------------------------------- /** - * utility methods for dealing with IChatComponent. + * utility methods for dealing with ITextComponent. */ public class ChatComponents { @@ -19,34 +19,34 @@ public class ChatComponents * Return true of the chat has associated events (click, hover). * * The current Watson highlighting implementation only supports old style - * formatting codes and so can only highlight IChatComponents that don't have + * formatting codes and so can only highlight ITextComponents that don't have * associated events. * * @return true of the chat has associated events (click, hover). */ - public static boolean hasEvents(IChatComponent chat) + public static boolean hasEvents(ITextComponent chat) { - return chat.getChatStyle().getChatClickEvent() != null || - chat.getChatStyle().getChatHoverEvent() != null; + return chat.getStyle().getClickEvent() != null || + chat.getStyle().getHoverEvent() != null; } // -------------------------------------------------------------------------- /** - * Return an array containing the specified IChatComponent and all its + * Return an array containing the specified ITextComponent and all its * siblings. * - * @return an array containing the specified IChatComponent and all its + * @return an array containing the specified ITextComponent and all its * siblings. */ @SuppressWarnings("unchecked") - public static ArrayList getComponents(IChatComponent chat) + public static ArrayList getComponents(ITextComponent chat) { - ArrayList components = new ArrayList(); + ArrayList components = new ArrayList(); for (Object o : chat) { - IChatComponent component = (IChatComponent) o; - IChatComponent copy = new ChatComponentText(component.getUnformattedTextForChat()); - copy.setChatStyle(component.getChatStyle().createDeepCopy()); + ITextComponent component = (ITextComponent) o; + ITextComponent copy = new TextComponentString(component.getUnformattedText()); + copy.setStyle(component.getStyle().createDeepCopy()); components.add(copy); } return components; @@ -57,14 +57,14 @@ public static ArrayList getComponents(IChatComponent chat) * Return an array containing all of the components in the input array and all * of their siblings, in their natural order. * - * @param components an array of IChatComponents. + * @param components an array of ITextComponents. * @return an array containing all of the components in the input array and * all of their siblings, in their natural order. */ - public static ArrayList flatten(ArrayList components) + public static ArrayList flatten(ArrayList components) { - ArrayList result = new ArrayList(); - for (IChatComponent component : components) + ArrayList result = new ArrayList(); + for (ITextComponent component : components) { result.addAll(getComponents(component)); } @@ -73,28 +73,28 @@ public static ArrayList flatten(ArrayList compon // -------------------------------------------------------------------------- /** - * Convert an array of IChatComponents into a single IChatComponent with all + * Convert an array of ITextComponents into a single ITextComponent with all * the individual components as siblings. * - * @param component the array of components to be added. - * @return an IChatComponent containing copies of all of the components in the + * @param components the array of components to be added. + * @return an ITextComponent containing copies of all of the components in the * array. */ - public static IChatComponent toChatComponent(ArrayList components) + public static ITextComponent toChatComponent(ArrayList components) { - ArrayList all = flatten(components); + ArrayList all = flatten(components); if (components.size() == 0) { - return new ChatComponentText(""); + return new TextComponentString(""); } else { - IChatComponent result = all.get(0); + ITextComponent result = all.get(0); for (int i = 1; i < all.size(); ++i) { - IChatComponent component = all.get(i); + ITextComponent component = all.get(i); - if (component.getUnformattedTextForChat().length() != 0 || !component.getChatStyle().isEmpty()) + if (component.getUnformattedText().length() != 0 || !component.getStyle().isEmpty()) { result.appendSibling(component); } @@ -106,23 +106,23 @@ public static IChatComponent toChatComponent(ArrayList component // -------------------------------------------------------------------------- /** * Map a formatting character to the corresponding Minecraft - * EnumChatFormatting. + * TextFormatting. * * @param code the formatting code. - * @param the corresponding enum value. + * @return the corresponding enum value. */ - public static EnumChatFormatting getEnumChatFormatting(char code) + public static TextFormatting getTextFormatting(char code) { return _formatCharToEnum.get(code); } // -------------------------------------------------------------------------- /** - * Dump information about the IChatComponent to standard output. + * Dump information about the ITextComponent to standard output. * * @patam component the component. */ - public static void dump(IChatComponent component) + public static void dump(ITextComponent component) { System.out.println("Formatted: " + component.getFormattedText()); dump(flatten(getComponents(component))); @@ -130,31 +130,31 @@ public static void dump(IChatComponent component) // -------------------------------------------------------------------------- /** - * Dump information about the IChatComponent to standard output. + * Dump information about the ITextComponent to standard output. * * @patam component the component. */ - public static void dump(ArrayList components) + public static void dump(ArrayList components) { System.out.println("Dump: " + toChatComponent(components).getFormattedText()); for (int i = 0; i < components.size(); ++i) { - IChatComponent c = components.get(i); + ITextComponent c = components.get(i); System.out.println(i + ": " + hasEvents(c) + ": \"" + c.getFormattedText() + "\" " - + c.getUnformattedTextForChat().length() + " " - + c.getChatStyle().isEmpty() + " " + c.getChatStyle().toString()); + + c.getUnformattedComponentText().length() + " " + + c.getStyle().isEmpty() + " " + c.getStyle().toString()); } } // -------------------------------------------------------------------------- /** - * Map formatting character to the corresponding Minecraft EnumChatFormatting. + * Map formatting character to the corresponding Minecraft TextFormatting. */ - private static HashMap _formatCharToEnum = new HashMap(); + private static HashMap _formatCharToEnum = new HashMap(); static { - for (EnumChatFormatting format : EnumChatFormatting.values()) + for (TextFormatting format : TextFormatting.values()) { _formatCharToEnum.put(PrivateFieldsWatson.formattingCode.get(format), format); } diff --git a/src/watson/chat/ChatHighlighter.java b/src/watson/chat/ChatHighlighter.java index 5650d9e..b2d61d2 100644 --- a/src/watson/chat/ChatHighlighter.java +++ b/src/watson/chat/ChatHighlighter.java @@ -12,8 +12,7 @@ import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import net.minecraft.util.IChatComponent; - +import net.minecraft.util.text.ITextComponent; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; @@ -76,12 +75,13 @@ public boolean isReisLikeCode(String chat) // -------------------------------------------------------------------------- /** + * TODO: Fix this. It doubles the message (first without formatting, second with) * Highlight the text in a chat component. * * @param chat the text to highlight. * @return highlighted text. */ - public IChatComponent highlight(IChatComponent chat) + public ITextComponent highlight(ITextComponent chat) { if (isReisLikeCode(chat.getFormattedText())) { @@ -89,11 +89,11 @@ public IChatComponent highlight(IChatComponent chat) } else { - ArrayList resultComponents = new ArrayList(); - ArrayList components = ChatComponents.getComponents(chat); + ArrayList resultComponents = new ArrayList(); + ArrayList components = ChatComponents.getComponents(chat); while (!components.isEmpty()) { - IChatComponent head = components.remove(0); + ITextComponent head = components.remove(0); if (ChatComponents.hasEvents(head)) { // Can't currently highlight links etc. @@ -103,12 +103,12 @@ public IChatComponent highlight(IChatComponent chat) { // Collect all consecutive components that don't have events // and therefore can be highlighted. - ArrayList highlightableComps = new ArrayList(); + ArrayList highlightableComps = new ArrayList(); highlightableComps.add(head); while (!components.isEmpty()) { - IChatComponent next = components.get(0); + ITextComponent next = components.get(0); if (ChatComponents.hasEvents(next)) { break; @@ -120,7 +120,7 @@ public IChatComponent highlight(IChatComponent chat) } } // while - IChatComponent highlightable = ChatComponents.toChatComponent(highlightableComps); + ITextComponent highlightable = ChatComponents.toChatComponent(highlightableComps); String highlightableText = highlightable.getFormattedText(); Text highlighted = highlight(highlightableText); resultComponents.add(highlighted.toChatComponent()); diff --git a/src/watson/chat/ChatProcessor.java b/src/watson/chat/ChatProcessor.java index 494cacc..671325f 100644 --- a/src/watson/chat/ChatProcessor.java +++ b/src/watson/chat/ChatProcessor.java @@ -2,7 +2,7 @@ import java.util.ArrayList; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import watson.Configuration; import watson.analysis.LbToolBlockAnalysis; import watson.analysis.CoreProtectAnalysis; @@ -52,7 +52,7 @@ public void addChatHandler(IChatHandler handler) * @return true if the chat should be echoed in the client chat GUI; false if * it should be filtered out. */ - public boolean onChat(IChatComponent chat) + public boolean onChat(ITextComponent chat) { if (Configuration.instance.isEnabled()) { diff --git a/src/watson/chat/IChatHandler.java b/src/watson/chat/IChatHandler.java index e597de5..c4ef7f2 100644 --- a/src/watson/chat/IChatHandler.java +++ b/src/watson/chat/IChatHandler.java @@ -1,6 +1,6 @@ package watson.chat; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; // ---------------------------------------------------------------------------- /** @@ -17,5 +17,5 @@ public interface IChatHandler * @return true if the chat should be echoed in the client chat GUI; false if * it should be filtered out. */ - public boolean onChat(IChatComponent chat); + public boolean onChat(ITextComponent chat); } \ No newline at end of file diff --git a/src/watson/chat/IMatchedChatHandler.java b/src/watson/chat/IMatchedChatHandler.java index b4097a0..3fb8150 100644 --- a/src/watson/chat/IMatchedChatHandler.java +++ b/src/watson/chat/IMatchedChatHandler.java @@ -2,7 +2,7 @@ import java.util.regex.Matcher; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; // ---------------------------------------------------------------------------- /** @@ -19,5 +19,5 @@ public interface IMatchedChatHandler * @return true if the chat should be echoed in the client GUI; false if it * should be filtered out. */ - public boolean onMatchedChat(IChatComponent chat, Matcher m); + public boolean onMatchedChat(ITextComponent chat, Matcher m); } diff --git a/src/watson/chat/Text.java b/src/watson/chat/Text.java index 3a8f67b..7670ff5 100644 --- a/src/watson/chat/Text.java +++ b/src/watson/chat/Text.java @@ -3,10 +3,10 @@ import java.util.ArrayList; import java.util.HashMap; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.ITextComponent; import watson.PrivateFieldsWatson; // ---------------------------------------------------------------------------- @@ -110,14 +110,14 @@ public String toString() * * @return the IChatComponent representation of the Text. */ - public IChatComponent toChatComponent() + public ITextComponent toChatComponent() { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList(); StringBuilder text = new StringBuilder(); // Sentinel: char colourStyle = Colour.white.getCode(); - ChatStyle style = new ChatStyle(); + Style style = new Style(); for (int i = 0; i < _unformatted.length(); ++i) { @@ -129,16 +129,16 @@ public IChatComponent toChatComponent() char colour = (char) (newColourStyle & Format.COLOUR_MASK); // Put all of the characters accumulated so far in ChatComponentText. - IChatComponent sibling = new ChatComponentText(text.toString()); - sibling.setChatStyle(style); + ITextComponent sibling = new TextComponentString(text.toString()); + sibling.setStyle(style); result.add(sibling); // Reuse StringBuilder to accumulate characters for the next sibling. text.setLength(0); // Configure the style of the next sibling to be appended to result. - style = new ChatStyle(); - EnumChatFormatting chatFormatting = _TO_ENUM_CHAT_FORMATTING.get(colour); + style = new Style(); + TextFormatting chatFormatting = _TO_ENUM_CHAT_FORMATTING.get(colour); style.setColor(chatFormatting); if ((newColourStyle & Format.BOLD) != 0) { @@ -167,8 +167,8 @@ public IChatComponent toChatComponent() text.append(_unformatted.charAt(i)); } // for - IChatComponent sibling = new ChatComponentText(text.toString()); - sibling.setChatStyle(style); + ITextComponent sibling = new TextComponentString(text.toString()); + sibling.setStyle(style); result.add(sibling); return ChatComponents.toChatComponent(result); } // toChatComponent @@ -288,10 +288,10 @@ public void setFormat(int begin, int end, Format format) * Map from single character formatting code for a colour to the corresponding * EnumChatFormatting instance. */ - protected static final HashMap _TO_ENUM_CHAT_FORMATTING = new HashMap(); + protected static final HashMap _TO_ENUM_CHAT_FORMATTING = new HashMap(); static { - for (EnumChatFormatting colour : EnumChatFormatting.values()) + for (TextFormatting colour : TextFormatting.values()) { _TO_ENUM_CHAT_FORMATTING.put(PrivateFieldsWatson.formattingCode.get(colour), colour); } diff --git a/src/watson/cli/AnnoCommand.java b/src/watson/cli/AnnoCommand.java index 77b4021..08acdec 100644 --- a/src/watson/cli/AnnoCommand.java +++ b/src/watson/cli/AnnoCommand.java @@ -5,6 +5,7 @@ import java.util.Locale; import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; import watson.Controller; import watson.db.Annotation; import watson.db.BlockEditSet; @@ -17,7 +18,7 @@ public class AnnoCommand extends WatsonCommandBase { // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommand#getCommandName() + * @see net.minecraft.command.ICommand#getCommandName() */ @Override public String getCommandName() @@ -27,11 +28,12 @@ public String getCommandName() // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommand#processCommand(net.minecraft.src.ICommandSender, + * @see net.minecraft.command.ICommand#execute(net.minecraft.server.MinecraftServer, + * net.minecraft.command.ICommandSender, * java.lang.String[]) */ @Override - public void processCommand(ICommandSender sender, String[] args) + public void execute(MinecraftServer server, ICommandSender sender, String[] args) { if (args.length == 0) { @@ -40,12 +42,12 @@ public void processCommand(ICommandSender sender, String[] args) } else if (args.length == 1) { - if (args[0].equals("help")) + if (args[0].equalsIgnoreCase("help")) { help(sender); return; } - else if (args[0].equals("list")) + else if (args[0].equalsIgnoreCase("list")) { BlockEditSet edits = Controller.instance.getBlockEditSet(); ArrayList annotations = edits.getAnnotations(); @@ -63,7 +65,7 @@ else if (args[0].equals("list")) } return; } - else if (args[0].equals("clear")) + else if (args[0].equalsIgnoreCase("clear")) { BlockEditSet edits = Controller.instance.getBlockEditSet(); ArrayList annotations = edits.getAnnotations(); @@ -77,7 +79,7 @@ else if (args[0].equals("clear")) } else if (args.length >= 2) { - if (args[0].equals("tp")) + if (args[0].equalsIgnoreCase("tp")) { if (args.length == 2) { @@ -98,7 +100,7 @@ else if (args.length >= 2) return; } } - else if (args[0].equals("remove")) + else if (args[0].equalsIgnoreCase("remove")) { if (args.length == 2) { @@ -119,7 +121,7 @@ else if (args[0].equals("remove")) return; } } - else if (args[0].equals("add")) + else if (args[0].equalsIgnoreCase("add")) { HashMap vars = Controller.instance.getVariables(); Integer x = (Integer) vars.get("x"); diff --git a/src/watson/cli/CalcCommand.java b/src/watson/cli/CalcCommand.java index 05516f0..313ddec 100644 --- a/src/watson/cli/CalcCommand.java +++ b/src/watson/cli/CalcCommand.java @@ -6,6 +6,7 @@ import java.util.Locale; import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; // -------------------------------------------------------------------------- /** @@ -34,28 +35,29 @@ public static void main(String[] args) // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommand#getCommandName() + * @see net.minecraft.command.ICommand#getCommandName() */ @Override public String getCommandName() { - return "calc"; + return "anno"; } // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommand#processCommand(net.minecraft.src.ICommandSender, + * @see net.minecraft.command.ICommand#execute(net.minecraft.server.MinecraftServer, + * net.minecraft.command.ICommandSender, * java.lang.String[]) */ @Override - public void processCommand(ICommandSender sender, String[] args) + public void execute(MinecraftServer server, ICommandSender sender, String[] args) { if (args.length == 0) { help(sender); return; } - else if (args.length == 1 && args[0].equals("help")) + else if (args.length == 1 && args[0].equalsIgnoreCase("help")) { help(sender); return; diff --git a/src/watson/cli/ClientCommandManager.java b/src/watson/cli/ClientCommandManager.java index 7260841..35d2d80 100644 --- a/src/watson/cli/ClientCommandManager.java +++ b/src/watson/cli/ClientCommandManager.java @@ -17,10 +17,10 @@ import net.minecraft.command.ICommandManager; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentTranslation; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TextFormatting; import watson.debug.Log; // ---------------------------------------------------------------------------- @@ -80,7 +80,7 @@ public boolean handleClientCommand(String commandLine) */ public void registerCommand(ICommand command) { - _commands.put(command.getCommandName(), command); + _commands.put(command.getCommandName().toLowerCase(), command); _canonicalCommands.add(command); // Add all aliases of the command. @@ -89,7 +89,7 @@ public void registerCommand(ICommand command) { for (String alias : aliases) { - _commands.put(alias, command); + _commands.put(alias.toLowerCase(), command); } } } // registerCommand @@ -102,7 +102,7 @@ public void registerCommand(ICommand command) */ public void unregisterCommand(ICommand command) { - _commands.remove(command.getCommandName()); + _commands.remove(command.getCommandName().toLowerCase()); _canonicalCommands.remove(command); // remove all aliases of the command. @@ -111,7 +111,7 @@ public void unregisterCommand(ICommand command) { for (String alias : aliases) { - _commands.remove(alias); + _commands.remove(alias.toLowerCase()); } } } // unregisterCommand @@ -120,23 +120,22 @@ public void unregisterCommand(ICommand command) /** * Return the command with the specified name, or null if there is no such * command. - * + * * @return the command with the specified name, or null if there is no such * command. */ public ICommand getCommand(String name) { - return _commands.get(name); + return _commands.get(name.toLowerCase()); } // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommandManager#executeCommand(net.minecraft.src.ICommandSender, - * java.lang.String) - * + * @see net.minecraft.command.ICommandManager#executeCommand(ICommandSender, String) + * * The JavaDocs for the interface don't currently describe the exact * meaning of the return value. Looking at the code for - * {@link net.minecraft.src.CommandHandler} it contains a loop that + * {@link net.minecraft.command.CommandHandler} it contains a loop that * applies a command for all players who match a particular name pattern. * The returned value is the number of times that the command was * successfully executed by that loop. Therefore in the case of this @@ -155,29 +154,29 @@ public int executeCommand(ICommandSender sender, String commandLine) throw new CommandNotFoundException(); } tokens = Arrays.copyOfRange(tokens, 1, tokens.length); - if (command.canCommandSenderUseCommand(sender)) + if (command.checkPermission(sender.getServer(), sender)) { - command.processCommand(sender, tokens); + command.execute(sender.getServer(), sender, tokens); return 1; } else { - sendError(sender, new ChatComponentTranslation("commands.generic.permission", new Object[0])); + sendError(sender, new TextComponentTranslation("commands.generic.permission", new Object[0])); } } catch (WrongUsageException ex) { sendError(sender, - new ChatComponentTranslation("commands.generic.usage", - new Object[]{new ChatComponentTranslation(ex.getMessage(), ex.getErrorObjects())})); + new TextComponentTranslation("commands.generic.usage", + new Object[]{new TextComponentTranslation(ex.getMessage(), ex.getErrorObjects())})); } catch (CommandException ex) { - sendError(sender, new ChatComponentTranslation(ex.getMessage(), ex.getErrorObjects())); + sendError(sender, new TextComponentTranslation(ex.getMessage(), ex.getErrorObjects())); } catch (Throwable throwable) { - sendError(sender, new ChatComponentTranslation("commands.generic.exception", new Object[0])); + sendError(sender, new TextComponentTranslation("commands.generic.exception", new Object[0])); Log.exception(Level.WARNING, "error processing command", throwable); } @@ -186,8 +185,7 @@ public int executeCommand(ICommandSender sender, String commandLine) // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommandManager#getPossibleCommands(net.minecraft.src.ICommandSender, - * java.lang.String) + * @see net.minecraft.command.ICommandManager#getPossibleCommands(net.minecraft.command.ICommandSender) */ @Override public List getTabCompletionOptions(ICommandSender var1, String prefix, BlockPos pos) @@ -208,7 +206,7 @@ public List getTabCompletionOptions(ICommandSender var1, String prefix, * The local client is assumed to be able to use any commands that have been * registered with mod_CLI. * - * @see net.minecraft.src.ICommandManager#getPossibleCommands(net.minecraft.src.ICommandSender) + * @see net.minecraft.command.ICommandManager#getPossibleCommands(net.minecraft.command.ICommandSender) */ @Override public List getPossibleCommands(ICommandSender var1) @@ -218,7 +216,7 @@ public List getPossibleCommands(ICommandSender var1) // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommandManager#getCommands() + * @see net.minecraft.command.ICommandManager#getCommands() */ @Override public Map getCommands() @@ -298,9 +296,9 @@ public ICommandSender getCommandSender() * @param sender the player executing the command. * @param chat the error message. */ - static void sendError(ICommandSender sender, IChatComponent chat) + static void sendError(ICommandSender sender, ITextComponent chat) { - chat.getChatStyle().setColor(EnumChatFormatting.RED); + chat.getStyle().setColor(TextFormatting.RED); sender.addChatMessage(chat); } diff --git a/src/watson/cli/ClientCommandSender.java b/src/watson/cli/ClientCommandSender.java index ec4148f..69a9e4a 100644 --- a/src/watson/cli/ClientCommandSender.java +++ b/src/watson/cli/ClientCommandSender.java @@ -4,10 +4,11 @@ import net.minecraft.command.CommandResultStats; import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.Vec3; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import watson.chat.Chat; @@ -36,20 +37,20 @@ public ClientCommandSender(ClientCommandManager ccm) // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommandSender#getCommandSenderName() + * @see net.minecraft.command.ICommandSender#getName() */ @Override - public String getCommandSenderName() + public String getName() { - return _sender.getCommandSenderName(); + return _sender.getName(); } // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommandSender#canCommandSenderUseCommand(java.lang.String) + * @see net.minecraft.command.ICommandSender#canCommandSenderUseCommand(int, java.lang.String) */ @Override - public boolean canCommandSenderUseCommand(int unknown, String command) + public boolean canCommandSenderUseCommand(int commandLevel, String command) { return true; } @@ -59,23 +60,23 @@ public boolean canCommandSenderUseCommand(int unknown, String command) * Vanilla class ChatComponentTranslation extracts the ChatStyle out of this * IChatComponent and uses it to set the style of translated text. * - * @see net.minecraft.command.ICommandSender#func_145748_c_() + * @see net.minecraft.command.ICommandSender#getDisplayName() */ @Override - public IChatComponent getDisplayName() + public ITextComponent getDisplayName() { // ChatComponentStyle.getChatStyle() creates a default ChatStyle instance on // demand, so a default ChatComponentText instance suffices. // TODO: correct, or should this string be player name? - return new ChatComponentText(""); + return new TextComponentString(""); } // -------------------------------------------------------------------------- /** - * @see net.minecraft.command.ICommandSender#addChatMessage(net.minecraft.util.IChatComponent) + * @see net.minecraft.command.ICommandSender#addChatMessage(net.minecraft.util.text.ITextComponent) */ @Override - public void addChatMessage(IChatComponent chat) + public void addChatMessage(ITextComponent chat) { Chat.localChat(chat); } @@ -111,9 +112,14 @@ public void setCommandStat(CommandResultStats.Type type, int amount) { } - // -------------------------------------------------------------------------- + @Override + public MinecraftServer getServer() { + return null; + } + + // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommandSender#getPlayerCoordinates() + * @see net.minecraft.command.ICommandSender#getPosition() */ @Override public BlockPos getPosition() @@ -124,7 +130,7 @@ public BlockPos getPosition() // -------------------------------------------------------------------------- @Override - public Vec3 getPositionVector() { + public Vec3d getPositionVector() { return Minecraft.getMinecraft().thePlayer.getPositionVector(); } diff --git a/src/watson/cli/HighlightCommand.java b/src/watson/cli/HighlightCommand.java index 384fa7e..b0f13e1 100644 --- a/src/watson/cli/HighlightCommand.java +++ b/src/watson/cli/HighlightCommand.java @@ -2,6 +2,8 @@ import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import watson.Configuration; import watson.chat.Chat; import watson.chat.ChatHighlighter; @@ -13,7 +15,7 @@ public class HighlightCommand extends WatsonCommandBase { // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommand#getCommandName() + * @see net.minecraft.command.ICommand#getCommandName() */ @Override public String getCommandName() @@ -23,12 +25,17 @@ public String getCommandName() // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommand#processCommand(net.minecraft.src.ICommandSender, + * @see net.minecraft.command.ICommand#execute(net.minecraft.server.MinecraftServer, + * net.minecraft.command.ICommandSender, * java.lang.String[]) */ @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException + public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + if (!Configuration.instance.useChatHighlights()) { + localOutput(sender, "Chat highlights are currently disabled. Set chat_highlights to true in the configuration to enabled them. (May be broken currently :/)"); + return; + } ChatHighlighter highlighter = Chat.getChatHighlighter(); if (args.length == 0) { @@ -37,12 +44,12 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE } else if (args.length == 1) { - if (args[0].equals("help")) + if (args[0].equalsIgnoreCase("help")) { help(sender); return; } - else if (args[0].equals("list")) + else if (args[0].equalsIgnoreCase("list")) { highlighter.listHighlights(); return; @@ -50,7 +57,7 @@ else if (args[0].equals("list")) } else if (args.length == 2) { - if (args[0].equals("remove")) + if (args[0].equalsIgnoreCase("remove")) { int index = parseInt(args[1], 1); highlighter.removeHighlight(index); @@ -59,7 +66,7 @@ else if (args.length == 2) } else if (args.length >= 3) { - if (args[0].equals("add") || args[0].equals("select")) + if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("select")) { // Allow patterns to contain spaces, rather than requiring \s. StringBuilder pattern = new StringBuilder(); @@ -72,7 +79,7 @@ else if (args.length >= 3) } } highlighter.addHighlight(args[1], pattern.toString(), - args[0].equals("select")); + args[0].equalsIgnoreCase("select")); return; } } diff --git a/src/watson/cli/WatsonCommand.java b/src/watson/cli/WatsonCommand.java index 642076e..2833739 100644 --- a/src/watson/cli/WatsonCommand.java +++ b/src/watson/cli/WatsonCommand.java @@ -5,12 +5,13 @@ import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; -import net.minecraft.event.ClickEvent; -import net.minecraft.event.ClickEvent.Action; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraft.util.text.event.ClickEvent.Action; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; import watson.Configuration; import watson.Controller; import watson.DisplaySettings; @@ -26,7 +27,7 @@ public class WatsonCommand extends WatsonCommandBase { // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommand#getCommandName() + * @see net.minecraft.command.ICommand#getCommandName() */ @Override public String getCommandName() @@ -36,11 +37,12 @@ public String getCommandName() // -------------------------------------------------------------------------- /** - * @see net.minecraft.src.ICommand#processCommand(net.minecraft.src.ICommandSender, + * @see net.minecraft.command.ICommand#execute(net.minecraft.server.MinecraftServer, + * net.minecraft.command.ICommandSender, * java.lang.String[]) */ @Override - public void processCommand(ICommandSender sender, String[] args) + public void execute(MinecraftServer server, ICommandSender sender, String[] args) { DisplaySettings display = Controller.instance.getDisplaySettings(); if (args.length == 0) @@ -50,22 +52,22 @@ public void processCommand(ICommandSender sender, String[] args) } else if (args.length == 1) { - if (args[0].equals("help")) + if (args[0].equalsIgnoreCase("help")) { help(sender); return; } - else if (args[0].equals("clear")) + else if (args[0].equalsIgnoreCase("clear")) { Controller.instance.clearBlockEditSet(); return; } - else if (args[0].equals("ratio")) + else if (args[0].equalsIgnoreCase("ratio")) { Controller.instance.getBlockEditSet().getOreDB().showRatios(); return; } - else if (args[0].equals("servertime")) + else if (args[0].equalsIgnoreCase("servertime")) { ServerTime.instance.queryServerTime(true); return; @@ -73,7 +75,7 @@ else if (args[0].equals("servertime")) } // "/w ore []" - if (args.length >= 1 && args[0].equals("ore")) + if (args.length >= 1 && args[0].equalsIgnoreCase("ore")) { if (args.length == 1) { @@ -105,7 +107,7 @@ else if (args.length == 2) } // "/w ore" // "/w pre []" - if (args.length >= 1 && args[0].equals("pre")) + if (args.length >= 1 && args[0].equalsIgnoreCase("pre")) { if (args.length == 1) { @@ -138,7 +140,7 @@ else if (args.length == 2) } // "/w post []" - if (args.length >= 1 && args[0].equals("post")) + if (args.length >= 1 && args[0].equalsIgnoreCase("post")) { if (args.length == 1) { @@ -171,7 +173,7 @@ else if (args.length == 2) } // "display" command. - if (args.length >= 1 && args[0].equals("display")) + if (args.length >= 1 && args[0].equalsIgnoreCase("display")) { if (args.length == 1) { @@ -181,12 +183,12 @@ else if (args.length == 2) } else if (args.length == 2) { - if (args[1].equals("on")) + if (args[1].equalsIgnoreCase("on")) { display.setDisplayed(true); return; } - else if (args[1].equals("off")) + else if (args[1].equalsIgnoreCase("off")) { display.setDisplayed(false); return; @@ -195,7 +197,7 @@ else if (args[1].equals("off")) } // display // "outline" command. - if (args.length >= 1 && args[0].equals("outline")) + if (args.length >= 1 && args[0].equalsIgnoreCase("outline")) { if (args.length == 1) { @@ -205,12 +207,12 @@ else if (args[1].equals("off")) } else if (args.length == 2) { - if (args[1].equals("on")) + if (args[1].equalsIgnoreCase("on")) { display.setOutlineShown(true); return; } - else if (args[1].equals("off")) + else if (args[1].equalsIgnoreCase("off")) { display.setOutlineShown(false); return; @@ -219,7 +221,7 @@ else if (args[1].equals("off")) } // outline // "/w anno" command. - if (args.length >= 1 && args[0].equals("anno")) + if (args.length >= 1 && args[0].equalsIgnoreCase("anno")) { if (args.length == 1) { @@ -229,12 +231,12 @@ else if (args[1].equals("off")) } else if (args.length == 2) { - if (args[1].equals("on")) + if (args[1].equalsIgnoreCase("on")) { display.setAnnotationsShown(true); return; } - else if (args[1].equals("off")) + else if (args[1].equalsIgnoreCase("off")) { display.setAnnotationsShown(false); return; @@ -243,7 +245,7 @@ else if (args[1].equals("off")) } // anno // "vector" command. - if (args.length >= 1 && args[0].equals("vector")) + if (args.length >= 1 && args[0].equalsIgnoreCase("vector")) { if (handleVectorCommand(sender, args)) { @@ -252,7 +254,7 @@ else if (args[1].equals("off")) } // "/w label" command. - if (args.length >= 1 && args[0].equals("label")) + if (args.length >= 1 && args[0].equalsIgnoreCase("label")) { if (args.length == 1) { @@ -262,12 +264,12 @@ else if (args[1].equals("off")) } else if (args.length == 2) { - if (args[1].equals("on")) + if (args[1].equalsIgnoreCase("on")) { display.setLabelsShown(true); return; } - else if (args[1].equals("off")) + else if (args[1].equalsIgnoreCase("off")) { display.setLabelsShown(false); return; @@ -276,7 +278,7 @@ else if (args[1].equals("off")) } // "/w label" // Ore teleport commands: /w tp [next|prev|] - if (args.length >= 1 && args[0].equals("tp")) + if (args.length >= 1 && args[0].equalsIgnoreCase("tp")) { OreDB oreDB = Controller.instance.getBlockEditSet().getOreDB(); if (args.length == 1) @@ -286,12 +288,12 @@ else if (args[1].equals("off")) } else if (args.length == 2) { - if (args[1].equals("next")) + if (args[1].equalsIgnoreCase("next")) { oreDB.tpNext(); return; } - else if (args[1].equals("prev")) + else if (args[1].equalsIgnoreCase("prev")) { oreDB.tpPrev(); return; @@ -312,25 +314,25 @@ else if (args[1].equals("prev")) } // /w tp // "/w edits" command. - if (args[0].equals("edits")) + if (args[0].equalsIgnoreCase("edits")) { - if (args.length == 1 || (args.length == 2 && args[1].equals("list"))) + if (args.length == 1 || (args.length == 2 && args[1].equalsIgnoreCase("list"))) { Controller.instance.getBlockEditSet().listEdits(); return; } else if (args.length >= 3) { - if (args[1].equals("hide") || args[1].equals("show")) + if (args[1].equalsIgnoreCase("hide") || args[1].equalsIgnoreCase("show")) { for (int i = 2; i < args.length; ++i) { Controller.instance.getBlockEditSet().setEditVisibility(args[i], - args[1].equals("show")); + args[1].equalsIgnoreCase("show")); } return; } - else if (args[1].equals("remove")) + else if (args[1].equalsIgnoreCase("remove")) { for (int i = 2; i < args.length; ++i) { @@ -342,22 +344,22 @@ else if (args[1].equals("remove")) } // "/w edits" // "/w filter" command. - if (args[0].equals("filter")) + if (args[0].equalsIgnoreCase("filter")) { Filters filters = Controller.instance.getFilters(); - if (args.length == 1 || (args.length == 2 && args[1].equals("list"))) + if (args.length == 1 || (args.length == 2 && args[1].equalsIgnoreCase("list"))) { filters.list(); return; } - else if (args.length == 2 && args[1].equals("clear")) + else if (args.length == 2 && args[1].equalsIgnoreCase("clear")) { filters.clear(); return; } else if (args.length >= 3) { - if (args[1].equals("add")) + if (args[1].equalsIgnoreCase("add")) { for (int i = 2; i < args.length; ++i) { @@ -365,7 +367,7 @@ else if (args.length >= 3) } return; } - else if (args[1].equals("remove")) + else if (args[1].equalsIgnoreCase("remove")) { for (int i = 2; i < args.length; ++i) { @@ -377,9 +379,9 @@ else if (args[1].equals("remove")) } // "/w filter" // File commands. - if (args.length >= 2 && args[0].equals("file")) + if (args.length >= 2 && args[0].equalsIgnoreCase("file")) { - if (args[1].equals("list")) + if (args[1].equalsIgnoreCase("list")) { if (args.length == 2) { @@ -414,23 +416,23 @@ else if (args.length == 4) return; } } - else if (args[1].equals("delete") && args.length == 3) + else if (args[1].equalsIgnoreCase("delete") && args.length == 3) { Controller.instance.deleteBlockEditFiles(args[2]); return; } - else if (args[1].equals("expire") && args.length == 3) + else if (args[1].equalsIgnoreCase("expire") && args.length == 3) { Controller.instance.expireBlockEditFiles(args[2]); return; } - else if (args[1].equals("load") && args.length == 3) + else if (args[1].equalsIgnoreCase("load") && args.length == 3) { // args[2] is either a full file name or a player name. Controller.instance.loadBlockEditFile(args[2]); return; } - else if (args[1].equals("save")) + else if (args[1].equalsIgnoreCase("save")) { if (args.length == 2) { @@ -446,7 +448,7 @@ else if (args.length == 3) } // file // "/w config" command with parameters. - if (args.length >= 2 && args[0].equals("config")) + if (args.length >= 2 && args[0].equalsIgnoreCase("config")) { if (handleConfigCommand(sender, args)) { @@ -455,7 +457,7 @@ else if (args.length == 3) } // config with parameters // "/w config" with no parameters, direct to /w config help - if (args.length == 1 && args[0].equals("config")) + if (args.length == 1 && args[0].equalsIgnoreCase("config")) { String w = Configuration.instance.getWatsonPrefix(); localOutput(sender, "Type \"/" + w + " config help\" for help with configuration options."); @@ -482,22 +484,22 @@ protected boolean handleVectorCommand(@SuppressWarnings("unused") ICommandSender } else if (args.length == 2) { - if (args[1].equals("on")) + if (args[1].equalsIgnoreCase("on")) { display.setVectorsShown(true); return true; } - else if (args[1].equals("off")) + else if (args[1].equalsIgnoreCase("off")) { display.setVectorsShown(false); return true; } - else if (args[1].equals("creations")) + else if (args[1].equalsIgnoreCase("creations")) { display.setLinkedCreations(!display.isLinkedCreations()); return true; } - else if (args[1].equals("destructions")) + else if (args[1].equalsIgnoreCase("destructions")) { display.setLinkedDestructions(!display.isLinkedDestructions()); return true; @@ -505,33 +507,33 @@ else if (args[1].equals("destructions")) } else if (args.length == 3) { - if (args[1].equals("creations")) + if (args[1].equalsIgnoreCase("creations")) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { display.setLinkedCreations(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { display.setLinkedCreations(false); return true; } } - else if (args[1].equals("destructions")) + else if (args[1].equalsIgnoreCase("destructions")) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { display.setLinkedDestructions(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { display.setLinkedDestructions(false); return true; } } - else if (args[1].equals("length")) + else if (args[1].equalsIgnoreCase("length")) { display.setMinVectorLength(Float.parseFloat(args[2]), true); return true; @@ -549,7 +551,7 @@ else if (args[1].equals("length")) protected boolean handleConfigCommand(ICommandSender sender, String[] args) { // Enable or disable the mod as a whole. - if (args[1].equals("watson")) + if (args[1].equalsIgnoreCase("watson")) { if (args.length == 2) { @@ -558,12 +560,12 @@ protected boolean handleConfigCommand(ICommandSender sender, String[] args) } else if (args.length == 3) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { Configuration.instance.setEnabled(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { Configuration.instance.setEnabled(false); return true; @@ -572,7 +574,7 @@ else if (args[2].equals("off")) } // /w config watson // Enable or disable debug logging. - if (args[1].equals("debug")) + if (args[1].equalsIgnoreCase("debug")) { if (args.length == 2) { @@ -581,12 +583,12 @@ else if (args[2].equals("off")) } else if (args.length == 3) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { Configuration.instance.setDebug(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { Configuration.instance.setDebug(false); return true; @@ -595,7 +597,7 @@ else if (args[2].equals("off")) } // /w config debug // Enable or disable automatic "/lb coords" paging. - if (args[1].equals("auto_page")) + if (args[1].equalsIgnoreCase("auto_page")) { if (args.length == 2) { @@ -604,12 +606,12 @@ else if (args[2].equals("off")) } else if (args.length == 3) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { Configuration.instance.setAutoPage(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { Configuration.instance.setAutoPage(false); return true; @@ -618,7 +620,7 @@ else if (args[2].equals("off")) } // /w config auto_page // Set minimum time separation between automatic "/region info"s. - if (args[1].equals("region_info_timeout")) + if (args[1].equalsIgnoreCase("region_info_timeout")) { if (args.length == 3) { @@ -643,7 +645,7 @@ else if (args.length == 2) } // /w config region_info_timeout // Set the text billboard background colour. - if (args[1].equals("billboard_background")) + if (args[1].equalsIgnoreCase("billboard_background")) { if (args.length == 3) { @@ -664,13 +666,13 @@ else if (args.length == 2) else if (args.length == 2) { int argb = Configuration.instance.getBillboardBackground(); - localOutput(sender, "Billboard background colour is currently set to #" + Integer.toUnsignedString(argb, 16) + "."); + localOutput(sender, "Billboard background colour is currently set to #" + Integer.valueOf(String.valueOf(argb), 16) + "."); return true; } } // /w config billboard_background // Set the text billboard foreground colour. - if (args[1].equals("billboard_foreground")) + if (args[1].equalsIgnoreCase("billboard_foreground")) { if (args.length == 3) { @@ -691,13 +693,13 @@ else if (args.length == 2) else if (args.length == 2) { int argb = Configuration.instance.getBillboardForeground(); - localOutput(sender, "Billboard foreground colour is currently set to #" + Integer.toUnsignedString(argb, 16) + "."); + localOutput(sender, "Billboard foreground colour is currently set to #" + Integer.valueOf(String.valueOf(argb), 16) + "."); return true; } } // /w config billboard_foreground // Enable or disable forced grouping of ores in creative mode. - if (args[1].equals("group_ores_in_creative")) + if (args[1].equalsIgnoreCase("group_ores_in_creative")) { if (args.length == 2) { @@ -706,12 +708,12 @@ else if (args.length == 2) } else if (args.length == 3) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { Configuration.instance.setGroupingOresInCreative(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { Configuration.instance.setGroupingOresInCreative(false); return true; @@ -719,7 +721,7 @@ else if (args[2].equals("off")) } } // /w config group_ores_in_creative - if (args[1].equals("teleport_command")) + if (args[1].equalsIgnoreCase("teleport_command")) { if (args.length >= 3) { @@ -737,7 +739,7 @@ else if (args.length == 2) // Set minimum time separation between programmatically generated chat // messages sent to the server - if (args[1].equals("chat_timeout")) + if (args[1].equalsIgnoreCase("chat_timeout")) { if (args.length == 3) { @@ -763,7 +765,7 @@ else if (args.length == 2) // Set the maximum number of pages of "/lb coords" results automatically // paged through. - if (args[1].equals("max_auto_pages")) + if (args[1].equalsIgnoreCase("max_auto_pages")) { if (args.length == 3) { @@ -799,7 +801,7 @@ else if (args.length == 2) // Set the default number of edits to query when no count parameter is // specified with "/w pre". - if (args[1].equals("pre_count")) + if (args[1].equalsIgnoreCase("pre_count")) { if (args.length == 3) { @@ -834,7 +836,7 @@ else if (args.length == 2) // Set the default number of edits to query when no count parameter is // specified with "/w post". - if (args[1].equals("post_count")) + if (args[1].equalsIgnoreCase("post_count")) { if (args.length == 3) { @@ -868,7 +870,7 @@ else if (args.length == 2) } // /w config post_count // Set the prefix for Watson commands. - if (args[1].equals("watson_prefix")) + if (args[1].equalsIgnoreCase("watson_prefix")) if (args.length == 3) { String newPrefix = args[2]; @@ -894,7 +896,7 @@ else if (args.length == 2) } // /w config watson_prefix // Enable or disable per-player screenshot subdirectories. - if (args[1].equals("ss_player_directory")) + if (args[1].equalsIgnoreCase("ss_player_directory")) { if (args.length == 2) { @@ -903,12 +905,12 @@ else if (args.length == 2) } else if (args.length == 3) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { Configuration.instance.setSsPlayerDirectory(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { Configuration.instance.setSsPlayerDirectory(false); return true; @@ -917,7 +919,7 @@ else if (args[2].equals("off")) } // /w config ss_player_directory // Enable or disable per-player screenshot suffixes. - if (args[1].equals("ss_player_suffix")) + if (args[1].equalsIgnoreCase("ss_player_suffix")) { if (args.length == 2) { @@ -926,12 +928,12 @@ else if (args[2].equals("off")) } else if (args.length == 3) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { Configuration.instance.setSsPlayerSuffix(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { Configuration.instance.setSsPlayerSuffix(false); return true; @@ -940,7 +942,7 @@ else if (args[2].equals("off")) } // /w config ss_player_directory // Set the anonymous screenshot subdirectory format specifier. - if (args[1].equals("ss_date_directory")) + if (args[1].equalsIgnoreCase("ss_date_directory")) { if (args.length == 2) { @@ -956,7 +958,7 @@ else if (args.length >= 3) } // /w config ss_date_directory // Enable or disable the reformatting of query results. - if (args[1].equals("reformat_query_results")) + if (args[1].equalsIgnoreCase("reformat_query_results")) { if (args.length == 2) { @@ -965,12 +967,12 @@ else if (args.length >= 3) } else if (args.length == 3) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { Configuration.instance.setReformatQueryResults(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { Configuration.instance.setReformatQueryResults(false); return true; @@ -979,7 +981,7 @@ else if (args[2].equals("off")) } // /w config reformat_query_results // Enable or disable the recolouring of query results. - if (args[1].equals("recolour_query_results")) + if (args[1].equalsIgnoreCase("recolour_query_results")) { if (args.length == 2) { @@ -988,12 +990,12 @@ else if (args[2].equals("off")) } else if (args.length == 3) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { Configuration.instance.setRecolourQueryResults(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { Configuration.instance.setRecolourQueryResults(false); return true; @@ -1002,7 +1004,7 @@ else if (args[2].equals("off")) } // /w config recolour_query_results // Enable timestamp-only ordering of ore deposits. - if (args[1].equals("time_ordered_deposits")) + if (args[1].equalsIgnoreCase("time_ordered_deposits")) { if (args.length == 2) { @@ -1011,12 +1013,12 @@ else if (args[2].equals("off")) } else if (args.length == 3) { - if (args[2].equals("on")) + if (args[2].equalsIgnoreCase("on")) { Configuration.instance.setTimeOrderedDeposits(true); return true; } - else if (args[2].equals("off")) + else if (args[2].equalsIgnoreCase("off")) { Configuration.instance.setTimeOrderedDeposits(false); return true; @@ -1025,7 +1027,7 @@ else if (args[2].equals("off")) } // /w config time_ordered_deposits // Minimum vector length (initial value for /w vector length ). - if (args[1].equals("vector_length")) + if (args[1].equalsIgnoreCase("vector_length")) { if (args.length == 2) { @@ -1048,8 +1050,31 @@ else if (args.length == 3) } } // /w config vector_length + // Enable or disable the highlighting of words/phrases in chat. + if (args[1].equalsIgnoreCase("chat_highlights")) + { + if (args.length == 2) + { + Configuration.instance.useChatHighlights(!Configuration.instance.useChatHighlights()); + return true; + } + else if (args.length == 3) + { + if (args[2].equalsIgnoreCase("on")) + { + Configuration.instance.useChatHighlights(true); + return true; + } + else if (args[2].equalsIgnoreCase("off")) + { + Configuration.instance.useChatHighlights(false); + return true; + } + } + } // /w config chat_highlights + // Help with /w config - if (args[1].equals("help")) + if (args[1].equalsIgnoreCase("help")) { String w = Configuration.instance.getWatsonPrefix(); localOutput(sender, @@ -1105,6 +1130,8 @@ else if (args.length == 3) " /" + w + " config vector_length [decimal]: set the default minimum length of a vector for it to be visible"); + localOutput(sender, " /" + w + + " config chat_highlights [on/off] : enable or disable chat highlight functionality"); return true; } // /w config help @@ -1144,19 +1171,19 @@ public void help(ICommandSender sender) localOutput(sender, " /" + w + " file load |"); localOutput(sender, " /" + w + " file save []"); localOutput(sender, " /" + w + " config []"); - localOutput(sender, " /hl help"); + localOutput(sender, " /hl help" + (Configuration.instance.useChatHighlights() ? "" : " (Disabled!)")); localOutput(sender, " /anno help"); // Make the documentation link clickable. - IChatComponent docs = new ChatComponentText("Documentation: "); - ChatStyle style = new ChatStyle().setColor(EnumChatFormatting.AQUA); - docs.setChatStyle(style); + ITextComponent docs = new TextComponentString("Documentation: "); + Style style = new Style().setColor(TextFormatting.AQUA); + docs.setStyle(style); String url = "http://github.com/totemo/watson"; - IChatComponent link = new ChatComponentText(url); - ChatStyle linkStyle = new ChatStyle(); + ITextComponent link = new TextComponentString(url); + Style linkStyle = new Style(); linkStyle.setUnderlined(true); - link.setChatStyle(linkStyle); - linkStyle.setChatClickEvent(new ClickEvent(Action.OPEN_URL, url)); + link.setStyle(linkStyle); + linkStyle.setClickEvent(new ClickEvent(Action.OPEN_URL, url)); docs.appendSibling(link); sender.addChatMessage(docs); diff --git a/src/watson/cli/WatsonCommandBase.java b/src/watson/cli/WatsonCommandBase.java index caa30d9..6f4d2ae 100644 --- a/src/watson/cli/WatsonCommandBase.java +++ b/src/watson/cli/WatsonCommandBase.java @@ -2,9 +2,9 @@ import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; // ---------------------------------------------------------------------------- /** @@ -48,7 +48,7 @@ public boolean canCommandSenderUseCommand(ICommandSender sender) */ public void localOutput(ICommandSender sender, String message) { - sendColouredText(sender, EnumChatFormatting.AQUA, message); + sendColouredText(sender, TextFormatting.AQUA, message); } // -------------------------------------------------------------------------- @@ -59,7 +59,7 @@ public void localOutput(ICommandSender sender, String message) */ public void localError(ICommandSender sender, String message) { - sendColouredText(sender, EnumChatFormatting.DARK_RED, message); + sendColouredText(sender, TextFormatting.DARK_RED, message); } // -------------------------------------------------------------------------- @@ -70,12 +70,12 @@ public void localError(ICommandSender sender, String message) * @param colour the colour. * @param message the text. */ - public void sendColouredText(ICommandSender sender, EnumChatFormatting colour, String message) + public void sendColouredText(ICommandSender sender, TextFormatting colour, String message) { - ChatComponentText chat = new ChatComponentText(message); - ChatStyle style = new ChatStyle(); + TextComponentString chat = new TextComponentString(message); + Style style = new Style(); style.setColor(colour); - chat.setChatStyle(style); + chat.setStyle(style); sender.addChatMessage(chat); } diff --git a/src/watson/db/Annotation.java b/src/watson/db/Annotation.java index 993ce03..81de337 100644 --- a/src/watson/db/Annotation.java +++ b/src/watson/db/Annotation.java @@ -1,16 +1,15 @@ package watson.db; +import com.mumfrey.liteloader.gl.GL; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.entity.RenderManager; -import org.lwjgl.opengl.GL11; - import watson.Configuration; import watson.PrivateFieldsWatson; +import watson.model.ARGB; // ---------------------------------------------------------------------------- /** @@ -135,50 +134,51 @@ public static void drawBillboard(double x, double y, double z, int bgARGB, dl = far; } - GlStateManager.pushMatrix(); + GL.glPushMatrix(); double scale = (0.05 * dl + 1.0) * scaleFactor; - GlStateManager.translate(dx, dy, dz); - GlStateManager.rotate(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f); - GlStateManager.rotate( + GL.glTranslated(dx, dy, dz); + GL.glRotatef(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f); + GL.glRotatef( mc.gameSettings.thirdPersonView != 2 ? renderManager.playerViewX : -renderManager.playerViewX, 1.0f, 0.0f, 0.0f); - GlStateManager.scale(-scale, -scale, scale); - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL.glScaled(-scale, -scale, scale); + GL.glDisableLighting(); + GL.glEnableBlend(); + GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer wr = tessellator.getWorldRenderer(); + VertexBuffer vr = tessellator.getBuffer(); int textWidth = fontRenderer.getStringWidth(text) >> 1; if (textWidth != 0) { - GlStateManager.disableTexture2D(); - GlStateManager.disableDepth(); - GlStateManager.depthMask(false); + GL.glDisableTexture2D(); + GL.glDisableDepthTest();; + GL.glDepthMask(false); // Draw background plate. - wr.startDrawingQuads(); - wr.setColorRGBA_I(bgARGB & 0x00FFFFFF, (bgARGB >>> 24) & 0xFF); - wr.addVertex(-textWidth - 1, -6, 0.0); - wr.addVertex(-textWidth - 1, 4, 0.0); - wr.addVertex(textWidth + 1, 4, 0.0); - wr.addVertex(textWidth + 1, -6, 0.0); + vr.begin(GL.GL_QUADS, GL.VF_POSITION); + ARGB bgColour = new ARGB(bgARGB); + GL.glColor4f(bgColour.getRed() / 255f, bgColour.getGreen() / 255f, bgColour.getBlue() / 255f, bgColour.getAlpha()); + vr.pos(-textWidth - 1, -6, 0.0).endVertex(); + vr.pos(-textWidth - 1, 4, 0.0).endVertex(); + vr.pos(textWidth + 1, 4, 0.0).endVertex(); + vr.pos(textWidth + 1, -6, 0.0).endVertex(); tessellator.draw(); // Draw text. - GlStateManager.enableTexture2D(); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + GL.glEnableTexture2D(); + GL.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); fontRenderer.drawString(text, -textWidth, -5, fgARGB); - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); + GL.glEnableDepthTest(); + GL.glDepthMask(true); } - GlStateManager.disableBlend(); - GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); - GlStateManager.enableTexture2D(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); + GL.glDisableBlend(); + GL.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + GL.glEnableTexture2D(); + GL.glEnableLighting(); + GL.glPopMatrix(); } // drawBillboard // -------------------------------------------------------------------------- diff --git a/src/watson/db/OreDB.java b/src/watson/db/OreDB.java index d3869e3..a62341b 100644 --- a/src/watson/db/OreDB.java +++ b/src/watson/db/OreDB.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.Locale; @@ -558,7 +559,7 @@ protected ArrayList getOreDepositSequence() // Reorder deposits by timestamp if required by the settings. if (config.timeOrderedDeposits()) { - _oreDepositSequence.sort(new Comparator() + Collections.sort(_oreDepositSequence, new Comparator() { @Override public int compare(OreDeposit o1, OreDeposit o2) diff --git a/src/watson/db/PlayerEditSet.java b/src/watson/db/PlayerEditSet.java index e2ba431..8c69513 100644 --- a/src/watson/db/PlayerEditSet.java +++ b/src/watson/db/PlayerEditSet.java @@ -5,10 +5,11 @@ import java.util.Iterator; import java.util.TreeSet; +import com.mumfrey.liteloader.gl.GL; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.util.Vec3; +import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.util.math.Vec3d; import org.lwjgl.opengl.GL11; import watson.Controller; @@ -180,16 +181,16 @@ public synchronized void drawVectors(ARGB colour) if (settings.areVectorsShown() && isVisible() && !_edits.isEmpty()) { final Tessellator tess = Tessellator.getInstance(); - final WorldRenderer wr = tess.getWorldRenderer(); - wr.startDrawing(GL11.GL_LINES); + final VertexBuffer vb = tess.getBuffer(); + vb.begin(GL.GL_LINES, GL.VF_POSITION); // TODO: Make the vector colour and thickness configurable. - wr.setColorRGBA_I(colour.getRGB(), colour.getAlpha()); - GL11.glLineWidth(0.5f); + GL.glColor4f(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f, colour.getAlpha()); + GL.glLineWidth(0.5f); // Unit X and Y vectors used for cross products to get arrow axes. - Vec3 unitX = new Vec3(1, 0, 0); - Vec3 unitY = new Vec3(0, 1, 0); + Vec3d unitX = new Vec3d(1, 0, 0); + Vec3d unitY = new Vec3d(0, 1, 0); // We only need to draw vectors if there are at least 2 edits. Iterator it = _edits.iterator(); @@ -205,10 +206,10 @@ public synchronized void drawVectors(ARGB colour) (!next.creation && settings.isLinkedDestructions()); if (show) { - Vec3 pPos = new Vec3(0.5 + prev.x, 0.5 + prev.y, 0.5 + prev.z); - Vec3 nPos = new Vec3(0.5 + next.x, 0.5 + next.y, 0.5 + next.z); + Vec3d pPos = new Vec3d(0.5 + prev.x, 0.5 + prev.y, 0.5 + prev.z); + Vec3d nPos = new Vec3d(0.5 + next.x, 0.5 + next.y, 0.5 + next.z); // Vector difference, from prev to next. - Vec3 diff = nPos.subtract(pPos); + Vec3d diff = nPos.subtract(pPos); // Compute length. We want to scale the arrow heads by the length, // so can't avoid the sqrt() here. @@ -216,8 +217,8 @@ public synchronized void drawVectors(ARGB colour) if (length >= settings.getMinVectorLength()) { // Draw the vector. - wr.addVertex(pPos.xCoord, pPos.yCoord, pPos.zCoord); - wr.addVertex(nPos.xCoord, nPos.yCoord, nPos.zCoord); + vb.pos(pPos.xCoord, pPos.yCoord, pPos.zCoord).endVertex(); + vb.pos(nPos.xCoord, nPos.yCoord, nPos.zCoord).endVertex(); // Length from arrow tip to midpoint of vector as a fraction of // the total vector length. Scale the arrow in proportion to the @@ -231,17 +232,17 @@ public synchronized void drawVectors(ARGB colour) // Position of the tip and tail of the arrow, sitting in the // middle of the vector. - Vec3 tip = new Vec3(pPos.xCoord * (0.5 - arrowScale) + nPos.xCoord * (0.5 + arrowScale), + Vec3d tip = new Vec3d(pPos.xCoord * (0.5 - arrowScale) + nPos.xCoord * (0.5 + arrowScale), pPos.yCoord * (0.5 - arrowScale) + nPos.yCoord * (0.5 + arrowScale), pPos.zCoord * (0.5 - arrowScale) + nPos.zCoord * (0.5 + arrowScale)); - Vec3 tail = new Vec3(pPos.xCoord * (0.5 + arrowScale) + nPos.xCoord * (0.5 - arrowScale), + Vec3d tail = new Vec3d(pPos.xCoord * (0.5 + arrowScale) + nPos.xCoord * (0.5 - arrowScale), pPos.yCoord * (0.5 + arrowScale) + nPos.yCoord * (0.5 - arrowScale), pPos.zCoord * (0.5 + arrowScale) + nPos.zCoord * (0.5 - arrowScale)); // Fin axes, perpendicular to vector. Scale by vector length. // If the vector is colinear with the Y axis, use the X axis for // the cross products to derive the fin directions. - Vec3 fin1; + Vec3d fin1; if (Math.abs(unitY.dotProduct(diff)) > 0.9 * length) { fin1 = unitX.crossProduct(diff).normalize(); @@ -251,24 +252,24 @@ public synchronized void drawVectors(ARGB colour) fin1 = unitY.crossProduct(diff).normalize(); } - Vec3 fin2 = fin1.crossProduct(diff).normalize(); + Vec3d fin2 = fin1.crossProduct(diff).normalize(); - Vec3 draw1 = new Vec3(fin1.xCoord * arrowScale * length, + Vec3d draw1 = new Vec3d(fin1.xCoord * arrowScale * length, fin1.yCoord * arrowScale * length, fin1.zCoord * arrowScale * length); - Vec3 draw2 = new Vec3(fin2.xCoord * arrowScale * length, + Vec3d draw2 = new Vec3d(fin2.xCoord * arrowScale * length, fin2.yCoord * arrowScale * length, fin2.zCoord * arrowScale * length); // Draw four fins. - wr.addVertex(tip.xCoord, tip.yCoord, tip.zCoord); - wr.addVertex(tail.xCoord + draw1.xCoord, tail.yCoord + draw1.yCoord, tail.zCoord + draw1.zCoord); - wr.addVertex(tip.xCoord, tip.yCoord, tip.zCoord); - wr.addVertex(tail.xCoord - draw1.xCoord, tail.yCoord - draw1.yCoord, tail.zCoord - draw1.zCoord); - wr.addVertex(tip.xCoord, tip.yCoord, tip.zCoord); - wr.addVertex(tail.xCoord + draw2.xCoord, tail.yCoord + draw2.yCoord, tail.zCoord + draw2.zCoord); - wr.addVertex(tip.xCoord, tip.yCoord, tip.zCoord); - wr.addVertex(tail.xCoord - draw2.xCoord, tail.yCoord - draw2.yCoord, tail.zCoord - draw2.zCoord); + vb.pos(tip.xCoord, tip.yCoord, tip.zCoord).endVertex(); + vb.pos(tail.xCoord + draw1.xCoord, tail.yCoord + draw1.yCoord, tail.zCoord + draw1.zCoord).endVertex(); + vb.pos(tip.xCoord, tip.yCoord, tip.zCoord).endVertex(); + vb.pos(tail.xCoord - draw1.xCoord, tail.yCoord - draw1.yCoord, tail.zCoord - draw1.zCoord).endVertex(); + vb.pos(tip.xCoord, tip.yCoord, tip.zCoord).endVertex(); + vb.pos(tail.xCoord + draw2.xCoord, tail.yCoord + draw2.yCoord, tail.zCoord + draw2.zCoord).endVertex(); + vb.pos(tip.xCoord, tip.yCoord, tip.zCoord).endVertex(); + vb.pos(tail.xCoord - draw2.xCoord, tail.yCoord - draw2.yCoord, tail.zCoord - draw2.zCoord).endVertex(); } // if we are drawing this vector prev = next; } // if diff --git a/src/watson/gui/WatsonGuiScreen.java b/src/watson/gui/WatsonGuiScreen.java index bee983d..fa8a2b0 100644 --- a/src/watson/gui/WatsonGuiScreen.java +++ b/src/watson/gui/WatsonGuiScreen.java @@ -46,7 +46,7 @@ public void initGui() GuiResponder sliderResponder = new GuiPageButtonList.GuiResponder() { @Override - public void onTick(int id, float value) + public void setEntryValue(int id, float value) { // Update the display when the slider slides. Save the new length in // the configuration when the GUI closes. @@ -55,12 +55,12 @@ public void onTick(int id, float value) } @Override - public void func_175321_a(int id, boolean value) + public void setEntryValue(int id, boolean value) { } @Override - public void func_175319_a(int id, String value) + public void setEntryValue(int id, String value) { } }; diff --git a/src/watson/model/BlockModel.java b/src/watson/model/BlockModel.java index 556a6c6..bef621a 100644 --- a/src/watson/model/BlockModel.java +++ b/src/watson/model/BlockModel.java @@ -1,9 +1,9 @@ package watson.model; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; -import org.lwjgl.opengl.GL11; +import com.mumfrey.liteloader.gl.GL; import watson.db.BlockType; @@ -90,47 +90,47 @@ protected void renderTaperedBox(double xBot1, double zBot1, double xBot2, double yTop, ARGB colour, float lineWidth) { Tessellator tess = Tessellator.getInstance(); - WorldRenderer wr = tess.getWorldRenderer(); + VertexBuffer vb = tess.getBuffer(); // Bottom face. - wr.startDrawing(GL11.GL_LINE_LOOP); - wr.setColorRGBA(colour.getRed(), colour.getGreen(), colour.getBlue(), - colour.getAlpha()); - GL11.glLineWidth(lineWidth); - wr.addVertex(xBot1, yBot, zBot1); - wr.addVertex(xBot2, yBot, zBot1); - wr.addVertex(xBot2, yBot, zBot2); - wr.addVertex(xBot1, yBot, zBot2); + vb.begin(GL.GL_LINE_LOOP, GL.VF_POSITION); + GL.glColor4f(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f, colour.getAlpha()); + //vb.color(colour.getAlpha(), colour.getRed(), colour.getGreen(), colour.getBlue()); + GL.glLineWidth(lineWidth); + vb.pos(xBot1, yBot, zBot1).endVertex(); + vb.pos(xBot2, yBot, zBot1).endVertex(); + vb.pos(xBot2, yBot, zBot2).endVertex(); + vb.pos(xBot1, yBot, zBot2).endVertex(); tess.draw(); // Top face. - wr.startDrawing(GL11.GL_LINE_LOOP); - wr.setColorRGBA(colour.getRed(), colour.getGreen(), colour.getBlue(), - colour.getAlpha()); - GL11.glLineWidth(lineWidth); - wr.addVertex(xTop1, yTop, zTop1); - wr.addVertex(xTop2, yTop, zTop1); - wr.addVertex(xTop2, yTop, zTop2); - wr.addVertex(xTop1, yTop, zTop2); + vb.begin(GL.GL_LINE_LOOP, GL.VF_POSITION); + GL.glColor4f(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f, colour.getAlpha()); + //vb.color(colour.getAlpha(), colour.getRed(), colour.getGreen(), colour.getBlue()); + GL.glLineWidth(lineWidth); + vb.pos(xTop1, yTop, zTop1).endVertex(); + vb.pos(xTop2, yTop, zTop1).endVertex(); + vb.pos(xTop2, yTop, zTop2).endVertex(); + vb.pos(xTop1, yTop, zTop2).endVertex(); tess.draw(); // Vertical lines joining top and bottom. - wr.startDrawing(GL11.GL_LINES); - wr.setColorRGBA(colour.getRed(), colour.getGreen(), colour.getBlue(), - colour.getAlpha()); - GL11.glLineWidth(lineWidth); + vb.begin(GL.GL_LINES, GL.VF_POSITION); + GL.glColor4f(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f, colour.getAlpha()); + //vb.color(colour.getAlpha(), colour.getRed(), colour.getGreen(), colour.getBlue()); + GL.glLineWidth(lineWidth); - wr.addVertex(xBot1, yBot, zBot1); - wr.addVertex(xTop1, yTop, zTop1); + vb.pos(xBot1, yBot, zBot1).endVertex(); + vb.pos(xTop1, yTop, zTop1).endVertex(); - wr.addVertex(xBot2, yBot, zBot1); - wr.addVertex(xTop2, yTop, zTop1); + vb.pos(xBot2, yBot, zBot1).endVertex(); + vb.pos(xTop2, yTop, zTop1).endVertex(); - wr.addVertex(xBot1, yBot, zBot2); - wr.addVertex(xTop1, yTop, zTop2); + vb.pos(xBot1, yBot, zBot2).endVertex(); + vb.pos(xTop1, yTop, zTop2).endVertex(); - wr.addVertex(xBot2, yBot, zBot2); - wr.addVertex(xTop2, yTop, zTop2); + vb.pos(xBot2, yBot, zBot2).endVertex(); + vb.pos(xTop2, yTop, zTop2).endVertex(); tess.draw(); } // renderTaperedBox diff --git a/src/watson/model/PlantBlockModel.java b/src/watson/model/PlantBlockModel.java index 4e79350..a2cd8d9 100644 --- a/src/watson/model/PlantBlockModel.java +++ b/src/watson/model/PlantBlockModel.java @@ -1,10 +1,8 @@ package watson.model; -import net.minecraft.client.renderer.GlStateManager; +import com.mumfrey.liteloader.gl.GL; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; - -import org.lwjgl.opengl.GL11; +import net.minecraft.client.renderer.VertexBuffer; import watson.db.BlockType; @@ -35,7 +33,7 @@ public PlantBlockModel() public void render(BlockType blockType, int x, int y, int z) { Tessellator tess = Tessellator.getInstance(); - WorldRenderer wr = tess.getWorldRenderer(); + VertexBuffer vb = tess.getBuffer(); double x1 = x + blockType.getX1(); double y1 = y + blockType.getY1(); @@ -45,27 +43,27 @@ public void render(BlockType blockType, int x, int y, int z) double z2 = z + blockType.getZ2(); // First rectangle. - wr.startDrawing(GL11.GL_LINE_LOOP); - wr.setColorRGBA(blockType.getARGB().getRed(), - blockType.getARGB().getGreen(), blockType.getARGB().getBlue(), - blockType.getARGB().getAlpha()); - GL11.glLineWidth(blockType.getLineWidth()); - wr.addVertex(x1, y1, z1); - wr.addVertex(x2, y1, z2); - wr.addVertex(x2, y2, z2); - wr.addVertex(x1, y2, z1); + vb.begin(GL.GL_LINE_LOOP, GL.VF_POSITION); + GL.glColor4f(blockType.getARGB().getRed() / 255f, + blockType.getARGB().getGreen() / 255f, blockType.getARGB().getBlue() / 255f, + blockType.getARGB().getAlpha()); + GL.glLineWidth(blockType.getLineWidth()); + vb.pos(x1, y1, z1).endVertex(); + vb.pos(x2, y1, z2).endVertex(); + vb.pos(x2, y2, z2).endVertex(); + vb.pos(x1, y2, z1).endVertex(); tess.draw(); // Second rectangle. - wr.startDrawing(GL11.GL_LINE_LOOP); - wr.setColorRGBA(blockType.getARGB().getRed(), - blockType.getARGB().getGreen(), blockType.getARGB().getBlue(), - blockType.getARGB().getAlpha()); - GL11.glLineWidth(blockType.getLineWidth()); - wr.addVertex(x1, y1, z2); - wr.addVertex(x2, y1, z1); - wr.addVertex(x2, y2, z1); - wr.addVertex(x1, y2, z2); + vb.begin(GL.GL_LINE_LOOP, GL.VF_POSITION); + GL.glColor4f(blockType.getARGB().getRed() / 255f, + blockType.getARGB().getGreen() / 255f, blockType.getARGB().getBlue() / 255f, + blockType.getARGB().getAlpha()); + GL.glLineWidth(blockType.getLineWidth()); + vb.pos(x1, y1, z2).endVertex(); + vb.pos(x2, y1, z1).endVertex(); + vb.pos(x2, y2, z1).endVertex(); + vb.pos(x1, y2, z2).endVertex(); tess.draw(); } // render } // class PlantBlockModel diff --git a/src/watson/model/StairBlockModel.java b/src/watson/model/StairBlockModel.java index b8234a2..2e63d40 100644 --- a/src/watson/model/StairBlockModel.java +++ b/src/watson/model/StairBlockModel.java @@ -1,8 +1,9 @@ package watson.model; +import com.mumfrey.liteloader.gl.GL; 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.db.BlockType; @@ -30,7 +31,7 @@ public StairBlockModel() public void render(BlockType blockType, int x, int y, int z) { Tessellator tess = Tessellator.getInstance(); - WorldRenderer wr = tess.getWorldRenderer(); + VertexBuffer vb = tess.getBuffer(); // Opposite corners. double x1 = x + blockType.getX1(); @@ -45,57 +46,51 @@ public void render(BlockType blockType, int x, int y, int z) double zMid = z + 0.5 * (blockType.getZ1() + blockType.getZ2()); // x1 side. - wr.startDrawing(GL11.GL_LINE_LOOP); - wr.setColorRGBA(blockType.getARGB().getRed(), - blockType.getARGB().getGreen(), blockType.getARGB().getBlue(), - blockType.getARGB().getAlpha()); - GL11.glLineWidth(blockType.getLineWidth()); - wr.addVertex(x1, y1, z1); - wr.addVertex(x1, y1, z2); - wr.addVertex(x1, y2, z2); - wr.addVertex(x1, y2, zMid); - wr.addVertex(x1, yMid, zMid); - wr.addVertex(x1, yMid, z1); + vb.begin(GL.GL_LINE_LOOP, GL.VF_POSITION); + GL.glColor4f(blockType.getARGB().getRed() / 255f, blockType.getARGB().getGreen() / 255f, blockType.getARGB().getBlue() / 255f, blockType.getARGB().getAlpha()); + GL.glLineWidth(blockType.getLineWidth()); + vb.pos(x1, y1, z1).endVertex(); + vb.pos(x1, y1, z2).endVertex(); + vb.pos(x1, y2, z2).endVertex(); + vb.pos(x1, y2, zMid).endVertex(); + vb.pos(x1, yMid, zMid).endVertex(); + vb.pos(x1, yMid, z1).endVertex(); tess.draw(); // x2 side. - wr.startDrawing(GL11.GL_LINE_LOOP); - wr.setColorRGBA(blockType.getARGB().getRed(), - blockType.getARGB().getGreen(), blockType.getARGB().getBlue(), - blockType.getARGB().getAlpha()); - GL11.glLineWidth(blockType.getLineWidth()); - wr.addVertex(x2, y1, z1); - wr.addVertex(x2, y1, z2); - wr.addVertex(x2, y2, z2); - wr.addVertex(x2, y2, zMid); - wr.addVertex(x2, yMid, zMid); - wr.addVertex(x2, yMid, z1); + vb.begin(GL.GL_LINE_LOOP, GL.VF_POSITION); + GL.glColor4f(blockType.getARGB().getRed() / 255f, blockType.getARGB().getGreen() / 255f, blockType.getARGB().getBlue() / 255f, blockType.getARGB().getAlpha()); + GL.glLineWidth(blockType.getLineWidth()); + vb.pos(x2, y1, z1).endVertex(); + vb.pos(x2, y1, z2).endVertex(); + vb.pos(x2, y2, z2).endVertex(); + vb.pos(x2, y2, zMid).endVertex(); + vb.pos(x2, yMid, zMid).endVertex(); + vb.pos(x2, yMid, z1).endVertex(); tess.draw(); // Horizontal lines joining the two sides. - wr.startDrawing(GL11.GL_LINES); - wr.setColorRGBA(blockType.getARGB().getRed(), - blockType.getARGB().getGreen(), blockType.getARGB().getBlue(), - blockType.getARGB().getAlpha()); - GL11.glLineWidth(blockType.getLineWidth()); + vb.begin(GL.GL_LINES, GL.VF_POSITION); + GL.glColor4f(blockType.getARGB().getRed() / 255f, blockType.getARGB().getGreen() / 255f, blockType.getARGB().getBlue() / 255f, blockType.getARGB().getAlpha()); + GL.glLineWidth(blockType.getLineWidth()); - wr.addVertex(x1, y1, z1); - wr.addVertex(x2, y1, z1); + vb.pos(x1, y1, z1).endVertex(); + vb.pos(x2, y1, z1).endVertex(); - wr.addVertex(x1, y1, z2); - wr.addVertex(x2, y1, z2); + vb.pos(x1, y1, z2).endVertex(); + vb.pos(x2, y1, z2).endVertex(); - wr.addVertex(x1, y2, z2); - wr.addVertex(x2, y2, z2); + vb.pos(x1, y2, z2).endVertex(); + vb.pos(x2, y2, z2).endVertex(); - wr.addVertex(x1, y2, zMid); - wr.addVertex(x2, y2, zMid); + vb.pos(x1, y2, zMid).endVertex(); + vb.pos(x2, y2, zMid).endVertex(); - wr.addVertex(x1, yMid, zMid); - wr.addVertex(x2, yMid, zMid); + vb.pos(x1, yMid, zMid).endVertex(); + vb.pos(x2, yMid, zMid).endVertex(); - wr.addVertex(x1, yMid, z1); - wr.addVertex(x2, yMid, z1); + vb.pos(x1, yMid, z1).endVertex(); + vb.pos(x2, yMid, z1).endVertex(); tess.draw(); } // render } // class StairBlockModel \ No newline at end of file