Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
Исправление неполной загрузки модов и другие мелкие правки
Browse files Browse the repository at this point in the history
  • Loading branch information
Serega007RU committed May 31, 2024
1 parent 9cca115 commit e8cb052
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Binary file modified Injector/Injector.7z
Binary file not shown.
29 changes: 24 additions & 5 deletions src/main/java/ru/serega007/bcsc/BetterCSC.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public void load(ClientApi api) {
} catch (Exception e) {
//noinspection CallToPrintStackTrace
e.printStackTrace();
api.chat().printChatMessage(prefix.copy().append(Text.of("Ошибка загрузки маппингов, обратитесь к разработчику https://github.com/Serega007RU/BetterCSC/issues " + e.getLocalizedMessage(), TextFormatting.DARK_RED)));
api.chat().printChatMessage(prefix.copy().append(Text.of("Ошибка загрузки маппингов (рефлексии), обратитесь к разработчику https://github.com/Serega007RU/BetterCSC/issues " + e.getLocalizedMessage(), TextFormatting.DARK_RED)));
return;
}

api.chat().printChatMessage(prefix.copy().append(Text.of("Plus Edition", TextFormatting.DARK_AQUA, " версии ", TextFormatting.GOLD, "@version@", TextFormatting.YELLOW, " загружен, by ", TextFormatting.GOLD, "Serega007", TextFormatting.DARK_GREEN, " & ", TextFormatting.GOLD, "VVHIX", TextFormatting.DARK_GREEN)));
api.chat().printChatMessage(prefix.copy().append(Text.of("версии ", TextFormatting.GOLD, "@version@", TextFormatting.YELLOW, " загружен, by ", TextFormatting.GOLD, "Serega007", TextFormatting.DARK_GREEN, " & ", TextFormatting.GOLD, "VVHIX", TextFormatting.DARK_GREEN)));
ChatSend.BUS.register(this, chatSend -> {
if (chatSend.isCommand()) {
String msg = chatSend.getMessage().toLowerCase();
Expand Down Expand Up @@ -286,7 +286,15 @@ public void load(ClientApi api) {
if (api.minecraft().getPlayerController().getGameMode().equals(GameMode.SPECTATOR)) return;
ItemStack itemStack = player.getInventory().getCurrentItem();
if (!itemStack.isEmpty() && !itemStack.getDisplayName().contains("Книга")) return;
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerTryUseItem(EnumHand.MAIN_HAND));
try {
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketPlayerTryUseItem(EnumHand.MAIN_HAND));
// api.minecraft().rightClickMouse();
// Wrapper.sendPacket(Wrapper.CPacketPlayerTryUseItem(EnumHand.MAIN_HAND));
} catch (Exception e) {
//noinspection CallToPrintStackTrace
e.printStackTrace();
disableBuy(api, Text.of("Произошла ошибка при попытке кликнуть ПКМ", TextFormatting.RED, ", ", TextFormatting.GOLD, e.toString(), TextFormatting.DARK_RED));
}
}, 0, 1000000 / periodUse, TimeUnit.MICROSECONDS);
}
} else if (msg.startsWith("/unloadbcsc")) {
Expand Down Expand Up @@ -548,11 +556,11 @@ public void load(ClientApi api) {
allowedBuy = false;
} else if (message.contains("wave.complete")) {
allowedBuy = true;
if (enableBuy) ((InventoryPlayer) api.minecraft().getPlayer().getInventory()).currentItem = slotForBuy;
if (enableBuy) changeActiveSlot(api, slotForBuy);
}
} else if (pluginMessage.getChannel().equals("func:drop-item")) {
allowedBuy = true;
if (enableBuy) ((InventoryPlayer) api.minecraft().getPlayer().getInventory()).currentItem = slotForBuy;
if (enableBuy) changeActiveSlot(api, slotForBuy);
} else if (pluginMessage.getChannel().equals("func:title")) {
if (enableUP || enableBuy) {
if (NetUtil.readUtf8(pluginMessage.getData().copy()).equals("i18n.csc.game.not.gold")) {
Expand Down Expand Up @@ -608,6 +616,17 @@ private void disableBuy(ClientApi api, Text reason) {
taskUse = null;
}

private void changeActiveSlot(ClientApi api, int slot) {
try {
((InventoryPlayer) api.minecraft().getPlayer().getInventory()).currentItem = slot;
// Wrapper.changeActiveSlot(api.minecraft().getPlayer().getInventory(), slot);
} catch (Exception e) {
//noinspection CallToPrintStackTrace
e.printStackTrace();
disableBuy(api, Text.of("Произошла ошибка при попытке сменить активный слот", TextFormatting.RED, ", ", TextFormatting.GOLD, e.toString(), TextFormatting.DARK_RED));
}
}

private int getMaxEnchantLvl(ItemStack stack) {
int enchantLvl = 0;
if (stack.isItemEnchanted()) {
Expand Down

0 comments on commit e8cb052

Please sign in to comment.