use of net.minecraft.client.gui.screen.ChatScreen in project BleachHack by BleachDrinker420.
the class Vector2 method onClose.
public void onClose() {
cursorMode(GLFW.GLFW_CURSOR_NORMAL);
// This makes the magic
if (focusedString != null) {
DecimalFormat coordFormat = new DecimalFormat("#.##");
String message = ModuleManager.getModule(EntityMenu.class).interactions.getValue(focusedString).replaceAll("%name%", entity.getDisplayName().getString()).replaceAll("%uuid%", entity.getEntityName()).replaceAll("%health%", String.valueOf((int) entity.getHealth())).replaceAll("%x%", coordFormat.format(entity.getX())).replaceAll("%y%", coordFormat.format(entity.getY())).replaceAll("%z%", coordFormat.format(entity.getZ()));
if (message.startsWith(">suggest ")) {
client.setScreen(new ChatScreen(message.substring(9)));
} else if (message.startsWith(">url ")) {
try {
Util.getOperatingSystem().open(new URI(message.substring(5)));
} catch (Exception e) {
BleachLogger.error("Invalid url \"" + message.substring(5) + "\"");
}
client.setScreen(null);
} else {
client.player.sendChatMessage(message);
client.setScreen(null);
}
} else {
client.setScreen(null);
}
}
use of net.minecraft.client.gui.screen.ChatScreen in project ImmersivePortalsMod by qouteall.
the class ClientWorldLoader method createFakedClientWorld.
// fool minecraft using the faked world
private ClientWorld createFakedClientWorld(DimensionType dimension) {
assert mc.world.dimension.getType() == mc.player.dimension;
assert (mc.player.dimension != dimension);
isLoadingFakedWorld = true;
// TODO get load distance
int chunkLoadDistance = 3;
WorldRenderer worldRenderer = new WorldRenderer(mc);
ClientWorld newWorld;
try {
ClientPlayNetworkHandler newNetworkHandler = new ClientPlayNetworkHandler(mc, new ChatScreen("You should not be seeing me. I'm just a faked screen."), new ClientConnection(NetworkSide.CLIENTBOUND), new GameProfile(null, "faked_profiler_id"));
// multiple net handlers share the same playerListEntries object
((IEClientPlayNetworkHandler) newNetworkHandler).setPlayerListEntries(((IEClientPlayNetworkHandler) mc.player.networkHandler).getPlayerListEntries());
newWorld = new ClientWorld(newNetworkHandler, new LevelInfo(0L, GameMode.CREATIVE, true, isHardCore, LevelGeneratorType.FLAT), dimension, chunkLoadDistance, mc.getProfiler(), worldRenderer);
} catch (Exception e) {
throw new IllegalStateException("Creating Faked World " + dimension + " " + clientWorldMap.keySet(), e);
}
worldRenderer.setWorld(newWorld);
worldRenderer.apply(mc.getResourceManager());
((IEClientPlayNetworkHandler) ((IEClientWorld) newWorld).getNetHandler()).setWorld(newWorld);
clientWorldMap.put(dimension, newWorld);
worldRendererMap.put(dimension, worldRenderer);
Helper.log("Faked World Created " + dimension);
isLoadingFakedWorld = false;
return newWorld;
}
use of net.minecraft.client.gui.screen.ChatScreen in project BleachHack by BleachDrinker420.
the class CommandSuggestor method onDrawOverlay.
@BleachSubscribe
public void onDrawOverlay(EventRenderInGameHud event) {
if (!Option.CHAT_SHOW_SUGGESTIONS.getValue())
return;
Screen screen = MinecraftClient.getInstance().currentScreen;
if (screen instanceof ChatScreen) {
TextFieldWidget field = ((AccessorChatScreen) screen).getChatField();
String text = field.getText();
if (!text.equals(curText)) {
suggestions.clear();
curText = text;
if (text.startsWith(Command.getPrefix())) {
suggestions.addAll(CommandManager.getSuggestionProvider().getSuggestions(text.substring(Command.getPrefix().length()).split(" ", -1)));
}
selected = 0;
scroll = 0;
}
if (selected >= 0 && selected < suggestions.size()) {
String[] split = field.getText().split(" ", -1);
int offset = split[split.length - 1].length() - (split.length == 1 ? Command.getPrefix().length() : 0);
if (offset > suggestions.get(selected).length()) {
field.setSuggestion("");
} else {
field.setSuggestion(suggestions.get(selected).substring(offset));
}
}
if (!suggestions.isEmpty()) {
event.getMatrix().push();
event.getMatrix().translate(0, 0, 200);
int length = suggestions.stream().map(s -> MinecraftClient.getInstance().textRenderer.getWidth(s)).min(Comparator.reverseOrder()).orElse(0);
int startX = MinecraftClient.getInstance().textRenderer.getWidth(field.getText().replaceFirst("[^ ]*$", "") + (!field.getText().contains(" ") ? Command.getPrefix() : "")) + 3;
int startY = screen.height - Math.min(suggestions.size(), 10) * 12 - 15;
for (int i = scroll; i < suggestions.size() && i < scroll + 10; i++) {
String suggestion = suggestions.get(i);
DrawableHelper.fill(event.getMatrix(), startX, startY, startX + length + 2, startY + 12, 0xd0000000);
MinecraftClient.getInstance().textRenderer.drawWithShadow(event.getMatrix(), suggestion, startX + 1, startY + 2, i == selected ? 0xffff00 : 0xb0b0b0);
startY += 12;
}
event.getMatrix().pop();
}
}
}
use of net.minecraft.client.gui.screen.ChatScreen in project BleachHack by BleachDrinker420.
the class MixinKeyboard method onKeyEvent_1.
@Inject(method = "onKey", at = @At(value = "INVOKE", target = "net/minecraft/client/util/InputUtil.isKeyPressed(JI)Z", ordinal = 5), cancellable = true)
private void onKeyEvent_1(long windowPointer, int key, int scanCode, int action, int modifiers, CallbackInfo callbackInfo) {
if (Option.CHAT_QUICK_PREFIX.getValue() && Command.getPrefix().length() == 1 && key == Command.getPrefix().charAt(0)) {
MinecraftClient.getInstance().setScreen(new ChatScreen(Command.getPrefix()));
}
ModuleManager.handleKey(key);
if (key >= 0) {
EventKeyPress.InWorld event = new EventKeyPress.InWorld(key, scanCode);
BleachHack.eventBus.post(event);
if (event.isCancelled()) {
callbackInfo.cancel();
}
}
}
use of net.minecraft.client.gui.screen.ChatScreen in project Hypnotic-Client by Hypnotic-Development.
the class KeyboardMixin method onKey.
@Inject(method = "onKey", at = @At("HEAD"), cancellable = true)
public void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo info) {
if (key != GLFW.GLFW_KEY_UNKNOWN) {
/*
* action == GLFW.GLFW_PRESS is important
* so the module does not toggle twice
*/
KeyUtils.setKeyState(key, action != GLFW.GLFW_RELEASE);
for (Mod mod : ModuleManager.INSTANCE.modules) {
if (mod.getKey() == key && action == GLFW.GLFW_PRESS && MinecraftClient.getInstance().currentScreen == null)
mod.toggle();
}
EventKeyPress event = new EventKeyPress(key, scancode, action);
event.call();
if (event.isCancelled())
info.cancel();
if (client.currentScreen == null && key == KeyUtils.getKey(CommandManager.INSTANCE.getPrefix()) && action == GLFW.GLFW_PRESS)
client.setScreen(new ChatScreen(""));
}
}
Aggregations