Начинающий
- Статус
- Оффлайн
- Регистрация
- 7 Мар 2025
- Сообщения
- 39
- Реакции
- 0
- Выберите загрузчик игры
- Vanilla
SS -
сарделька:
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package im.expensive.functions.impl.player;
import com.google.common.eventbus.Subscribe;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.Setting;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.client.IMinecraft;
import im.expensive.utils.text.GradientUtil;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.NewChatGui;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.PotionEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
@FunctionRegister(
name = "PotionTracker",
type = Category.Player,
description = "Видит что накинули на игрока"
)
public class PotionDetector extends Function implements IMinecraft {
private final SliderSetting radius = new SliderSetting("Радиус", 50.0F, 10.0F, 100.0F, 1.0F);
private final BooleanSetting showHitChance = new BooleanSetting("Показывать шанс попадания", true);
private final BooleanSetting showEffects = new BooleanSetting("Показывать эффекты", true);
private final Map<Integer, PotionData> trackedPotions = new HashMap();
public PotionDetector() {
this.addSettings(new Setting[]{this.radius, this.showHitChance, this.showEffects});
}
private void printWithClientName(String message) {
Minecraft var10000 = mc;
if (Minecraft.player != null) {
NewChatGui var2 = mc.ingameGUI.getChatGUI();
StringTextComponent var10001 = GradientUtil.gradient("Debuda");
String var10004 = String.valueOf(TextFormatting.DARK_GRAY);
var2.printChatMessage(var10001.append(new StringTextComponent(var10004 + " >> " + String.valueOf(TextFormatting.RESET) + message)));
}
}
@Subscribe
private void onUpdate(EventUpdate event) {
Minecraft var10000 = mc;
if (Minecraft.world != null) {
var10000 = mc;
if (Minecraft.player != null) {
Set<Integer> currentPotions = new HashSet();
var10000 = mc;
for(Entity entity : Minecraft.world.getAllEntities()) {
if (entity instanceof PotionEntity) {
PotionEntity potionEntity = (PotionEntity)entity;
int entityId = entity.getEntityId();
var10000 = mc;
double myDistance = (double)Minecraft.player.getDistance(entity);
if (!(myDistance > (double)(Float)this.radius.get())) {
currentPotions.add(entityId);
if (!this.trackedPotions.containsKey(entityId)) {
ItemStack potionStack = potionEntity.getItem();
this.trackedPotions.put(entityId, new PotionData(potionStack.copy(), entity.getPosX(), entity.getPosY(), entity.getPosZ()));
} else {
PotionData data = (PotionData)this.trackedPotions.get(entityId);
data.lastX = entity.getPosX();
data.lastY = entity.getPosY();
data.lastZ = entity.getPosZ();
}
}
}
}
Set<Integer> removedPotions = new HashSet(this.trackedPotions.keySet());
removedPotions.removeAll(currentPotions);
for(int entityId : removedPotions) {
PotionData data = (PotionData)this.trackedPotions.get(entityId);
AxisAlignedBB potionBB = new AxisAlignedBB(data.lastX - (double)4.0F, data.lastY - (double)2.0F, data.lastZ - (double)4.0F, data.lastX + (double)4.0F, data.lastY + (double)2.0F, data.lastZ + (double)4.0F);
var10000 = mc;
for(LivingEntity hitEntity : Minecraft.world.getEntitiesWithinAABB(LivingEntity.class, potionBB)) {
if (hitEntity instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity)hitEntity;
double dx = player.getPosX() - data.lastX;
double dz = player.getPosZ() - data.lastZ;
double distance = Math.sqrt(dx * dx + dz * dz);
if (distance <= (double)4.0F) {
ItemStack potionStack = data.stack;
List<EffectInstance> effects = PotionUtils.getEffectsFromStack(potionStack);
double proximity = Math.max((double)0.0F, (double)1.0F - distance / (double)4.0F);
double hitChance = proximity * (double)100.0F;
int potionColorInt = PotionUtils.getColor(potionStack);
TextFormatting potionColor = this.getColorFromInt(potionColorInt);
String playerName = player.getName().getString();
String potionName = potionStack.getDisplayName().getString();
String message = String.valueOf(TextFormatting.WHITE) + playerName + String.valueOf(TextFormatting.GRAY) + " получил " + String.valueOf(potionColor) + potionName;
this.print(message);
if ((Boolean)this.showHitChance.get()) {
String var50 = String.valueOf(TextFormatting.DARK_GRAY);
String hitMessage = var50 + "• " + String.valueOf(TextFormatting.WHITE) + "Успешность: " + String.valueOf(TextFormatting.GREEN) + String.format("%.0f%%", hitChance);
mc.ingameGUI.getChatGUI().printChatMessage(new StringTextComponent(hitMessage));
}
if ((Boolean)this.showEffects.get() && !effects.isEmpty()) {
for(EffectInstance effect : effects) {
String effectName = effect.getPotion().getDisplayName().getString();
int amplifier = effect.getAmplifier() + 1;
int duration = effect.getDuration() / 20;
int adjustedDuration = (int)((double)duration * (hitChance / (double)100.0F));
int minutes = adjustedDuration / 60;
int seconds = adjustedDuration % 60;
String effectMessage = String.valueOf(TextFormatting.DARK_GRAY) + "• " + String.valueOf(TextFormatting.RED) + effectName + String.valueOf(TextFormatting.RED) + " " + this.toRoman(amplifier) + String.valueOf(TextFormatting.GRAY) + " (" + minutes + ":" + String.format("%02d", seconds) + ")";
mc.ingameGUI.getChatGUI().printChatMessage(new StringTextComponent(effectMessage));
}
}
}
}
}
this.trackedPotions.remove(entityId);
}
return;
}
}
}
private TextFormatting getColorFromInt(int color) {
int red = color >> 16 & 199;
int green = color >> 8 & 199;
int blue = color & 199;
if (red > green && red > blue) {
return TextFormatting.RED;
} else if (green > red && green > blue) {
return TextFormatting.GREEN;
} else if (blue > red && blue > green) {
return TextFormatting.BLUE;
} else if (red > 240 && green > 100 && blue < 100) {
return TextFormatting.GOLD;
} else if (red > 174 && green < 100 && blue > 174) {
return TextFormatting.LIGHT_PURPLE;
} else {
return red < 100 && green > 174 && blue > 174 ? TextFormatting.AQUA : TextFormatting.WHITE;
}
}
private String toRoman(int number) {
switch (number) {
case 1 -> {
return "I";
}
case 2 -> {
return "II";
}
case 3 -> {
return "III";
}
case 4 -> {
return "IV";
}
case 5 -> {
return "V";
}
case 6 -> {
return "VI";
}
case 7 -> {
return "VII";
}
case 8 -> {
return "VIII";
}
case 9 -> {
return "IX";
}
case 10 -> {
return "X";
}
default -> {
return String.valueOf(number);
}
}
}
public boolean onDisable() {
this.trackedPotions.clear();
super.onDisable();
return false;
}
}