use of net.minecraft.client.Minecraft in project watson by totemo.
the class Controller method getServerIP.
// --------------------------------------------------------------------------
/**
* Return the IP address or DNS name of the currently connected server, or
* null if not connected.
*
* @return the IP address or DNS name of the currently connected server, or
* null if not connected.
*/
public String getServerIP() {
Minecraft mc = Minecraft.getMinecraft();
ServerData serverData = mc.getCurrentServerData();
if (!mc.isSingleplayer() && serverData != null) {
return serverData.serverIP;
} else {
return null;
}
}
use of net.minecraft.client.Minecraft in project watson by totemo.
the class Controller method initialise.
// --------------------------------------------------------------------------
/**
* Mod-wide initialisation tasks, including loading configuration files and
* setting up commands.
*/
public void initialise() {
createBlockEditDirectory();
BlockTypeRegistry.instance.loadBlockTypes();
Chat.getChatHighlighter().loadHighlights();
// Initialise the commands.
ClientCommandManager.instance.registerCommand(new WatsonCommand());
ClientCommandManager.instance.registerCommand(new AnnoCommand());
ClientCommandManager.instance.registerCommand(new HighlightCommand());
ClientCommandManager.instance.registerCommand(new CalcCommand());
// Set up event handlers for key bindings.
final Configuration config = Configuration.instance;
config.KEYBIND_INGAME.setDisplayDependent(false);
config.KEYBIND_INGAME.setHandler(new Runnable() {
@Override
public void run() {
Minecraft.getMinecraft().displayGuiScreen(new WatsonGuiScreen());
}
});
config.KEYBIND_SCREENSHOT.setDisplayDependent(false);
config.KEYBIND_SCREENSHOT.setHandler(new Runnable() {
@Override
public void run() {
Date now = new Date();
Configuration config = Configuration.instance;
String player = (String) Controller.instance.getVariables().get("player");
String subdirectoryName = (player != null && config.isSsPlayerDirectory()) ? player : config.getSsDateDirectory().format(now).toString();
Minecraft mc = Minecraft.getMinecraft();
File screenshotsDir = new File(mc.mcDataDir, "screenshots");
File subdirectory = new File(screenshotsDir, subdirectoryName);
File file = Screenshot.getUniqueFilename(subdirectory, player, now);
Chat.localChat(Screenshot.save(file, mc.displayWidth, mc.displayHeight));
}
});
config.KEYBIND_TP_NEXT.setHandler(new Runnable() {
@Override
public void run() {
getBlockEditSet().getOreDB().tpNext();
}
});
config.KEYBIND_TP_PREV.setHandler(new Runnable() {
@Override
public void run() {
getBlockEditSet().getOreDB().tpPrev();
}
});
Controller.instance.queryPreEdits(config.getPreCount());
config.KEYBIND_QUERY_BEFORE.setHandler(new Runnable() {
@Override
public void run() {
queryPreEdits(config.getPreCount());
}
});
config.KEYBIND_QUERY_AFTER.setHandler(new Runnable() {
@Override
public void run() {
queryPostEdits(config.getPostCount());
}
});
config.KEYBIND_CURSOR_NEXT.setHandler(new Runnable() {
@Override
public void run() {
// in which case it does not belong to a set of player edits.
if (_selection != null && _selection.playerEditSet != null) {
BlockEdit edit = _selection.playerEditSet.getEditAfter(_selection);
if (edit != null) {
selectBlockEdit(edit);
}
}
}
});
config.KEYBIND_CURSOR_PREV.setHandler(new Runnable() {
@Override
public void run() {
// in which case it does not belong to a set of player edits.
if (_selection != null && _selection.playerEditSet != null) {
BlockEdit edit = _selection.playerEditSet.getEditBefore(_selection);
if (edit != null) {
selectBlockEdit(edit);
}
}
}
});
config.KEYBIND_TP_CURSOR.setHandler(new Runnable() {
@Override
public void run() {
if (_selection != null) {
teleport(_selection.x, _selection.y, _selection.z);
}
}
});
}
use of net.minecraft.client.Minecraft in project watson by totemo.
the class Controller method getBlockEditSet.
// --------------------------------------------------------------------------
/**
* Return the current {@link BlockEditSet} under examination.
*
* A separate {@link BlockEditSet} is maintained for each dimension
* (overworld, nether, end).
*
* @return the current {@link BlockEditSet} under examination.
*/
public BlockEditSet getBlockEditSet() {
// Compute id of the form: address/dimension
// Note: Minecraft.theWorld.getWorldInfo().getDimension() doesn't update.
Minecraft mc = Minecraft.getMinecraft();
StringBuilder idBuilder = new StringBuilder();
// This code might get referenced at startup when changing display settings
// if the mod happens to be disabled in the config file. At that time,
// getServerIP() will be null. Let's avoid that crash.
String serverIP = getServerIP();
if (serverIP != null) {
idBuilder.append(serverIP);
}
idBuilder.append('/');
idBuilder.append(mc.thePlayer.dimension);
String id = idBuilder.toString();
// Lookup BlockEditSet or create new mapping if not found.
BlockEditSet edits = _edits.get(id);
if (edits == null) {
edits = new BlockEditSet();
_edits.put(id, edits);
}
return edits;
}
use of net.minecraft.client.Minecraft in project malmo by Microsoft.
the class TimeHelper method setMinecraftClientClockSpeed.
public static boolean setMinecraftClientClockSpeed(float ticksPerSecond) {
boolean devEnv = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
// We need to know, because the member name will either be obfuscated or not.
String timerMemberName = devEnv ? "timer" : "field_71428_T";
// NOTE: obfuscated name may need updating if Forge changes - search for "timer" in Malmo\Minecraft\build\tasklogs\retromapSources.log
Field timer;
try {
timer = Minecraft.class.getDeclaredField(timerMemberName);
timer.setAccessible(true);
timer.set(Minecraft.getMinecraft(), new Timer(ticksPerSecond));
return true;
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
return false;
}
use of net.minecraft.client.Minecraft in project PneumaticCraft by MineMaarten.
the class AreaShowManager method renderWorldLastEvent.
@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event) {
Minecraft mc = FMLClientHandler.instance().getClient();
EntityPlayer player = mc.thePlayer;
double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.partialTicks;
double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.partialTicks;
double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.partialTicks;
GL11.glPushMatrix();
GL11.glTranslated(-playerX, -playerY, -playerZ);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// GL11.glDisable(GL11.GL_DEPTH_TEST);
for (AreaShowHandler handler : showHandlers.values()) {
handler.render();
}
ItemStack curItem = player.getCurrentEquippedItem();
if (curItem != null && curItem.getItem() == Itemss.GPSTool) {
ChunkPosition gpsLocation = ItemGPSTool.getGPSLocation(curItem);
if (gpsLocation != null) {
Set<ChunkPosition> set = new HashSet<ChunkPosition>();
set.add(gpsLocation);
GL11.glDisable(GL11.GL_DEPTH_TEST);
new AreaShowHandler(set, 0xFFFF00).render();
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
}
ItemStack helmet = player.getCurrentArmor(3);
if (helmet != null && helmet.getItem() == Itemss.pneumaticHelmet) {
if (droneDebugger == null)
droneDebugger = HUDHandler.instance().getSpecificRenderer(DroneDebugUpgradeHandler.class);
Set<ChunkPosition> set = droneDebugger.getShowingPositions();
GL11.glDisable(GL11.GL_DEPTH_TEST);
new AreaShowHandler(set, 0xFF0000).render();
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
// GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
Aggregations