Skip to content

Commit

Permalink
Made minebot 1.7.10 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Zangl committed Aug 9, 2014
1 parent fbedc2f commit e65b39a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
38 changes: 27 additions & 11 deletions Minebot/src/net/famzangl/minecraft/minebot/ai/AIController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.famzangl.minecraft.minebot.ai;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.Map.Entry;
Expand All @@ -13,6 +15,7 @@
import net.famzangl.minecraft.minebot.ai.strategy.MineStrategy;
import net.famzangl.minecraft.minebot.ai.strategy.PlantStrategy;
import net.famzangl.minecraft.minebot.ai.task.AITask;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.EntityLivingBase;
Expand Down Expand Up @@ -200,18 +203,31 @@ public void drawHUD(RenderGameOverlayEvent.Post event) {
doUngrab = false;
}

final ScaledResolution res = new ScaledResolution(
getMinecraft().gameSettings, getMinecraft().displayWidth,
getMinecraft().displayHeight);
String str;
synchronized (strategyDescrMutex) {
str = strategyDescr;
try {
// Dynamic 1.7.2 / 1.7.10 fix.
ScaledResolution res;
Constructor<?> method = ScaledResolution.class.getConstructors()[0];
Object arg1 = method.getParameterTypes()[0] == Minecraft.class ? getMinecraft()
: getMinecraft().gameSettings;
res = (ScaledResolution) method.newInstance(arg1,
getMinecraft().displayWidth, getMinecraft().displayHeight);

String str;
synchronized (strategyDescrMutex) {
str = strategyDescr;
}
getMinecraft().fontRenderer.drawStringWithShadow(
str,
res.getScaledWidth()
- getMinecraft().fontRenderer.getStringWidth(str)
- 10, 10, 16777215);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
getMinecraft().fontRenderer.drawStringWithShadow(
str,
res.getScaledWidth()
- getMinecraft().fontRenderer.getStringWidth(str) - 10,
10, 16777215);
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,29 @@ public void processCommand(ICommandSender sender, String[] args) {
AIChatController
.addChatLine("ERROR: More than 1 command matches your command line.");
} else {
AIChatController.addChatLine("ERROR: No such command.");

AIChatController.addChatLine("ERROR: No command:"
+ combine(args) + ".");
}
} catch (CommandEvaluationException e) {
AIChatController
.addChatLine("ERROR while evaluating: " + e.getMessage());
AIChatController.addChatLine("ERROR while evaluating: "
+ e.getMessage());
} catch (Throwable e) {
e.printStackTrace();
AIChatController
.addChatLine("ERROR: Could not evaluate. Please report.");
}
}

private String combine(String[] args) {
StringBuilder b = new StringBuilder();
for (String a : args) {
b.append(" ");
b.append(a);
}
return b.toString();
}

@Override
public String getCommandUsage(ICommandSender var1) {
return "/" + name + " ...";
Expand Down

0 comments on commit e65b39a

Please sign in to comment.