Начинающий
-
Автор темы
- #1
В общем и мне надо что-то подарить этому форуму на новый год. 
Хочу сказать спасибо всем участникам этого форума за такой необычный и интересный год за такое количество конфликтов кряков сливов и другого.
С новым годом пастеры! (Я в том числе если что)
AuctionHelperFeature создайте сами там просто класс с функцией нужен. Думаю с добавлениям миксинов в ваш проэкт разберётесь сами.
Drop All:

Хочу сказать спасибо всем участникам этого форума за такой необычный и интересный год за такое количество конфликтов кряков сливов и другого.
С новым годом пастеры! (Я в том числе если что)
AuctionHelperFeature создайте сами там просто класс с функцией нужен. Думаю с добавлениям миксинов в ваш проэкт разберётесь сами.
AuctionHelperMixin.java:
@OnlyIn(Dist.CLIENT)
@Mixin(ContainerScreen.class)
public abstract class MixinContainerScreen {
[USER=8455]@Shadow[/USER]
public abstract int getGuiTop();
[USER=8455]@Shadow[/USER]
public abstract int getGuiLeft();
@Inject(method = "render", at = @At("TAIL"))
private void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
ContainerScreen<?> screen = (ContainerScreen<?>) (Object) this;
int x = (screen.width - screen.getXSize()) / 2 + screen.getXSize() / 2 - 50;
int y = (screen.height - screen.getYSize()) / 2 + screen.getYSize() / 2 - 10;
for (Feature feature : FeatureProvider.features) {
if (feature.name.contains("AuctionHelper") && feature.enable == true) {
if (screen.getTitle().getString().contains("Аукцион") || screen.getTitle().getString().contains("Поиск")) {
int minSlot = AuctionUtil.cheapItem();
for (Slot slot : screen.getMenu().slots) {
if (slot.getSlotIndex() == minSlot) {
int sosalX = this.getGuiLeft() + slot.x;
int sosalY = this.getGuiTop() + slot.y;
mc.gui.fill(matrices, sosalX - 2, sosalY - 2, sosalX + 18, sosalY + 18, 0x8000FF00);
break;
}
}
}
}
}
}
}
AuctionUtil.java:
public static int getPrice(String nbt) {
String regex = "\\$(\\d{1,3}(?:,\\d{3})*(?:\\.\\d{2})?)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(nbt);
if (matcher.find()) {
String priceString = matcher.group(1).replace(",", "").replace("$", "");
return Integer.parseInt(priceString);
}
return 0;
}
public static int cheapItem() {
int cheapestSlot = -1;
int cheapestPrice = Integer.MAX_VALUE;
for (int i = 0; i < 44; i++) {
ItemStack itemStack = mc.player.containerMenu.getSlot(i).getItem();
if (!itemStack.isEmpty()) {
String nbt = itemStack.getTag() != null ? itemStack.getTag().toString() : "";
int price = getPrice(nbt);
if (price < cheapestPrice) {
cheapestPrice = price;
cheapestSlot = i;
}
}
}
return cheapestSlot;
}
}
DropAllMixin.java:
@Mixin(InventoryScreen.class)
public abstract class MixinInventoryScreen extends ContainerScreen<Container> {
public MixinInventoryScreen(Container container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
}
@Inject(method = "init", at = @At("TAIL"))
private void renderButton(CallbackInfo ci) {
Button dropAll = new Button(
width / 2 - 50, //
140,
100,
20,
new StringTextComponent("Выбросить всё"),
button -> {
for(int index = 0; index <= 36; index++) {
if(!mc.player.inventory.getItem(index).isEmpty()) {
mc.gameMode.handleInventoryMouseClick(mc.player.containerMenu.containerId, index, 0, ClickType.THROW, mc.player);
}
}
}
);
this.addButton(dropAll);
}
}