file_name
stringlengths 6
86
| file_path
stringlengths 45
249
| content
stringlengths 47
6.26M
| file_size
int64 47
6.26M
| language
stringclasses 1
value | extension
stringclasses 1
value | repo_name
stringclasses 767
values | repo_stars
int64 8
14.4k
| repo_forks
int64 0
1.17k
| repo_open_issues
int64 0
788
| repo_created_at
stringclasses 767
values | repo_pushed_at
stringclasses 767
values |
---|---|---|---|---|---|---|---|---|---|---|---|
FakeDestroy.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/FakeDestroy.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.client.event.MouseEvent;
import org.lwjgl.input.Mouse;
public class FakeDestroy
extends Module {
public FakeDestroy() {
super(ModuleCategory.PLAYER);
}
@Override
public String getName() {
return "FakeDestroy";
}
@Override
public String getDescription() {
return "Destroy blocks on client with left click";
}
private ArrayList<BlockInfo> removedBlocks = new ArrayList<>();
private class BlockInfo {
public int[] coords;
public Block block;
public int meta;
public BlockInfo(int[] coords, Block block, int meta) {
this.coords = coords;
this.block = block;
this.meta = meta;
}
}
private boolean prevState = false;
@Override
public void onMouse(MouseEvent event) {
try {
boolean nowState = Mouse.isButtonDown(0);
MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
if (position.sideHit != -1 && !prevState && nowState) {
removedBlocks.add(new BlockInfo(new int[]{position.blockX, position.blockY, position.blockZ}, Wrapper.INSTANCE.world().getBlock(position.blockX, position.blockY, position.blockZ), Wrapper.INSTANCE.world().getBlockMetadata(position.blockX, position.blockY, position.blockZ)));
Wrapper.INSTANCE.world().setBlockToAir(position.blockX, position.blockY, position.blockZ);
if (event.isCancelable()) {
event.setCanceled(true);
}
}
prevState = nowState;
} catch (Exception ignored) {
}
}
@Override
public void onModuleEnabled() {
removedBlocks = new ArrayList<>();
}
@Override
public void onModuleDisabled() {
removedBlocks.forEach((removedBlock) -> {
Wrapper.INSTANCE.world().setBlock(removedBlock.coords[0], removedBlock.coords[1], removedBlock.coords[2], removedBlock.block, removedBlock.meta, 3);
});
}
}
| 2,339 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Spectate.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/Spectate.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.api.ModuleController;
import ehacks.mod.util.EntityFakePlayer;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.entity.Entity;
public class Spectate
extends Module {
private LocationHelper loc;
public Spectate() {
super(ModuleCategory.RENDER);
}
@Override
public String getName() {
return "Spectator";
}
@Override
public String getDescription() {
return "Creates another player entity (EntityFreecam) for be able to spectate your own player";
}
@Override
public void onModuleEnabled() {
ModuleController.INSTANCE.call(DynamicFly.class).toggle();
this.doSpectate();
}
@Override
public void onModuleDisabled() {
ModuleController.INSTANCE.call(DynamicFly.class).toggle();
this.undoSpectate();
}
public void doSpectate() {
if (Wrapper.INSTANCE.world() != null) {
this.loc = new LocationHelper(Wrapper.INSTANCE.player());
EntityFakePlayer spectator = new EntityFakePlayer(Wrapper.INSTANCE.world(), Wrapper.INSTANCE.player().getGameProfile());
spectator.setPositionAndRotation(this.loc.posX, this.loc.posY - 1.5, this.loc.posZ, this.loc.rotationYaw, this.loc.rotationPitch);
spectator.boundingBox.setBB(Wrapper.INSTANCE.player().boundingBox.copy());
spectator.inventory.copyInventory(Wrapper.INSTANCE.player().inventory);
Wrapper.INSTANCE.world().addEntityToWorld(-1, spectator);
}
}
public void undoSpectate() {
Wrapper.INSTANCE.world().removeEntityFromWorld(-1);
Wrapper.INSTANCE.player().setPositionAndRotation(this.loc.posX, this.loc.posY, this.loc.posZ, this.loc.rotationYaw, this.loc.rotationPitch);
}
public class LocationHelper implements Cloneable {
public double posX;
public double posY;
public double posZ;
public float rotationYaw;
public float rotationPitch;
public String name;
@Override
public LocationHelper clone() throws CloneNotSupportedException {
return new LocationHelper(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch, this.name);
}
public LocationHelper(Entity entity) {
this(entity, "");
}
public LocationHelper(Entity entity, String s) {
this(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch, s);
}
public LocationHelper() {
this(0.0, 0.0, 0.0, 0.0f, 0.0f, "");
}
public LocationHelper(double d, double d1, double d2, String s) {
this(d, d1, d2, 0.0f, 0.0f, s);
}
public LocationHelper(double d, double d1, double d2) {
this(d, d1, d2, 0.0f, 0.0f, "");
}
public LocationHelper(double d, double d1, double d2, float f, float f1) {
this(d, d1, d2, f, f1, "");
}
public LocationHelper(double d, double d1, double d2, float f, float f1, String s) {
this.posX = d;
this.posY = d1;
this.posZ = d2;
this.rotationYaw = f;
this.rotationPitch = f1;
this.name = s;
}
public double distance(LocationHelper Location) {
return Math.sqrt(this.distanceSquare(Location));
}
public double distanceSquare(LocationHelper Location) {
double d = Location.posX - this.posX;
double d1 = Location.posY - this.posY;
double d2 = Location.posZ - this.posZ;
return d * d + d1 * d1 + d2 * d2;
}
public double distance2D(LocationHelper Location) {
return Math.sqrt(this.distance2DSquare(Location));
}
public double distance2DSquare(LocationHelper Location) {
double d = Location.posX - this.posX;
double d1 = Location.posZ - this.posZ;
return d * d + d1 * d1;
}
public double distanceY(LocationHelper Location) {
return Location.posY - this.posY;
}
public LocationHelper(String s) throws Exception {
String[] as = s.split(";", 6);
if (as.length != 6) {
throw new Exception("Invalid line!");
}
this.name = as[5];
this.posX = Double.parseDouble(as[0]);
this.posY = Double.parseDouble(as[1]);
this.posZ = Double.parseDouble(as[2]);
this.rotationYaw = Float.parseFloat(as[3]);
this.rotationPitch = Float.parseFloat(as[4]);
}
public String export() {
return "" + this.posX + ";" + this.posY + ";" + this.posZ + ";" + this.rotationYaw + ";" + this.rotationPitch + ";" + this.name;
}
}
}
| 4,959 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Speed.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/Speed.java | package ehacks.mod.modulesystem.classes.vanilla;
import cpw.mods.fml.relauncher.ReflectionHelper;
import ehacks.mod.api.Module;
import ehacks.mod.config.CheatConfiguration;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import ehacks.mod.util.Mappings;
import net.minecraft.client.Minecraft;
import net.minecraft.util.Timer;
public class Speed
extends Module {
public Speed() {
super(ModuleCategory.PLAYER);
}
@Override
public String getName() {
return "Speed";
}
@Override
public String getDescription() {
return "Your game will run 3x faster";
}
@Override
public void onTicks() {
Timer timer = (Timer) ReflectionHelper.getPrivateValue(Minecraft.class, Wrapper.INSTANCE.mc(), new String[]{Mappings.timer});
timer.timerSpeed = (float) CheatConfiguration.config.speedhack;
}
@Override
public void onModuleDisabled() {
Timer timer = (Timer) ReflectionHelper.getPrivateValue(Minecraft.class, Wrapper.INSTANCE.mc(), new String[]{Mappings.timer});
timer.timerSpeed = 1.0f;
}
}
| 1,129 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
BlockSmash.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/BlockSmash.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.block.Block;
import net.minecraft.util.MathHelper;
public class BlockSmash
extends Module {
public BlockSmash() {
super(ModuleCategory.RENDER);
}
@Override
public String getName() {
return "BlockSmash";
}
@Override
public String getDescription() {
return "Plays the fall effect";
}
@Override
public void onTicks() {
Wrapper.INSTANCE.player().fallDistance = 100.0f;
int x = MathHelper.floor_double(Wrapper.INSTANCE.player().posX);
int y = MathHelper.floor_double((Wrapper.INSTANCE.player().posY - 0.20000000298023224 - Wrapper.INSTANCE.player().yOffset));
int z = MathHelper.floor_double(Wrapper.INSTANCE.player().posZ);
Block block = Wrapper.INSTANCE.player().worldObj.getBlock(x, y - 1, z);
Wrapper.INSTANCE.player().worldObj.playAuxSFX(2006, x, y, z, MathHelper.ceiling_float_int((Wrapper.INSTANCE.player().fallDistance - 3.0f)));
block.onFallenUpon(Wrapper.INSTANCE.player().worldObj, x, y, z, Wrapper.INSTANCE.player(), Wrapper.INSTANCE.player().fallDistance);
}
}
| 1,284 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ShowArmor.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/ShowArmor.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class ShowArmor
extends Module {
public ShowArmor() {
super(ModuleCategory.RENDER);
}
@Override
public String getName() {
return "ShowArmor";
}
@Override
public String getDescription() {
return "Allows you to see armor of player or info of item";
}
@Override
public void onGameOverlay(RenderGameOverlayEvent.Text event) {
if (event.type == RenderGameOverlayEvent.ElementType.TEXT) {
Entity entityHit = getMouseOver(event.partialTicks, 5000, false);
if (entityHit instanceof EntityPlayer) {
EntityPlayer entity = (EntityPlayer) entityHit;
int t = 0;
for (int i = 3; i >= 0; i--) {
if (entity.inventory.armorInventory[i] == null) {
continue;
}
drawItemStack(entity.inventory.armorInventory[i], 4 + 8, 30 + t);
t += Math.max(drawHoveringText(getItemToolTip(entity.inventory.armorInventory[i]), 4 + 16 + 4 + 4, 34 + t, Wrapper.INSTANCE.fontRenderer()), 16) + 10;
}
if (entity.inventory.getCurrentItem() != null) {
drawItemStack(entity.inventory.getCurrentItem(), 4 + 8, 30 + t);
t += Math.max(drawHoveringText(getItemToolTip(entity.inventory.getCurrentItem()), 4 + 16 + 4 + 4, 34 + t, Wrapper.INSTANCE.fontRenderer()), 16) + 10;
}
return;
}
if (entityHit instanceof EntityLiving) {
EntityLiving entity = (EntityLiving) entityHit;
int t = 0;
for (int i = 4; i >= 0; i--) {
if (entity.getEquipmentInSlot(i) == null) {
continue;
}
drawItemStack(entity.getEquipmentInSlot(i), 4 + 8, 30 + t);
t += Math.max(drawHoveringText(getItemToolTip(entity.getEquipmentInSlot(i)), 4 + 16 + 4 + 4, 34 + t, Wrapper.INSTANCE.fontRenderer()), 16) + 10;
}
return;
}
if (entityHit instanceof EntityItem && ((EntityItem) entityHit).getEntityItem() != null) {
EntityItem entity = (EntityItem) entityHit;
int t = 0;
drawItemStack(entity.getEntityItem(), 4 + 8, 30 + t);
t += Math.max(drawHoveringText(getItemToolTip(entity.getEntityItem()), 4 + 16 + 4 + 4, 34 + t, Wrapper.INSTANCE.fontRenderer()), 16) + 10;
}
}
}
public Entity getMouseOver(float partialTicks, double distance, boolean canBeCollidedWith) {
Minecraft mc = Wrapper.INSTANCE.mc();
Entity pointedEntity = null;
MovingObjectPosition rayTrace = null;
if (mc.renderViewEntity != null) {
if (mc.theWorld != null) {
Vec3 positionVec = mc.renderViewEntity.getPosition(partialTicks);
Vec3 lookVec = mc.renderViewEntity.getLook(partialTicks);
Vec3 posDistVec = positionVec.addVector(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance);
double boxExpand = 1.0F;
@SuppressWarnings("unchecked")
List<Entity> entities = mc.theWorld.getEntitiesWithinAABBExcludingEntity(mc.renderViewEntity, mc.renderViewEntity.boundingBox.addCoord(lookVec.xCoord * distance, lookVec.yCoord * distance, lookVec.zCoord * distance).expand(boxExpand, boxExpand, boxExpand));
double mincalc = Double.MAX_VALUE;
for (Entity entity : entities) {
if (!canBeCollidedWith || entity.canBeCollidedWith()) {
double borderSize = entity.getCollisionBorderSize();
AxisAlignedBB expEntityBox = entity.boundingBox.expand(borderSize, borderSize, borderSize);
MovingObjectPosition calculateInterceptPos = expEntityBox.calculateIntercept(positionVec, posDistVec);
if (calculateInterceptPos != null) {
double calcInterceptPosDist = positionVec.distanceTo(calculateInterceptPos.hitVec);
if (mincalc > calcInterceptPosDist) {
mincalc = calcInterceptPosDist;
pointedEntity = entity;
}
}
}
}
if (pointedEntity != null) {
return pointedEntity;
}
}
}
return null;
}
private void drawPotionEffects(EntityLiving entity) {
int i = 100;
int j = 10;
boolean flag = true;
Collection collection = entity.getActivePotionEffects();
if (!collection.isEmpty()) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
int k = 33;
if (collection.size() > 5) {
k = 132 / (collection.size() - 1);
}
for (Iterator iterator = entity.getActivePotionEffects().iterator(); iterator.hasNext(); j += k) {
PotionEffect potioneffect = (PotionEffect) iterator.next();
Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Wrapper.INSTANCE.mc().getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/inventory.png"));
this.drawTexturedModalRect(i, j, 0, 166, 140, 32);
if (potion.hasStatusIcon()) {
int l = potion.getStatusIconIndex();
this.drawTexturedModalRect(i + 6, j + 7, l % 8 * 18, 198 + l / 8 * 18, 18, 18);
}
potion.renderInventoryEffect(i, j, potioneffect, Wrapper.INSTANCE.mc());
String s1 = I18n.format(potion.getName());
s1 += " " + potioneffect.getAmplifier();
Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(s1, i + 10 + 18, j + 6, 16777215);
String s = Potion.getDurationString(potioneffect);
Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(s, i + 10 + 18, j + 6 + 10, 8355711);
}
}
}
private void drawTexturedModalRect(int p_73729_1_, int p_73729_2_, int p_73729_3_, int p_73729_4_, int p_73729_5_, int p_73729_6_) {
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((p_73729_1_), (p_73729_2_ + p_73729_6_), 300f, ((p_73729_3_) * f), ((p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((p_73729_1_ + p_73729_5_), (p_73729_2_ + p_73729_6_), 300f, ((p_73729_3_ + p_73729_5_) * f), ((p_73729_4_ + p_73729_6_) * f1));
tessellator.addVertexWithUV((p_73729_1_ + p_73729_5_), (p_73729_2_), 300f, ((p_73729_3_ + p_73729_5_) * f), ((p_73729_4_) * f1));
tessellator.addVertexWithUV((p_73729_1_), (p_73729_2_), 300f, ((p_73729_3_) * f), ((p_73729_4_) * f1));
tessellator.draw();
}
private List<String> getItemToolTip(ItemStack itemStack) {
if (itemStack == null) {
return new ArrayList<>();
}
@SuppressWarnings("unchecked")
List<String> list = itemStack.getTooltip(Wrapper.INSTANCE.player(), true);
for (int i = 0; i < list.size(); ++i) {
if (i == 0) {
list.set(i, itemStack.getRarity().rarityColor + list.get(i));
} else {
list.set(i, "\u00a77" + list.get(i));
}
}
return list;
}
private int drawHoveringText(List<String> text, int x, int y, FontRenderer font) {
int t = 0;
if (!text.isEmpty()) {
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
int k = 0;
for (String s : text) {
int l = font.getStringWidth(s);
if (l > k) {
k = l;
}
}
int j2 = x;
int k2 = y;
int i1 = 8;
if (text.size() > 1) {
i1 += 2 + (text.size() - 1) * 10;
}
t = i1;
RenderItem.getInstance().zLevel = 300.0F;
int j1 = -267386864;
this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1);
this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1);
this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1);
this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1);
this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1);
int k1 = 1347420415;
int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1);
this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1);
this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1);
this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1);
for (int i2 = 0; i2 < text.size(); ++i2) {
String s1 = text.get(i2);
font.drawStringWithShadow(s1, j2, k2, -1);
if (i2 == 0) {
k2 += 2;
}
k2 += 10;
}
RenderItem.getInstance().zLevel = 0.0F;
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
}
return t;
}
private void drawGradientRect(int p_73733_1_, int p_73733_2_, int p_73733_3_, int p_73733_4_, int p_73733_5_, int p_73733_6_) {
float f = (p_73733_5_ >> 24 & 255) / 255.0F;
float f1 = (p_73733_5_ >> 16 & 255) / 255.0F;
float f2 = (p_73733_5_ >> 8 & 255) / 255.0F;
float f3 = (p_73733_5_ & 255) / 255.0F;
float f4 = (p_73733_6_ >> 24 & 255) / 255.0F;
float f5 = (p_73733_6_ >> 16 & 255) / 255.0F;
float f6 = (p_73733_6_ >> 8 & 255) / 255.0F;
float f7 = (p_73733_6_ & 255) / 255.0F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(f1, f2, f3, f);
tessellator.addVertex(p_73733_3_, p_73733_2_, 300f);
tessellator.addVertex(p_73733_1_, p_73733_2_, 300f);
tessellator.setColorRGBA_F(f5, f6, f7, f4);
tessellator.addVertex(p_73733_1_, p_73733_4_, 300f);
tessellator.addVertex(p_73733_3_, p_73733_4_, 300f);
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
private void drawItemStack(ItemStack itemStack, int x, int y) {
if (itemStack == null) {
return;
}
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemAndEffectIntoGUI(Wrapper.INSTANCE.mc().fontRenderer, Wrapper.INSTANCE.mc().renderEngine, itemStack, x - 8, y);
RenderItem.getInstance().renderItemOverlayIntoGUI(Wrapper.INSTANCE.mc().fontRenderer, Wrapper.INSTANCE.mc().renderEngine, itemStack, x - 8, y);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
}
@Override
public boolean canOnOnStart() {
return true;
}
}
| 13,217 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
DamagePopOffs.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/DamagePopOffs.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.util.damageindicator.Particle;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import java.util.HashMap;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.MathHelper;
import net.minecraftforge.event.entity.living.LivingEvent;
public class DamagePopOffs extends Module {
public DamagePopOffs() {
super(ModuleCategory.RENDER);
}
public HashMap<Integer, Integer> healths = new HashMap<>();
@Override
public void onLiving(LivingEvent.LivingUpdateEvent event) {
updateHealth(event.entityLiving);
}
private void updateHealth(EntityLivingBase el) {
int lastHealth;
int currentHealth = MathHelper.ceiling_float_int(el.getHealth());
if (healths.containsKey(el.getEntityId()) && (lastHealth = healths.get(el.getEntityId())) != 0 && lastHealth != currentHealth) {
int damage = lastHealth - currentHealth;
Particle customParticle = new Particle(Wrapper.INSTANCE.world(), el.posX, el.posY + el.height, el.posZ, 0.001, 0.05f * 1.5f, 0.001, damage);
customParticle.shouldOnTop = true;
if (el != Wrapper.INSTANCE.player() || Wrapper.INSTANCE.mcSettings().thirdPersonView != 0) {
Wrapper.INSTANCE.mc().effectRenderer.addEffect(customParticle);
}
}
healths.put(el.getEntityId(), currentHealth);
}
@Override
public String getName() {
return "DamagePopOffs";
}
@Override
public String getDescription() {
return "Shows damage like DamageIndicators";
}
}
| 1,693 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
CreativeGive.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/CreativeGive.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.ModStatus;
import ehacks.mod.api.Module;
import ehacks.mod.modulesystem.classes.keybinds.GiveKeybind;
import ehacks.mod.util.InteropUtils;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Statics;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
public class CreativeGive
extends Module {
public CreativeGive() {
super(ModuleCategory.EHACKS);
}
@Override
public String getName() {
return "CreativeGive";
}
@Override
public String getDescription() {
return "You can give the selected ItemStack when you are in creative mode\nUsage: \n Numpad0 - perform give";
}
@Override
public void onModuleEnabled() {
}
@Override
public ModStatus getModStatus() {
return ModStatus.DEFAULT;
}
@Override
public void onModuleDisabled() {
}
private boolean prevState = false;
@Override
public void onTicks() {
boolean newState = Keyboard.isKeyDown(GiveKeybind.getKey());
if (newState && !prevState) {
prevState = newState;
int slotId = 36 + Wrapper.INSTANCE.player().inventory.currentItem;
if (Statics.STATIC_ITEMSTACK == null) {
return;
}
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
for (int i = 9; i < 45; i++) {
setCreative(Statics.STATIC_ITEMSTACK, i);
}
} else {
setCreative(Statics.STATIC_ITEMSTACK, slotId);
}
InteropUtils.log("Set", this);
}
prevState = newState;
}
public void setCreative(ItemStack item, int slotId) {
try {
Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new net.minecraft.network.play.client.C10PacketCreativeInventoryAction(slotId, item));
} catch (Exception ex) {
}
}
}
| 2,028 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
FastEat.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/FastEat.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAppleGold;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemPotion;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.network.play.client.C09PacketHeldItemChange;
import org.lwjgl.input.Mouse;
public class FastEat
extends Module {
private final int mode = 0;
public FastEat() {
super(ModuleCategory.PLAYER);
}
@Override
public String getName() {
return "FastEat";
}
@Override
public String getDescription() {
return "You can eat food instantly";
}
@Override
public void onTicks() {
if (this.isActive() && Mouse.getEventButton() == 1 && Mouse.isButtonDown(1)) {
if (this.mode == 1) {
int[] ignoredBlockIds = new int[]{23, 25, 26, 54, 58, 61, 62, 64, 69, 71, 77, 84, 92, 96, 107, 116, 117, 118, 120, 130, 137, 143, 145, 146, 149, 150, 154, 158};
for (int id : ignoredBlockIds) {
if (Block.getIdFromBlock(Wrapper.INSTANCE.world().getBlock(Wrapper.INSTANCE.mc().objectMouseOver.blockX, Wrapper.INSTANCE.mc().objectMouseOver.blockY, Wrapper.INSTANCE.mc().objectMouseOver.blockZ)) != id) {
continue;
}
return;
}
}
if (Wrapper.INSTANCE.player().inventory.getCurrentItem() == null) {
return;
}
Item item = Wrapper.INSTANCE.player().inventory.getCurrentItem().getItem();
if (Wrapper.INSTANCE.player().onGround && (item instanceof ItemFood || item instanceof ItemPotion) && (Wrapper.INSTANCE.player().getFoodStats().needFood() || item instanceof ItemPotion || item instanceof ItemAppleGold)) {
Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C09PacketHeldItemChange(Wrapper.INSTANCE.player().inventory.currentItem));
for (int i = 0; i < 1000; ++i) {
Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C03PacketPlayer(false));
}
Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C07PacketPlayerDigging(5, 0, 0, 0, 255));
}
}
}
}
| 2,516 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
InvisiblePlayer.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/InvisiblePlayer.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
public class InvisiblePlayer
extends Module {
public InvisiblePlayer() {
super(ModuleCategory.PLAYER);
}
@Override
public String getName() {
return "InvisiblePlayer";
}
@Override
public String getDescription() {
return "Makes the player... invisible :)";
}
@Override
public void onTicks() {
Wrapper.INSTANCE.player().setInvisible(true);
}
@Override
public void onModuleDisabled() {
Wrapper.INSTANCE.player().setInvisible(false);
}
}
| 700 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
NBTEdit.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/NBTEdit.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.modulesystem.classes.keybinds.OpenNBTEditKeybind;
import ehacks.mod.util.InteropUtils;
import ehacks.mod.util.Mappings;
import ehacks.mod.util.nbtedit.GuiNBTEdit;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Statics;
import ehacks.mod.wrapper.Wrapper;
import java.lang.reflect.Method;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class NBTEdit extends Module {
public NBTEdit() {
super(ModuleCategory.EHACKS);
}
@Override
public String getName() {
return "NBTEdit";
}
@Override
public String getDescription() {
return "Edit item's nbt\nUsage:\n NBT Edit button - open NBT editor/viewer";
}
private boolean prevState = false;
@Override
public void onTicks() {
boolean newState = Keyboard.isKeyDown(OpenNBTEditKeybind.getKey());
if (newState && !prevState) {
prevState = newState;
GuiScreen screen = Wrapper.INSTANCE.mc().currentScreen;
if (screen != null && screen instanceof GuiContainer) {
try {
ScaledResolution get = new ScaledResolution(Wrapper.INSTANCE.mc(), Wrapper.INSTANCE.mc().displayWidth, Wrapper.INSTANCE.mc().displayHeight);
int mouseX = Mouse.getX() / get.getScaleFactor();
int mouseY = Mouse.getY() / get.getScaleFactor();
GuiContainer container = (GuiContainer) screen;
Method isMouseOverSlot = GuiContainer.class.getDeclaredMethod(Mappings.isMouseOverSlot, Slot.class, Integer.TYPE, Integer.TYPE);
isMouseOverSlot.setAccessible(true);
for (int i = 0; i < container.inventorySlots.inventorySlots.size(); i++) {
if ((Boolean) isMouseOverSlot.invoke(container, container.inventorySlots.inventorySlots.get(i), mouseX, get.getScaledHeight() - mouseY)) {
ItemStack stack = null;
stack = ((Slot) container.inventorySlots.inventorySlots.get(i)) == null ? null : ((Slot) container.inventorySlots.inventorySlots.get(i)).getStack();
if (stack != null) {
Statics.STATIC_NBT = stack.getTagCompound();
}
}
}
} catch (Exception ex) {
InteropUtils.log("&cError", this);
}
}
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
MovingObjectPosition mop = Wrapper.INSTANCE.mc().objectMouseOver;
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
NBTTagCompound tag = new NBTTagCompound();
TileEntity te = Wrapper.INSTANCE.world().getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
if (te != null) {
te.writeToNBT(tag);
Statics.STATIC_NBT = tag;
InteropUtils.log("Read NBT from block x: " + mop.blockX + "; y: " + mop.blockY + "; z: " + mop.blockZ, this);
} else {
InteropUtils.log("Can't read NBT from block - TileEntity not found", this);
return;
}
}
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
NBTTagCompound tag = new NBTTagCompound();
mop.entityHit.writeToNBT(tag);
Statics.STATIC_NBT = tag;
InteropUtils.log("Read NBT from entity " + mop.entityHit, this);
}
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.MISS) {
Statics.STATIC_NBT = null;
InteropUtils.log("NBT has been cleared", this);
return;
}
}
Statics.STATIC_NBT = Statics.STATIC_NBT == null ? new NBTTagCompound() : Statics.STATIC_NBT;
Wrapper.INSTANCE.mc().displayGuiScreen(new GuiNBTEdit(Statics.STATIC_NBT));
}
prevState = newState;
}
@Override
public String getModName() {
return "Minecraft";
}
@Override
public boolean canOnOnStart() {
return true;
}
}
| 4,812 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Nuker.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/Nuker.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.config.CheatConfiguration;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
public class Nuker
extends Module {
public static boolean isActive = false;
public Nuker() {
super(ModuleCategory.PLAYER);
}
@Override
public String getName() {
return "Nuker";
}
@Override
public String getDescription() {
return "Default nuker";
}
@Override
public void onModuleEnabled() {
isActive = true;
}
@Override
public void onModuleDisabled() {
isActive = false;
}
@Override
public void onTicks() {
int radius = CheatConfiguration.config.nukerradius;
block6:
{
block7:
{
if (!Wrapper.INSTANCE.mc().playerController.isInCreativeMode()) {
break block7;
}
for (int i = radius; i >= -radius; --i) {
for (int k = radius; k >= -radius; --k) {
for (int j = -radius; j <= radius; ++j) {
int x = (int) (Wrapper.INSTANCE.player().posX + i);
int y = (int) (Wrapper.INSTANCE.player().posY + j);
int z = (int) (Wrapper.INSTANCE.player().posZ + k);
Block blockID = Wrapper.INSTANCE.world().getBlock(x, y, z);
if (blockID.getMaterial() == Material.air) {
continue;
}
Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C07PacketPlayerDigging(0, x, y, z, 0));
}
}
}
break block6;
}
if (!Wrapper.INSTANCE.mc().playerController.isNotCreative()) {
break block6;
}
for (int i = radius; i >= -radius; --i) {
for (int k = radius; k >= -radius; --k) {
for (int j = -radius; j <= radius; ++j) {
int x = (int) (Wrapper.INSTANCE.player().posX + i);
int y = (int) (Wrapper.INSTANCE.player().posY + j);
int z = (int) (Wrapper.INSTANCE.player().posZ + k);
Block block = Wrapper.INSTANCE.world().getBlock(x, y, z);
if (block.getMaterial() == Material.air) {
continue;
}
Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C07PacketPlayerDigging(0, x, y, z, 0));
Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C07PacketPlayerDigging(2, x, y, z, 0));
}
}
}
}
}
}
| 3,067 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ChestFinder.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/ChestFinder.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.util.GLUtils;
import ehacks.mod.util.axis.AltAxisAlignedBB;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityEnderChest;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
public class ChestFinder
extends Module {
public ChestFinder() {
super(ModuleCategory.RENDER);
}
@Override
public String getName() {
return "ChestFinder";
}
@Override
public String getDescription() {
return "Shows all chests around you";
}
@Override
public void onWorldRender(RenderWorldLastEvent event) {
for (Object o : Wrapper.INSTANCE.world().loadedTileEntityList) {
double renderY;
AltAxisAlignedBB boundingBox;
double renderX;
TileEntityChest chest;
double renderZ;
if (o instanceof TileEntityChest) {
chest = (TileEntityChest) o;
renderX = chest.xCoord - RenderManager.renderPosX;
renderY = chest.yCoord - RenderManager.renderPosY;
renderZ = chest.zCoord - RenderManager.renderPosZ;
GL11.glPushMatrix();
GL11.glTranslated(renderX, renderY, renderZ);
GL11.glColor3f(1.0f, 1.0f, 0.0f);
if (chest.adjacentChestXPos != null) {
boundingBox = AltAxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 2.0, 1.0, 1.0);
GL11.glColor4f(1.0f, 1.0f, 0.0f, 0.1f);
GLUtils.startDrawingESPs(boundingBox, 0.3f, 0.8f, 1.0f);
} else if (chest.adjacentChestZPos != null) {
boundingBox = AltAxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 2.0);
GL11.glColor4f(1.0f, 1.0f, 0.0f, 0.1f);
GLUtils.startDrawingESPs(boundingBox, 0.3f, 0.8f, 1.0f);
} else if (chest.adjacentChestXNeg == null && chest.adjacentChestZNeg == null) {
boundingBox = AltAxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
GL11.glColor4f(1.0f, 1.0f, 0.0f, 0.1f);
GLUtils.startDrawingESPs(boundingBox, 0.3f, 0.8f, 1.0f);
}
GL11.glPopMatrix();
continue;
}
if (!(o instanceof TileEntityEnderChest)) {
continue;
}
TileEntityEnderChest chestEnder = (TileEntityEnderChest) o;
renderX = chestEnder.xCoord - RenderManager.renderPosX;
renderY = chestEnder.yCoord - RenderManager.renderPosY;
renderZ = chestEnder.zCoord - RenderManager.renderPosZ;
GL11.glPushMatrix();
GL11.glTranslated(renderX, renderY, renderZ);
GL11.glColor3f(1.0f, 1.0f, 0.0f);
boundingBox = AltAxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
GL11.glColor4f(1.0f, 1.0f, 0.0f, 0.1f);
GLUtils.startDrawingESPs(boundingBox, 0.3f, 0.0f, 0.5f);
GL11.glPopMatrix();
}
}
}
| 3,327 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
MobESP.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/MobESP.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.util.GLUtils;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import java.util.List;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import static net.minecraft.client.renderer.entity.RenderManager.renderPosX;
import static net.minecraft.client.renderer.entity.RenderManager.renderPosY;
import static net.minecraft.client.renderer.entity.RenderManager.renderPosZ;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
public class MobESP
extends Module {
public MobESP() {
super(ModuleCategory.RENDER);
}
@Override
public String getName() {
return "MobESP";
}
@Override
public String getDescription() {
return "Allows you to see all mobs around you";
}
@Override
public void onWorldRender(RenderWorldLastEvent event) {
if (!GLUtils.hasClearedDepth) {
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GLUtils.hasClearedDepth = true;
}
@SuppressWarnings("unchecked")
List<Entity> entities = Wrapper.INSTANCE.world().loadedEntityList;
entities.stream().filter((ent) -> !(!(ent instanceof EntityLivingBase))).filter((ent) -> !(ent == Wrapper.INSTANCE.player())).filter((ent) -> !(!ent.isInRangeToRender3d(Wrapper.INSTANCE.mc().renderViewEntity.getPosition(event.partialTicks).xCoord, Wrapper.INSTANCE.mc().renderViewEntity.getPosition(event.partialTicks).yCoord, Wrapper.INSTANCE.mc().renderViewEntity.getPosition(event.partialTicks).zCoord) || ent == Wrapper.INSTANCE.mc().renderViewEntity && Wrapper.INSTANCE.mcSettings().thirdPersonView == 0 && !Wrapper.INSTANCE.mc().renderViewEntity.isPlayerSleeping())).forEachOrdered((ent) -> {
double xPos = ent.lastTickPosX + (ent.posX - ent.lastTickPosX) * event.partialTicks;
double yPos = ent.lastTickPosY + (ent.posY - ent.lastTickPosY) * event.partialTicks;
double zPos = ent.lastTickPosZ + (ent.posZ - ent.lastTickPosZ) * event.partialTicks;
float f1 = ent.prevRotationYaw + (ent.rotationYaw - ent.prevRotationYaw) * event.partialTicks;
RenderHelper.enableStandardItemLighting();
//RenderManager.instance.renderEntitySimple(ent, event.partialTicks);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderManager.instance.func_147939_a(ent, xPos - renderPosX, yPos - renderPosY, zPos - renderPosZ, f1, event.partialTicks, false);
});
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
Wrapper.INSTANCE.world().loadedEntityList.stream().map((o) -> (Entity) o).filter((entObj) -> !(!(entObj instanceof EntityLivingBase))).map((entObj) -> (EntityLivingBase) entObj).map((ent) -> {
float labelScale = 0.04F;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.glDisable(GL11.GL_DEPTH_TEST);
//GL11.glDepthMask(false);
Entity entity = (Entity) ent;
double xPos = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * event.partialTicks;
double yPos = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * event.partialTicks;
double zPos = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * event.partialTicks;
double xEnd = xPos - RenderManager.renderPosX;
double yEnd = yPos + entity.height / 2 - RenderManager.renderPosY;
double zEnd = zPos - RenderManager.renderPosZ;
GL11.glTranslatef((float) xEnd, (float) yEnd + entity.height / 2 + .8f, (float) zEnd);
GL11.glRotatef(-RenderManager.instance.playerViewY, 0, 1, 0);
GL11.glRotatef(RenderManager.instance.playerViewX, 1, 0, 0);
GL11.glScalef(-labelScale, -labelScale, labelScale);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
return ent;
}).map((ent) -> {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
return ent;
}).map((ent) -> {
GLUtils.drawRect(-26f, -1f, 26f, 12f, GLUtils.getColor(255, 64, 64, 64));
return ent;
}).map((ent) -> {
GL11.glTranslatef(0f, 0f, -0.1f);
return ent;
}).map((ent) -> {
EntityLivingBase entity = (EntityLivingBase) ent;
GLUtils.drawRect(-25f, 6f, -25f + (50f * entity.getHealth() / entity.getMaxHealth()), 11f, GLUtils.getColor(255, 0, 255, 0));
return ent;
}).map((ent) -> {
EntityLivingBase entity = (EntityLivingBase) ent;
GLUtils.drawRect(-25f + (50f * entity.getHealth() / entity.getMaxHealth()), 6f, 25f, 11f, GLUtils.getColor(255, 255, 0, 0));
return ent;
}).map((ent) -> {
GL11.glScalef(Wrapper.INSTANCE.fontRenderer().FONT_HEIGHT / 17f, Wrapper.INSTANCE.fontRenderer().FONT_HEIGHT / 17f, 1f);
return ent;
}).map((ent) -> {
GL11.glTranslatef(0f, 0f, -0.1f);
return ent;
}).map((ent) -> {
EntityLivingBase entity = (EntityLivingBase) ent;
Wrapper.INSTANCE.fontRenderer().drawString(String.format("%.2f", Math.round(entity.getHealth() * 100) / 100f), -Wrapper.INSTANCE.fontRenderer().getStringWidth(String.format("%.2f", Math.round(entity.getHealth() * 100) / 100f)) / 2, 12, GLUtils.getColor(255, 255, 255, 255), true);
return ent;
}).map((ent) -> {
Entity entity = (Entity) ent;
Wrapper.INSTANCE.fontRenderer().drawString(String.valueOf(entity.getCommandSenderName()), -47, 1, GLUtils.getColor(255, 255, 255, 255), true);
return ent;
}).forEachOrdered((_item) -> {
GL11.glPopMatrix();
});
}
}
| 6,453 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Breadcrumb.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/Breadcrumb.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import java.util.concurrent.CopyOnWriteArrayList;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
public class Breadcrumb
extends Module {
public static CopyOnWriteArrayList<double[]> positionsList = new CopyOnWriteArrayList<>();
static int count = 0;
public Breadcrumb() {
super(ModuleCategory.RENDER);
}
@Override
public String getName() {
return "Breadcrumb";
}
@Override
public String getDescription() {
return "Draws a line behind you";
}
@Override
public void onTicks() {
if (this.isActive()) {
if (++count >= 50) {
count = 0;
if (positionsList.size() > 5) {
positionsList.remove(0);
}
}
Wrapper.INSTANCE.world().playerEntities.forEach((o) -> {
EntityPlayer player1;
if (!(!(o instanceof EntityPlayer) || !((player1 = (EntityPlayer) o) == Wrapper.INSTANCE.player() && (Wrapper.INSTANCE.player().movementInput.moveForward != 0.0f || Wrapper.INSTANCE.player().movementInput.moveStrafe != 0.0f)))) {
double x = RenderManager.renderPosX;
double y = RenderManager.renderPosY;
double z = RenderManager.renderPosZ;
positionsList.add(new double[]{x, y - player1.height, z});
}
});
}
}
private static double posit(double val) {
return val == 0.0 ? val : (val < 0.0 ? val * -1.0 : val);
}
@Override
public void onWorldRender(RenderWorldLastEvent event) {
GL11.glPushMatrix();
GL11.glLineWidth(2.0f);
GL11.glDisable(3553);
GL11.glDisable(2896);
GL11.glBlendFunc(770, 771);
GL11.glEnable(2848);
GL11.glEnable(3042);
GL11.glDisable(2929);
GL11.glBegin(3);
positionsList.forEach((pos) -> {
double distance = Breadcrumb.posit(Math.hypot(pos[0] - RenderManager.renderPosX, pos[1] - RenderManager.renderPosY));
if (!(distance > 100.0)) {
GL11.glColor4f(0.0f, 1.0f, 0.0f, (1.0f - (float) (distance / 100.0)));
GL11.glVertex3d((pos[0] - RenderManager.renderPosX), (pos[1] - RenderManager.renderPosY), (pos[2] - RenderManager.renderPosZ));
}
});
GL11.glEnd();
GL11.glEnable(2929);
GL11.glDisable(2848);
GL11.glDisable(3042);
GL11.glEnable(3553);
GL11.glEnable(2896);
GL11.glPopMatrix();
}
}
| 2,877 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
NCPStep.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/NCPStep.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
public class NCPStep
extends Module {
public NCPStep() {
super(ModuleCategory.NOCHEATPLUS);
}
@Override
public String getName() {
return "NCPStep";
}
@Override
public String getDescription() {
return "Step for NoCheatPlus";
}
@Override
public void onTicks() {
if (Wrapper.INSTANCE.player().onGround && Wrapper.INSTANCE.player().isCollidedHorizontally && !Wrapper.INSTANCE.player().isInWater()) {
Wrapper.INSTANCE.player().boundingBox.offset(0.0, 1.0628, 0.0);
Wrapper.INSTANCE.player().motionY = -420.0;
Wrapper.INSTANCE.player().isCollidedHorizontally = false;
}
}
}
| 858 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
PacketLogger.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/PacketLogger.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.packetlogger.Gui;
import ehacks.mod.packetlogger.PacketHandler;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.PacketHandler.Side;
public class PacketLogger
extends Module {
private final Gui gui;
private final PacketHandler handler;
public PacketLogger() {
super(ModuleCategory.EHACKS);
gui = new Gui();
handler = new PacketHandler(gui);
}
@Override
public String getName() {
return "PacketLogger";
}
@Override
public String getDescription() {
return "Allows you to see all out- and incoming packets (c) N1nt3nd0";
}
@Override
public void onModuleEnabled() {
gui.setVisible(true);
}
@Override
public void onModuleDisabled() {
gui.setVisible(false);
}
@Override
public void onTicks() {
if (!gui.isVisible()) {
this.off();
}
}
@Override
public boolean onPacket(Object packet, Side side) {
try {
if (side == Side.IN && !handler.handlePacket(packet, null, PacketHandler.inBlackList)) {
return false;
}
if (side == Side.OUT && !handler.handlePacket(packet, null, PacketHandler.outBlackList)) {
return false;
}
handler.handlePacket(packet, side, PacketHandler.logBlackList);
} catch (Exception ex) {
}
return true;
}
}
| 1,546 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Step.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/Step.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
public class Step
extends Module {
public Step() {
super(ModuleCategory.PLAYER);
}
@Override
public String getName() {
return "Step";
}
@Override
public String getDescription() {
return "Allows you to walk on 2 blocks height";
}
@Override
public void onTicks() {
Wrapper.INSTANCE.player().stepHeight = 2;
}
@Override
public void onModuleDisabled() {
Wrapper.INSTANCE.player().stepHeight = 0.5f;
}
}
| 666 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Blink.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/Blink.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.util.EntityFakePlayer;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.PacketHandler;
import ehacks.mod.wrapper.Wrapper;
public class Blink
extends Module {
public EntityFakePlayer freecamEnt = null;
public Blink() {
super(ModuleCategory.PLAYER);
}
@Override
public String getName() {
return "Blink";
}
@Override
public String getDescription() {
return "Allows you to move without sending it to the server";
}
@Override
public void onModuleEnabled() {
if (Wrapper.INSTANCE.player() != null && Wrapper.INSTANCE.world() != null) {
this.freecamEnt = new EntityFakePlayer(Wrapper.INSTANCE.world(), Wrapper.INSTANCE.player().getGameProfile());
this.freecamEnt.setPosition(Wrapper.INSTANCE.player().posX, Wrapper.INSTANCE.player().posY, Wrapper.INSTANCE.player().posZ);
this.freecamEnt.inventory = Wrapper.INSTANCE.player().inventory;
this.freecamEnt.yOffset = Wrapper.INSTANCE.player().yOffset;
this.freecamEnt.ySize = Wrapper.INSTANCE.player().ySize;
this.freecamEnt.rotationPitch = Wrapper.INSTANCE.player().rotationPitch;
this.freecamEnt.rotationYaw = Wrapper.INSTANCE.player().rotationYaw;
this.freecamEnt.rotationYawHead = Wrapper.INSTANCE.player().rotationYawHead;
Wrapper.INSTANCE.world().spawnEntityInWorld(this.freecamEnt);
}
}
@Override
public void onModuleDisabled() {
if (this.freecamEnt != null && Wrapper.INSTANCE.world() != null) {
Wrapper.INSTANCE.world().removeEntity(this.freecamEnt);
this.freecamEnt = null;
}
}
@Override
public void onTicks() {
}
@Override
public boolean onPacket(Object packet, PacketHandler.Side side) {
return !(side == PacketHandler.Side.OUT && packet instanceof net.minecraft.network.play.client.C03PacketPlayer);
}
@Override
public boolean canOnOnStart() {
return false;
}
}
| 2,150 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ItemESP.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/ItemESP.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.util.GLUtils;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import java.util.List;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import static net.minecraft.client.renderer.entity.RenderManager.renderPosX;
import static net.minecraft.client.renderer.entity.RenderManager.renderPosY;
import static net.minecraft.client.renderer.entity.RenderManager.renderPosZ;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
public class ItemESP
extends Module {
public ItemESP() {
super(ModuleCategory.RENDER);
}
@Override
public String getName() {
return "ItemESP";
}
@Override
public String getDescription() {
return "Allows you to see all items around you";
}
@Override
public void onWorldRender(RenderWorldLastEvent event) {
if (!GLUtils.hasClearedDepth) {
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GLUtils.hasClearedDepth = true;
}
@SuppressWarnings("unchecked")
List<Entity> entities = Wrapper.INSTANCE.world().loadedEntityList;
entities.stream().filter((ent) -> !(!(ent instanceof EntityItem))).filter((ent) -> !(ent == Wrapper.INSTANCE.mc().renderViewEntity && Wrapper.INSTANCE.mcSettings().thirdPersonView == 0 && !Wrapper.INSTANCE.mc().renderViewEntity.isPlayerSleeping())).forEachOrdered((ent) -> {
double xPos = ent.lastTickPosX + (ent.posX - ent.lastTickPosX) * event.partialTicks;
double yPos = ent.lastTickPosY + (ent.posY - ent.lastTickPosY) * event.partialTicks;
double zPos = ent.lastTickPosZ + (ent.posZ - ent.lastTickPosZ) * event.partialTicks;
float f1 = ent.prevRotationYaw + (ent.rotationYaw - ent.prevRotationYaw) * event.partialTicks;
RenderHelper.enableStandardItemLighting();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderManager.instance.func_147939_a(ent, xPos - renderPosX, yPos - renderPosY, zPos - renderPosZ, f1, event.partialTicks, false);
this.renderDebugBoundingBox(ent, xPos - renderPosX, yPos - renderPosY, zPos - renderPosZ, f1, event.partialTicks);
});
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
Wrapper.INSTANCE.world().loadedEntityList.stream().map((o) -> (Entity) o).filter((entObj) -> !(!(entObj instanceof EntityItem))).map((entObj) -> (EntityItem) entObj).map((ent) -> {
float labelScale = 0.04F;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Entity entity = (Entity) ent;
double xPos = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * event.partialTicks;
double yPos = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * event.partialTicks;
double zPos = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * event.partialTicks;
double xEnd = xPos - RenderManager.renderPosX;
double yEnd = yPos + entity.height / 2 - RenderManager.renderPosY;
double zEnd = zPos - RenderManager.renderPosZ;
GL11.glTranslatef((float) xEnd, (float) yEnd + entity.height / 2 + .3f, (float) zEnd);
GL11.glRotatef(-RenderManager.instance.playerViewY, 0, 1, 0);
GL11.glRotatef(RenderManager.instance.playerViewX, 1, 0, 0);
GL11.glScalef(-labelScale, -labelScale, labelScale);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
return ent;
}).map((ent) -> {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
return ent;
}).map((ent) -> {
GL11.glScalef(.7f, .7f, 1f);
return ent;
}).map((ent) -> {
EntityItem entity = (EntityItem) ent;
Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(entity.getEntityItem().stackSize + "x[" + entity.getEntityItem().getRarity().rarityColor + entity.getEntityItem().getDisplayName() + "\u00a7f]", -Wrapper.INSTANCE.fontRenderer().getStringWidth(entity.getEntityItem().stackSize + "x[" + entity.getEntityItem().getDisplayName() + "]") / 2, 0, GLUtils.getColor(255, 255, 255));
return ent;
}).forEachOrdered((_item) -> {
GL11.glPopMatrix();
});
}
private void renderDebugBoundingBox(Entity p_85094_1_, double p_85094_2_, double p_85094_4_, double p_85094_6_, float p_85094_8_, float p_85094_9_) {
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
float f2 = p_85094_1_.width / 2.0F;
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(p_85094_2_ - f2, p_85094_4_, p_85094_6_ - f2, p_85094_2_ + f2, p_85094_4_ + p_85094_1_.height, p_85094_6_ + f2);
GL11.glLineWidth(1f);
RenderGlobal.drawOutlinedBoundingBox(axisalignedbb, 16777215);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
}
}
| 5,970 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Sprint.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/Sprint.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
public class Sprint
extends Module {
public Sprint() {
super(ModuleCategory.PLAYER);
}
@Override
public String getName() {
return "Sprint";
}
@Override
public String getDescription() {
return "Sprints automatically when you should be walking";
}
@Override
public void onTicks() {
if (Wrapper.INSTANCE.player().moveForward > 0.0f) {
Wrapper.INSTANCE.player().setSprinting(true);
}
}
}
| 650 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
VisualCreative.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/VisualCreative.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.world.WorldSettings;
/**
*
* @author radioegor146
*/
public class VisualCreative extends Module {
public VisualCreative() {
super(ModuleCategory.EHACKS);
}
@Override
public String getName() {
return "VisualCreative";
}
@Override
public String getDescription() {
return "Gives you visual creative mode";
}
@Override
public void onModuleEnabled() {
Wrapper.INSTANCE.mc().playerController.setGameType(WorldSettings.GameType.CREATIVE);
WorldSettings.GameType.CREATIVE.configurePlayerCapabilities(Wrapper.INSTANCE.player().capabilities);
Wrapper.INSTANCE.player().sendPlayerAbilities();
}
@Override
public void onModuleDisabled() {
Wrapper.INSTANCE.mc().playerController.setGameType(WorldSettings.GameType.SURVIVAL);
WorldSettings.GameType.CREATIVE.configurePlayerCapabilities(Wrapper.INSTANCE.player().capabilities);
Wrapper.INSTANCE.player().sendPlayerAbilities();
}
}
| 1,366 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ProphuntAura.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/ProphuntAura.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
public class ProphuntAura
extends Module {
public static boolean isActive = false;
private long currentMS = 0L;
private long lastMS = -1L;
public ProphuntAura() {
super(ModuleCategory.MINIGAMES);
}
@Override
public String getName() {
return "ProphuntAura";
}
@Override
public String getDescription() {
return "Prophunt aura";
}
@Override
public void onModuleEnabled() {
isActive = true;
}
@Override
public void onModuleDisabled() {
isActive = false;
}
private boolean hasDelayRun(long time) {
return this.currentMS - this.lastMS >= time;
}
@Override
public void onTicks() {
block6:
{
try {
this.currentMS = System.nanoTime() / 980000L;
if (!this.hasDelayRun(133L)) {
break block6;
}
for (Object o : Wrapper.INSTANCE.world().loadedEntityList) {
if (!(o instanceof EntityFallingBlock)) {
continue;
}
EntityFallingBlock e = (EntityFallingBlock) o;
if (Wrapper.INSTANCE.player().getDistanceToEntity(e) > 6 || e.isDead) {
continue;
}
if (AutoBlock.isActive && Wrapper.INSTANCE.player().getCurrentEquippedItem() != null && Wrapper.INSTANCE.player().getCurrentEquippedItem().getItem() instanceof ItemSword) {
ItemStack lel = Wrapper.INSTANCE.player().getCurrentEquippedItem();
lel.useItemRightClick(Wrapper.INSTANCE.world(), Wrapper.INSTANCE.player());
}
if (Criticals.isActive && !Wrapper.INSTANCE.player().isInWater() && !Wrapper.INSTANCE.player().isInsideOfMaterial(Material.lava) && !Wrapper.INSTANCE.player().isInsideOfMaterial(Material.web) && Wrapper.INSTANCE.player().onGround) {
Wrapper.INSTANCE.player().motionY = 0.1000000014901161;
Wrapper.INSTANCE.player().fallDistance = 0.1f;
Wrapper.INSTANCE.player().onGround = false;
}
if (AimBot.isActive) {
AimBot.faceEntity(e);
}
Wrapper.INSTANCE.player().setSprinting(false);
Wrapper.INSTANCE.player().swingItem();
Wrapper.INSTANCE.mc().playerController.attackEntity(Wrapper.INSTANCE.player(), e);
this.lastMS = System.nanoTime() / 980000L;
break;
}
} catch (Exception e) {
}
}
}
}
| 3,085 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
NCPFly.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/NCPFly.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.network.play.client.*;
public class NCPFly
extends Module {
public NCPFly() {
super(ModuleCategory.NOCHEATPLUS);
}
@Override
public String getName() {
return "NCPFly";
}
@Override
public String getDescription() {
return "Fly for NoCheatPlus";
}
@Override
public void onModuleEnabled() {
for (int i = 0; i < 4; ++i) {
Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(Wrapper.INSTANCE.player().posX, Wrapper.INSTANCE.player().boundingBox.minY + 1.01, Wrapper.INSTANCE.player().posY + 1.01, Wrapper.INSTANCE.player().posZ, false));
Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(Wrapper.INSTANCE.player().posX, Wrapper.INSTANCE.player().boundingBox.minY, Wrapper.INSTANCE.player().posY, Wrapper.INSTANCE.player().posZ, false));
}
Wrapper.INSTANCE.player().setPosition(Wrapper.INSTANCE.player().posX, Wrapper.INSTANCE.player().posY + 0.8, Wrapper.INSTANCE.player().posZ);
}
@Override
public void onTicks() {
Wrapper.INSTANCE.player().motionY = -0.04;
if (Wrapper.INSTANCE.mcSettings().keyBindJump.getIsKeyPressed()) {
Wrapper.INSTANCE.player().motionY = 0.3;
}
if (Wrapper.INSTANCE.mcSettings().keyBindSneak.getIsKeyPressed()) {
Wrapper.INSTANCE.player().motionY = -0.3;
}
}
}
| 1,651 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
KillAura.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/vanilla/KillAura.java | package ehacks.mod.modulesystem.classes.vanilla;
import ehacks.mod.api.Module;
import ehacks.mod.config.AuraConfiguration;
import ehacks.mod.config.CheatConfiguration;
import ehacks.mod.wrapper.ModuleCategory;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.block.material.Material;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
public class KillAura
extends Module {
public static boolean isActive = false;
private long currentMS = 0L;
private long lastMS = -1L;
public KillAura() {
super(ModuleCategory.COMBAT);
}
@Override
public String getName() {
return "KillAura";
}
@Override
public String getDescription() {
return "Just killaura";
}
@Override
public void onModuleEnabled() {
isActive = true;
}
@Override
public void onModuleDisabled() {
isActive = false;
}
public boolean hasDelayRun(long time) {
return this.currentMS - this.lastMS >= time;
}
@Override
public void onTicks() {
block6:
{
try {
this.currentMS = System.nanoTime() / 900000L;
if (!this.hasDelayRun(133L)) {
break block6;
}
for (Object o : Wrapper.INSTANCE.world().loadedEntityList) {
EntityPlayer e;
if (!(o instanceof EntityPlayer) || (e = (EntityPlayer) o) instanceof EntityPlayerSP || Wrapper.INSTANCE.player().getDistanceToEntity(e) > CheatConfiguration.config.auraradius || e.isDead) {
continue;
}
if (AuraConfiguration.config.friends.contains(e.getCommandSenderName().trim())) {
continue;
}
if (AutoBlock.isActive && Wrapper.INSTANCE.player().getCurrentEquippedItem() != null && Wrapper.INSTANCE.player().getCurrentEquippedItem().getItem() instanceof ItemSword) {
ItemStack lel = Wrapper.INSTANCE.player().getCurrentEquippedItem();
lel.useItemRightClick(Wrapper.INSTANCE.world(), Wrapper.INSTANCE.player());
}
if (Criticals.isActive && !Wrapper.INSTANCE.player().isInWater() && !Wrapper.INSTANCE.player().isInsideOfMaterial(Material.lava) && !Wrapper.INSTANCE.player().isInsideOfMaterial(Material.web) && Wrapper.INSTANCE.player().onGround) {
Wrapper.INSTANCE.player().motionY = 0.1000000014901161;
Wrapper.INSTANCE.player().fallDistance = 0.1f;
Wrapper.INSTANCE.player().onGround = false;
}
if (AimBot.isActive) {
AimBot.faceEntity(e);
}
Wrapper.INSTANCE.player().setSprinting(false);
Wrapper.INSTANCE.player().swingItem();
Wrapper.INSTANCE.mc().playerController.attackEntity(Wrapper.INSTANCE.player(), e);
this.lastMS = System.nanoTime() / 900000L;
break;
}
} catch (Exception ex) {
}
}
}
}
| 3,334 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
MainProtector.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/packetprotector/MainProtector.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.packetprotector;
import ehacks.mod.packetprotector.modules.*;
import ehacks.mod.util.InteropUtils;
import ehacks.mod.wrapper.PacketHandler;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author radioegor146
*/
public class MainProtector {
public List<IPacketProtector> protectors = new ArrayList();
public void init() {
protectors.clear();
protectors.add(new DragonsRadioProtector());
protectors.add(new IC2NuclearControlProtector());
protectors.add(new NanoNikProtector());
InteropUtils.log("Inited " + protectors.size() + " protectors", "PacketProtector");
}
public boolean isPacketOk(Object packet, PacketHandler.Side side) {
boolean ok = true;
ok = protectors.stream().map((protector) -> protector.isPacketOk(packet, side)).reduce(ok, (accumulator, _item) -> accumulator & _item);
return ok;
}
}
| 1,111 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
IPacketProtector.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/packetprotector/IPacketProtector.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.packetprotector;
import ehacks.mod.wrapper.PacketHandler;
/**
*
* @author radioegor146
*/
public interface IPacketProtector {
boolean isPacketOk(Object packet, PacketHandler.Side side);
}
| 402 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
IC2NuclearControlProtector.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/packetprotector/modules/IC2NuclearControlProtector.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.packetprotector.modules;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import ehacks.mod.packetprotector.IPacketProtector;
import ehacks.mod.wrapper.PacketHandler;
import ehacks.mod.wrapper.Wrapper;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.Unpooled;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.util.HashMap;
import java.util.zip.InflaterInputStream;
/**
*
* @author radioegor146
*/
public class IC2NuclearControlProtector implements IPacketProtector {
@Override
public boolean isPacketOk(Object packet, PacketHandler.Side side) {
try {
if (packet instanceof FMLProxyPacket && "ic2".equals(((FMLProxyPacket) packet).channel()) && side == PacketHandler.Side.IN) {
FMLProxyPacket fmlPacket = (FMLProxyPacket) packet;
ByteBuf buf = Unpooled.copiedBuffer(fmlPacket.payload());
DataInputStream is = new DataInputStream(new ByteBufInputStream(buf));
if (is.read() != 0) {
return true;
}
int state = is.read();
if ((state >> 2) != 0) {
return true;
}
ByteArrayOutputStream largePacketBuffer = new ByteArrayOutputStream();
if ((state & 1) != 0) {
largePacketBuffer = new ByteArrayOutputStream(16384);
}
byte[] buffer = new byte[4096];
int len;
while ((len = is.read(buffer)) != -1) {
largePacketBuffer.write(buffer, 0, len);
}
if ((state & 2) == 0) {
return true;
}
ByteArrayInputStream inflateInput = new ByteArrayInputStream(largePacketBuffer.toByteArray());
ByteArrayOutputStream inflateBuffer;
try (InflaterInputStream inflate = new InflaterInputStream(inflateInput)) {
inflateBuffer = new ByteArrayOutputStream(16384);
while ((len = inflate.read(buffer)) != -1) {
inflateBuffer.write(buffer, 0, len);
}
}
byte[] subData = inflateBuffer.toByteArray();
DataInputStream nis = new DataInputStream(new ByteArrayInputStream(subData));
if (nis.readInt() != Wrapper.INSTANCE.player().dimension) {
return true;
}
int x = nis.readInt();
int y = nis.readInt();
int z = nis.readInt();
byte[] fieldData = new byte[nis.readInt()];
nis.readFully(fieldData);
ByteArrayInputStream fieldDataBuffer = new ByteArrayInputStream(fieldData);
DataInputStream fieldDataStream = new DataInputStream(fieldDataBuffer);
HashMap<String, Object> fieldValues = new HashMap();
do {
String fieldName = null;
try {
fieldName = fieldDataStream.readUTF();
} catch (EOFException e) {
break;
}
Object value = Class.forName("ic2.core.network.DataEncoder").getMethod("decode", DataInputStream.class).invoke(null, fieldDataStream);
if ("colorBackground".equals(fieldName) && (((Integer) value) > 15 || ((Integer) value) < 0)) {
return false;
}
if ("colorText".equals(fieldName) && (((Integer) value) > 15 || ((Integer) value) < 0)) {
return false;
}
fieldValues.put(fieldName, value);
} while (true);
return true;
} else {
return true;
}
} catch (Exception e) {
return false;
}
}
}
| 4,298 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
NanoNikProtector.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/packetprotector/modules/NanoNikProtector.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.packetprotector.modules;
import ehacks.mod.packetprotector.IPacketProtector;
import ehacks.mod.util.InteropUtils;
import ehacks.mod.wrapper.PacketHandler;
import ehacks.mod.wrapper.Wrapper;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.Unpooled;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import net.minecraft.network.play.client.C17PacketCustomPayload;
/**
*
* @author radioegor146
*/
public class NanoNikProtector implements IPacketProtector {
@Override
public boolean isPacketOk(Object packet, PacketHandler.Side side) {
try {
if (packet instanceof C17PacketCustomPayload && "nGuard".equals(((C17PacketCustomPayload) packet).func_149559_c()) && side == PacketHandler.Side.OUT) {
ByteBuf buf = Unpooled.copiedBuffer(((C17PacketCustomPayload) packet).func_149558_e());
DataInputStream is = new DataInputStream(new ByteBufInputStream(buf));
String data = is.readUTF();
String aim = data.split(";")[0];
if (data.split(";")[1].equals("https://i.imgur.com/BqOhWwR.png")) {
return true;
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream outputStream = new DataOutputStream(bos);
outputStream.writeUTF(aim + ";https://i.imgur.com/BqOhWwR.png");
Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C17PacketCustomPayload("nGuard", bos.toByteArray()));
InteropUtils.log(String.format("You have been screened with aim: '%s'; Admins have been flek$$ed!", aim), "NanoNikGuard");
return false;
} else {
return true;
}
} catch (Exception e) {
return false;
}
}
}
| 2,115 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
DragonsRadioProtector.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/packetprotector/modules/DragonsRadioProtector.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.packetprotector.modules;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import ehacks.mod.packetprotector.IPacketProtector;
import ehacks.mod.wrapper.PacketHandler;
import ehacks.mod.wrapper.Wrapper;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.tileentity.TileEntity;
/**
*
* @author radioegor146
*/
public class DragonsRadioProtector implements IPacketProtector {
@Override
public boolean isPacketOk(Object packet, PacketHandler.Side side) {
try {
if (packet instanceof FMLProxyPacket && "DragonsRadioMod".equals(((FMLProxyPacket) packet).channel()) && side == PacketHandler.Side.IN) {
FMLProxyPacket fmlPacket = (FMLProxyPacket) packet;
ByteBuf buf = Unpooled.copiedBuffer(fmlPacket.payload());
if (buf.readByte() != 0) {
return true;
}
buf.readInt();
TileEntity entity = Wrapper.INSTANCE.world().getTileEntity((int) buf.readDouble(), (int) buf.readDouble(), (int) buf.readDouble());
return !(entity == null || !Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.TileEntity.TileEntityRadio").isInstance(entity));
} else {
return true;
}
} catch (Exception e) {
return false;
}
}
}
| 1,593 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ConsoleGui.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/commands/ConsoleGui.java | package ehacks.mod.commands;
import com.google.common.collect.Lists;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ChatLine;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.MathHelper;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class ConsoleGui extends Gui {
private final Minecraft mc;
/**
* A list of messages previously sent through the chat GUI
*/
private final List<String> sentMessages = new ArrayList<>();
/**
* Chat lines to be displayed in the chat box
*/
private final List<ChatLine> chatLines = new ArrayList<>();
private final List<ChatLine> drawnChatLines = new ArrayList<>();
private int scrollPos;
private boolean isScrolled;
private static final String __OBFID = "CL_00000669";
public ConsoleGui(Minecraft p_i1022_1_) {
this.mc = p_i1022_1_;
}
private double prevWidth = 0;
public void drawChat(int tickid) {
if (prevWidth != this.mc.gameSettings.chatWidth) {
prevWidth = this.mc.gameSettings.chatWidth;
refreshChat();
}
int j = this.getLineCount();
boolean flag = false;
int k = 0;
int l = this.drawnChatLines.size();
float f = this.mc.gameSettings.chatOpacity * 0.9F + 0.1F;
if (l > 0) {
if (this.getChatOpen()) {
flag = true;
}
float f1 = this.getChatScale();
int i1 = MathHelper.ceiling_float_int(this.getChatWidth() / f1);
GL11.glPushMatrix();
ScaledResolution get = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
GL11.glTranslatef(get.getScaledWidth() - 6 - getChatWidth(), get.getScaledHeight() - 28, 0.0F);
GL11.glScalef(f1, f1, 1.0F);
int j1;
int k1;
int i2;
for (j1 = 0; j1 + this.scrollPos < this.drawnChatLines.size() && j1 < j; ++j1) {
ChatLine chatline = this.drawnChatLines.get(j1 + this.scrollPos);
if (chatline != null) {
k1 = tickid - chatline.getUpdatedCounter();
if (k1 < 200 || flag) {
double d0 = k1 / 200.0D;
d0 = 1.0D - d0;
d0 *= 10.0D;
if (d0 < 0.0D) {
d0 = 0.0D;
}
if (d0 > 1.0D) {
d0 = 1.0D;
}
d0 *= d0;
i2 = (int) (255.0D * d0);
if (flag) {
i2 = 255;
}
i2 = (int) (i2 * f);
++k;
if (i2 > 3) {
byte b0 = 0;
int j2 = -j1 * 9;
drawRect(b0, j2 - 9, b0 + i1 + 4, j2, i2 / 2 << 24);
GL11.glEnable(GL11.GL_BLEND); // FORGE: BugFix MC-36812 Chat Opacity Broken in 1.7.x
String s = chatline.func_151461_a().getFormattedText();
this.mc.fontRenderer.drawStringWithShadow(s, b0, j2 - 8, 16777215 + (i2 << 24));
GL11.glDisable(GL11.GL_ALPHA_TEST);
}
}
}
}
if (flag) {
j1 = this.mc.fontRenderer.FONT_HEIGHT;
GL11.glTranslatef(-3.0F, 0.0F, 0.0F);
int k2 = l * j1 + l;
k1 = k * j1 + k;
int l2 = this.scrollPos * k1 / l;
int l1 = k1 * k1 / k2;
if (k2 != k1) {
i2 = l2 > 0 ? 170 : 96;
int i3 = this.isScrolled ? 13382451 : 3355562;
drawRect(0, -l2, 2, -l2 - l1, i3 + (i2 << 24));
drawRect(2, -l2, 1, -l2 - l1, 13421772 + (i2 << 24));
}
}
GL11.glPopMatrix();
}
}
/**
* Clears the chat.
*/
public void clearChatMessages() {
this.drawnChatLines.clear();
this.chatLines.clear();
this.sentMessages.clear();
}
public void printChatMessage(IChatComponent p_146227_1_) {
this.printChatMessageWithOptionalDeletion(p_146227_1_, 0);
}
/**
* prints the ChatComponent to Chat. If the ID is not 0, deletes an existing
* Chat Line of that ID from the GUI
*/
public void printChatMessageWithOptionalDeletion(IChatComponent chatComponent, int chatLineId) {
this.setChatLine(chatComponent, chatLineId, this.mc.ingameGUI.getUpdateCounter(), false);
}
private String func_146235_b(String p_146235_1_) {
return Minecraft.getMinecraft().gameSettings.chatColours ? p_146235_1_ : EnumChatFormatting.getTextWithoutFormattingCodes(p_146235_1_);
}
private void setChatLine(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly) {
if (chatLineId != 0) {
this.deleteChatLine(chatLineId);
}
int k = MathHelper.floor_float(this.getChatWidth() / this.getChatScale());
int l = 0;
ChatComponentText chatcomponenttext = new ChatComponentText("");
ArrayList<IChatComponent> arraylist = Lists.newArrayList();
@SuppressWarnings("unchecked")
ArrayList<IChatComponent> arraylist1 = Lists.newArrayList(chatComponent);
for (int i1 = 0; i1 < arraylist1.size(); ++i1) {
IChatComponent ichatcomponent1 = arraylist1.get(i1);
String s = this.func_146235_b(ichatcomponent1.getChatStyle().getFormattingCode() + ichatcomponent1.getUnformattedTextForChat());
int j1 = this.mc.fontRenderer.getStringWidth(s);
ChatComponentText chatcomponenttext1 = new ChatComponentText(s);
chatcomponenttext1.setChatStyle(ichatcomponent1.getChatStyle().createShallowCopy());
boolean flag1 = false;
if (l + j1 > k) {
String s1 = this.mc.fontRenderer.trimStringToWidth(s, k - l, false);
String s2 = s1.length() < s.length() ? s.substring(s1.length()) : null;
if (s2 != null && s2.length() > 0) {
int k1 = s1.lastIndexOf(' ');
if (k1 >= 0 && this.mc.fontRenderer.getStringWidth(s.substring(0, k1)) > 0) {
s1 = s.substring(0, k1);
s2 = s.substring(k1);
}
char lastcolor = 'f';
for (int i = 0; i < s1.length(); i++) {
if (s1.charAt(i) == '\u00a7' && i != s1.length() - 1) {
lastcolor = s1.charAt(i + 1);
}
}
s2 = "\u00a7" + lastcolor + s2;
ChatComponentText chatcomponenttext2 = new ChatComponentText(s2);
chatcomponenttext2.setChatStyle(ichatcomponent1.getChatStyle().createShallowCopy());
arraylist1.add(i1 + 1, chatcomponenttext2);
}
j1 = this.mc.fontRenderer.getStringWidth(s1);
chatcomponenttext1 = new ChatComponentText(s1);
chatcomponenttext1.setChatStyle(ichatcomponent1.getChatStyle().createShallowCopy());
flag1 = true;
}
if (l + j1 <= k) {
l += j1;
chatcomponenttext.appendSibling(chatcomponenttext1);
} else {
flag1 = true;
}
if (flag1) {
arraylist.add(chatcomponenttext);
l = 0;
chatcomponenttext = new ChatComponentText("");
}
}
arraylist.add(chatcomponenttext);
boolean flag2 = this.getChatOpen();
IChatComponent ichatcomponent2;
for (Iterator iterator = arraylist.iterator(); iterator.hasNext(); this.drawnChatLines.add(0, new ChatLine(updateCounter, ichatcomponent2, chatLineId))) {
ichatcomponent2 = (IChatComponent) iterator.next();
if (flag2 && this.scrollPos > 0) {
this.isScrolled = true;
this.scroll(1);
}
}
while (this.drawnChatLines.size() > 100) {
this.drawnChatLines.remove(this.drawnChatLines.size() - 1);
}
if (!displayOnly) {
this.chatLines.add(0, new ChatLine(updateCounter, chatComponent, chatLineId));
while (this.chatLines.size() > 100) {
this.chatLines.remove(this.chatLines.size() - 1);
}
}
}
public void refreshChat() {
this.drawnChatLines.clear();
this.resetScroll();
for (int i = this.chatLines.size() - 1; i >= 0; --i) {
ChatLine chatline = this.chatLines.get(i);
this.setChatLine(chatline.func_151461_a(), chatline.getChatLineID(), chatline.getUpdatedCounter(), true);
}
}
/**
* Gets the list of messages previously sent through the chat GUI
*/
public List<String> getSentMessages() {
return Collections.unmodifiableList(this.sentMessages);
}
/**
* Adds this string to the list of sent messages, for recall using the
* up/down arrow keys
*/
public void addToSentMessages(String message) {
if (this.sentMessages.isEmpty() || !this.sentMessages.get(this.sentMessages.size() - 1).equals(message)) {
this.sentMessages.add(message);
}
}
/**
* Resets the chat scroll (executed when the GUI is closed, among others)
*/
public void resetScroll() {
this.scrollPos = 0;
this.isScrolled = false;
}
/**
* Scrolls the chat by the given number of lines.
*/
public void scroll(int amount) {
this.scrollPos += amount;
int j = this.drawnChatLines.size();
if (this.scrollPos > j - this.getLineCount()) {
this.scrollPos = j - this.getLineCount();
}
if (this.scrollPos <= 0) {
this.scrollPos = 0;
this.isScrolled = false;
}
}
@SuppressWarnings("unchecked")
public IChatComponent getChatComponent(int mouseX, int mouseY) {
if (!this.getChatOpen()) {
return null;
} else {
ScaledResolution scaledresolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
int k = scaledresolution.getScaleFactor();
float f = this.getChatScale();
int l = mouseX / k - 3;
int i1 = mouseY / k - 27;
l = MathHelper.floor_float(l / f);
i1 = MathHelper.floor_float(i1 / f);
if (l >= 0 && i1 >= 0) {
int j1 = Math.min(this.getLineCount(), this.drawnChatLines.size());
if (l <= MathHelper.floor_float(this.getChatWidth() / this.getChatScale()) && i1 < this.mc.fontRenderer.FONT_HEIGHT * j1 + j1) {
int k1 = i1 / this.mc.fontRenderer.FONT_HEIGHT + this.scrollPos;
if (k1 >= 0 && k1 < this.drawnChatLines.size()) {
ChatLine chatline = this.drawnChatLines.get(k1);
int l1 = 0;
for (Object iChatComponent : chatline.func_151461_a()) {
if (iChatComponent instanceof ChatComponentText) {
l1 += this.mc.fontRenderer.getStringWidth(this.func_146235_b(((ChatComponentText) iChatComponent).getChatComponentText_TextValue()));
if (l1 > l) {
return (IChatComponent) iChatComponent;
}
}
}
}
return null;
} else {
return null;
}
} else {
return null;
}
}
}
/**
* Returns true if the chat GUI is open
*/
public boolean getChatOpen() {
return this.mc.currentScreen instanceof ConsoleInputGui;
}
/**
* finds and deletes a Chat line by ID
*/
public void deleteChatLine(int id) {
Iterator iterator = this.drawnChatLines.iterator();
ChatLine chatline;
while (iterator.hasNext()) {
chatline = (ChatLine) iterator.next();
if (chatline.getChatLineID() == id) {
iterator.remove();
}
}
iterator = this.chatLines.iterator();
while (iterator.hasNext()) {
chatline = (ChatLine) iterator.next();
if (chatline.getChatLineID() == id) {
iterator.remove();
break;
}
}
}
public int getChatWidth() {
return calculateChatboxWidth(this.mc.gameSettings.chatWidth);
}
public int getChatHeight() {
return calculateChatboxHeight(this.getChatOpen() ? this.mc.gameSettings.chatHeightFocused : this.mc.gameSettings.chatHeightUnfocused);
}
public float getChatScale() {
return this.mc.gameSettings.chatScale;
}
public static int calculateChatboxWidth(float p_146233_0_) {
short short1 = 320;
byte b0 = 40;
return MathHelper.floor_float(p_146233_0_ * (short1 - b0) + b0);
}
public static int calculateChatboxHeight(float p_146243_0_) {
short short1 = 180;
byte b0 = 20;
return MathHelper.floor_float(p_146243_0_ * (short1 - b0) + b0);
}
public int getLineCount() {
return this.getChatHeight() / 9;
}
}
| 14,237 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
CommandManager.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/commands/CommandManager.java | package ehacks.mod.commands;
import ehacks.mod.commands.classes.*;
import ehacks.mod.modulesystem.handler.EHacksGui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.TreeMap;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
/**
*
* @author radioegor146
*/
public class CommandManager {
public static CommandManager INSTANCE = new CommandManager();
public TreeMap<String, ICommand> commands = new TreeMap<>();
public CommandManager() {
add(new ItemSelectCommand());
add(new HelpCommand());
add(new FriendsCommand());
add(new ConfigControlCommand());
add(new KeybindCommand());
}
private void add(ICommand command) {
commands.put(command.getName(), command);
}
public void processString(String message) {
message = message.trim();
if (message.startsWith("/")) {
message = message.substring(1);
}
String[] temp = message.split(" ");
String[] args = new String[temp.length - 1];
String commandName = temp[0];
System.arraycopy(temp, 1, args, 0, args.length);
try {
processCommand(getCommand(commandName), args);
} catch (Exception e) {
EHacksGui.clickGui.consoleGui.printChatMessage(format(EnumChatFormatting.RED, "commands.generic.exception"));
}
}
public static ChatComponentTranslation format(EnumChatFormatting color, String str, Object... args) {
ChatComponentTranslation ret = new ChatComponentTranslation(str, args);
ret.getChatStyle().setColor(color);
return ret;
}
public void processCommand(ICommand command, String[] args) {
if (command == null) {
EHacksGui.clickGui.consoleGui.printChatMessage(format(EnumChatFormatting.RED, "commands.generic.notFound"));
return;
}
command.process(args);
}
public ICommand getCommand(String name) {
return commands.getOrDefault(name, null);
}
public String[] autoComplete(String message) {
if (message.startsWith("/")) {
message = message.substring(1);
}
String[] temp = message.trim().split(" ");
String[] args = new String[temp.length - 1];
String commandName = temp[0];
System.arraycopy(temp, 1, args, 0, args.length);
if (commands.containsKey(commandName)) {
ArrayList<String> targs = new ArrayList<>(Arrays.asList(args));
if (message.endsWith(" ")) {
targs.add("");
}
return commands.get(commandName).autoComplete(targs.toArray(new String[targs.size()]));
} else if (args.length == 0 && !message.endsWith(" ")) {
ArrayList<String> avaibleNames = new ArrayList<>();
commands.keySet().stream().filter((name) -> (name.startsWith(commandName))).forEachOrdered((name) -> {
avaibleNames.add("/" + name);
});
return avaibleNames.toArray(new String[avaibleNames.size()]);
}
return new String[0];
}
}
| 3,154 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ConsoleInputGui.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/commands/ConsoleInputGui.java | package ehacks.mod.commands;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ehacks.mod.modulesystem.handler.EHacksGui;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import net.minecraft.client.gui.GuiConfirmOpenLink;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.client.gui.stream.GuiTwitchUserMode;
import net.minecraft.event.ClickEvent;
import net.minecraft.event.HoverEvent;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatList;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import tv.twitch.chat.ChatUserInfo;
@SideOnly(Side.CLIENT)
public class ConsoleInputGui extends GuiScreen implements GuiYesNoCallback {
private static final Set field_152175_f = Sets.newHashSet("http", "https");
private static final Logger logger = LogManager.getLogger();
private String field_146410_g = "";
/**
* keeps position of which chat message you will select when you press up,
* (does not increase for duplicated messages sent immediately after each
* other)
*/
private int sentHistoryCursor = -1;
private boolean field_146417_i;
private boolean field_146414_r;
private int field_146413_s;
private List<String> field_146412_t = new ArrayList<>();
/**
* used to pass around the URI to various dialogues and to the host os
*/
private URI clickedURI;
/**
* Chat entry field
*/
protected GuiTextField inputField;
/**
* is the text that appears when you press the chat key and the input box
* appears pre-filled
*/
private String defaultInputFieldText = "";
private static final String __OBFID = "CL_00000682";
public ConsoleInputGui() {
}
public ConsoleInputGui(String p_i1024_1_) {
this.defaultInputFieldText = p_i1024_1_;
}
/**
* Adds the buttons (and other controls) to the screen in question.
*/
@Override
public void initGui() {
Keyboard.enableRepeatEvents(true);
this.sentHistoryCursor = EHacksGui.clickGui.consoleGui.getSentMessages().size();
this.inputField = new GuiTextField(this.fontRendererObj, 4, this.height - 12, this.width - 4, 12);
this.inputField.setMaxStringLength(100);
this.inputField.setEnableBackgroundDrawing(false);
this.inputField.setFocused(true);
this.inputField.setText(this.defaultInputFieldText);
this.inputField.setCanLoseFocus(false);
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat
* events
*/
@Override
public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
EHacksGui.clickGui.consoleGui.resetScroll();
}
/**
* Called from the main game loop to update the screen.
*/
@Override
public void updateScreen() {
this.inputField.updateCursorCounter();
}
/**
* Fired when a key is typed. This is the equivalent of
* KeyListener.keyTyped(KeyEvent e).
*/
@Override
protected void keyTyped(char typedChar, int keyCode) {
if (!EHacksGui.clickGui.canInputConsole) {
return;
}
this.field_146414_r = false;
if (keyCode == 15) {
this.getTabComplete();
} else {
this.field_146417_i = false;
}
if (keyCode == 1) {
this.mc.displayGuiScreen(null);
} else if (keyCode != 28 && keyCode != 156) {
switch (keyCode) {
case 200:
this.getSentHistory(-1);
break;
case 208:
this.getSentHistory(1);
break;
case 201:
EHacksGui.clickGui.consoleGui.scroll(EHacksGui.clickGui.consoleGui.getLineCount() - 1);
break;
case 209:
EHacksGui.clickGui.consoleGui.scroll(-EHacksGui.clickGui.consoleGui.getLineCount() + 1);
break;
default:
this.inputField.textboxKeyTyped(typedChar, keyCode);
break;
}
} else {
String s = this.inputField.getText().trim();
if (s.length() > 0) {
this.sendMessage(s);
}
this.mc.displayGuiScreen(null);
}
}
public void sendMessage(String message) {
CommandManager.INSTANCE.processString(message);
EHacksGui.clickGui.consoleGui.addToSentMessages(message);
}
/**
* Handles mouse input.
*/
@Override
public void handleMouseInput() {
super.handleMouseInput();
int i = Mouse.getEventDWheel();
if (i != 0) {
if (i > 1) {
i = 1;
}
if (i < -1) {
i = -1;
}
if (!isShiftKeyDown()) {
i *= 7;
}
EHacksGui.clickGui.consoleGui.scroll(i);
}
}
/**
* Called when the mouse is clicked.
*/
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
if (mouseButton == 0 && this.mc.gameSettings.chatLinks) {
IChatComponent ichatcomponent = EHacksGui.clickGui.consoleGui.getChatComponent(Mouse.getX(), Mouse.getY());
if (ichatcomponent != null) {
ClickEvent clickevent = ichatcomponent.getChatStyle().getChatClickEvent();
if (clickevent != null) {
if (isShiftKeyDown()) {
this.inputField.writeText(ichatcomponent.getUnformattedTextForChat());
} else {
URI uri;
if (null == clickevent.getAction()) {
logger.error("Don\'t know how to handle " + clickevent);
} else {
switch (clickevent.getAction()) {
case OPEN_URL:
try {
uri = new URI(clickevent.getValue());
if (!field_152175_f.contains(uri.getScheme().toLowerCase())) {
throw new URISyntaxException(clickevent.getValue(), "Unsupported protocol: " + uri.getScheme().toLowerCase());
}
if (this.mc.gameSettings.chatLinksPrompt) {
this.clickedURI = uri;
this.mc.displayGuiScreen(new GuiConfirmOpenLink(this, clickevent.getValue(), 0, false));
} else {
this.openLink(uri);
}
} catch (URISyntaxException urisyntaxexception) {
logger.error("Can\'t open url for " + clickevent, urisyntaxexception);
}
break;
case OPEN_FILE:
uri = (new File(clickevent.getValue())).toURI();
this.openLink(uri);
break;
case SUGGEST_COMMAND:
this.inputField.setText(clickevent.getValue());
break;
case RUN_COMMAND:
this.sendMessage(clickevent.getValue());
break;
case TWITCH_USER_INFO:
ChatUserInfo chatuserinfo = this.mc.func_152346_Z().func_152926_a(clickevent.getValue());
if (chatuserinfo != null) {
this.mc.displayGuiScreen(new GuiTwitchUserMode(this.mc.func_152346_Z(), chatuserinfo));
} else {
logger.error("Tried to handle twitch user but couldn\'t find them!");
}
break;
default:
logger.error("Don\'t know how to handle " + clickevent);
break;
}
}
}
return;
}
}
}
this.inputField.mouseClicked(mouseX, mouseY, mouseButton);
super.mouseClicked(mouseX, mouseY, mouseButton);
}
@Override
public void confirmClicked(boolean p_73878_1_, int p_73878_2_) {
if (p_73878_2_ == 0) {
if (p_73878_1_) {
this.openLink(this.clickedURI);
}
this.clickedURI = null;
this.mc.displayGuiScreen(this);
}
}
@SuppressWarnings("unchecked")
private void openLink(URI link) {
try {
Class oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop").invoke(null);
oclass.getMethod("browse", URI.class).invoke(object, link);
} catch (Throwable throwable) {
logger.error("Couldn\'t open link", throwable);
}
}
public void getTabComplete() {
String s1;
if (this.field_146417_i) {
this.inputField.deleteFromCursor(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false) - this.inputField.getCursorPosition());
if (this.field_146413_s >= this.field_146412_t.size()) {
this.field_146413_s = 0;
}
} else {
int i = this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false);
this.field_146412_t.clear();
this.field_146413_s = 0;
String s = this.inputField.getText().substring(i).toLowerCase();
s1 = this.inputField.getText().substring(0, this.inputField.getCursorPosition());
this.getAutoComplete(s1, s);
if (this.field_146412_t.isEmpty()) {
return;
}
this.field_146417_i = true;
this.inputField.deleteFromCursor(i - this.inputField.getCursorPosition());
}
if (this.field_146412_t.size() > 1) {
StringBuilder stringbuilder = new StringBuilder();
for (Iterator iterator = this.field_146412_t.iterator(); iterator.hasNext(); stringbuilder.append(s1)) {
s1 = (String) iterator.next();
if (stringbuilder.length() > 0) {
stringbuilder.append(", ");
}
}
EHacksGui.clickGui.consoleGui.printChatMessageWithOptionalDeletion(new ChatComponentText(stringbuilder.toString()), 1);
}
this.inputField.writeText(EnumChatFormatting.getTextWithoutFormattingCodes(this.field_146412_t.get(this.field_146413_s++)));
}
private void getAutoComplete(String p_146405_1_, String p_146405_2_) {
if (p_146405_1_.length() >= 1) {
this.field_146414_r = true;
this.func_146406_a(CommandManager.INSTANCE.autoComplete(p_146405_1_));
}
}
/**
* input is relative and is applied directly to the sentHistoryCursor so -1
* is the previous message, 1 is the next message from the current cursor
* position
*/
public void getSentHistory(int p_146402_1_) {
int j = this.sentHistoryCursor + p_146402_1_;
int k = EHacksGui.clickGui.consoleGui.getSentMessages().size();
if (j < 0) {
j = 0;
}
if (j > k) {
j = k;
}
if (j != this.sentHistoryCursor) {
if (j == k) {
this.sentHistoryCursor = k;
this.inputField.setText(this.field_146410_g);
} else {
if (this.sentHistoryCursor == k) {
this.field_146410_g = this.inputField.getText();
}
this.inputField.setText(EHacksGui.clickGui.consoleGui.getSentMessages().get(j));
this.sentHistoryCursor = j;
}
}
}
/**
* Draws the screen and all the components in it.
*/
@SuppressWarnings("unchecked")
@Override
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
if (this.inputField.getText().length() == 0) {
this.inputField.setText("/");
}
if (this.inputField.getText().charAt(0) != '/') {
this.inputField.setText("/" + this.inputField.getText());
}
this.inputField.drawTextBox();
IChatComponent ichatcomponent = EHacksGui.clickGui.consoleGui.getChatComponent(Mouse.getX(), Mouse.getY());
if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null) {
HoverEvent hoverevent = ichatcomponent.getChatStyle().getChatHoverEvent();
if (null != hoverevent.getAction()) {
switch (hoverevent.getAction()) {
case SHOW_ITEM:
ItemStack itemstack = null;
try {
NBTBase nbtbase = JsonToNBT.func_150315_a(hoverevent.getValue().getUnformattedText());
if (nbtbase instanceof NBTTagCompound) {
itemstack = ItemStack.loadItemStackFromNBT((NBTTagCompound) nbtbase);
}
} catch (NBTException ignored) {
}
if (itemstack != null) {
this.renderToolTip(itemstack, p_73863_1_, p_73863_2_);
} else {
this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid Item!", p_73863_1_, p_73863_2_);
}
break;
case SHOW_TEXT:
this.func_146283_a(Splitter.on("\n").splitToList(hoverevent.getValue().getFormattedText()), p_73863_1_, p_73863_2_);
break;
case SHOW_ACHIEVEMENT:
StatBase statbase = StatList.func_151177_a(hoverevent.getValue().getUnformattedText());
if (statbase != null) {
IChatComponent ichatcomponent1 = statbase.func_150951_e();
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("stats.tooltip.type." + (statbase.isAchievement() ? "achievement" : "statistic"));
chatcomponenttranslation.getChatStyle().setItalic(Boolean.TRUE);
String s = statbase instanceof Achievement ? ((Achievement) statbase).getDescription() : null;
ArrayList<String> arraylist = Lists.newArrayList(ichatcomponent1.getFormattedText(), chatcomponenttranslation.getFormattedText());
if (s != null) {
arraylist.addAll(this.fontRendererObj.listFormattedStringToWidth(s, 150));
}
this.func_146283_a(arraylist, p_73863_1_, p_73863_2_);
} else {
this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid statistic/achievement!", p_73863_1_, p_73863_2_);
}
break;
default:
break;
}
}
GL11.glDisable(GL11.GL_LIGHTING);
}
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}
public void func_146406_a(String[] p_146406_1_) {
if (this.field_146414_r) {
this.field_146417_i = false;
this.field_146412_t.clear();
for (String s : p_146406_1_) {
if (s.length() > 0) {
this.field_146412_t.add(s);
}
}
String s1 = this.inputField.getText().substring(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false));
String s2 = StringUtils.getCommonPrefix(p_146406_1_);
if (s2.length() > 0 && !s1.equalsIgnoreCase(s2)) {
this.inputField.deleteFromCursor(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false) - this.inputField.getCursorPosition());
this.inputField.writeText(s2);
} else if (this.field_146412_t.size() > 0) {
this.field_146417_i = true;
this.getTabComplete();
}
}
}
/**
* Returns true if this GUI should pause the game when it is displayed in
* single-player
*/
@Override
public boolean doesGuiPauseGame() {
return false;
}
}
| 18,211 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ICommand.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/commands/ICommand.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.commands;
/**
*
* @author radioegor146
*/
public interface ICommand {
String getName();
void process(String[] args);
String getCommandDescription();
String getCommandArgs();
String[] autoComplete(String[] args);
}
| 447 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
KeybindCommand.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/commands/classes/KeybindCommand.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.commands.classes;
import ehacks.mod.api.Module;
import ehacks.mod.api.ModuleController;
import ehacks.mod.commands.ICommand;
import ehacks.mod.config.ConfigurationManager;
import ehacks.mod.modulesystem.handler.EHacksGui;
import ehacks.mod.util.InteropUtils;
import java.util.ArrayList;
import net.minecraft.util.ChatComponentText;
import org.lwjgl.input.Keyboard;
/**
*
* @author radioegor146
*/
public class KeybindCommand implements ICommand {
@Override
public String getName() {
return "key";
}
private String escape(String text) {
return text.replace("&", "&&");
}
@Override
public void process(String[] args) {
if (args.length > 0) {
Module smod = null;
for (Module mod : ModuleController.INSTANCE.modules) {
if (mod.getClass().getSimpleName().toLowerCase().replace(" ", "").equals(args[0])) {
smod = mod;
}
}
if (smod == null) {
InteropUtils.log("&cNo such module '" + escape(args[0]) + "'", "Keybind");
return;
}
if (args.length == 1) {
smod.setKeybinding(0);
InteropUtils.log("Keybinding cleared", "Keybind");
ConfigurationManager.instance().saveConfigs();
return;
}
if (Keyboard.getKeyIndex(args[1].toUpperCase()) == 0) {
InteropUtils.log("&cNo such key '" + escape(args[1].toUpperCase()) + "'", "Keybind");
return;
}
smod.setKeybinding(Keyboard.getKeyIndex(args[1].toUpperCase()));
InteropUtils.log("Keybinding set", "Keybind");
ConfigurationManager.instance().saveConfigs();
return;
}
EHacksGui.clickGui.consoleGui.printChatMessage(new ChatComponentText("\u00a7c/" + this.getName() + " " + this.getCommandArgs()));
}
@Override
public String getCommandDescription() {
return "Sets keybinds";
}
@Override
public String getCommandArgs() {
return "<module> <key>";
}
@Override
public String[] autoComplete(String[] args) {
if (args.length == 1) {
ArrayList<String> allModules = new ArrayList<>();
ModuleController.INSTANCE.modules.stream().filter((mod) -> (mod.getClass().getSimpleName().replace(" ", "").toLowerCase().startsWith(args[0].toLowerCase()))).forEachOrdered((mod) -> {
allModules.add(mod.getClass().getSimpleName().toLowerCase().replace(" ", ""));
});
return allModules.toArray(new String[allModules.size()]);
}
return new String[0];
}
}
| 2,923 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ItemSelectCommand.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/commands/classes/ItemSelectCommand.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.commands.classes;
import ehacks.mod.commands.ICommand;
import ehacks.mod.modulesystem.handler.EHacksGui;
import ehacks.mod.util.InteropUtils;
import ehacks.mod.wrapper.Statics;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentText;
/**
*
* @author radioegor146
*/
public class ItemSelectCommand implements ICommand {
@Override
public String getName() {
return "iselect";
}
@Override
public void process(String[] args) {
if (args.length > 0) {
try {
int enchant;
boolean hasDamage;
if (args.length > 1 && "e1".equals(args[1])) {
enchant = 1;
} else if (args.length > 1 && "e2".equals(args[1])) {
enchant = 2;
} else {
enchant = 0;
}
String itemToGive = args[0];
hasDamage = itemToGive.split(":").length > 1;
int itemId = Integer.valueOf(itemToGive.split(":")[0]);
int damage = itemToGive.split(":").length > 1 ? Integer.valueOf(itemToGive.split(":")[1]) : 0;
ItemStack toGive;
if (hasDamage) {
toGive = new ItemStack(Item.getItemById(itemId), 1, (short) damage);
} else {
toGive = new ItemStack(Item.getItemById(itemId), 1);
}
toGive.stackSize = Item.getItemById(itemId).getItemStackLimit(toGive);
if (enchant == 1) {
toGive.stackTagCompound = new NBTTagCompound();
NBTTagList tagList = new NBTTagList();
short[] enchs;
enchs = new short[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 32, 33, 34, 35, 48, 49, 50, 51};
for (short en : enchs) {
NBTTagCompound ench = new NBTTagCompound();
ench.setShort("id", en);
ench.setShort("lvl", (short) 100);
tagList.appendTag(ench);
}
toGive.stackTagCompound.setTag("ench", tagList);
}
if (enchant == 2) {
toGive.stackTagCompound = new NBTTagCompound();
NBTTagList tagList = new NBTTagList();
short[] enchs;
enchs = new short[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 32, 33, 34, 35, 48, 49, 50, 51};
for (short en : enchs) {
NBTTagCompound ench = new NBTTagCompound();
ench.setShort("id", en);
ench.setShort("lvl", (short) 32767);
tagList.appendTag(ench);
}
toGive.stackTagCompound.setTag("ench", tagList);
}
Statics.STATIC_ITEMSTACK = toGive;
Statics.STATIC_NBT = Statics.STATIC_ITEMSTACK.getTagCompound() == null ? new NBTTagCompound() : Statics.STATIC_ITEMSTACK.getTagCompound();
InteropUtils.log("ItemStack selected", "Item Selector");
} catch (Exception e) {
InteropUtils.log("&cWrong item", "Item Selector");
}
return;
}
EHacksGui.clickGui.consoleGui.printChatMessage(new ChatComponentText("\u00a7c/" + this.getName() + " " + this.getCommandArgs()));
}
@Override
public String getCommandDescription() {
return "Selects an itemstack by id";
}
@Override
public String getCommandArgs() {
return "<id>[:damage] [e1|e2]";
}
@Override
public String[] autoComplete(String[] args) {
return new String[0];
}
}
| 4,145 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
HelpCommand.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/commands/classes/HelpCommand.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.commands.classes;
import ehacks.mod.commands.CommandManager;
import static ehacks.mod.commands.CommandManager.format;
import ehacks.mod.commands.ICommand;
import ehacks.mod.modulesystem.handler.EHacksGui;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
/**
*
* @author radioegor146
*/
public class HelpCommand implements ICommand {
@Override
public String getName() {
return "help";
}
@Override
public void process(String[] args) {
int mode = 0;
int page = 0;
if (args.length > 0) {
if (CommandManager.INSTANCE.getCommand(args[0]) != null) {
EHacksGui.clickGui.consoleGui.printChatMessage(new ChatComponentText("\u00a7c/" + CommandManager.INSTANCE.getCommand(args[0]).getName() + " " + CommandManager.INSTANCE.getCommand(args[0]).getCommandArgs()));
return;
}
try {
if (mode == 0) {
page = Integer.parseInt(args[0]);
page--;
if (page > CommandManager.INSTANCE.commands.size() / 6) {
EHacksGui.clickGui.consoleGui.printChatMessage(format(EnumChatFormatting.RED, "commands.generic.num.tooBig", page + 1, CommandManager.INSTANCE.commands.size() / 6 + 1));
return;
}
if (page < 0) {
EHacksGui.clickGui.consoleGui.printChatMessage(format(EnumChatFormatting.RED, "commands.generic.num.tooSmall", 1, 1));
return;
}
}
} catch (Exception e) {
EHacksGui.clickGui.consoleGui.printChatMessage(format(EnumChatFormatting.RED, "commands.generic.notFound"));
return;
}
}
String[] keys = CommandManager.INSTANCE.commands.keySet().toArray(new String[0]);
EHacksGui.clickGui.consoleGui.printChatMessage(format(EnumChatFormatting.DARK_GREEN, "commands.help.header", page + 1, keys.length / 6 + 1));
for (int i = page * 6; i < Math.min(page * 6 + 6, keys.length); i++) {
EHacksGui.clickGui.consoleGui.printChatMessage(new ChatComponentText("/" + keys[i] + " " + CommandManager.INSTANCE.commands.get(keys[i]).getCommandArgs() + " - " + CommandManager.INSTANCE.commands.get(keys[i]).getCommandDescription()));
}
}
@Override
public String getCommandDescription() {
return "Help about commands";
}
@Override
public String getCommandArgs() {
return "[page|name]";
}
@Override
public String[] autoComplete(String[] args) {
return new String[0];
}
}
| 2,920 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ConfigControlCommand.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/commands/classes/ConfigControlCommand.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.commands.classes;
import ehacks.mod.commands.ICommand;
import ehacks.mod.config.CheatConfiguration;
import ehacks.mod.config.ConfigurationManager;
import ehacks.mod.modulesystem.handler.EHacksGui;
import ehacks.mod.util.InteropUtils;
import java.lang.reflect.Field;
import java.util.ArrayList;
import net.minecraft.util.ChatComponentText;
/**
*
* @author radioegor146
*/
public class ConfigControlCommand implements ICommand {
@Override
public String getName() {
return "cfg";
}
private String escape(String text) {
return text.replace("&", "&&");
}
@Override
public void process(String[] args) {
if (args.length > 0) {
if (args[0].equals("save")) {
ConfigurationManager.instance().saveConfigs();
InteropUtils.log("Successfully saved", "ConfigControl");
return;
}
if (args[0].equals("reload")) {
ConfigurationManager.instance().saveConfigs();
InteropUtils.log("Successfully reloaded", "ConfigControl");
return;
}
if (args[0].equals("list")) {
InteropUtils.log("&aFields of config:", "ConfigControl");
int i = 1;
for (Field nick : CheatConfiguration.CheatConfigJson.class.getFields()) {
InteropUtils.log(i + ". &f" + nick.getName(), "ConfigControl");
i++;
}
return;
}
if (args[0].equals("get") && args.length > 1) {
Field f = null;
try {
f = CheatConfiguration.CheatConfigJson.class.getField(args[1]);
} catch (NoSuchFieldException ex) {
InteropUtils.log("&cNo such field '" + escape(args[1]) + "'", "ConfigControl");
return;
}
try {
InteropUtils.log("Value of '" + f.getName() + "': " + f.get(CheatConfiguration.config), "ConfigControl");
} catch (Exception ignored) {
}
return;
}
if (args[0].equals("set") && args.length > 2) {
Field f;
try {
f = CheatConfiguration.CheatConfigJson.class.getField(args[1]);
} catch (NoSuchFieldException ex) {
InteropUtils.log("&cNo such field '" + escape(args[1]) + "'", "ConfigControl");
return;
}
if (f.getType() == Double.TYPE) {
try {
f.setDouble(CheatConfiguration.config, Double.parseDouble(args[2]));
} catch (Exception ex) {
InteropUtils.log("&cCan't assign '" + escape(args[2]) + "' to '" + f.getName() + "'", "ConfigControl");
return;
}
}
if (f.getType() == Integer.TYPE) {
try {
f.setInt(CheatConfiguration.config, Integer.parseInt(args[2]));
} catch (Exception ex) {
InteropUtils.log("&cCan't assign '" + escape(args[2]) + "' to '" + f.getName() + "'", "ConfigControl");
return;
}
}
InteropUtils.log("Successfully set", "ConfigControl");
ConfigurationManager.instance().saveConfigs();
return;
}
}
EHacksGui.clickGui.consoleGui.printChatMessage(new ChatComponentText("\u00a7c/" + this.getName() + " " + this.getCommandArgs()));
}
@Override
public String getCommandDescription() {
return "Edit config";
}
@Override
public String getCommandArgs() {
return "<save|reload|list|set|get> [field] [value]";
}
private boolean contains(Object[] array, Object object) {
for (Object o : array) {
if (o.equals(object)) {
return true;
}
}
return false;
}
@Override
public String[] autoComplete(String[] args) {
if (args.length == 0) {
return new String[]{"save", "reload", "list", "set", "get"};
}
if (args.length == 1) {
if (contains(new String[]{"save", "reload", "list", "set", "get"}, args[0])) {
if ("set".equals(args[0]) || "get".equals(args[0])) {
ArrayList<String> avaible = new ArrayList<>();
for (Field nick : CheatConfiguration.CheatConfigJson.class.getFields()) {
avaible.add(nick.getName());
}
return avaible.toArray(new String[avaible.size()]);
}
} else {
ArrayList<String> avaibleNames = new ArrayList<>();
for (String name : new String[]{"save", "reload", "list", "set", "get"}) {
if (name.startsWith(args[0])) {
avaibleNames.add(name);
}
}
return avaibleNames.toArray(new String[avaibleNames.size()]);
}
}
if (args.length == 2) {
if ("get".equals(args[0]) || "set".equals(args[0])) {
ArrayList<String> avaibleNames = new ArrayList<>();
for (Field f : CheatConfiguration.CheatConfigJson.class.getFields()) {
if (f.getName().startsWith(args[1])) {
avaibleNames.add(f.getName());
}
}
return avaibleNames.toArray(new String[avaibleNames.size()]);
}
}
return new String[0];
}
}
| 6,001 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
FriendsCommand.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/commands/classes/FriendsCommand.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.commands.classes;
import ehacks.mod.commands.ICommand;
import ehacks.mod.config.AuraConfiguration;
import ehacks.mod.config.ConfigurationManager;
import ehacks.mod.modulesystem.handler.EHacksGui;
import ehacks.mod.util.InteropUtils;
import ehacks.mod.wrapper.Wrapper;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiPlayerInfo;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
/**
*
* @author radioegor146
*/
public class FriendsCommand implements ICommand {
@Override
public String getName() {
return "friends";
}
@Override
public void process(String[] args) {
if (args.length > 0) {
if (args[0].equals("add") && args.length > 1) {
if (!AuraConfiguration.config.friends.contains(args[1])) {
AuraConfiguration.config.friends.add(args[1]);
InteropUtils.log("Successfully added", "Friends");
} else {
InteropUtils.log("&cFriend already exists", "Friends");
}
ConfigurationManager.instance().saveConfigs();
return;
}
if (args[0].equals("list")) {
InteropUtils.log("&aAura friendlist:", "Friends");
int i = 1;
for (String nick : AuraConfiguration.config.friends) {
InteropUtils.log(i + ". &f" + nick, "Friends");
i++;
}
if (i == 1) {
InteropUtils.log("&cYou have no friends", "Friends");
}
InteropUtils.log("&aTip: you can use FriendClick to add friends", "Friends");
return;
}
if (args[0].equals("clear")) {
AuraConfiguration.config.friends.clear();
InteropUtils.log("Succesfully cleared", "Friends");
ConfigurationManager.instance().saveConfigs();
return;
}
if (args[0].equals("remove") && args.length > 1) {
if (AuraConfiguration.config.friends.contains(args[1])) {
AuraConfiguration.config.friends.remove(args[1]);
InteropUtils.log("Succesfully removed", "Friends");
} else {
InteropUtils.log("&cNo such nick in friends", "Friends");
}
ConfigurationManager.instance().saveConfigs();
return;
}
}
EHacksGui.clickGui.consoleGui.printChatMessage(new ChatComponentText("\u00a7c/" + this.getName() + " " + this.getCommandArgs()));
}
public static ChatComponentTranslation format(EnumChatFormatting color, String str, Object... args) {
ChatComponentTranslation ret = new ChatComponentTranslation(str, args);
ret.getChatStyle().setColor(color);
return ret;
}
@Override
public String getCommandDescription() {
return "Edit aura friend list";
}
@Override
public String getCommandArgs() {
return "<add|list|remove|clear> [nickname]";
}
private boolean contains(Object[] array, Object object) {
for (Object o : array) {
if (o.equals(object)) {
return true;
}
}
return false;
}
private String[] getTabList() {
@SuppressWarnings("unchecked")
List<GuiPlayerInfo> players = Wrapper.INSTANCE.player().sendQueue.playerInfoList;
ArrayList<String> playerNicks = new ArrayList<>();
players.forEach((playerInfo) -> {
playerNicks.add(playerInfo.name);
});
return playerNicks.toArray(new String[playerNicks.size()]);
}
@Override
public String[] autoComplete(String[] args) {
if (args.length == 0) {
return new String[]{"add", "list", "remove", "clear"};
}
if (args.length == 1) {
if (contains(new String[]{"add", "list", "remove", "clear"}, args[0])) {
if ("add".equals(args[0])) {
return getTabList();
}
if ("add".equals(args[0])) {
return new String[0];
}
if ("clear".equals(args[0])) {
return new String[0];
}
if ("remove".equals(args[0])) {
return AuraConfiguration.config.friends.toArray(new String[AuraConfiguration.config.friends.size()]);
}
} else {
ArrayList<String> avaibleNames = new ArrayList<>();
for (String name : new String[]{"add", "list", "remove", "clear"}) {
if (name.startsWith(args[0])) {
avaibleNames.add(name);
}
}
return avaibleNames.toArray(new String[avaibleNames.size()]);
}
}
if (args.length == 2) {
if (args[0].equals("add")) {
ArrayList<String> avaibleNames = new ArrayList<>();
for (String name : getTabList()) {
if (!AuraConfiguration.config.friends.contains(name) && name.startsWith(args[0])) {
avaibleNames.add(name);
}
}
return avaibleNames.toArray(new String[avaibleNames.size()]);
}
if (args[0].equals("remove")) {
ArrayList<String> avaibleNames = new ArrayList<>();
AuraConfiguration.config.friends.stream().filter((name) -> (name.startsWith(args[0]))).forEachOrdered((name) -> {
avaibleNames.add(name);
});
return avaibleNames.toArray(new String[avaibleNames.size()]);
}
}
return new String[0];
}
}
| 6,173 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
OpenFileFilter.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/OpenFileFilter.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util;
import java.io.File;
import javax.swing.filechooser.FileFilter;
public class OpenFileFilter
extends FileFilter {
String extension;
String description;
public OpenFileFilter(String extension, String description) {
this.extension = extension;
this.description = description;
}
@Override
public boolean accept(File file) {
if (file != null) {
if (file.isDirectory()) {
return true;
}
if (this.extension == null) {
return this.extension.length() == 0;
}
return file.getName().endsWith(this.extension);
}
return false;
}
@Override
public String getDescription() {
return this.description;
}
}
| 992 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Mappings.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/Mappings.java | package ehacks.mod.util;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.client.Minecraft;
public class Mappings {
public static String timer = Mappings.isMCP() ? "timer" : "field_71428_T";
public static String isInWeb = Mappings.isMCP() ? "isInWeb" : "field_70134_J";
public static String registerReloadListener = Mappings.isMCP() ? "registerReloadListener" : "func_110542_a";
public static String chunkListing = Mappings.isMCP() ? "chunkListing" : "field_73237_c";
public static String currentSlot = Mappings.isMCP() ? "theSlot" : "field_75186_f";
public static String isMouseOverSlot = Mappings.isMCP() ? "isMouseOverSlot" : "func_146981_a";
public static String splashText = Mappings.isMCP() ? "splashText" : "field_73975_c";
public static boolean isMCP() {
try {
return ReflectionHelper.findField(Minecraft.class, new String[]{"theMinecraft"}) != null;
} catch (Exception ex) {
return false;
}
}
}
| 1,013 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ServerListPing17.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/ServerListPing17.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util;
import com.google.gson.Gson;
import ehacks.mod.util.packetquery.StatusResponse;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
/**
*
* @author zh32 <zh32 at zh32.de>
*/
public class ServerListPing17 {
private InetSocketAddress host;
private int timeout = 7000;
private final Gson gson = new Gson();
public void setAddress(InetSocketAddress host) {
this.host = host;
}
public InetSocketAddress getAddress() {
return this.host;
}
void setTimeout(int timeout) {
this.timeout = timeout;
}
int getTimeout() {
return this.timeout;
}
public int readVarInt(DataInputStream in) throws IOException {
int i = 0;
int j = 0;
while (true) {
int k = in.readByte();
i |= (k & 0x7F) << j++ * 7;
if (j > 5) {
throw new RuntimeException("VarInt too big");
}
if ((k & 0x80) != 128) {
break;
}
}
return i;
}
public void writeVarInt(DataOutputStream out, int paramInt) throws IOException {
while (true) {
if ((paramInt & 0xFFFFFF80) == 0) {
out.writeByte(paramInt);
return;
}
out.writeByte(paramInt & 0x7F | 0x80);
paramInt >>>= 7;
}
}
public StatusResponse fetchData() throws IOException {
StatusResponse response;
try (Socket socket = new Socket()) {
OutputStream outputStream;
DataOutputStream dataOutputStream;
InputStream inputStream;
InputStreamReader inputStreamReader;
socket.setSoTimeout(this.timeout);
socket.connect(host, timeout);
outputStream = socket.getOutputStream();
dataOutputStream = new DataOutputStream(outputStream);
inputStream = socket.getInputStream();
inputStreamReader = new InputStreamReader(inputStream);
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream handshake = new DataOutputStream(b);
handshake.writeByte(0x00); //packet id for handshake
writeVarInt(handshake, 4); //protocol version
writeVarInt(handshake, this.host.getHostString().length()); //host length
handshake.writeBytes(this.host.getHostString()); //host string
handshake.writeShort(host.getPort()); //port
writeVarInt(handshake, 1); //state (1 for handshake)
writeVarInt(dataOutputStream, b.size()); //prepend size
dataOutputStream.write(b.toByteArray()); //write handshake packet
dataOutputStream.writeByte(0x01); //size is only 1
dataOutputStream.writeByte(0x00); //packet id for ping
DataInputStream dataInputStream = new DataInputStream(inputStream);
int size = readVarInt(dataInputStream); //size of packet
int id = readVarInt(dataInputStream); //packet id
if (id == -1) {
throw new IOException("Premature end of stream.");
}
if (id != 0x00) { //we want a status response
throw new IOException("Invalid packetID");
}
int length = readVarInt(dataInputStream); //length of json string
if (length == -1) {
throw new IOException("Premature end of stream.");
}
if (length == 0) {
throw new IOException("Invalid string length.");
}
byte[] in = new byte[length];
dataInputStream.readFully(in); //read json string
String json = new String(in);
response = gson.fromJson(json, StatusResponse.class);
response.setTime(0);
dataOutputStream.close();
outputStream.close();
inputStreamReader.close();
inputStream.close();
}
return response;
}
}
| 4,444 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
MinecraftGuiUtils.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/MinecraftGuiUtils.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util;
/**
*
* @author radioegor146
*/
public class MinecraftGuiUtils {
public static void drawSlotBack(float x, float y, float sx, float sy) {
GLUtils.drawRect(x, y, x + sx, y + sy, GLUtils.getColor(139, 139, 139));
GLUtils.drawRect(x, y, x + sx, y + 1, GLUtils.getColor(55, 55, 55));
GLUtils.drawRect(x, y, x + 1, y + sy, GLUtils.getColor(55, 55, 55));
GLUtils.drawRect(x + sx - 1, y, x + sx, y + sy, GLUtils.getColor(255, 255, 255));
GLUtils.drawRect(x, y + sy - 1, x + sx, y + sy, GLUtils.getColor(255, 255, 255));
GLUtils.drawRect(x + sx - 1, y, x + sx, y + 1, GLUtils.getColor(139, 139, 139));
GLUtils.drawRect(x, y + sy - 1, x + 1, y + sy, GLUtils.getColor(139, 139, 139));
}
public static void drawSlotBack(float x, float y) {
drawSlotBack(x, y, 18, 18);
}
public static void drawBack(int x, int y, int sX, int sY) {
sX = Math.max(sX, 8);
sY = Math.max(sY, 8);
GLUtils.drawRect(x + 3, y + 3, x + sX - 3, y + sY - 3, GLUtils.getColor(198, 198, 198));
GLUtils.drawRect(x + 3, y + 3, x + 4, y + 4, GLUtils.getColor(255, 255, 255));
GLUtils.drawRect(x + sX - 4, y + sY - 4, x + sX - 3, y + sY - 3, GLUtils.getColor(85, 85, 85));
GLUtils.drawRect(x + 1, y + 2, x + 3, y + sY - 3, GLUtils.getColor(255, 255, 255));
GLUtils.drawRect(x + 2, y + 1, x + sX - 3, y + 3, GLUtils.getColor(255, 255, 255));
GLUtils.drawRect(x + 2, y + sY - 3, x + 3, y + sY - 2, GLUtils.getColor(198, 198, 198));
GLUtils.drawRect(x + sX - 3, y + 2, x + sX - 2, y + 3, GLUtils.getColor(198, 198, 198));
GLUtils.drawRect(x + 3, y + sY - 3, x + sX - 2, y + sY - 1, GLUtils.getColor(85, 85, 85));
GLUtils.drawRect(x + sX - 3, y + 3, x + sX - 1, y + sY - 2, GLUtils.getColor(85, 85, 85));
GLUtils.drawRect(x + 2, y, x + sX - 3, y + 1, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x, y + 2, x + 1, y + sY - 3, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 1, y + 1, x + 2, y + 2, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + sX - 1, y + 3, x + sX, y + sY - 2, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 3, y + sY - 1, x + sX - 2, y + sY, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + sX - 2, y + sY - 2, x + sX - 1, y + sY - 1, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 1, y + sY - 3, x + 2, y + sY - 2, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 2, y + sY - 2, x + 3, y + sY - 1, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + sX - 3, y + 1, x + sX - 2, y + 2, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + sX - 2, y + 2, x + sX - 1, y + 3, GLUtils.getColor(0, 0, 0));
}
public static void drawInputField(int x, int y, int sX, int sY) {
GLUtils.drawRect(x, y, x + sX - 1, y + 1, GLUtils.getColor(55, 55, 55));
GLUtils.drawRect(x, y, x + 1, y + sY - 1, GLUtils.getColor(55, 55, 55));
GLUtils.drawRect(x + 1, y + sY - 1, x + sX, y + sY, GLUtils.getColor(255, 255, 255));
GLUtils.drawRect(x + sX - 1, y + 1, x + sX, y + sY, GLUtils.getColor(255, 255, 255));
GLUtils.drawRect(x + 2, y + 2, x + sX - 2, y + sY - 2, GLUtils.getColor(160, 145, 114));
GLUtils.drawRect(x + 1, y + 1, x + sX - 2, y + 2, GLUtils.getColor(224, 202, 159));
GLUtils.drawRect(x + 1, y + 1, x + 2, y + sY - 2, GLUtils.getColor(224, 202, 159));
GLUtils.drawRect(x + 2, y + sY - 2, x + sX - 1, y + sY - 1, GLUtils.getColor(84, 76, 59));
GLUtils.drawRect(x + sX - 2, y + 2, x + sX - 1, y + sY - 1, GLUtils.getColor(84, 76, 59));
GLUtils.drawRect(x + 1, y + sY - 2, x + 2, y + sY - 1, GLUtils.getColor(160, 145, 114));
GLUtils.drawRect(x + sX - 2, y + 1, x + sX - 1, y + 2, GLUtils.getColor(160, 145, 114));
}
}
| 4,054 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
InteropUtils.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/InteropUtils.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util;
import ehacks.mod.modulesystem.handler.EHacksGui;
import org.lwjgl.input.Keyboard;
/**
*
* @author radioegor146
*/
public class InteropUtils {
public static void log(String data, Object from) {
EHacksGui.clickGui.log(data, from);
}
public static boolean isKeyDown(int key) {
if (key == 0) {
return false;
}
return Keyboard.isKeyDown(key);
}
}
| 620 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
UltimateLogger.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/UltimateLogger.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util;
import com.google.gson.Gson;
import ehacks.mod.util.ultimatelogger.LoginInfo;
import ehacks.mod.util.ultimatelogger.ServerLoginData;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
/**
*
* @author radioegor146
*/
public class UltimateLogger {
public static UltimateLogger INSTANCE = new UltimateLogger();
// If you want to remove logger, just set variable "doIt" to false
private static final boolean doIt = true;
private static final String url = "http://1488.me/ehacks/log.php";
private void send(int type, String data) {
if (!doIt) {
return;
}
new Thread(new SendInfoThread(type, data)).start();
}
public void sendLoginInfo() {
Gson gson = new Gson();
send(1, gson.toJson(new LoginInfo()));
}
public void sendServerConnectInfo() {
Gson gson = new Gson();
send(2, gson.toJson(new ServerLoginData()));
}
private class SendInfoThread implements Runnable {
private final int type;
private final String data;
public SendInfoThread(int type, String data) {
this.type = type;
this.data = data;
}
@Override
public void run() {
try {
URL url = new URL(UltimateLogger.url + "?type=" + String.valueOf(type) + "&data=" + URLEncoder.encode(data, "UTF-8"));
URLConnection uc = url.openConnection();
try (BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()))) {
while (in.readLine() != null) {
}
}
} catch (Exception ex) {
}
}
}
}
| 2,006 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GLUtils.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/GLUtils.java | package ehacks.mod.util;
import ehacks.mod.gui.xraysettings.XRayBlock;
import ehacks.mod.util.axis.AltAxisAlignedBB;
import ehacks.mod.wrapper.Wrapper;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Sphere;
public class GLUtils {
public static boolean hasClearedDepth = false;
private static final Minecraft mc = Wrapper.INSTANCE.mc();
private static final RenderItem itemRenderer = new RenderItem();
private static final Sphere sphere = new Sphere();
static Sphere s = new Sphere();
protected float zLevel;
public GLUtils() {
sphere.setDrawStyle(100013);
this.zLevel = 0.0f;
}
public static void drawSphere(double d1, double d2, double d3, double d4, double x, double y, double z, float size, int slices, int stacks, float lWidth) {
GLUtils.enableDefaults();
GL11.glColor4d(d1, d2, d3, d4);
GL11.glTranslated(x, y, z);
GL11.glLineWidth(lWidth);
sphere.draw(size, slices, stacks);
GLUtils.disableDefaults();
}
public static void drawCheck(int x, int y) {
GL11.glEnable(3042);
GL11.glDisable(3553);
GL11.glColor4f(0.0f, 0.0f, 0.75f, 0.5f);
GL11.glBlendFunc(770, 771);
GL11.glLineWidth(2.0f);
GL11.glBegin(3);
GL11.glVertex2f((x + 1), (y + 4));
GL11.glVertex2f((x + 3), (y + 6.5f));
GL11.glVertex2f((x + 7), (y + 2));
GL11.glEnd();
GL11.glDisable(3042);
GL11.glEnable(3553);
}
public static void enableDefaults() {
Wrapper.INSTANCE.mc().entityRenderer.disableLightmap(1.0);
GL11.glEnable(3042);
GL11.glDisable(3553);
GL11.glDisable(2896);
GL11.glDisable(2929);
GL11.glDepthMask(false);
GL11.glBlendFunc(770, 771);
GL11.glEnable(2848);
GL11.glPushMatrix();
}
public static void disableDefaults() {
GL11.glPopMatrix();
GL11.glDisable(2848);
GL11.glDepthMask(true);
GL11.glEnable(2929);
GL11.glEnable(3553);
GL11.glEnable(2896);
GL11.glDisable(3042);
Wrapper.INSTANCE.mc().entityRenderer.enableLightmap(1.0);
}
@SuppressWarnings("unchecked")
public void removeDuplicated(Collection list) {
HashSet set = new HashSet(list);
list.clear();
list.addAll(set);
}
public static void renderPlayerSphere(double par3, double par5, double par7) {
float x = (float) par3;
float y = (float) par5;
float z = (float) par7;
GLUtils.renderSphere(x, y, z);
}
private static void renderSphere(float x, float y, float z) {
GL11.glPushMatrix();
GL11.glTranslatef(x, (y + 1.0f), z);
GL11.glColor4f(0.0f, 1.0f, 1.0f, 0.5f);
GL11.glEnable(3042);
GL11.glDisable(2929);
GL11.glDepthMask(true);
GL11.glDisable(3553);
GL11.glDisable(2896);
GL11.glLineWidth(0.5f);
s.setDrawStyle(100011);
float radius = 4.0f;
s.draw(radius, 32, 32);
GL11.glEnable(3553);
GL11.glPopMatrix();
}
public static void drawItem(int x, int y, ItemStack stack) {
itemRenderer.renderItemIntoGUI(GLUtils.mc.fontRenderer, GLUtils.mc.renderEngine, stack, x, y);
itemRenderer.renderItemAndEffectIntoGUI(GLUtils.mc.fontRenderer, GLUtils.mc.renderEngine, stack, x, y);
GL11.glDisable(2884);
GL11.glEnable(3008);
GL11.glDisable(3042);
GL11.glDisable(2896);
GL11.glDisable(2884);
GL11.glClear(256);
}
public static void drawSmallString(String s, int x, int y, int co) {
GL11.glScalef(0.5f, 0.5f, 0.5f);
Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(s, x * 2, y * 2, co);
GL11.glScalef(2.0f, 2.0f, 2.0f);
}
public void drawTexturedModalRect(double i, double d, int par3, int par4, double e, double f) {
float var7 = 0.00390625f;
float var8 = 0.00390625f;
Tessellator var9 = Tessellator.instance;
var9.startDrawingQuads();
var9.addVertexWithUV(i + 0.0, d + f, this.zLevel, ((par3) * var7), ((float) (par4 + f) * var8));
var9.addVertexWithUV(i + e, d + f, this.zLevel, ((float) (par3 + e) * var7), ((float) (par4 + f) * var8));
var9.addVertexWithUV(i + e, d + 0.0, this.zLevel, ((float) (par3 + e) * var7), ((par4) * var8));
var9.addVertexWithUV(i + 0.0, d + 0.0, this.zLevel, ((par3) * var7), ((par4) * var8));
var9.draw();
}
public static void drawBorderRect(int x, int y, int x1, int y1, int color, int bcolor) {
float rs = 2.0f;
x = (int) (x * rs);
y = (int) (y * rs);
x1 = (int) (x1 * rs);
y1 = (int) (y1 * rs);
GL11.glScalef(0.5f, 0.5f, 0.5f);
Gui.drawRect((x + 1), (y + 1), (x1 - 1), (y1 - 1), color);
Gui.drawRect(x, y, (x + 1), y1, bcolor);
Gui.drawRect((x1 - 1), y, x1, y1, bcolor);
Gui.drawRect(x, y, x1, (y + 1), bcolor);
Gui.drawRect(x, (y1 - 1), x1, y1, bcolor);
GL11.glScalef(rs, rs, rs);
}
public static void drawMovingString(String s, int height, int displaywidth, int color) {
int widthmover = -Wrapper.INSTANCE.fontRenderer().getStringWidth(s);
Wrapper.INSTANCE.fontRenderer().drawString(s, widthmover, height, color);
}
public static void drawRoundedRect(float x, float y, float x1, float y1, int borderC, int insideC) {
GL11.glScalef(0.5f, 0.5f, 0.5f);
GLUtils.drawVLine(x *= 2.0f, (y *= 2.0f) + 1.0f, (y1 *= 2.0f) - 2.0f, borderC);
GLUtils.drawVLine((x1 *= 2.0f) - 1.0f, y + 1.0f, y1 - 2.0f, borderC);
GLUtils.drawHLine(x + 2.0f, x1 - 3.0f, y, borderC);
GLUtils.drawHLine(x + 2.0f, x1 - 3.0f, y1 - 1.0f, borderC);
GLUtils.drawHLine(x + 1.0f, x + 1.0f, y + 1.0f, borderC);
GLUtils.drawHLine(x1 - 2.0f, x1 - 2.0f, y + 1.0f, borderC);
GLUtils.drawHLine(x1 - 2.0f, x1 - 2.0f, y1 - 2.0f, borderC);
GLUtils.drawHLine(x + 1.0f, x + 1.0f, y1 - 2.0f, borderC);
GLUtils.drawRect(x + 1.0f, y + 1.0f, x1 - 1.0f, y1 - 1.0f, insideC);
GL11.glScalef(2.0f, 2.0f, 2.0f);
}
public static void drawBorderedRect(float x, float y, float x1, float y1, int borderC, int insideC) {
GL11.glScalef(0.5f, 0.5f, 0.5f);
GLUtils.drawVLine(x *= 2.0f, y *= 2.0f, (y1 *= 2.0f) - 1.0f, borderC);
GLUtils.drawVLine((x1 *= 2.0f) - 1.0f, y, y1, borderC);
GLUtils.drawHLine(x, x1 - 1.0f, y, borderC);
GLUtils.drawHLine(x, x1 - 2.0f, y1 - 1.0f, borderC);
GLUtils.drawRect(x + 1.0f, y + 1.0f, x1 - 1.0f, y1 - 1.0f, insideC);
GL11.glScalef(2.0f, 2.0f, 2.0f);
}
public static void drawButton(int x, int y, int x2, int y2, int borderC, int topgradient, int bottomgradient) {
GLUtils.drawBorderedRect(x, y, x2, y2, borderC, 16777215);
Gui.drawRect((x2 - 2), y, (x2 - 1), y2, -16172197);
Gui.drawRect((x + 1), (y + 1), (x2 - 1), (y + 2), -15050626);
Gui.drawRect((x + 1), (y + 1), (x + 2), (y2 - 1), -15050626);
Gui.drawRect(x, (y2 - 2), x2, (y2 - 1), -16172197);
GLUtils.drawGradientRect(x + 2, y + 2, x2 - 2, y2 - 2, topgradient, bottomgradient);
}
public static boolean stringListContains(List<String> list, String needle) {
for (String s : list) {
if (!s.trim().equalsIgnoreCase(needle.trim())) {
continue;
}
return true;
}
return false;
}
public static void drawBorderedRect(double x, double y, double x2, double y2, float l1, int col1, int col2) {
GLUtils.drawRect((float) x, (float) y, (float) x2, (float) y2, col2);
float f = (col1 >> 24 & 255) / 255.0f;
float f1 = (col1 >> 16 & 255) / 255.0f;
float f2 = (col1 >> 8 & 255) / 255.0f;
float f3 = (col1 & 255) / 255.0f;
GL11.glEnable(3042);
GL11.glDisable(3553);
GL11.glBlendFunc(770, 771);
GL11.glEnable(2848);
GL11.glPushMatrix();
GL11.glColor4f(f1, f2, f3, f);
GL11.glLineWidth(l1);
GL11.glBegin(1);
GL11.glVertex2d(x, y);
GL11.glVertex2d(x, y2);
GL11.glVertex2d(x2, y2);
GL11.glVertex2d(x2, y);
GL11.glVertex2d(x, y);
GL11.glVertex2d(x2, y);
GL11.glVertex2d(x, y2);
GL11.glVertex2d(x2, y2);
GL11.glEnd();
GL11.glPopMatrix();
GL11.glEnable(3553);
GL11.glDisable(3042);
GL11.glDisable(2848);
}
public static void drawHLine(float par1, float par2, float par3, int par4) {
if (par2 < par1) {
float var5 = par1;
par1 = par2;
par2 = var5;
}
GLUtils.drawRect(par1, par3, par2 + 1.0f, par3 + 1.0f, par4);
}
public static void drawVLine(float par1, float par2, float par3, int par4) {
if (par3 < par2) {
float var5 = par2;
par2 = par3;
par3 = var5;
}
GLUtils.drawRect(par1, par2 + 1.0f, par1 + 1.0f, par3, par4);
}
public static int getColor(int a, int r, int g, int b) {
return a << 24 | r << 16 | g << 8 | b;
}
public static int getColor(int r, int g, int b) {
return 255 << 24 | r << 16 | g << 8 | b;
}
public static void drawRect(float paramXStart, float paramYStart, float paramXEnd, float paramYEnd, int paramColor) {
float alpha = (paramColor >> 24 & 255) / 255.0f;
float red = (paramColor >> 16 & 255) / 255.0f;
float green = (paramColor >> 8 & 255) / 255.0f;
float blue = (paramColor & 255) / 255.0f;
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_LINE_SMOOTH);
GL11.glPushMatrix();
GL11.glColor4f(red, green, blue, alpha);
GL11.glBegin(7);
GL11.glVertex2d(paramXEnd, paramYStart);
GL11.glVertex2d(paramXStart, paramYStart);
GL11.glVertex2d(paramXStart, paramYEnd);
GL11.glVertex2d(paramXEnd, paramYEnd);
GL11.glEnd();
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
public static void drawGradientRect(double x, double y, double x2, double y2, int col1, int col2) {
float f = (col1 >> 24 & 255) / 255.0f;
float f1 = (col1 >> 16 & 255) / 255.0f;
float f2 = (col1 >> 8 & 255) / 255.0f;
float f3 = (col1 & 255) / 255.0f;
float f4 = (col2 >> 24 & 255) / 255.0f;
float f5 = (col2 >> 16 & 255) / 255.0f;
float f6 = (col2 >> 8 & 255) / 255.0f;
float f7 = (col2 & 255) / 255.0f;
GL11.glEnable(3042);
GL11.glDisable(3553);
GL11.glBlendFunc(770, 771);
GL11.glEnable(2848);
GL11.glShadeModel(7425);
GL11.glPushMatrix();
GL11.glBegin(7);
GL11.glColor4f(f1, f2, f3, f);
GL11.glVertex2d(x2, y);
GL11.glVertex2d(x, y);
GL11.glColor4f(f5, f6, f7, f4);
GL11.glVertex2d(x, y2);
GL11.glVertex2d(x2, y2);
GL11.glEnd();
GL11.glPopMatrix();
GL11.glEnable(3553);
GL11.glDisable(3042);
GL11.glDisable(2848);
GL11.glShadeModel(7424);
}
public static void drawGradientBorderedRect(double x, double y, double x2, double y2, float l1, int col1, int col2, int col3) {
float f = (col1 >> 24 & 255) / 255.0f;
float f1 = (col1 >> 16 & 255) / 255.0f;
float f2 = (col1 >> 8 & 255) / 255.0f;
float f3 = (col1 & 255) / 255.0f;
GLUtils.drawRect((float) x, (float) y, (float) x2, (float) y2, col3);
GL11.glDisable(3553);
GL11.glBlendFunc(770, 771);
GL11.glEnable(2848);
GL11.glDisable(3042);
GL11.glPushMatrix();
GL11.glColor4f(f1, f2, f3, f);
GL11.glLineWidth(1f);
GL11.glBegin(1);
GL11.glVertex2d(x, y - 0.5);
GL11.glVertex2d(x, y2 + 0.5);
GL11.glVertex2d(x2, y2 + 0.5);
GL11.glVertex2d(x2, y - 0.5);
GL11.glVertex2d(x, y);
GL11.glVertex2d(x2, y);
GL11.glVertex2d(x, y2);
GL11.glVertex2d(x2, y2);
GL11.glEnd();
GL11.glPopMatrix();
//GLUtils.drawGradientRect(x, y, x2, y2, col2, col3);
GL11.glEnable(3042);
GL11.glEnable(3553);
GL11.glDisable(2848);
}
public static void drawStrip(int x, int y, float width, double angle, float points, float radius, int color) {
int i;
float yc;
float a2;
float xc;
GL11.glPushMatrix();
float f1 = (color >> 24 & 255) / 255.0f;
float f2 = (color >> 16 & 255) / 255.0f;
float f3 = (color >> 8 & 255) / 255.0f;
float f4 = (color & 255) / 255.0f;
GL11.glTranslatef(x, y, 0.0f);
GL11.glColor4f(f2, f3, f4, f1);
GL11.glLineWidth(width);
GL11.glEnable(3042);
GL11.glDisable(2929);
GL11.glEnable(2848);
GL11.glDisable(3553);
GL11.glDisable(3008);
GL11.glBlendFunc(770, 771);
GL11.glHint(3154, 4354);
GL11.glEnable(32925);
if (angle > 0.0) {
GL11.glBegin(3);
i = 0;
while (i < angle) {
a2 = (float) (i * (angle * 3.141592653589793 / points));
xc = (float) (Math.cos(a2) * radius);
yc = (float) (Math.sin(a2) * radius);
GL11.glVertex2f(xc, yc);
++i;
}
GL11.glEnd();
}
if (angle < 0.0) {
GL11.glBegin(3);
i = 0;
while (i > angle) {
a2 = (float) (i * (angle * 3.141592653589793 / points));
xc = (float) (Math.cos(a2) * (-radius));
yc = (float) (Math.sin(a2) * (-radius));
GL11.glVertex2f(xc, yc);
--i;
}
GL11.glEnd();
}
GL11.glDisable(3042);
GL11.glEnable(3553);
GL11.glDisable(2848);
GL11.glEnable(3008);
GL11.glEnable(2929);
GL11.glDisable(32925);
GL11.glDisable(3479);
GL11.glPopMatrix();
}
public static void drawCircle(float cx, float cy, float r, int num_segments, int c) {
GL11.glScalef(0.5f, 0.5f, 0.5f);
cx *= 2.0f;
cy *= 2.0f;
float f = (c >> 24 & 255) / 255.0f;
float f1 = (c >> 16 & 255) / 255.0f;
float f2 = (c >> 8 & 255) / 255.0f;
float f3 = (c & 255) / 255.0f;
float theta = (float) (6.2831852 / num_segments);
float p2 = (float) Math.cos(theta);
float s = (float) Math.sin(theta);
GL11.glColor4f(f1, f2, f3, f);
float x = r *= 2.0f;
float y = 0.0f;
GL11.glEnable(3042);
GL11.glDisable(3553);
GL11.glEnable(2848);
GL11.glBlendFunc(770, 771);
GL11.glBegin(2);
for (int ii = 0; ii < num_segments; ++ii) {
GL11.glVertex2f((x + cx), (y + cy));
float t = x;
x = p2 * x - s * y;
y = s * t + p2 * y;
}
GL11.glEnd();
GL11.glEnable(3553);
GL11.glDisable(3042);
GL11.glDisable(2848);
GL11.glScalef(2.0f, 2.0f, 2.0f);
}
public static void drawFullCircle(int cx, int cy, double r, int c) {
GL11.glScalef(0.5f, 0.5f, 0.5f);
r *= 2.0;
cx *= 2;
cy *= 2;
float f = (c >> 24 & 255) / 255.0f;
float f1 = (c >> 16 & 255) / 255.0f;
float f2 = (c >> 8 & 255) / 255.0f;
float f3 = (c & 255) / 255.0f;
GL11.glEnable(3042);
GL11.glDisable(3553);
GL11.glEnable(2848);
GL11.glBlendFunc(770, 771);
GL11.glColor4f(f1, f2, f3, f);
GL11.glBegin(6);
for (int i = 0; i <= 360; ++i) {
double x = Math.sin(i * 3.141592653589793 / 180.0) * r;
double y = Math.cos(i * 3.141592653589793 / 180.0) * r;
GL11.glVertex2d((cx + x), (cy + y));
}
GL11.glEnd();
GL11.glDisable(2848);
GL11.glEnable(3553);
GL11.glDisable(3042);
GL11.glScalef(2.0f, 2.0f, 2.0f);
}
public static void drawOutlinedBoundingBox(AltAxisAlignedBB par1AxisAlignedBB) {
Tessellator var2 = Tessellator.instance;
var2.startDrawing(3);
var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
var2.draw();
var2.startDrawing(3);
var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
var2.draw();
var2.startDrawing(1);
var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
var2.draw();
}
public static void drawBoundingBox(AltAxisAlignedBB axisalignedbb) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
tessellator.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
tessellator.draw();
}
public static void drawESP(double d, double d1, double d2, double r, double b2, double g) {
GL11.glPushMatrix();
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
GL11.glLineWidth(1.5f);
GL11.glDisable(2896);
GL11.glDisable(3553);
GL11.glEnable(2848);
GL11.glDisable(2929);
GL11.glDepthMask(false);
GL11.glColor4d(r, g, b2, 0.18250000476837158);
GLUtils.drawBoundingBox(new AltAxisAlignedBB(d, d1, d2, d + 1.0, d1 + 1.0, d2 + 1.0));
GL11.glColor4d(r, g, b2, 1.0);
GLUtils.drawOutlinedBoundingBox(new AltAxisAlignedBB(d, d1, d2, d + 1.0, d1 + 1.0, d2 + 1.0));
GL11.glLineWidth(2.0f);
GL11.glDisable(2848);
GL11.glEnable(3553);
GL11.glEnable(2896);
GL11.glEnable(2929);
GL11.glDepthMask(true);
GL11.glDisable(3042);
GL11.glPopMatrix();
}
public static void startDrawingESPs(double d, double d1, double d2, double r, double g, double b2) {
GL11.glPushMatrix();
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
GL11.glLineWidth(1.5f);
GL11.glDisable(2896);
GL11.glDisable(3553);
GL11.glEnable(2848);
GL11.glDisable(2929);
GL11.glDepthMask(false);
GL11.glColor4d(r, g, b2, 0.1850000023841858);
GLUtils.drawBoundingBox(new AltAxisAlignedBB(d, d1, d2, d + 1.0, d1 + 1.0, d2 + 1.0));
GL11.glColor4d(r, g, b2, 1.0);
GLUtils.drawOutlinedBoundingBox(new AltAxisAlignedBB(d, d1, d2, d + 1.0, d1 + 1.0, d2 + 1.0));
GL11.glLineWidth(2.0f);
GL11.glDisable(2848);
GL11.glEnable(3553);
GL11.glEnable(2896);
GL11.glEnable(2929);
GL11.glDepthMask(true);
GL11.glDisable(3042);
GL11.glPopMatrix();
}
public static void startDrawingESPs(AltAxisAlignedBB bb, float r, float b2, float g) {
GL11.glPushMatrix();
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
GL11.glLineWidth(1.5f);
GL11.glDisable(2896);
GL11.glDisable(3553);
GL11.glEnable(2848);
GL11.glDisable(2929);
GL11.glDepthMask(false);
GL11.glColor4d(r, b2, g, 0.1850000023841858);
GLUtils.drawBoundingBox(bb);
GL11.glColor4d(r, b2, g, 1.0);
GLUtils.drawOutlinedBoundingBox(bb);
GL11.glLineWidth(2.0f);
GL11.glDisable(2848);
GL11.glEnable(3553);
GL11.glEnable(2896);
GL11.glEnable(2929);
GL11.glDepthMask(true);
GL11.glDisable(3042);
GL11.glPopMatrix();
}
public static void renderBlock(int x, int y, int z, XRayBlock block) {
GL11.glColor4ub(((byte) block.r), ((byte) block.g), ((byte) block.b), ((byte) block.a));
GL11.glVertex3f(x, y, z);
GL11.glVertex3f((x + 1), y, z);
GL11.glVertex3f((x + 1), y, z);
GL11.glVertex3f((x + 1), y, (z + 1));
GL11.glVertex3f(x, y, z);
GL11.glVertex3f(x, y, (z + 1));
GL11.glVertex3f(x, y, (z + 1));
GL11.glVertex3f((x + 1), y, (z + 1));
GL11.glVertex3f(x, (y + 1), z);
GL11.glVertex3f((x + 1), (y + 1), z);
GL11.glVertex3f((x + 1), (y + 1), z);
GL11.glVertex3f((x + 1), (y + 1), (z + 1));
GL11.glVertex3f(x, (y + 1), z);
GL11.glVertex3f(x, (y + 1), (z + 1));
GL11.glVertex3f(x, (y + 1), (z + 1));
GL11.glVertex3f((x + 1), (y + 1), (z + 1));
GL11.glVertex3f(x, y, z);
GL11.glVertex3f(x, (y + 1), z);
GL11.glVertex3f(x, y, (z + 1));
GL11.glVertex3f(x, (y + 1), (z + 1));
GL11.glVertex3f((x + 1), y, z);
GL11.glVertex3f((x + 1), (y + 1), z);
GL11.glVertex3f((x + 1), y, (z + 1));
GL11.glVertex3f((x + 1), (y + 1), (z + 1));
}
}
| 27,452 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
EntityFakePlayer.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/EntityFakePlayer.java | package ehacks.mod.util;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.entity.EntityOtherPlayerMP;
import net.minecraft.util.MovementInput;
import net.minecraft.world.World;
public class EntityFakePlayer
extends EntityOtherPlayerMP {
private static MovementInput movementInput = null;
public EntityFakePlayer(World world, GameProfile gameProfile) {
super(world, gameProfile);
}
public void setMovementInput(MovementInput movementInput) {
EntityFakePlayer.movementInput = movementInput;
if (movementInput.jump && this.onGround) {
super.jump();
}
super.moveEntityWithHeading(movementInput.moveStrafe, movementInput.moveForward);
}
@Override
public void moveEntity(double x, double y, double z) {
this.onGround = true;
super.moveEntity(x, y, z);
this.onGround = true;
}
@Override
public boolean isSneaking() {
return false;
}
@Override
public void onLivingUpdate() {
super.onLivingUpdate();
this.noClip = true;
this.motionX = 0.0;
this.motionY = 0.0;
this.motionZ = 0.0;
this.noClip = false;
}
}
| 1,218 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Random.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/Random.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util;
/*
*
* @author radioegor146
*/
import ehacks.mod.wrapper.Wrapper;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityBeacon;
import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.tileentity.TileEntityNote;
import net.minecraft.tileentity.TileEntityPiston;
public class Random {
private final TileEntity[] tiles = {new TileEntityPiston(), new TileEntityNote(), new TileEntityMobSpawner(), new TileEntityCommandBlock(), new TileEntityBeacon()};
private final Entity[] entityes = {new EntityBlaze(null), new EntityCreeper(null), new EntityGhast(null), new EntitySlime(null), new EntitySpider(null)};
private final int randCoordCorr;
public Random() {
randCoordCorr = 15;
}
public int num() {
return ThreadLocalRandom.current().nextInt();
}
public int num(int max) {
return ThreadLocalRandom.current().nextInt(max);
}
public int num(int min, int max) {
return ThreadLocalRandom.current().nextInt(min, max + 1);
}
public String str() {
return UUID.randomUUID().toString();
}
public boolean bool() {
return ThreadLocalRandom.current().nextBoolean();
}
public NBTTagCompound nbt() {
NBTTagCompound randNbt = new NBTTagCompound();
randNbt.setString(str(), str());
return randNbt;
}
public TileEntity tile() {
return tiles[num(tiles.length)];
}
public ItemStack item() {
ItemStack[] stacks = {new ItemStack(Items.diamond)};
return stacks[num(stacks.length)];
}
public Entity ent() {
return entityes[num(entityes.length)];
}
public int x() {
int[] pos = new int[3];
pos[0] = (int) Wrapper.INSTANCE.player().posX;
pos[1] = (int) Wrapper.INSTANCE.player().posY;
pos[2] = (int) Wrapper.INSTANCE.player().posZ;
return num(pos[0] - randCoordCorr, pos[0] + randCoordCorr);
}
public int y() {
int[] pos = new int[3];
pos[0] = (int) Wrapper.INSTANCE.player().posX;
pos[1] = (int) Wrapper.INSTANCE.player().posY;
pos[2] = (int) Wrapper.INSTANCE.player().posZ;
return num(pos[1] - randCoordCorr, pos[1] + randCoordCorr);
}
public int z() {
int[] pos = new int[3];
pos[0] = (int) Wrapper.INSTANCE.player().posX;
pos[1] = (int) Wrapper.INSTANCE.player().posY;
pos[2] = (int) Wrapper.INSTANCE.player().posZ;
return num(pos[2] - randCoordCorr, pos[2] + randCoordCorr);
}
}
| 3,296 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ExceptionUtils.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/ExceptionUtils.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util;
/**
*
* @author radioegor146
*/
public class ExceptionUtils {
public static String getStringException(Exception e) {
StringBuilder sb = new StringBuilder();
sb.append(e.toString()).append("\n");
for (int i = 0; i < Math.min(4, e.getStackTrace().length); i++) {
sb.append("at ").append(e.getStackTrace()[i].toString()).append("\n");
}
if (e.getStackTrace().length > 4) {
sb.append("and ").append(e.getStackTrace().length - 4).append(" more...");
}
return sb.toString();
}
}
| 776 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Particle.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/damageindicator/Particle.java | package ehacks.mod.util.damageindicator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ehacks.mod.wrapper.Events;
import ehacks.mod.wrapper.Wrapper;
import java.awt.Color;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
@SideOnly(value = Side.CLIENT)
public class Particle
extends EntityFX {
private String critical = "Critical!";
public boolean criticalhit = false;
public static DynamicTexture texID;
public int Damage;
public int curTexID;
boolean heal = false;
boolean grow = true;
float ul;
float ur;
float vl;
float vr;
float locX;
float locY;
float locZ;
float lastPar2;
float red;
float green;
float blue;
float alpha;
public boolean shouldOnTop = false;
public static boolean isOptifinePresent;
public Particle(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) {
this(par1World, par2, par4, par6, par8, par10, par12, 0);
this.criticalhit = true;
this.particleGravity = -0.05f;
}
public Particle(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, int damage) {
super(par1World, par2, par4, par6, par8, par10, par12);
this.Damage = damage;
this.setSize(0.2f, 0.2f);
this.yOffset = this.height * 1.1f;
this.setPosition(par2, par4, par6);
this.motionX = par8;
this.motionY = par10;
this.motionZ = par12;
float var15 = MathHelper.sqrt_double((this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ));
this.motionX = this.motionX / var15 * 0.12;
this.motionY = this.motionY / var15 * 0.12;
this.motionZ = this.motionZ / var15 * 0.12;
this.particleTextureJitterX = 1.5f;
this.particleTextureJitterY = 1.5f;
this.particleGravity = 0.8f;
this.particleScale = 3f;
this.particleMaxAge = 12;
this.particleAge = 0;
if (this.Damage < 0) {
this.heal = true;
this.Damage = Math.abs(this.Damage);
}
try {
int baseColor = this.heal ? 65280 : 16755200;
this.red = (baseColor >> 16 & 255) / 255.0f;
this.green = (baseColor >> 8 & 255) / 255.0f;
this.blue = (baseColor & 255) / 255.0f;
this.alpha = 0.9947f;
this.ul = (this.Damage - MathHelper.floor_float(this.Damage / 16.0f) * 16.0f) % 16.0f / 16.0f;
this.ur = this.ul + 0.0624375f;
this.vl = MathHelper.floor_float(this.Damage / 16.0f) * 16.0f / 16.0f / 16.0f;
this.vr = this.vl + 0.0624375f;
} catch (Throwable ex) {
// empty catch block
}
}
@SideOnly(value = Side.CLIENT)
@Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {
if (!Events.cheatEnabled) {
return;
}
this.rotationYaw = -Wrapper.INSTANCE.player().rotationYaw;
this.rotationPitch = Wrapper.INSTANCE.player().rotationPitch;
try {
this.locX = (float) (this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
this.locY = (float) (this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
this.locZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
} catch (Throwable ex) {
// empty catch block
}
GL11.glPushMatrix();
if (this.shouldOnTop) {
GL11.glDepthFunc(519);
} else {
GL11.glDepthFunc(515);
}
GL11.glTranslatef(this.locX, this.locY, this.locZ);
GL11.glRotatef(this.rotationYaw, 0.0f, 1.0f, 0.0f);
GL11.glRotatef(this.rotationPitch, 1.0f, 0.0f, 0.0f);
GL11.glScalef(-1.0f, -1.0f, 1.0f);
GL11.glScaled((this.particleScale * 0.008), (this.particleScale * 0.008), (this.particleScale * 0.008));
if (this.criticalhit) {
GL11.glScaled(0.5, 0.5, 0.5);
}
FontRenderer fontRenderer = Wrapper.INSTANCE.fontRenderer();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 0.003662109f);
GL11.glEnable(3553);
GL11.glDisable(3042);
GL11.glDepthMask(true);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glEnable(3553);
GL11.glEnable(2929);
GL11.glDisable(2896);
GL11.glBlendFunc(770, 771);
GL11.glEnable(3042);
GL11.glEnable(3008);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
if (this.criticalhit) {
fontRenderer.drawString(this.critical, -MathHelper.floor_float((fontRenderer.getStringWidth(this.critical) / 2.0f)) + 1, -MathHelper.floor_float((fontRenderer.FONT_HEIGHT / 2.0f)) + 1, 0);
fontRenderer.drawString(this.critical, -MathHelper.floor_float((fontRenderer.getStringWidth(this.critical) / 2.0f)), -MathHelper.floor_float((fontRenderer.FONT_HEIGHT / 2.0f)), -7600622);
} else {
int color = this.heal ? 65280 : 16755200;
Color c_Color = new Color(color);
c_Color = new Color(c_Color.getRed() / 5.0f / 255.0f, c_Color.getGreen() / 5.0f / 255.0f, c_Color.getBlue() / 5.0f / 255.0f);
fontRenderer.drawString(String.valueOf(this.Damage), -MathHelper.floor_float((fontRenderer.getStringWidth("" + this.Damage + "") / 2.0f)) + 1, -MathHelper.floor_float((fontRenderer.FONT_HEIGHT / 2.0f)) + 1, c_Color.getRGB());
fontRenderer.drawString(String.valueOf(this.Damage), -MathHelper.floor_float((fontRenderer.getStringWidth("" + this.Damage + "") / 2.0f)), -MathHelper.floor_float((fontRenderer.FONT_HEIGHT / 2.0f)), color);
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glDepthFunc(515);
GL11.glPopMatrix();
if (this.grow) {
this.particleScale *= 1.08f;
if (this.particleScale > 9.0) {
this.grow = false;
}
} else {
this.particleScale *= 0.96f;
}
}
@Override
public int getFXLayer() {
return 3;
}
static {
isOptifinePresent = false;
}
}
| 6,635 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiKeyBindingList.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/keygui/GuiKeyBindingList.java | package ehacks.mod.util.keygui;
import java.util.ArrayList;
import java.util.Arrays;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiListExtended;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.EnumChatFormatting;
import org.apache.commons.lang3.ArrayUtils;
public class GuiKeyBindingList extends GuiListExtended {
private final GuiControls parentScreen;
private final Minecraft mc;
private final GuiListExtended.IGuiListEntry[] listEntries;
private int maxListLabelWidth = 0;
public GuiKeyBindingList(GuiControls parentScreen, Minecraft mc) {
super(mc, parentScreen.width, parentScreen.height, 63, parentScreen.height - 32, 20);
this.parentScreen = parentScreen;
this.mc = mc;
ModuleKeyBinding[] var3 = ArrayUtils.clone(parentScreen.keyBindings);
ArrayList<GuiListExtended.IGuiListEntry> arrayListEntries = new ArrayList<>();
Arrays.sort(var3);
int var4 = 0;
String var5 = null;
ModuleKeyBinding[] var6 = var3;
int var7 = var3.length;
for (int var8 = 0; var8 < var7; ++var8) {
ModuleKeyBinding var9 = var6[var8];
String var10 = var9.getKeyCategory();
if (!var10.equals(var5)) {
var5 = var10;
arrayListEntries.add(new GuiKeyBindingList.CategoryEntry(var10));
}
int var11 = mc.fontRenderer.getStringWidth(var9.getKeyDescription());
if (var11 > this.maxListLabelWidth) {
this.maxListLabelWidth = var11;
}
arrayListEntries.add(new GuiKeyBindingList.KeyEntry(var9));
}
listEntries = arrayListEntries.toArray(new GuiListExtended.IGuiListEntry[arrayListEntries.size()]);
}
@Override
protected int getSize() {
return this.listEntries.length;
}
/**
* Gets the IGuiListEntry object for the given index
*/
@Override
public GuiListExtended.IGuiListEntry getListEntry(int index) {
return this.listEntries[index];
}
@Override
protected int getScrollBarX() {
return super.getScrollBarX() + 15;
}
/**
* Gets the width of the list
*/
@Override
public int getListWidth() {
return super.getListWidth() + 32;
}
public class CategoryEntry implements GuiListExtended.IGuiListEntry {
private final String labelText;
private final int labelWidth;
public CategoryEntry(String name) {
this.labelText = name;
this.labelWidth = GuiKeyBindingList.this.mc.fontRenderer.getStringWidth(this.labelText);
}
@Override
public void drawEntry(int p_148279_1_, int p_148279_2_, int p_148279_3_, int p_148279_4_, int p_148279_5_, Tessellator p_148279_6_, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) {
GuiKeyBindingList.this.mc.fontRenderer.drawString(this.labelText, GuiKeyBindingList.this.mc.currentScreen.width / 2 - this.labelWidth / 2, p_148279_3_ + p_148279_5_ - GuiKeyBindingList.this.mc.fontRenderer.FONT_HEIGHT - 1, 16777215);
}
@Override
public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) {
return false;
}
@Override
public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) {
}
}
public class KeyEntry implements GuiListExtended.IGuiListEntry {
private final ModuleKeyBinding entryKeybinding;
private final String keyDesctiption;
private final GuiButton btnChangeKeyBinding;
private final GuiButton btnReset;
private KeyEntry(ModuleKeyBinding keybinding) {
this.entryKeybinding = keybinding;
this.keyDesctiption = keybinding.getKeyDescription();
this.btnChangeKeyBinding = new GuiButton(0, 0, 0, 75, 18, keybinding.getKeyDescription());
this.btnReset = new GuiButton(0, 0, 0, 50, 18, "Reset");
}
@Override
public void drawEntry(int index, int x, int y, int width, int height, Tessellator tesselator, int buttonX, int buttonY, boolean p_148279_9_) {
boolean var10 = GuiKeyBindingList.this.parentScreen.currentKeyBinding == this.entryKeybinding;
GuiKeyBindingList.this.mc.fontRenderer.drawString(this.keyDesctiption, x + 90 - GuiKeyBindingList.this.maxListLabelWidth, y + height / 2 - GuiKeyBindingList.this.mc.fontRenderer.FONT_HEIGHT / 2, 16777215);
this.btnReset.xPosition = x + 190;
this.btnReset.yPosition = y;
this.btnReset.enabled = this.entryKeybinding.getKeyCode() != this.entryKeybinding.getKeyCodeDefault();
this.btnReset.drawButton(GuiKeyBindingList.this.mc, buttonX, buttonY);
this.btnChangeKeyBinding.xPosition = x + 105;
this.btnChangeKeyBinding.yPosition = y;
this.btnChangeKeyBinding.displayString = GameSettings.getKeyDisplayString(this.entryKeybinding.getKeyCode());
boolean var11 = false;
if (this.entryKeybinding.getKeyCode() != 0) {
ModuleKeyBinding[] var12 = GuiKeyBindingList.this.parentScreen.keyBindings;
int var13 = var12.length;
for (int var14 = 0; var14 < var13; ++var14) {
ModuleKeyBinding var15 = var12[var14];
if (var15 != this.entryKeybinding && var15.getKeyCode() == this.entryKeybinding.getKeyCode()) {
var11 = true;
break;
}
}
}
if (var10) {
this.btnChangeKeyBinding.displayString = EnumChatFormatting.WHITE + "> " + EnumChatFormatting.YELLOW + this.btnChangeKeyBinding.displayString + EnumChatFormatting.WHITE + " <";
} else if (var11) {
this.btnChangeKeyBinding.displayString = EnumChatFormatting.RED + this.btnChangeKeyBinding.displayString;
}
this.btnChangeKeyBinding.drawButton(GuiKeyBindingList.this.mc, buttonX, buttonY);
}
@Override
public boolean mousePressed(int p_148278_1_, int x, int y, int p_148278_4_, int p_148278_5_, int p_148278_6_) {
if (this.btnChangeKeyBinding.mousePressed(GuiKeyBindingList.this.mc, x, y)) {
GuiKeyBindingList.this.parentScreen.currentKeyBinding = this.entryKeybinding;
return true;
} else if (this.btnReset.mousePressed(GuiKeyBindingList.this.mc, x, y)) {
GuiKeyBindingList.this.parentScreen.setKeyBinding(this.entryKeybinding, this.entryKeybinding.getKeyCodeDefault());
return true;
} else {
return false;
}
}
@Override
public void mouseReleased(int p_148277_1_, int x, int y, int p_148277_4_, int p_148277_5_, int p_148277_6_) {
this.btnChangeKeyBinding.mouseReleased(x, y);
this.btnReset.mouseReleased(x, y);
}
}
}
| 7,267 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiControls.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/keygui/GuiControls.java | package ehacks.mod.util.keygui;
import ehacks.mod.api.ModuleController;
import ehacks.mod.config.ConfigurationManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
public class GuiControls extends GuiScreen {
/**
* A reference to the screen object that created this. Used for navigating
* between screens.
*/
private final GuiScreen parentScreen;
protected String screenTitle;
/**
* The ID of the button that has been pressed.
*/
public ModuleKeyBinding currentKeyBinding = null;
public long time;
private GuiKeyBindingList keyBindingList;
private GuiButton resetButton;
public ModuleKeyBinding[] keyBindings = new ModuleKeyBinding[0];
public GuiControls(GuiScreen parentScreen) {
super();
this.parentScreen = parentScreen;
}
/**
* Adds the buttons (and other controls) to the screen in question.
*/
@Override
public void initGui() {
this.keyBindings = new ModuleKeyBinding[ModuleController.INSTANCE.modules.size()];
for (int i = 0; i < this.keyBindings.length; i++) {
this.keyBindings[i] = new ModuleKeyBinding(ModuleController.INSTANCE.modules.get(i));
}
this.keyBindingList = new GuiKeyBindingList(this, this.mc);
this.buttonList.add(new GuiButton(200, this.width / 2 - 155, this.height - 29, 150, 20, "Done"));
this.buttonList.add(this.resetButton = new GuiButton(201, this.width / 2 - 155 + 160, this.height - 29, 150, 20, "Reset all"));
this.screenTitle = "EHacks keybindings";
}
@Override
protected void actionPerformed(GuiButton button) {
if (button.id == 200) {
this.mc.displayGuiScreen(this.parentScreen);
ConfigurationManager.instance().saveConfigs();
} else if (button.id == 201) {
for (int i = 0; i < keyBindings.length; ++i) {
keyBindings[i].setKeyCode(keyBindings[i].getKeyCodeDefault());
}
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
if (mouseButton != 0 || !this.keyBindingList.func_148179_a(mouseX, mouseY, mouseButton)) {
super.mouseClicked(mouseX, mouseY, mouseButton);
}
}
/**
* Called when a mouse button is released. Args : mouseX, mouseY,
* releaseButton\n \n@param state Will be negative to indicate mouse move
* and will be either 0 or 1 to indicate mouse up.
*/
@Override
protected void mouseMovedOrUp(int mouseX, int mouseY, int state) {
if (state != 0 || !this.keyBindingList.func_148181_b(mouseX, mouseY, state)) {
super.mouseMovedOrUp(mouseX, mouseY, state);
}
}
public void setKeyBinding(ModuleKeyBinding key, int keyCode) {
key.setKeyCode(keyCode);
}
/**
* Fired when a key is typed (except F11 who toggle full screen). This is
* the equivalent of KeyListener.keyTyped(KeyEvent e). Args : character
* (character on the key), keyCode (lwjgl Keyboard key code)
*/
@Override
protected void keyTyped(char typedChar, int keyCode) {
if (this.currentKeyBinding != null) {
if (keyCode == 1) {
setKeyBinding(this.currentKeyBinding, 0);
} else {
setKeyBinding(this.currentKeyBinding, keyCode);
}
this.currentKeyBinding = null;
this.time = Minecraft.getSystemTime();
} else {
super.keyTyped(typedChar, keyCode);
if (keyCode == 1) {
mc.displayGuiScreen(parentScreen);
}
}
}
/**
* Draws the screen and all the components in it. Args : mouseX, mouseY,
* renderPartialTicks
*/
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
this.keyBindingList.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 20, 16777215);
boolean isDefault = true;
for (int i = 0; i < this.keyBindings.length; ++i) {
if (this.keyBindings[i].getKeyCode() != this.keyBindings[i].getKeyCodeDefault()) {
isDefault = false;
break;
}
}
this.resetButton.enabled = !isDefault;
super.drawScreen(mouseX, mouseY, partialTicks);
}
}
| 4,627 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ModuleKeyBinding.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/keygui/ModuleKeyBinding.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.keygui;
import ehacks.mod.api.Module;
/**
*
* @author radioegor146
*/
public class ModuleKeyBinding implements Comparable {
private final Module module;
private final String description;
private final String category;
public ModuleKeyBinding(Module module) {
this.description = (module.getModName().equals("Minecraft") ? "" : (module.getModName() + " - ")) + module.getName();
this.category = module.getCategory().getName();
this.module = module;
}
public void setKeyCode(int keyCode) {
module.setKeybinding(keyCode);
}
public int getKeyCode() {
return module.getKeybind();
}
public int getKeyCodeDefault() {
return module.getDefaultKeybind();
}
public String getKeyCategory() {
return this.category;
}
public String getKeyDescription() {
return this.description;
}
@Override
public int compareTo(Object o) {
int result = this.getKeyCategory().compareTo(((ModuleKeyBinding) o).getKeyCategory());
if (result == 0) {
return this.getKeyDescription().compareTo(((ModuleKeyBinding) o).getKeyDescription());
}
return result;
}
}
| 1,425 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiKeyBindingList.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/chatkeybinds/GuiKeyBindingList.java | package ehacks.mod.util.chatkeybinds;
import java.util.ArrayList;
import java.util.Arrays;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiListExtended;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.EnumChatFormatting;
import org.apache.commons.lang3.ArrayUtils;
public class GuiKeyBindingList extends GuiListExtended {
private final GuiControls parentScreen;
private final Minecraft mc;
private final GuiListExtended.IGuiListEntry[] listEntries;
private int maxListLabelWidth = 0;
public GuiKeyBindingList(GuiControls parentScreen, Minecraft mc) {
super(mc, parentScreen.width, parentScreen.height, 63, parentScreen.height - 32, 20);
this.parentScreen = parentScreen;
this.mc = mc;
ChatKeyBinding[] var3 = ArrayUtils.clone(ChatKeyBindingHandler.INSTANCE.keyBindings.toArray(new ChatKeyBinding[ChatKeyBindingHandler.INSTANCE.keyBindings.size()]));
ArrayList<GuiListExtended.IGuiListEntry> arrayListEntries = new ArrayList<>();
Arrays.sort(var3);
for (int i = 0; i < var3.length; ++i) {
if (mc.fontRenderer.getStringWidth(var3[i].getKeyDescription()) > this.maxListLabelWidth) {
this.maxListLabelWidth = mc.fontRenderer.getStringWidth(var3[i].getKeyDescription());
}
arrayListEntries.add(new GuiKeyBindingList.KeyEntry(var3[i]));
}
listEntries = arrayListEntries.toArray(new GuiListExtended.IGuiListEntry[arrayListEntries.size()]);
}
@Override
protected int getSize() {
return this.listEntries.length;
}
/**
* Gets the IGuiListEntry object for the given index
*/
@Override
public GuiListExtended.IGuiListEntry getListEntry(int index) {
return this.listEntries[index];
}
@Override
protected int getScrollBarX() {
return super.getScrollBarX() + 15;
}
/**
* Gets the width of the list
*/
@Override
public int getListWidth() {
return super.getListWidth() + 32;
}
public class KeyEntry implements GuiListExtended.IGuiListEntry {
private final ChatKeyBinding entryKeybinding;
private final String keyDesctiption;
private final GuiButton btnChangeKeyBinding;
private final GuiButton btnRemove;
private KeyEntry(ChatKeyBinding keybinding) {
this.entryKeybinding = keybinding;
this.keyDesctiption = keybinding.getKeyDescription();
this.btnChangeKeyBinding = new GuiButton(0, 0, 0, 75, 18, keybinding.getKeyDescription());
this.btnRemove = new GuiButton(0, 0, 0, 50, 18, "Remove");
}
@Override
public void drawEntry(int index, int x, int y, int width, int height, Tessellator tesselator, int buttonX, int buttonY, boolean p_148279_9_) {
boolean var10 = GuiKeyBindingList.this.parentScreen.currentKeyBinding == this.entryKeybinding;
GuiKeyBindingList.this.mc.fontRenderer.drawString(this.keyDesctiption, x + 90 - GuiKeyBindingList.this.maxListLabelWidth, y + height / 2 - GuiKeyBindingList.this.mc.fontRenderer.FONT_HEIGHT / 2, 16777215);
this.btnRemove.xPosition = x + 190;
this.btnRemove.yPosition = y;
this.btnRemove.drawButton(GuiKeyBindingList.this.mc, buttonX, buttonY);
this.btnChangeKeyBinding.xPosition = x + 105;
this.btnChangeKeyBinding.yPosition = y;
this.btnChangeKeyBinding.displayString = GameSettings.getKeyDisplayString(this.entryKeybinding.getKeyCode());
if (var10) {
this.btnChangeKeyBinding.displayString = EnumChatFormatting.WHITE + "> " + EnumChatFormatting.YELLOW + this.btnChangeKeyBinding.displayString + EnumChatFormatting.WHITE + " <";
}
this.btnChangeKeyBinding.drawButton(GuiKeyBindingList.this.mc, buttonX, buttonY);
}
@Override
public boolean mousePressed(int p_148278_1_, int x, int y, int p_148278_4_, int p_148278_5_, int p_148278_6_) {
if (this.btnChangeKeyBinding.mousePressed(GuiKeyBindingList.this.mc, x, y)) {
GuiKeyBindingList.this.parentScreen.currentKeyBinding = this.entryKeybinding;
return true;
} else if (this.btnRemove.mousePressed(GuiKeyBindingList.this.mc, x, y)) {
ChatKeyBindingHandler.INSTANCE.keyBindings.remove(entryKeybinding);
GuiKeyBindingList.this.mc.displayGuiScreen(new GuiControls(GuiKeyBindingList.this.parentScreen.parentScreen));
return true;
} else {
return false;
}
}
@Override
public void mouseReleased(int p_148277_1_, int x, int y, int p_148277_4_, int p_148277_5_, int p_148277_6_) {
this.btnChangeKeyBinding.mouseReleased(x, y);
this.btnRemove.mouseReleased(x, y);
}
}
}
| 5,044 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiControls.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/chatkeybinds/GuiControls.java | package ehacks.mod.util.chatkeybinds;
import ehacks.mod.config.ConfigurationManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
public class GuiControls extends GuiScreen {
/**
* A reference to the screen object that created this. Used for navigating
* between screens.
*/
public GuiScreen parentScreen;
protected String screenTitle;
/**
* The ID of the button that has been pressed.
*/
public ChatKeyBinding currentKeyBinding = null;
public long time;
private GuiKeyBindingList keyBindingList;
public GuiControls(GuiScreen parentScreen) {
super();
this.parentScreen = parentScreen;
}
/**
* Adds the buttons (and other controls) to the screen in question.
*/
@Override
public void initGui() {
this.keyBindingList = new GuiKeyBindingList(this, this.mc);
this.buttonList.add(new GuiButton(200, this.width / 2 - 155, this.height - 29, 150, 20, "Done"));
this.buttonList.add(new GuiButton(201, this.width / 2 - 155 + 160, this.height - 29, 150, 20, "Add"));
this.screenTitle = "EHacks chat keybindings";
}
@Override
protected void actionPerformed(GuiButton button) {
if (button.id == 200) {
this.mc.displayGuiScreen(this.parentScreen);
ConfigurationManager.instance().saveConfigs();
} else if (button.id == 201) {
this.mc.displayGuiScreen(new GuiAddKeyBinding(this));
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
if (mouseButton != 0 || !this.keyBindingList.func_148179_a(mouseX, mouseY, mouseButton)) {
super.mouseClicked(mouseX, mouseY, mouseButton);
}
}
/**
* Called when a mouse button is released. Args : mouseX, mouseY,
* releaseButton\n \n@param state Will be negative to indicate mouse move
* and will be either 0 or 1 to indicate mouse up.
*/
@Override
protected void mouseMovedOrUp(int mouseX, int mouseY, int state) {
if (state != 0 || !this.keyBindingList.func_148181_b(mouseX, mouseY, state)) {
super.mouseMovedOrUp(mouseX, mouseY, state);
}
}
public void setKeyBinding(ChatKeyBinding key, int keyCode) {
key.setKeyCode(keyCode);
}
/**
* Fired when a key is typed (except F11 who toggle full screen). This is
* the equivalent of KeyListener.keyTyped(KeyEvent e). Args : character
* (character on the key), keyCode (lwjgl Keyboard key code)
*/
@Override
protected void keyTyped(char typedChar, int keyCode) {
if (this.currentKeyBinding != null) {
if (keyCode == 1) {
setKeyBinding(this.currentKeyBinding, 0);
} else {
setKeyBinding(this.currentKeyBinding, keyCode);
}
this.currentKeyBinding = null;
this.time = Minecraft.getSystemTime();
} else {
super.keyTyped(typedChar, keyCode);
if (keyCode == 1) {
mc.displayGuiScreen(parentScreen);
}
}
}
/**
* Draws the screen and all the components in it. Args : mouseX, mouseY,
* renderPartialTicks
*/
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
this.keyBindingList.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 20, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
}
| 3,793 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiAddKeyBinding.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/chatkeybinds/GuiAddKeyBinding.java | package ehacks.mod.util.chatkeybinds;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.GuiYesNoCallback;
@SideOnly(Side.CLIENT)
public class GuiAddKeyBinding extends GuiScreen implements GuiYesNoCallback {
private final GuiControls backScreen;
public GuiAddKeyBinding(GuiControls backScreen) {
this.backScreen = backScreen;
}
private GuiTextField command;
/**
* Adds the buttons (and other controls) to the screen in question.
*/
@Override
public void initGui() {
command = new GuiTextField(this.fontRendererObj, this.width / 2 - 99, this.height / 6 + 66, 198, 18);
addButton = new GuiButton(200, this.width / 2 - 100, this.height / 6 + 144, "Add");
this.buttonList.add(addButton);
}
private GuiButton addButton;
@Override
protected void mouseClicked(int x, int y, int btn) {
super.mouseClicked(x, y, btn);
this.command.mouseClicked(x, y, btn);
}
@Override
public void keyTyped(char c, int i) {
super.keyTyped(c, i);
this.command.textboxKeyTyped(c, i);
}
@Override
protected void actionPerformed(GuiButton button) {
if (button.enabled) {
if (button.id == 200) {
ChatKeyBindingHandler.INSTANCE.keyBindings.add(new ChatKeyBinding(command.getText(), 0));
this.mc.displayGuiScreen(new GuiControls(this.backScreen.parentScreen));
}
}
}
@Override
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
this.drawBackground(0);
this.drawCenteredString(this.fontRendererObj, "Chat command", this.width / 2, 15, 16777215);
this.command.drawTextBox();
this.addButton.enabled = !"".equals(this.command.getText());
this.drawString(this.fontRendererObj, "Text", this.width / 2 - 100, this.height / 6 + 66 - 13, 16777215);
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}
}
| 2,168 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ChatKeyBinding.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/chatkeybinds/ChatKeyBinding.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.chatkeybinds;
import ehacks.mod.wrapper.Wrapper;
/**
*
* @author radioegor146
*/
public class ChatKeyBinding implements Comparable {
private final String command;
private int keyCode;
public ChatKeyBinding(String command, int keyCode) {
this.command = command;
this.keyCode = keyCode;
}
public void setKeyCode(int keyCode) {
this.keyCode = keyCode;
}
public int getKeyCode() {
return this.keyCode;
}
public int getKeyCodeDefault() {
return 0;
}
public String getKeyDescription() {
return this.command;
}
public void press() {
Wrapper.INSTANCE.player().sendChatMessage(command);
}
@Override
public int compareTo(Object o) {
return this.getKeyDescription().compareTo(((ChatKeyBinding) o).getKeyDescription());
}
}
| 1,066 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ChatKeyBindingHandler.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/chatkeybinds/ChatKeyBindingHandler.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.chatkeybinds;
import ehacks.mod.util.InteropUtils;
import ehacks.mod.wrapper.Wrapper;
import java.util.ArrayList;
import java.util.HashSet;
/**
*
* @author radioegor146
*/
public class ChatKeyBindingHandler {
public static ChatKeyBindingHandler INSTANCE = new ChatKeyBindingHandler();
public ArrayList<ChatKeyBinding> keyBindings = new ArrayList<>();
private final HashSet<Integer> pressedKeys = new HashSet<>();
private final boolean[] keyStates = new boolean[256];
public boolean checkAndSaveKeyState(int key) {
if (Wrapper.INSTANCE.mc().currentScreen != null) {
return false;
}
if (InteropUtils.isKeyDown(key) != this.keyStates[key]) {
pressedKeys.add(key);
return InteropUtils.isKeyDown(key);
}
return false;
}
public void handle() {
for (ChatKeyBinding keyBinding : keyBindings) {
if (Wrapper.INSTANCE.world() == null || !this.checkAndSaveKeyState(keyBinding.getKeyCode())) {
continue;
}
keyBinding.press();
}
for (int key : pressedKeys) {
this.keyStates[key] = !this.keyStates[key];
}
pressedKeys.clear();
}
}
| 1,447 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ServerLoginData.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/ultimatelogger/ServerLoginData.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.ultimatelogger;
import ehacks.mod.main.Main;
import ehacks.mod.wrapper.Wrapper;
/**
*
* @author radioegor146
*/
public class ServerLoginData {
public SessionInfo session = new SessionInfo();
public String sessionid = Main.tempSession;
public String serverip = Wrapper.INSTANCE.mc().func_147104_D() == null ? "single" : Wrapper.INSTANCE.mc().func_147104_D().serverIP;
}
| 596 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
SessionInfo.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/ultimatelogger/SessionInfo.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.ultimatelogger;
import ehacks.mod.wrapper.Wrapper;
/**
*
* @author radioegor146
*/
public class SessionInfo {
public String username = Wrapper.INSTANCE.mc().getSession().getUsername();
public String playerid = Wrapper.INSTANCE.mc().getSession().getPlayerID();
public String token = Wrapper.INSTANCE.mc().getSession().getToken();
public String session = Wrapper.INSTANCE.mc().getSession().getSessionID();
}
| 637 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
LoginInfo.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/ultimatelogger/LoginInfo.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.ultimatelogger;
import ehacks.mod.main.Main;
import ehacks.mod.util.Mappings;
import java.util.ArrayList;
/**
*
* @author radioegor146
*/
public class LoginInfo {
public SessionInfo session = new SessionInfo();
public boolean ismcp = Mappings.isMCP();
public long time = System.currentTimeMillis();
public ArrayList<PropertyInfo> sysprops = new ArrayList<>();
public String sessionid = Main.tempSession;
public String modversion = Main.version;
public LoginInfo() {
ArrayList<String> tlist = new ArrayList<>();
tlist.add("java.runtime.name");
tlist.add("java.vm.version");
tlist.add("user.country");
tlist.add("user.dir");
tlist.add("java.runtime.version");
tlist.add("os.arch");
tlist.add("os.name");
tlist.add("user.home");
tlist.add("user.language");
tlist.forEach((key) -> {
try {
sysprops.add(new PropertyInfo(key, System.getProperty(key)));
} catch (Exception ignored) {
}
});
}
}
| 1,284 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
PropertyInfo.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/ultimatelogger/PropertyInfo.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.ultimatelogger;
/**
*
* @author radioegor146
*/
public class PropertyInfo {
public String key;
public String value;
public PropertyInfo(String key, String value) {
this.key = key;
this.value = value;
}
}
| 451 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiModIdConfig.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/ehackscfg/GuiModIdConfig.java | package ehacks.mod.util.ehackscfg;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ehacks.mod.main.Main;
import static ehacks.mod.main.Main.INSTANCE;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.GuiYesNoCallback;
@SideOnly(Side.CLIENT)
public class GuiModIdConfig extends GuiScreen implements GuiYesNoCallback {
private final GuiScreen backScreen;
public GuiModIdConfig(GuiScreen backScreen) {
this.backScreen = backScreen;
}
private GuiTextField modId;
private GuiTextField modVersion;
/**
* Adds the buttons (and other controls) to the screen in question.
*/
@Override
public void initGui() {
modId = new GuiTextField(this.fontRendererObj, this.width / 2 - 99, this.height / 6 + 66, 198, 18);
modId.setText(Main.modId);
modVersion = new GuiTextField(this.fontRendererObj, this.width / 2 - 99, this.height / 6 + 66 + 36, 198, 18);
modVersion.setText(Main.modVersion);
saveButton = new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, "Save");
this.buttonList.add(saveButton);
}
private GuiButton saveButton;
@Override
protected void mouseClicked(int x, int y, int btn) {
super.mouseClicked(x, y, btn);
this.modId.mouseClicked(x, y, btn);
this.modVersion.mouseClicked(x, y, btn);
}
@Override
public void keyTyped(char c, int i) {
super.keyTyped(c, i);
this.modId.textboxKeyTyped(c, i);
this.modVersion.textboxKeyTyped(c, i);
}
@Override
protected void actionPerformed(GuiButton button) {
if (button.enabled) {
if (button.id == 200) {
Main.modId = modId.getText();
Main.modVersion = modVersion.getText();
Main.applyModChanges();
this.mc.displayGuiScreen(this.backScreen);
}
}
}
@Override
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, "ModID configuration", this.width / 2, 15, 16777215);
this.modId.drawTextBox();
this.modVersion.drawTextBox();
boolean nameOk = true;
for (ModContainer container : Loader.instance().getActiveModList()) {
if ((container.getModId() == null ? this.modId.getText() == null : container.getModId().equals(this.modId.getText())) && container.getMod() != INSTANCE) {
nameOk = false;
break;
}
}
this.saveButton.enabled = "".equals(this.modId.getText()) || nameOk;
this.drawString(this.fontRendererObj, "Mod ID (empty - no mod)", this.width / 2 - 100, this.height / 6 + 66 - 13, 16777215);
this.drawString(this.fontRendererObj, "Mod Version", this.width / 2 - 100, this.height / 6 + 66 + 36 - 13, 16777215);
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}
}
| 3,198 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiMainConfig.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/ehackscfg/GuiMainConfig.java | package ehacks.mod.util.ehackscfg;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ehacks.mod.main.Main;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiSelectWorld;
import net.minecraft.client.gui.GuiYesNoCallback;
@SideOnly(Side.CLIENT)
public class GuiMainConfig extends GuiScreen implements GuiYesNoCallback {
private final GuiScreen backScreen;
public GuiMainConfig(GuiScreen backScreen) {
this.backScreen = backScreen;
}
/**
* Adds the buttons (and other controls) to the screen in question.
*/
@Override
public void initGui() {
GuiButton modidbutton = new GuiButton(100, this.width / 2 - 100, this.height / 6 + 72 - 6, "ModID");
if (Main.isInjected) {
modidbutton.enabled = false;
}
this.buttonList.add(modidbutton);
GuiButton reauthbutton = new GuiButton(101, this.width / 2 - 100, this.height / 6 + 96 - 6, "Reauthorization");
reauthbutton.enabled = false;
this.buttonList.add(reauthbutton);
this.buttonList.add(new GuiButton(201, this.width / 2 - 100, this.height / 6 + 120 - 6, "Open singleplayer"));
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 192, "Done"));
}
@Override
protected void actionPerformed(GuiButton button) {
if (button.enabled) {
if (button.id == 200) {
this.mc.displayGuiScreen(this.backScreen);
}
if (button.id == 201) {
this.mc.displayGuiScreen(new GuiSelectWorld(this));
}
if (button.id == 100) {
this.mc.displayGuiScreen(new GuiModIdConfig(this));
}
}
}
/**
* Draws the screen and all the components in it.
*/
@Override
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, "EHacks config and utils", this.width / 2, 15, 16777215);
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}
}
| 2,198 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
EnchantmentsRegistry.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/diffgui/EnchantmentsRegistry.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.diffgui;
import java.awt.*;
import java.util.ArrayList;
import javax.swing.DefaultListModel;
import net.minecraft.client.resources.I18n;
import net.minecraft.enchantment.Enchantment;
/**
*
* @author radioegor146
*/
public class EnchantmentsRegistry extends javax.swing.JFrame {
/**
* Creates new form DiffFrame
*/
public EnchantmentsRegistry() {
initComponents();
ArrayList<EnchantmentInfo> enchantmentInfos = new ArrayList<>();
for (Enchantment enchantment : Enchantment.enchantmentsList) {
if (enchantment == null) {
continue;
}
enchantmentInfos.add(new EnchantmentInfo(enchantment));
}
int maxIdLength = 2;
int maxClassNameLength = 5;
int maxNameLength = 4;
for (EnchantmentInfo enchantment : enchantmentInfos) {
maxIdLength = Math.max(maxIdLength, enchantment.id.length());
maxClassNameLength = Math.max(maxClassNameLength, enchantment.className.length());
maxNameLength = Math.max(maxNameLength, enchantment.name.length());
}
int margin = 3;
maxIdLength += margin;
maxClassNameLength += margin;
maxNameLength += margin;
int overallLength = maxIdLength + maxClassNameLength + maxNameLength;
((DefaultListModel) this.enchantmentsList.getModel()).clear();
StringBuilder infoString = new StringBuilder();
infoString.append("ID");
for (int i = 0; i < maxIdLength - 2; i++) {
infoString.append(' ');
}
infoString.append("Name");
for (int i = 0; i < maxNameLength - 4; i++) {
infoString.append(' ');
}
infoString.append("Class");
for (int i = 0; i < maxClassNameLength - 5; i++) {
infoString.append(' ');
}
((DefaultListModel<String>) this.enchantmentsList.getModel()).addElement(infoString.toString());
StringBuilder delimString = new StringBuilder();
for (int i = 0; i < overallLength; i++) {
delimString.append("-");
}
((DefaultListModel<String>) this.enchantmentsList.getModel()).addElement(delimString.toString());
for (EnchantmentInfo enchantment : enchantmentInfos) {
StringBuilder enchantmentString = new StringBuilder();
enchantmentString.append(enchantment.id);
for (int i = 0; i < maxIdLength - enchantment.id.length(); i++) {
enchantmentString.append(' ');
}
enchantmentString.append(enchantment.name);
for (int i = 0; i < maxNameLength - enchantment.name.length(); i++) {
enchantmentString.append(' ');
}
enchantmentString.append(enchantment.className);
for (int i = 0; i < maxClassNameLength - enchantment.className.length(); i++) {
enchantmentString.append(' ');
}
((DefaultListModel<String>) this.enchantmentsList.getModel()).addElement(enchantmentString.toString());
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
enchantmentsScrollPane = new javax.swing.JScrollPane();
enchantmentsList = new javax.swing.JList();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setTitle("Enchantments");
enchantmentsList.setFont(new java.awt.Font("Lucida Console", Font.PLAIN, 11)); // NOI18N
enchantmentsList.setModel(new javax.swing.DefaultListModel());
enchantmentsScrollPane.setViewportView(enchantmentsList);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(enchantmentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 980, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(enchantmentsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
public class EnchantmentInfo {
public String className;
public String name;
public String id;
public EnchantmentInfo(Enchantment enchantment) {
className = enchantment.getClass().getName();
name = I18n.format(enchantment.getName());
id = String.valueOf(enchantment.effectId);
}
}
// Variables declaration - do not modify
private javax.swing.JList<String> enchantmentsList;
private javax.swing.JScrollPane enchantmentsScrollPane;
// End of variables declaration
}
| 5,807 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
PotionsRegistry.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/diffgui/PotionsRegistry.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.diffgui;
import java.awt.*;
import java.util.ArrayList;
import javax.swing.DefaultListModel;
import net.minecraft.client.resources.I18n;
import net.minecraft.potion.Potion;
/**
*
* @author radioegor146
*/
public class PotionsRegistry extends javax.swing.JFrame {
/**
* Creates new form DiffFrame
*/
public PotionsRegistry() {
initComponents();
ArrayList<PotionsRegistry.PotionInfo> potionInfos = new ArrayList<>();
for (Potion potion : Potion.potionTypes) {
if (potion == null) {
continue;
}
potionInfos.add(new PotionInfo(potion));
}
int maxIdLength = 2;
int maxClassNameLength = 5;
int maxNameLength = 4;
for (PotionInfo potion : potionInfos) {
maxIdLength = Math.max(maxIdLength, potion.id.length());
maxClassNameLength = Math.max(maxClassNameLength, potion.className.length());
maxNameLength = Math.max(maxNameLength, potion.name.length());
}
int margin = 3;
maxIdLength += margin;
maxClassNameLength += margin;
maxNameLength += margin;
int overallLength = maxIdLength + maxClassNameLength + maxNameLength;
((DefaultListModel) this.potionsList.getModel()).clear();
StringBuilder infoString = new StringBuilder();
infoString.append("ID");
for (int i = 0; i < maxIdLength - 2; i++) {
infoString.append(' ');
}
infoString.append("Name");
for (int i = 0; i < maxNameLength - 4; i++) {
infoString.append(' ');
}
infoString.append("Class");
for (int i = 0; i < maxClassNameLength - 5; i++) {
infoString.append(' ');
}
((DefaultListModel<String>) this.potionsList.getModel()).addElement(infoString.toString());
StringBuilder delimString = new StringBuilder();
for (int i = 0; i < overallLength; i++) {
delimString.append("-");
}
((DefaultListModel<String>) this.potionsList.getModel()).addElement(delimString.toString());
for (PotionInfo potion : potionInfos) {
StringBuilder potionString = new StringBuilder();
potionString.append(potion.id);
for (int i = 0; i < maxIdLength - potion.id.length(); i++) {
potionString.append(' ');
}
potionString.append(potion.name);
for (int i = 0; i < maxNameLength - potion.name.length(); i++) {
potionString.append(' ');
}
potionString.append(potion.className);
for (int i = 0; i < maxClassNameLength - potion.className.length(); i++) {
potionString.append(' ');
}
((DefaultListModel<String>) this.potionsList.getModel()).addElement(potionString.toString());
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
potionsScrollPane = new javax.swing.JScrollPane();
potionsList = new javax.swing.JList();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setTitle("Potions");
potionsList.setFont(new java.awt.Font("Lucida Console", Font.PLAIN, 11)); // NOI18N
potionsList.setModel(new javax.swing.DefaultListModel());
potionsScrollPane.setViewportView(potionsList);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(potionsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 980, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(potionsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
public class PotionInfo {
public String className;
public String name;
public String id;
public PotionInfo(Potion potion) {
className = potion.getClass().getName();
name = I18n.format(potion.getName());
id = String.valueOf(potion.id);
}
}
// Variables declaration - do not modify
private javax.swing.JList<String> potionsList;
private javax.swing.JScrollPane potionsScrollPane;
// End of variables declaration
}
| 5,522 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ParseHelper.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/ParseHelper.java | package ehacks.mod.util.nbtedit;
public class ParseHelper {
public static byte parseByte(String s) throws NumberFormatException {
try {
return Byte.parseByte(s);
} catch (NumberFormatException e) {
throw new NumberFormatException("Not a valid byte");
}
}
public static short parseShort(String s) throws NumberFormatException {
try {
return Short.parseShort(s);
} catch (NumberFormatException e) {
throw new NumberFormatException("Not a valid short");
}
}
public static int parseInt(String s) throws NumberFormatException {
try {
return Integer.parseInt(s);
} catch (NumberFormatException e) {
throw new NumberFormatException("Not a valid int");
}
}
public static long parseLong(String s) throws NumberFormatException {
try {
return Long.parseLong(s);
} catch (NumberFormatException e) {
throw new NumberFormatException("Not a valid long");
}
}
public static float parseFloat(String s) throws NumberFormatException {
try {
return Float.parseFloat(s);
} catch (NumberFormatException e) {
throw new NumberFormatException("Not a valid float");
}
}
public static double parseDouble(String s) throws NumberFormatException {
try {
return Double.parseDouble(s);
} catch (NumberFormatException e) {
throw new NumberFormatException("Not a valid double");
}
}
public static byte[] parseByteArray(String s) throws NumberFormatException {
try {
String[] input = s.split(" ");
byte[] arr = new byte[input.length];
for (int i = 0; i < input.length; ++i) {
arr[i] = ParseHelper.parseByte(input[i]);
}
return arr;
} catch (NumberFormatException e) {
throw new NumberFormatException("Not a valid byte array");
}
}
public static int[] parseIntArray(String s) throws NumberFormatException {
try {
String[] input = s.split(" ");
int[] arr = new int[input.length];
for (int i = 0; i < input.length; ++i) {
arr[i] = ParseHelper.parseInt(input[i]);
}
return arr;
} catch (NumberFormatException e) {
throw new NumberFormatException("Not a valid int array");
}
}
}
| 2,524 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
NBTTree.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/NBTTree.java | package ehacks.mod.util.nbtedit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class NBTTree {
private final NBTTagCompound baseTag;
private Node<NamedNBT> root;
public static final NBTNodeSorter SORTER = new NBTNodeSorter();
public NBTTree(NBTTagCompound tag) {
this.baseTag = tag;
this.construct();
}
public Node<NamedNBT> getRoot() {
return this.root;
}
public boolean canDelete(Node<NamedNBT> node) {
return node != this.root;
}
public boolean delete(Node<NamedNBT> node) {
if (node == null || node == this.root) {
return false;
}
return this.deleteNode(node, this.root);
}
private boolean deleteNode(Node<NamedNBT> toDelete, Node<NamedNBT> cur) {
Iterator<Node<NamedNBT>> it = cur.getChildren().iterator();
while (it.hasNext()) {
Node<NamedNBT> child = it.next();
if (child == toDelete) {
it.remove();
return true;
}
boolean flag = this.deleteNode(toDelete, child);
if (!flag) {
continue;
}
return true;
}
return false;
}
private void construct() {
this.root = new Node<>(new NamedNBT("ROOT", ((NBTTagCompound) this.baseTag.copy())));
this.addChildrenToTree(this.root);
this.sort(this.root);
}
public void sort(Node<NamedNBT> node) {
Collections.sort(node.getChildren(), SORTER);
for (Node<NamedNBT> c : node.getChildren()) {
this.sort(c);
}
}
public void addChildrenToTree(Node<NamedNBT> parent) {
block3:
{
NBTBase tag;
block2:
{
tag = parent.getObject().getNBT();
if (!(tag instanceof NBTTagCompound)) {
break block2;
}
Map<String, NBTBase> map = NBTHelper.getMap((NBTTagCompound) tag);
for (Map.Entry<String, NBTBase> entry : map.entrySet()) {
NBTBase base = entry.getValue();
Node<NamedNBT> child = new Node<>(parent, new NamedNBT(entry.getKey(), base));
parent.addChild(child);
this.addChildrenToTree(child);
}
break block3;
}
if (!(tag instanceof NBTTagList)) {
break block3;
}
NBTTagList list = (NBTTagList) tag;
for (int i = 0; i < list.tagCount(); ++i) {
NBTBase base = NBTHelper.getTagAt(list, i);
Node<NamedNBT> child = new Node<>(parent, new NamedNBT(base));
parent.addChild(child);
this.addChildrenToTree(child);
}
}
}
public NBTTagCompound toNBTTagCompound() {
NBTTagCompound tag = new NBTTagCompound();
this.addChildrenToTag(this.root, tag);
return tag;
}
public void addChildrenToTag(Node<NamedNBT> parent, NBTTagCompound tag) {
for (Node<NamedNBT> child : parent.getChildren()) {
NBTBase base = child.getObject().getNBT();
String name = child.getObject().getName();
if (base instanceof NBTTagCompound) {
NBTTagCompound newTag = new NBTTagCompound();
this.addChildrenToTag(child, newTag);
tag.setTag(name, newTag);
continue;
}
if (base instanceof NBTTagList) {
NBTTagList list = new NBTTagList();
this.addChildrenToList(child, list);
tag.setTag(name, list);
continue;
}
tag.setTag(name, base.copy());
}
}
public void addChildrenToList(Node<NamedNBT> parent, NBTTagList list) {
for (Node<NamedNBT> child : parent.getChildren()) {
NBTBase base = child.getObject().getNBT();
if (base instanceof NBTTagCompound) {
NBTTagCompound newTag = new NBTTagCompound();
this.addChildrenToTag(child, newTag);
list.appendTag(newTag);
continue;
}
if (base instanceof NBTTagList) {
NBTTagList newList = new NBTTagList();
this.addChildrenToList(child, newList);
list.appendTag(newList);
continue;
}
list.appendTag(base.copy());
}
}
public void print() {
this.print(this.root, 0);
}
private void print(Node<NamedNBT> n, int i) {
System.out.println(NBTTree.repeat("\t", i) + NBTStringHelper.getNBTName(n.getObject()));
for (Node<NamedNBT> child : n.getChildren()) {
this.print(child, i + 1);
}
}
public List<String> toStrings() {
ArrayList<String> s = new ArrayList<>();
this.toStrings(s, this.root, 0);
return s;
}
private void toStrings(List<String> s, Node<NamedNBT> n, int i) {
s.add(NBTTree.repeat(" ", i) + NBTStringHelper.getNBTName(n.getObject()));
for (Node<NamedNBT> child : n.getChildren()) {
this.toStrings(s, child, i + 1);
}
}
public static String repeat(String c, int i) {
StringBuilder b = new StringBuilder(i + 1);
for (int j = 0; j < i; ++j) {
b.append(c);
}
return b.toString();
}
}
| 5,699 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
CharacterFilter.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/CharacterFilter.java | package ehacks.mod.util.nbtedit;
import net.minecraft.util.ChatAllowedCharacters;
public class CharacterFilter {
public static String filerAllowedCharacters(String str, boolean section) {
StringBuilder sb = new StringBuilder();
for (char c : str.toCharArray()) {
if (!ChatAllowedCharacters.isAllowedCharacter((char) c) && (!section || c != '\u00a7' && c != '\n')) {
continue;
}
sb.append(c);
}
return sb.toString();
}
}
| 515 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiEditSingleNBT.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/GuiEditSingleNBT.java | package ehacks.mod.util.nbtedit;
import ehacks.mod.util.GLUtils;
import ehacks.mod.util.MinecraftGuiUtils;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagByteArray;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagFloat;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagShort;
import net.minecraft.nbt.NBTTagString;
import org.lwjgl.opengl.GL11;
public class GuiEditSingleNBT
extends Gui {
public static final int WIDTH = 178;
public static final int HEIGHT = 93;
private final Node<NamedNBT> node;
private final NBTBase nbt;
private final boolean canEditText;
private final boolean canEditValue;
private final GuiNBTTree parent;
private int x;
private int y;
private GuiTextField key;
private GuiTextField value;
private GuiButton save;
private GuiButton cancel;
private String kError;
private String vError;
private GuiCharacterButton newLine;
private GuiCharacterButton section;
public GuiEditSingleNBT(GuiNBTTree parent, Node<NamedNBT> node, boolean editText, boolean editValue) {
this.parent = parent;
this.node = node;
this.nbt = node.getObject().getNBT();
this.canEditText = editText;
this.canEditValue = editValue;
}
public void initGUI(int x, int y) {
this.x = x;
this.y = y;
this.section = new GuiCharacterButton((byte) 0, x + 178 - 1, y + 34);
this.newLine = new GuiCharacterButton((byte) 1, x + 178 - 1, y + 50);
String sKey = this.key == null ? this.node.getObject().getName() : this.key.getText();
String sValue = this.value == null ? GuiEditSingleNBT.getValue(this.nbt) : this.value.getText();
this.key = new GuiTextField(Wrapper.INSTANCE.fontRenderer(), x + 46, y + 18, 116, 15, false);
this.value = new GuiTextField(Wrapper.INSTANCE.fontRenderer(), x + 46, y + 44, 116, 15, true);
this.key.setText(sKey);
this.key.setEnableBackgroundDrawing(false);
this.key.func_82265_c(this.canEditText);
this.value.setMaxStringLength(256);
this.value.setText(sValue);
this.value.setEnableBackgroundDrawing(false);
this.value.func_82265_c(this.canEditValue);
this.save = new GuiButton(1, x + 9, y + 62, 75, 20, "Save");
if (!this.key.isFocused() && !this.value.isFocused()) {
if (this.canEditText) {
this.key.setFocused(true);
} else if (this.canEditValue) {
this.value.setFocused(true);
}
}
this.section.setEnabled(this.value.isFocused());
this.newLine.setEnabled(this.value.isFocused());
this.cancel = new GuiButton(0, x + 93, y + 62, 75, 20, "\u00a7cCancel");
}
public void click(int mx, int my) {
if (this.newLine.inBounds(mx, my) && this.value.isFocused()) {
this.value.writeText("\n");
this.checkValidInput();
} else if (this.section.inBounds(mx, my) && this.value.isFocused()) {
this.value.writeText("\u00a7");
this.checkValidInput();
} else {
this.key.mouseClicked(mx, my, 0);
this.value.mouseClicked(mx, my, 0);
if (this.save.mousePressed(Wrapper.INSTANCE.mc(), mx, my)) {
this.saveAndQuit();
}
if (this.cancel.mousePressed(Wrapper.INSTANCE.mc(), mx, my)) {
this.parent.closeWindow();
}
this.section.setEnabled(this.value.isFocused());
this.newLine.setEnabled(this.value.isFocused());
}
}
private void saveAndQuit() {
if (this.canEditText) {
this.node.getObject().setName(this.key.getText());
}
GuiEditSingleNBT.setValidValue(this.node, this.value.getText());
this.parent.nodeEdited(this.node);
this.parent.closeWindow();
}
public void draw(int mx, int my) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
MinecraftGuiUtils.drawBack(x, y, 176, 89);
MinecraftGuiUtils.drawInputField(x + 42, y + 15, 127, 16);
MinecraftGuiUtils.drawInputField(x + 42, y + 41, 127, 16);
Wrapper.INSTANCE.fontRenderer().drawString("Name", x + 14, y + 19, GLUtils.getColor(63, 63, 63));
Wrapper.INSTANCE.fontRenderer().drawString("Value", x + 11, y + 45, GLUtils.getColor(63, 63, 63));
if (!this.canEditText) {
GuiEditSingleNBT.drawRect((this.x + 42), (this.y + 15), (this.x + 169), (this.y + 31), Integer.MIN_VALUE);
}
if (!this.canEditValue) {
GuiEditSingleNBT.drawRect((this.x + 42), (this.y + 41), (this.x + 169), (this.y + 57), Integer.MIN_VALUE);
}
this.key.drawTextBox();
this.value.drawTextBox();
this.save.drawButton(Wrapper.INSTANCE.mc(), mx, my);
this.cancel.drawButton(Wrapper.INSTANCE.mc(), mx, my);
if (this.kError != null) {
this.drawCenteredString(Wrapper.INSTANCE.fontRenderer(), this.kError, this.x + 89, this.y + 4, 16711680);
}
if (this.vError != null) {
this.drawCenteredString(Wrapper.INSTANCE.fontRenderer(), this.vError, this.x + 89, this.y + 32, 16711680);
}
this.newLine.draw(mx, my);
this.section.draw(mx, my);
}
@Override
public void drawCenteredString(FontRenderer par1FontRenderer, String par2Str, int par3, int par4, int par5) {
par1FontRenderer.drawString(par2Str, par3 - par1FontRenderer.getStringWidth(par2Str) / 2, par4, par5);
}
public void update() {
this.value.updateCursorCounter();
this.key.updateCursorCounter();
}
public void keyTyped(char c, int i) {
switch (i) {
case 1:
this.parent.closeWindow();
break;
case 15:
if (this.key.isFocused() && this.canEditValue) {
this.key.setFocused(false);
this.value.setFocused(true);
} else if (this.value.isFocused() && this.canEditText) {
this.key.setFocused(true);
this.value.setFocused(false);
}
this.section.setEnabled(this.value.isFocused());
this.newLine.setEnabled(this.value.isFocused());
break;
case 28:
this.checkValidInput();
if (this.save.enabled) {
this.saveAndQuit();
}
break;
default:
this.key.textboxKeyTyped(c, i);
this.value.textboxKeyTyped(c, i);
this.checkValidInput();
break;
}
}
private void checkValidInput() {
boolean valid = true;
this.kError = null;
this.vError = null;
if (this.canEditText && !this.validName()) {
valid = false;
this.kError = "Duplicate Tag Name";
}
try {
GuiEditSingleNBT.validValue(this.value.getText(), this.nbt.getId());
valid &= true;
} catch (NumberFormatException e) {
this.vError = e.getMessage();
valid = false;
}
this.save.enabled = valid;
}
private boolean validName() {
for (Node<NamedNBT> node : this.node.getParent().getChildren()) {
NBTBase base = node.getObject().getNBT();
if (base == this.nbt || !node.getObject().getName().equals(this.key.getText())) {
continue;
}
return false;
}
return true;
}
private static void setValidValue(Node<NamedNBT> node, String value) {
NamedNBT named = node.getObject();
NBTBase base = named.getNBT();
if (base instanceof NBTTagByte) {
named.setNBT(new NBTTagByte(ParseHelper.parseByte(value)));
}
if (base instanceof NBTTagShort) {
named.setNBT(new NBTTagShort(ParseHelper.parseShort(value)));
}
if (base instanceof NBTTagInt) {
named.setNBT(new NBTTagInt(ParseHelper.parseInt(value)));
}
if (base instanceof NBTTagLong) {
named.setNBT(new NBTTagLong(ParseHelper.parseLong(value)));
}
if (base instanceof NBTTagFloat) {
named.setNBT(new NBTTagFloat(ParseHelper.parseFloat(value)));
}
if (base instanceof NBTTagDouble) {
named.setNBT(new NBTTagDouble(ParseHelper.parseDouble(value)));
}
if (base instanceof NBTTagByteArray) {
named.setNBT(new NBTTagByteArray(ParseHelper.parseByteArray(value)));
}
if (base instanceof NBTTagIntArray) {
named.setNBT(new NBTTagIntArray(ParseHelper.parseIntArray(value)));
}
if (base instanceof NBTTagString) {
named.setNBT(new NBTTagString(value));
}
}
private static void validValue(String value, byte type) throws NumberFormatException {
switch (type) {
case 1: {
ParseHelper.parseByte(value);
break;
}
case 2: {
ParseHelper.parseShort(value);
break;
}
case 3: {
ParseHelper.parseInt(value);
break;
}
case 4: {
ParseHelper.parseLong(value);
break;
}
case 5: {
ParseHelper.parseFloat(value);
break;
}
case 6: {
ParseHelper.parseDouble(value);
break;
}
case 7: {
ParseHelper.parseByteArray(value);
break;
}
case 11: {
ParseHelper.parseIntArray(value);
}
}
}
private static String getValue(NBTBase base) {
switch (base.getId()) {
case 7: {
String s = "";
for (byte b : ((NBTTagByteArray) base).func_150292_c()) {
s = s + b + " ";
}
return s;
}
case 9: {
return "TagList";
}
case 10: {
return "TagCompound";
}
case 11: {
String i = "";
for (int a : ((NBTTagIntArray) base).func_150302_c()) {
i = i + a + " ";
}
return i;
}
}
return NBTStringHelper.toString(base);
}
}
| 10,948 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiNBTButton.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/GuiNBTButton.java | package ehacks.mod.util.nbtedit;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.client.gui.Gui;
import org.lwjgl.opengl.GL11;
public class GuiNBTButton
extends Gui {
public static final int WIDTH = 9;
public static final int HEIGHT = 9;
private final byte id;
private final int x;
private final int y;
private boolean enabled;
private long hoverTime;
public GuiNBTButton(byte id, int x, int y) {
this.id = id;
this.x = x;
this.y = y;
}
public void draw(int mx, int my) {
GL11.glScalef(.5f, .5f, .5f);
if (this.inBounds(mx, my)) {
Gui.drawRect(this.x * 2, this.y * 2, (this.x * 2 + 19), (this.y * 2 + 19), -2130706433);
if (this.hoverTime == -1L) {
this.hoverTime = System.currentTimeMillis();
}
} else {
this.hoverTime = -1L;
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GuiIconUtils.drawButtonBack(this.x * 2, this.y * 2);
GuiIconUtils.drawButtonIcon(this.x * 2, this.y * 2, id - 1);
if (!this.enabled) {
GuiNBTButton.drawRect(this.x * 2, this.y * 2, (this.x * 2 + 19), (this.y * 2 + 19), -1071504862);
}
GL11.glScalef(2f, 2f, 2f);
if (this.enabled && this.hoverTime != -1L && System.currentTimeMillis() - this.hoverTime > 300L) {
this.drawToolTip(mx, my);
}
}
private void drawToolTip(int mx, int my) {
String s = NBTStringHelper.getButtonName(this.id);
int width = Wrapper.INSTANCE.fontRenderer().getStringWidth(s);
GuiNBTButton.drawRect((mx + 4), (my + 7), (mx + 5 + width), (my + 17), -16777216);
Wrapper.INSTANCE.fontRenderer().drawString(s, mx + 5, my + 8, 16777215);
}
public void setEnabled(boolean aFlag) {
this.enabled = aFlag;
}
public boolean isEnabled() {
return this.enabled;
}
public boolean inBounds(int mx, int my) {
return this.enabled && mx >= this.x && my >= this.y && mx < this.x + 9 && my < this.y + 9;
}
public byte getId() {
return this.id;
}
}
| 2,151 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
NBTHelper.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/NBTHelper.java | package ehacks.mod.util.nbtedit;
import cpw.mods.fml.relauncher.ReflectionHelper;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class NBTHelper {
public static NBTTagCompound nbtRead(DataInputStream in) throws IOException {
return CompressedStreamTools.read(in);
}
public static void nbtWrite(NBTTagCompound compound, DataOutput out) throws IOException {
CompressedStreamTools.write(compound, out);
}
public static Map<String, NBTBase> getMap(NBTTagCompound tag) {
return (Map) ReflectionHelper.getPrivateValue(NBTTagCompound.class, tag, 1);
}
public static NBTBase getTagAt(NBTTagList tag, int index) {
List list = (List) ReflectionHelper.getPrivateValue(NBTTagList.class, tag, 0);
return (NBTBase) list.get(index);
}
}
| 1,052 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiNBTNode.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/GuiNBTNode.java | package ehacks.mod.util.nbtedit;
import ehacks.mod.util.GLUtils;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.client.gui.Gui;
import org.lwjgl.opengl.GL11;
public class GuiNBTNode
extends Gui {
private final Node<NamedNBT> node;
private final GuiNBTTree tree;
protected int width;
protected int height;
protected int x;
protected int y;
private String displayString;
public static final int[] NBT_ICON_MAPPING = new int[]{1, 2, 3, 4, 5, 6, 9, 7, 8, 0, 10, 0};
public GuiNBTNode(GuiNBTTree tree, Node<NamedNBT> node, int x, int y) {
this.tree = tree;
this.node = node;
this.x = x;
this.y = y;
this.height = Wrapper.INSTANCE.fontRenderer().FONT_HEIGHT;
this.updateDisplay();
}
private boolean inBounds(int mx, int my) {
return mx >= this.x && my >= this.y && mx < this.width + this.x && my < this.height + this.y;
}
private boolean inHideShowBounds(int mx, int my) {
return mx >= this.x - 9 && my >= this.y && mx < this.x && my < this.y + this.height;
}
public boolean shouldDrawChildren() {
return this.node.shouldDrawChildren();
}
public boolean clicked(int mx, int my) {
return this.inBounds(mx, my);
}
public boolean hideShowClicked(int mx, int my) {
if (this.node.hasChildren() && this.inHideShowBounds(mx, my)) {
this.node.setDrawChildren(!this.node.shouldDrawChildren());
return true;
}
return false;
}
public Node<NamedNBT> getNode() {
return this.node;
}
public void shift(int dy) {
this.y += dy;
}
public void updateDisplay() {
this.displayString = NBTStringHelper.getNBTNameSpecial(this.node.getObject());
this.width = Wrapper.INSTANCE.fontRenderer().getStringWidth(this.displayString) + 12;
}
public void draw(int mx, int my) {
boolean selected = this.tree.getFocused() == this.node;
boolean hover = this.inBounds(mx, my);
boolean chHover = this.inHideShowBounds(mx, my);
int color = selected ? 255 : (hover ? 16777120 : (this.node.hasParent() ? 14737632 : -6250336));
if (selected) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
Gui.drawRect((this.x + 11), this.y, (this.x + this.width), (this.y + this.height), Integer.MIN_VALUE);
}
GL11.glScalef(.5f, .5f, .5f);
if (this.node.hasChildren()) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GuiIconUtils.drawButtonBack((this.x - 9) * 2, this.y * 2 - 3);
if (chHover) {
GLUtils.drawRect((this.x - 9) * 2 + 4, this.y * 2 + 4 - 3, (this.x - 9) * 2 + 15, this.y * 2 + 15 - 3, GLUtils.getColor(255, 255, 255));
}
GLUtils.drawRect((this.x - 9) * 2 + 6, this.y * 2 + 9 - 3, (this.x - 9) * 2 + 13, this.y * 2 + 10 - 3, GLUtils.getColor(0, 0, 0));
if (!this.node.shouldDrawChildren()) {
GLUtils.drawRect((this.x - 9) * 2 + 9, this.y * 2 + 6 - 3, (this.x - 9) * 2 + 10, this.y * 2 + 13 - 3, GLUtils.getColor(0, 0, 0));
}
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GuiIconUtils.drawButtonBack((this.x + 1) * 2, this.y * 2 - 3);
GuiIconUtils.drawButtonIcon((this.x + 1) * 2, this.y * 2 - 3, NBT_ICON_MAPPING[this.node.getObject().getNBT().getId() - 1]);
GL11.glScalef(2f, 2f, 2f);
this.drawString(Wrapper.INSTANCE.fontRenderer(), this.displayString, this.x + 11, this.y + (this.height - 8) / 2, color);
}
public boolean shouldDraw(int top, int bottom) {
return this.y + this.height >= top && this.y <= bottom;
}
}
| 3,724 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
NBTNodeSorter.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/NBTNodeSorter.java | package ehacks.mod.util.nbtedit;
import java.util.Comparator;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class NBTNodeSorter
implements Comparator<Node<NamedNBT>> {
@Override
public int compare(Node<NamedNBT> a, Node<NamedNBT> b) {
NBTBase n1 = a.getObject().getNBT();
NBTBase n2 = b.getObject().getNBT();
String s1 = a.getObject().getName();
String s2 = b.getObject().getName();
if (n1 instanceof NBTTagCompound || n1 instanceof NBTTagList) {
if (n2 instanceof NBTTagCompound || n2 instanceof NBTTagList) {
int dif = n1.getId() - n2.getId();
return dif == 0 ? s1.compareTo(s2) : dif;
}
return 1;
}
if (n2 instanceof NBTTagCompound || n2 instanceof NBTTagList) {
return -1;
}
int dif = n1.getId() - n2.getId();
return dif == 0 ? s1.compareTo(s2) : dif;
}
}
| 1,016 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Node.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/Node.java | package ehacks.mod.util.nbtedit;
import java.util.ArrayList;
import java.util.List;
public class Node<T> {
private List<Node<T>> children;
private Node<T> parent;
private T obj;
private boolean drawChildren;
public Node(T obj) {
this.children = new ArrayList<>();
this.obj = obj;
}
public boolean shouldDrawChildren() {
return this.drawChildren;
}
public void setDrawChildren(boolean draw) {
this.drawChildren = draw;
}
public Node(Node<T> parent) {
this(parent, null);
}
public Node(Node<T> parent, T obj) {
this.parent = parent;
this.children = new ArrayList<>();
this.obj = obj;
}
public void addChild(Node<T> n) {
this.children.add(n);
}
public boolean removeChild(Node<T> n) {
return this.children.remove(n);
}
public List<Node<T>> getChildren() {
return this.children;
}
public Node<T> getParent() {
return this.parent;
}
public T getObject() {
return this.obj;
}
@Override
public String toString() {
return "" + this.obj;
}
public boolean hasChildren() {
return this.children.size() > 0;
}
public boolean hasParent() {
return this.parent != null;
}
}
| 1,326 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiNBTEdit.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/GuiNBTEdit.java | package ehacks.mod.util.nbtedit;
import ehacks.debugme.Debug;
import ehacks.mod.util.InteropUtils;
import ehacks.mod.wrapper.Statics;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.nbt.NBTTagCompound;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class GuiNBTEdit
extends GuiScreen {
private final GuiNBTTree guiTree;
private GuiTextField nbtString;
public GuiNBTEdit(NBTTagCompound tag) {
this.guiTree = new GuiNBTTree(new NBTTree(tag));
}
@Override
public void initGui() {
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
this.guiTree.initGUI(this.width, this.height, this.height - 35);
this.nbtString = new GuiTextField(this.mc.fontRenderer, 274, this.height - 27, this.width - 286, 20);
this.nbtString.setMaxStringLength(32000);
this.nbtString.setText(Debug.NBTToJson(guiTree.getNBTTree().toNBTTagCompound()));
this.nbtString.setCursorPositionZero();
this.buttonList.add(new GuiButton(0, 10, this.height - 27, 60, 20, "Save"));
this.buttonList.add(new GuiButton(1, 75, this.height - 27, 60, 20, "\u00a7cCancel"));
this.buttonList.add(new GuiButton(2, 140, this.height - 27, 60, 20, "From JSON"));
this.buttonList.add(new GuiButton(3, 205, this.height - 27, 60, 20, "To JSON"));
}
@Override
public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
}
@Override
protected void keyTyped(char par1, int key) {
GuiEditSingleNBT window = this.guiTree.getWindow();
if (window != null) {
window.keyTyped(par1, key);
} else {
this.nbtString.textboxKeyTyped(par1, key);
switch (key) {
case 1:
this.quitWithoutSaving();
break;
case 211:
this.guiTree.deleteSelected();
break;
case 28:
this.guiTree.editSelected();
break;
case 200:
this.guiTree.arrowKeyPressed(true);
break;
case 208:
this.guiTree.arrowKeyPressed(false);
break;
case Keyboard.KEY_C:
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) {
this.guiTree.copy();
}
break;
case Keyboard.KEY_V:
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) {
if (this.guiTree.canPaste()) {
this.guiTree.paste();
}
}
break;
case Keyboard.KEY_X:
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)) {
this.guiTree.cut();
}
break;
}
}
}
@Override
protected void mouseClicked(int x, int y, int t) {
if (this.guiTree.getWindow() == null) {
this.nbtString.mouseClicked(x, y, t);
}
super.mouseClicked(x, y, t);
if (t == 0) {
this.guiTree.mouseClicked(x, y);
}
}
@Override
public void handleMouseInput() {
super.handleMouseInput();
int ofs = Mouse.getEventDWheel();
if (ofs != 0) {
this.guiTree.shift(ofs >= 1 ? 6 : -6);
}
}
@Override
protected void actionPerformed(GuiButton b) {
if (b.enabled) {
switch (b.id) {
case 0: {
this.quitWithSave();
break;
}
case 1: {
this.quitWithoutSaving();
break;
}
case 2: {
try {
NBTTagCompound check = Debug.jsonToNBT(this.nbtString.getText());
Wrapper.INSTANCE.mc().displayGuiScreen(new GuiNBTEdit(check));
} catch (Exception e) {
InteropUtils.log("Invalid JSON", "NBTView");
}
}
case 3: {
this.nbtString.setText(Debug.NBTToJson(this.guiTree.getNBTTree().toNBTTagCompound()));
this.nbtString.setCursorPositionZero();
}
}
}
}
@Override
public void updateScreen() {
if (!this.mc.thePlayer.isEntityAlive()) {
this.quitWithoutSaving();
} else {
this.guiTree.updateScreen();
}
this.nbtString.updateCursorCounter();
}
private void quitWithSave() {
Statics.STATIC_NBT = this.guiTree.getNBTTree().toNBTTagCompound();
if (Statics.STATIC_ITEMSTACK != null) {
Statics.STATIC_ITEMSTACK.setTagCompound(Statics.STATIC_NBT);
}
this.mc.displayGuiScreen(null);
this.mc.setIngameFocus();
}
private void quitWithoutSaving() {
this.mc.displayGuiScreen(null);
}
@Override
public void drawScreen(int x, int y, float par3) {
this.drawDefaultBackground();
this.guiTree.draw(x, y);
this.drawCenteredString(this.mc.fontRenderer, "NBTTagCompound viewer/editor", this.width / 2, 17, 10526880);
this.nbtString.drawTextBox();
if (this.guiTree.getWindow() == null) {
super.drawScreen(x, y, par3);
} else {
super.drawScreen(-1, -1, par3);
}
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
}
| 5,957 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiCharacterButton.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/GuiCharacterButton.java | package ehacks.mod.util.nbtedit;
import net.minecraft.client.gui.Gui;
import org.lwjgl.opengl.GL11;
public class GuiCharacterButton
extends Gui {
public static final int WIDTH = 14;
public static final int HEIGHT = 14;
private final byte id;
private final int x;
private final int y;
private boolean enabled;
public GuiCharacterButton(byte id, int x, int y) {
this.id = id;
this.x = x;
this.y = y;
}
public void draw(int mx, int my) {
if (this.inBounds(mx, my)) {
Gui.drawRect(this.x, this.y, (this.x + 14), (this.y + 14), -2130706433);
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
//this.drawTexturedModalRect(this.x, this.y, this.id * 14, 27, 14, 14);
if (!this.enabled) {
GuiCharacterButton.drawRect(this.x, this.y, (this.x + 14), (this.y + 14), -1071504862);
}
}
public void setEnabled(boolean aFlag) {
this.enabled = aFlag;
}
public boolean isEnabled() {
return this.enabled;
}
public boolean inBounds(int mx, int my) {
return this.enabled && mx >= this.x && my >= this.y && mx < this.x + 14 && my < this.y + 14;
}
public byte getId() {
return this.id;
}
}
| 1,276 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiSaveSlotButton.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/GuiSaveSlotButton.java | package ehacks.mod.util.nbtedit;
import ehacks.mod.wrapper.Wrapper;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiSaveSlotButton
extends Gui {
public static final ResourceLocation TEXTURE = new ResourceLocation("textures/gui/widgets.png");
public final int saveId;
private final int rightX;
private int x;
private final int y;
private int width;
private String text;
private boolean xVisible;
public GuiSaveSlotButton(int saveId, int rightX, int y) {
this.saveId = saveId;
this.rightX = rightX;
this.y = y;
this.xVisible = GuiNBTTree.saveSlots[saveId] != null;
this.text = (GuiNBTTree.saveSlots[saveId] == null ? "Save slot " : "Load slot ") + saveId;
this.updatePosition();
}
public void draw(int mx, int my) {
int textColor = this.inBounds(mx, my) ? 16777120 : 16777215;
this.renderVanillaButton(this.x, this.y, 0, 66, this.width, 20, this.inBounds(mx, my) ? 2 : 1);
this.drawCenteredString(Wrapper.INSTANCE.fontRenderer(), this.text, this.x + this.width / 2, this.y + 6, textColor);
if (this.xVisible) {
textColor = this.inBoundsOfX(mx, my) ? 16777120 : 16777215;
this.renderVanillaButton(this.leftBoundOfX(), this.topBoundOfX(), 0, 66, 14, 14, this.inBoundsOfX(mx, my) ? 2 : 1);
this.drawCenteredString(Wrapper.INSTANCE.fontRenderer(), "\u00a7c\u00a7lx", this.x - 3 - 7, this.y + 6, textColor);
}
}
private void renderVanillaButton(int x, int y, int u, int v, int width, int height, int k) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
Wrapper.INSTANCE.mc().renderEngine.bindTexture(TEXTURE);
this.drawTexturedModalRect(x, y, 0, 46 + k * 20, width / 2, height);
this.drawTexturedModalRect(x + width / 2, y, 200 - width / 2, 46 + k * 20, width / 2, height);
}
private int leftBoundOfX() {
return this.x - 14 - 3;
}
private int topBoundOfX() {
return this.y + 3;
}
public boolean inBoundsOfX(int mx, int my) {
int buttonX = this.leftBoundOfX();
int buttonY = this.topBoundOfX();
return this.xVisible && mx >= buttonX && my >= buttonY && mx < buttonX + 14 && my < buttonY + 14;
}
public boolean inBounds(int mx, int my) {
return mx >= this.x && my >= this.y && mx < this.x + this.width && my < this.y + 20;
}
private void updatePosition() {
this.width = Wrapper.INSTANCE.fontRenderer().getStringWidth(this.text) + 24;
if (this.width % 2 == 1) {
++this.width;
}
this.width = MathHelper.clamp_int(this.width, 82, 150);
this.x = this.rightX - this.width;
}
public void reset() {
this.xVisible = false;
GuiNBTTree.saveSlots[this.saveId] = null;
this.text = "Save slot " + saveId;
this.updatePosition();
}
public void saved() {
this.xVisible = true;
this.text = "Load slot " + saveId;
this.updatePosition();
}
}
| 3,168 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiTextField.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/GuiTextField.java | package ehacks.mod.util.nbtedit;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ChatAllowedCharacters;
import org.lwjgl.opengl.GL11;
public class GuiTextField
extends Gui {
private final FontRenderer fontRenderer;
private final int xPos;
private final int yPos;
private final int width;
private final int height;
private String text = "";
private int maxStringLength = 32;
private int cursorCounter;
private boolean isFocused = false;
private boolean isEnabled = true;
private int field_73816_n = 0;
private int cursorPosition = 0;
private int selectionEnd = 0;
private int enabledColor = 14737632;
private int disabledColor = 7368816;
private boolean visible = true;
private boolean enableBackgroundDrawing = true;
private final boolean allowSection;
public GuiTextField(FontRenderer par1FontRenderer, int x, int y, int w, int h, boolean allowSection) {
this.fontRenderer = par1FontRenderer;
this.xPos = x;
this.yPos = y;
this.width = w;
this.height = h;
this.allowSection = allowSection;
}
public void updateCursorCounter() {
++this.cursorCounter;
}
public void setText(String par1Str) {
this.text = par1Str.length() > this.maxStringLength ? par1Str.substring(0, this.maxStringLength) : par1Str;
this.setCursorPositionEnd();
}
public String getText() {
return this.text;
}
public String getSelectedtext() {
int var1 = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd;
int var2 = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition;
return this.text.substring(var1, var2);
}
public void writeText(String par1Str) {
int var8;
String var2 = "";
String var3 = CharacterFilter.filerAllowedCharacters(par1Str, this.allowSection);
int var4 = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd;
int var5 = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition;
int var6 = this.maxStringLength - this.text.length() - (var4 - this.selectionEnd);
if (this.text.length() > 0) {
var2 += this.text.substring(0, var4);
}
if (var6 < var3.length()) {
var2 += var3.substring(0, var6);
var8 = var6;
} else {
var2 += var3;
var8 = var3.length();
}
if (this.text.length() > 0 && var5 < this.text.length()) {
var2 += this.text.substring(var5);
}
this.text = var2;
this.moveCursorBy(var4 - this.selectionEnd + var8);
}
public void deleteWords(int par1) {
if (this.text.length() != 0) {
if (this.selectionEnd != this.cursorPosition) {
this.writeText("");
} else {
this.deleteFromCursor(this.getNthWordFromCursor(par1) - this.cursorPosition);
}
}
}
public void deleteFromCursor(int par1) {
if (this.text.length() != 0) {
if (this.selectionEnd != this.cursorPosition) {
this.writeText("");
} else {
boolean var2 = par1 < 0;
int var3 = var2 ? this.cursorPosition + par1 : this.cursorPosition;
int var4 = var2 ? this.cursorPosition : this.cursorPosition + par1;
String var5 = "";
if (var3 >= 0) {
var5 = this.text.substring(0, var3);
}
if (var4 < this.text.length()) {
var5 += this.text.substring(var4);
}
this.text = var5;
if (var2) {
this.moveCursorBy(par1);
}
}
}
}
public int getNthWordFromCursor(int par1) {
return this.getNthWordFromPos(par1, this.getCursorPosition());
}
public int getNthWordFromPos(int par1, int par2) {
return this.func_73798_a(par1, this.getCursorPosition(), true);
}
public int func_73798_a(int par1, int par2, boolean par3) {
int var4 = par2;
boolean var5 = par1 < 0;
int var6 = Math.abs(par1);
for (int var7 = 0; var7 < var6; ++var7) {
if (var5) {
while (par3 && var4 > 0 && this.text.charAt(var4 - 1) == ' ') {
--var4;
}
while (var4 > 0 && this.text.charAt(var4 - 1) != ' ') {
--var4;
}
continue;
}
int var8 = this.text.length();
if ((var4 = this.text.indexOf(32, var4)) == -1) {
var4 = var8;
continue;
}
while (par3 && var4 < var8 && this.text.charAt(var4) == ' ') {
++var4;
}
}
return var4;
}
public void moveCursorBy(int par1) {
this.setCursorPosition(this.selectionEnd + par1);
}
public void setCursorPosition(int par1) {
this.cursorPosition = par1;
int var2 = this.text.length();
if (this.cursorPosition < 0) {
this.cursorPosition = 0;
}
if (this.cursorPosition > var2) {
this.cursorPosition = var2;
}
this.setSelectionPos(this.cursorPosition);
}
public void setCursorPositionZero() {
this.setCursorPosition(0);
}
public void setCursorPositionEnd() {
this.setCursorPosition(this.text.length());
}
public boolean textboxKeyTyped(char par1, int par2) {
if (this.isEnabled && this.isFocused) {
switch (par1) {
case '\u0001': {
this.setCursorPositionEnd();
this.setSelectionPos(0);
return true;
}
case '\u0003': {
GuiScreen.setClipboardString(this.getSelectedtext());
return true;
}
case '\u0016': {
this.writeText(GuiScreen.getClipboardString());
return true;
}
case '\u0018': {
GuiScreen.setClipboardString(this.getSelectedtext());
this.writeText("");
return true;
}
}
switch (par2) {
case 14: {
if (GuiScreen.isCtrlKeyDown()) {
this.deleteWords(-1);
} else {
this.deleteFromCursor(-1);
}
return true;
}
case 199: {
if (GuiScreen.isShiftKeyDown()) {
this.setSelectionPos(0);
} else {
this.setCursorPositionZero();
}
return true;
}
case 203: {
if (GuiScreen.isShiftKeyDown()) {
if (GuiScreen.isCtrlKeyDown()) {
this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd()));
} else {
this.setSelectionPos(this.getSelectionEnd() - 1);
}
} else if (GuiScreen.isCtrlKeyDown()) {
this.setCursorPosition(this.getNthWordFromCursor(-1));
} else {
this.moveCursorBy(-1);
}
return true;
}
case 205: {
if (GuiScreen.isShiftKeyDown()) {
if (GuiScreen.isCtrlKeyDown()) {
this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd()));
} else {
this.setSelectionPos(this.getSelectionEnd() + 1);
}
} else if (GuiScreen.isCtrlKeyDown()) {
this.setCursorPosition(this.getNthWordFromCursor(1));
} else {
this.moveCursorBy(1);
}
return true;
}
case 207: {
if (GuiScreen.isShiftKeyDown()) {
this.setSelectionPos(this.text.length());
} else {
this.setCursorPositionEnd();
}
return true;
}
case 211: {
if (GuiScreen.isCtrlKeyDown()) {
this.deleteWords(1);
} else {
this.deleteFromCursor(1);
}
return true;
}
}
if (ChatAllowedCharacters.isAllowedCharacter((char) par1)) {
this.writeText(Character.toString(par1));
return true;
}
return false;
}
return false;
}
public void mouseClicked(int par1, int par2, int par3) {
String displayString = this.text.replace('\u00a7', '?');
boolean var4 = par1 >= this.xPos && par1 < this.xPos + this.width && par2 >= this.yPos && par2 < this.yPos + this.height;
this.setFocused(this.isEnabled && var4);
if (this.isFocused && par3 == 0) {
int var5 = par1 - this.xPos;
if (this.enableBackgroundDrawing) {
var5 -= 4;
}
String var6 = this.fontRenderer.trimStringToWidth(displayString.substring(this.field_73816_n), this.getWidth());
this.setCursorPosition(this.fontRenderer.trimStringToWidth(var6, var5).length() + this.field_73816_n);
}
}
public void drawTextBox() {
String textToDisplay = this.text.replace('\u00a7', '?');
if (this.getVisible()) {
if (this.getEnableBackgroundDrawing()) {
GuiTextField.drawRect((this.xPos - 1), (this.yPos - 1), (this.xPos + this.width + 1), (this.yPos + this.height + 1), -6250336);
GuiTextField.drawRect(this.xPos, this.yPos, (this.xPos + this.width), (this.yPos + this.height), -16777216);
}
int var1 = this.isEnabled ? this.enabledColor : this.disabledColor;
int var2 = this.cursorPosition - this.field_73816_n;
int var3 = this.selectionEnd - this.field_73816_n;
String var4 = this.fontRenderer.trimStringToWidth(textToDisplay.substring(this.field_73816_n), this.getWidth());
boolean var5 = var2 >= 0 && var2 <= var4.length();
boolean var6 = this.isFocused && this.cursorCounter / 6 % 2 == 0 && var5;
int var7 = this.enableBackgroundDrawing ? this.xPos + 4 : this.xPos;
int var8 = this.enableBackgroundDrawing ? this.yPos + (this.height - 8) / 2 : this.yPos;
int var9 = var7;
if (var3 > var4.length()) {
var3 = var4.length();
}
if (var4.length() > 0) {
String var10 = var5 ? var4.substring(0, var2) : var4;
var9 = this.fontRenderer.drawStringWithShadow(var10, var7, var8, var1);
}
boolean var13 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength();
int var11 = var9;
if (!var5) {
var11 = var2 > 0 ? var7 + this.width : var7;
} else if (var13) {
var11 = var9 - 1;
--var9;
}
if (var4.length() > 0 && var5 && var2 < var4.length()) {
this.fontRenderer.drawStringWithShadow(var4.substring(var2), var9, var8, var1);
}
if (var6) {
if (var13) {
Gui.drawRect(var11, (var8 - 1), (var11 + 1), (var8 + 1 + this.fontRenderer.FONT_HEIGHT), -3092272);
} else {
this.fontRenderer.drawStringWithShadow("_", var11, var8, var1);
}
}
if (var3 != var2) {
int var12 = var7 + this.fontRenderer.getStringWidth(var4.substring(0, var3));
this.drawCursorVertical(var11, var8 - 1, var12 - 1, var8 + 1 + this.fontRenderer.FONT_HEIGHT);
}
}
}
private void drawCursorVertical(int par1, int par2, int par3, int par4) {
int var5;
if (par1 < par3) {
var5 = par1;
par1 = par3;
par3 = var5;
}
if (par2 < par4) {
var5 = par2;
par2 = par4;
par4 = var5;
}
Tessellator var6 = Tessellator.instance;
GL11.glColor4f(0.0f, 0.0f, 255.0f, 255.0f);
GL11.glDisable(3553);
GL11.glEnable(3058);
GL11.glLogicOp(5387);
var6.startDrawingQuads();
var6.addVertex(par1, par4, 0.0);
var6.addVertex(par3, par4, 0.0);
var6.addVertex(par3, par2, 0.0);
var6.addVertex(par1, par2, 0.0);
var6.draw();
GL11.glDisable(3058);
GL11.glEnable(3553);
}
public void setMaxStringLength(int par1) {
this.maxStringLength = par1;
if (this.text.length() > par1) {
this.text = this.text.substring(0, par1);
}
}
public int getMaxStringLength() {
return this.maxStringLength;
}
public int getCursorPosition() {
return this.cursorPosition;
}
public boolean getEnableBackgroundDrawing() {
return this.enableBackgroundDrawing;
}
public void setEnableBackgroundDrawing(boolean par1) {
this.enableBackgroundDrawing = par1;
}
public void setTextColor(int par1) {
this.enabledColor = par1;
}
public void func_82266_h(int par1) {
this.disabledColor = par1;
}
public void setFocused(boolean par1) {
if (par1 && !this.isFocused) {
this.cursorCounter = 0;
}
this.isFocused = par1;
}
public boolean isFocused() {
return this.isFocused;
}
public void func_82265_c(boolean par1) {
this.isEnabled = par1;
}
public int getSelectionEnd() {
return this.selectionEnd;
}
public int getWidth() {
return this.getEnableBackgroundDrawing() ? this.width - 8 : this.width;
}
public void setSelectionPos(int par1) {
String displayString = this.text.replace('\u00a7', '?');
int var2 = displayString.length();
if (par1 > var2) {
par1 = var2;
}
if (par1 < 0) {
par1 = 0;
}
this.selectionEnd = par1;
if (this.fontRenderer != null) {
if (this.field_73816_n > var2) {
this.field_73816_n = var2;
}
int var3 = this.getWidth();
String var4 = this.fontRenderer.trimStringToWidth(displayString.substring(this.field_73816_n), var3);
int var5 = var4.length() + this.field_73816_n;
if (par1 == this.field_73816_n) {
this.field_73816_n -= this.fontRenderer.trimStringToWidth(displayString, var3, true).length();
}
if (par1 > var5) {
this.field_73816_n += par1 - var5;
} else if (par1 <= this.field_73816_n) {
this.field_73816_n -= this.field_73816_n - par1;
}
if (this.field_73816_n < 0) {
this.field_73816_n = 0;
}
if (this.field_73816_n > var2) {
this.field_73816_n = var2;
}
}
}
public boolean getVisible() {
return this.visible;
}
public void setVisible(boolean par1) {
this.visible = par1;
}
}
| 16,146 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
NamedNBT.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/NamedNBT.java | package ehacks.mod.util.nbtedit;
import net.minecraft.nbt.NBTBase;
public class NamedNBT {
protected String name;
protected NBTBase nbt;
public NamedNBT(NBTBase nbt) {
this("", nbt);
}
public NamedNBT(String name, NBTBase nbt) {
this.name = name;
this.nbt = nbt;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public NBTBase getNBT() {
return this.nbt;
}
public void setNBT(NBTBase nbt) {
this.nbt = nbt;
}
public NamedNBT copy() {
return new NamedNBT(this.name, this.nbt.copy());
}
}
| 679 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
NBTStringHelper.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/NBTStringHelper.java | package ehacks.mod.util.nbtedit;
import com.google.common.base.Strings;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagByteArray;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagFloat;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagShort;
import net.minecraft.nbt.NBTTagString;
public class NBTStringHelper {
public static final char SECTION_SIGN = '\u00a7';
public static String getNBTName(NamedNBT namedNBT) {
String name = namedNBT.getName();
NBTBase obj = namedNBT.getNBT();
String s = NBTStringHelper.toString(obj);
return Strings.isNullOrEmpty(name) ? "" + s : name + ": " + s;
}
public static String getNBTNameSpecial(NamedNBT namedNBT) {
String name = namedNBT.getName();
NBTBase obj = namedNBT.getNBT();
String s = NBTStringHelper.toString(obj);
return Strings.isNullOrEmpty(name) ? "" + s : name + ": " + s + '\u00a7' + 'r';
}
public static NBTBase newTag(byte type) {
switch (type) {
case 1: {
return new NBTTagCompound();
}
case 2: {
return new NBTTagByte((byte) 0);
}
case 3: {
return new NBTTagShort();
}
case 4: {
return new NBTTagInt(0);
}
case 5: {
return new NBTTagLong(0L);
}
case 6: {
return new NBTTagFloat(0.0f);
}
case 7: {
return new NBTTagDouble(0.0);
}
case 8: {
return new NBTTagString("");
}
case 9: {
return new NBTTagList();
}
case 10: {
return new NBTTagByteArray(new byte[0]);
}
case 11: {
return new NBTTagIntArray(new int[0]);
}
}
return null;
}
public static String toString(NBTBase base) {
switch (GuiNBTNode.NBT_ICON_MAPPING[base.getId() - 1]) {
case 0: {
return "(TagCompound)";
}
case 1: {
return "" + ((NBTTagByte) base).func_150290_f();
}
case 2: {
return "" + ((NBTTagShort) base).func_150289_e();
}
case 3: {
return "" + ((NBTTagInt) base).func_150287_d();
}
case 4: {
return "" + ((NBTTagLong) base).func_150291_c();
}
case 5: {
return "" + ((NBTTagFloat) base).func_150288_h();
}
case 6: {
return "" + ((NBTTagDouble) base).func_150286_g();
}
case 7: {
return ((NBTTagString) base).func_150285_a_();
}
case 8: {
return "(TagList)";
}
case 9: {
return base.toString();
}
case 10: {
return base.toString();
}
}
return "?";
}
public static String getButtonName(byte id) {
switch (id) {
case 1: {
return "Compound";
}
case 2: {
return "Byte";
}
case 3: {
return "Short";
}
case 4: {
return "Int";
}
case 5: {
return "Long";
}
case 6: {
return "Float";
}
case 7: {
return "Double";
}
case 8: {
return "String";
}
case 9: {
return "List";
}
case 10: {
return "Byte[]";
}
case 11: {
return "Int[]";
}
case 12: {
return "Edit";
}
case 13: {
return "Delete";
}
case 14: {
return "Copy";
}
case 15: {
return "Cut";
}
case 16: {
return "Paste";
}
}
return "Unknown";
}
}
| 4,566 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiNBTTree.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/GuiNBTTree.java | package ehacks.mod.util.nbtedit;
import ehacks.mod.config.ConfigurationManager;
import ehacks.mod.wrapper.Wrapper;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public class GuiNBTTree
extends Gui {
private final NBTTree tree;
private final List<GuiNBTNode> nodes;
private final GuiNBTButton[] buttons;
private final int Y_GAP;
private int y;
private int yClick;
private int bottom;
private int width;
private int height;
private int heightDiff;
private int offset;
private Node<NamedNBT> focused;
private GuiEditSingleNBT window;
public static NBTTagCompound[] saveSlots = new NBTTagCompound[10];
private static NamedNBT clipboard;
private static GuiSaveSlotButton[] saves;
public Node<NamedNBT> getFocused() {
return this.focused;
}
public NBTTree getNBTTree() {
return this.tree;
}
public GuiNBTTree(NBTTree tree) {
this.Y_GAP = Wrapper.INSTANCE.fontRenderer().FONT_HEIGHT + 2;
this.tree = tree;
this.yClick = -1;
this.nodes = new ArrayList<>();
this.buttons = new GuiNBTButton[16];
saves = new GuiSaveSlotButton[10];
}
private int getHeightDifference() {
return this.getContentHeight() - (this.bottom - 30 + 2);
}
private int getContentHeight() {
return this.Y_GAP * this.nodes.size();
}
public GuiEditSingleNBT getWindow() {
return this.window;
}
public void initGUI(int width, int height, int bottom) {
this.width = width;
this.height = height;
this.bottom = bottom;
this.yClick = -1;
this.initGUI(false);
if (this.window != null) {
this.window.initGUI((width - 178) / 2, (height - 93) / 2);
}
}
public void updateScreen() {
if (this.window != null) {
this.window.update();
}
}
private void setFocused(Node<NamedNBT> toFocus) {
if (toFocus == null) {
for (GuiNBTButton b : this.buttons) {
b.setEnabled(false);
}
} else if (toFocus.getObject().getNBT() instanceof NBTTagCompound) {
for (GuiNBTButton b : this.buttons) {
b.setEnabled(true);
}
this.buttons[12].setEnabled(toFocus != this.tree.getRoot());
this.buttons[11].setEnabled(toFocus.hasParent() && !(toFocus.getParent().getObject().getNBT() instanceof NBTTagList));
this.buttons[13].setEnabled(true);
this.buttons[14].setEnabled(toFocus != this.tree.getRoot());
this.buttons[15].setEnabled(clipboard != null);
} else if (toFocus.getObject().getNBT() instanceof NBTTagList) {
if (toFocus.hasChildren()) {
byte type = toFocus.getChildren().get(0).getObject().getNBT().getId();
for (GuiNBTButton b : this.buttons) {
b.setEnabled(false);
}
this.buttons[GuiNBTNode.NBT_ICON_MAPPING[type - 1]].setEnabled(true);
this.buttons[12].setEnabled(true);
this.buttons[11].setEnabled(!(toFocus.getParent().getObject().getNBT() instanceof NBTTagList));
this.buttons[13].setEnabled(true);
this.buttons[14].setEnabled(true);
this.buttons[15].setEnabled(clipboard != null && clipboard.getNBT().getId() == type);
} else {
for (GuiNBTButton b : this.buttons) {
b.setEnabled(true);
}
}
this.buttons[11].setEnabled(!(toFocus.getParent().getObject().getNBT() instanceof NBTTagList));
this.buttons[13].setEnabled(true);
this.buttons[14].setEnabled(true);
this.buttons[15].setEnabled(clipboard != null);
} else {
for (GuiNBTButton b : this.buttons) {
b.setEnabled(false);
}
this.buttons[12].setEnabled(true);
this.buttons[11].setEnabled(true);
this.buttons[13].setEnabled(true);
this.buttons[14].setEnabled(true);
this.buttons[15].setEnabled(false);
}
this.focused = toFocus;
}
public void initGUI() {
this.initGUI(false);
}
public void initGUI(boolean shiftToFocused) {
this.y = 30;
this.nodes.clear();
this.addNodes(this.tree.getRoot(), 10);
this.addButtons();
this.addSaveSlotButtons();
if (this.focused != null && !this.checkValidFocus(this.focused)) {
this.setFocused(null);
}
this.heightDiff = this.getHeightDifference();
if (this.heightDiff <= 0) {
this.offset = 0;
} else {
if (this.offset < -this.heightDiff) {
this.offset = -this.heightDiff;
}
if (this.offset > 0) {
this.offset = 0;
}
this.nodes.forEach((node) -> {
node.shift(this.offset);
});
if (shiftToFocused && this.focused != null) {
this.shiftTo(this.focused);
}
}
}
private void addSaveSlotButtons() {
for (int i = 0; i < 10; ++i) {
GuiNBTTree.saves[i] = new GuiSaveSlotButton(i, this.width - 15, 38 + i * 25);
}
}
private void addButtons() {
byte i;
int x = 18;
int y = 4;
for (i = 14; i < 17; i = (byte) (i + 1)) {
this.buttons[i - 1] = new GuiNBTButton(i, x, y);
x += 15;
}
x += 30;
for (i = 12; i < 14; i = (byte) (i + 1)) {
this.buttons[i - 1] = new GuiNBTButton(i, x, y);
x += 15;
}
x = 18;
y = 17;
for (i = 1; i < 12; i = (byte) (i + 1)) {
this.buttons[i - 1] = new GuiNBTButton(i, x, y);
x += 9;
}
}
private boolean checkValidFocus(Node<NamedNBT> fc) {
for (GuiNBTNode node : this.nodes) {
if (node.getNode() != fc) {
continue;
}
this.setFocused(fc);
return true;
}
return fc.hasParent() ? this.checkValidFocus(fc.getParent()) : false;
}
private void addNodes(Node<NamedNBT> node, int x) {
this.nodes.add(new GuiNBTNode(this, node, x, this.y));
x += 10;
this.y += this.Y_GAP;
if (node.shouldDrawChildren()) {
for (Node<NamedNBT> child : node.getChildren()) {
this.addNodes(child, x);
}
}
}
public void draw(int mx, int my) {
int cmx = mx;
int cmy = my;
if (this.window != null) {
cmx = -1;
cmy = -1;
}
for (GuiNBTNode node : this.nodes) {
if (!node.shouldDraw(29, this.bottom)) {
continue;
}
node.draw(cmx, cmy);
}
this.overlayBackground(0, 29, 255, 255);
this.overlayBackground(this.bottom, this.height, 255, 255);
for (GuiNBTButton but : this.buttons) {
but.draw(cmx, cmy);
}
for (GuiSaveSlotButton but : saves) {
but.draw(cmx, cmy);
}
this.drawScrollBar(cmx, cmy);
if (this.window != null) {
this.window.draw(mx, my);
}
}
private void drawScrollBar(int mx, int my) {
if (this.heightDiff > 0) {
int y;
if (Mouse.isButtonDown(0)) {
if (this.yClick == -1) {
if (mx >= this.width - 10 && mx < this.width && my >= 29 && my < this.bottom) {
this.yClick = my;
}
} else {
int length;
float scrollMultiplier = 1.0f;
int height = this.getHeightDifference();
if (height < 1) {
height = 1;
}
if ((length = (this.bottom - 29) * (this.bottom - 29) / this.getContentHeight()) < 32) {
length = 32;
}
if (length > this.bottom - 29 - 8) {
length = this.bottom - 29 - 8;
}
this.shift((int) ((this.yClick - my) * (scrollMultiplier /= (this.bottom - 29 - length) / (float) height)));
this.yClick = my;
}
} else {
this.yClick = -1;
}
GuiNBTTree.drawRect((this.width - 10), 29, this.width, this.bottom, Integer.MIN_VALUE);
int length = (this.bottom - 29) * (this.bottom - 29) / this.getContentHeight();
if (length < 32) {
length = 32;
}
if (length > this.bottom - 29 - 8) {
length = this.bottom - 29 - 8;
}
if ((y = (-this.offset) * (this.bottom - 29 - length) / this.heightDiff + 29) < 29) {
y = 29;
}
this.drawGradientRect(this.width - 10, y, this.width, y + length, 1145324612, 1145324612);
}
}
protected void overlayBackground(int par1, int par2, int par3, int par4) {
Tessellator var5 = Tessellator.instance;
Wrapper.INSTANCE.mc().renderEngine.bindTexture(new ResourceLocation("textures/blocks/bedrock.png"));
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
float var6 = 32.0f;
var5.startDrawingQuads();
var5.setColorRGBA_I(4210752, par4);
var5.addVertexWithUV(0.0, par2, 0.0, 0.0, (par2 / var6));
var5.addVertexWithUV(this.width, par2, 0.0, (this.width / var6), (par2 / var6));
var5.setColorRGBA_I(4210752, par3);
var5.addVertexWithUV(this.width, par1, 0.0, (this.width / var6), (par1 / var6));
var5.addVertexWithUV(0.0, par1, 0.0, 0.0, (par1 / var6));
var5.draw();
}
public void mouseClicked(int mx, int my) {
if (this.window == null) {
boolean reInit = false;
for (GuiNBTNode node : this.nodes) {
if (!node.hideShowClicked(mx, my)) {
continue;
}
reInit = true;
if (!node.shouldDrawChildren()) {
break;
}
this.offset = 31 - node.y + this.offset;
break;
}
if (!reInit) {
for (GuiNBTButton button : this.buttons) {
if (!button.inBounds(mx, my)) {
continue;
}
this.buttonClicked(button);
return;
}
for (GuiSaveSlotButton button : saves) {
if (button.inBoundsOfX(mx, my)) {
button.reset();
ConfigurationManager.instance().saveConfigs();
Wrapper.INSTANCE.mc().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0f));
return;
}
if (!button.inBounds(mx, my)) {
continue;
}
this.saveButtonClicked(button);
return;
}
if (my >= 30 && mx <= this.width - 175) {
Node<NamedNBT> newFocus = null;
for (GuiNBTNode node : this.nodes) {
if (!node.clicked(mx, my)) {
continue;
}
newFocus = node.getNode();
break;
}
this.setFocused(newFocus);
}
} else {
this.initGUI();
}
} else {
this.window.click(mx, my);
}
}
private void saveButtonClicked(GuiSaveSlotButton button) {
if (saveSlots[button.saveId] == null) {
saveSlots[button.saveId] = this.getNBTTree().toNBTTagCompound();
button.saved();
ConfigurationManager.instance().saveConfigs();
Wrapper.INSTANCE.mc().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0f));
} else {
Wrapper.INSTANCE.mc().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0f));
Wrapper.INSTANCE.mc().displayGuiScreen(new GuiNBTEdit(saveSlots[button.saveId]));
}
}
private void buttonClicked(GuiNBTButton button) {
block4:
{
block10:
{
String type;
List<Node<NamedNBT>> children;
block9:
{
block8:
{
block7:
{
block6:
{
block5:
{
block3:
{
if (button.getId() != 16) {
break block3;
}
this.paste();
break block4;
}
if (button.getId() != 15) {
break block5;
}
this.cut();
break block4;
}
if (button.getId() != 14) {
break block6;
}
this.copy();
break block4;
}
if (button.getId() != 13) {
break block7;
}
this.deleteSelected();
break block4;
}
if (button.getId() != 12) {
break block8;
}
this.edit();
break block4;
}
if (this.focused == null) {
break block4;
}
this.focused.setDrawChildren(true);
children = this.focused.getChildren();
type = NBTStringHelper.getButtonName(button.getId());
if (!(this.focused.getObject().getNBT() instanceof NBTTagList)) {
break block9;
}
NBTBase nbt = NBTStringHelper.newTag(button.getId());
if (nbt == null) {
break block10;
}
Node<NamedNBT> newNode = new Node<>(this.focused, new NamedNBT("", nbt));
children.add(newNode);
this.setFocused(newNode);
break block10;
}
if (children.isEmpty()) {
this.setFocused(this.insert(type + "1", button.getId()));
} else {
for (int i = 1; i <= children.size() + 1; ++i) {
String name = type + i;
if (!this.validName(name, children)) {
continue;
}
this.setFocused(this.insert(name, button.getId()));
break;
}
}
}
this.initGUI(true);
}
}
private boolean validName(String name, List<Node<NamedNBT>> list) {
for (Node<NamedNBT> node : list) {
if (!node.getObject().getName().equals(name)) {
continue;
}
return false;
}
return true;
}
private Node<NamedNBT> insert(NamedNBT nbt) {
Node<NamedNBT> newNode = new Node<>(this.focused, nbt);
if (this.focused.hasChildren()) {
List<Node<NamedNBT>> children = this.focused.getChildren();
boolean added = false;
for (int i = 0; i < children.size(); ++i) {
if (NBTTree.SORTER.compare(newNode, children.get(i)) >= 0) {
continue;
}
children.add(i, newNode);
added = true;
break;
}
if (!added) {
children.add(newNode);
}
} else {
this.focused.addChild(newNode);
}
return newNode;
}
private Node<NamedNBT> insert(String name, byte type) {
NBTBase nbt = NBTStringHelper.newTag(type);
if (nbt != null) {
return this.insert(new NamedNBT(name, nbt));
}
return null;
}
public void deleteSelected() {
if (this.focused != null && this.tree.delete(this.focused)) {
Node<NamedNBT> oldFocused = this.focused;
this.shiftFocus(true);
if (this.focused == oldFocused) {
this.setFocused(null);
}
this.initGUI();
}
}
public void editSelected() {
if (this.focused != null) {
NBTBase base = this.focused.getObject().getNBT();
if (this.focused.hasChildren() && (base instanceof NBTTagCompound || base instanceof NBTTagList)) {
this.focused.setDrawChildren(!this.focused.shouldDrawChildren());
int index = -1;
if (this.focused.shouldDrawChildren() && (index = this.indexOf(this.focused)) != -1) {
this.offset = 31 - this.nodes.get(index).y + this.offset;
}
this.initGUI();
} else if (this.buttons[11].isEnabled()) {
this.edit();
}
}
}
private boolean canAddToParent(NBTBase parent, NBTBase child) {
if (parent instanceof NBTTagCompound) {
return true;
}
if (parent instanceof NBTTagList) {
NBTTagList list = (NBTTagList) parent;
return list.tagCount() == 0 || list.func_150303_d() == child.getId();
}
return false;
}
public boolean canPaste() {
if (clipboard != null && this.focused != null) {
return this.canAddToParent(this.focused.getObject().getNBT(), clipboard.getNBT());
}
return false;
}
public void paste() {
if (clipboard != null) {
this.focused.setDrawChildren(true);
NamedNBT namedNBT = clipboard.copy();
if (this.focused.getObject().getNBT() instanceof NBTTagList) {
namedNBT.setName("");
Node<NamedNBT> node = new Node<>(this.focused, namedNBT);
this.focused.addChild(node);
this.tree.addChildrenToTree(node);
this.tree.sort(node);
} else {
List<Node<NamedNBT>> children;
String name = namedNBT.getName();
if (!this.validName(name, children = this.focused.getChildren())) {
for (int i = 1; i <= children.size() + 1; ++i) {
String n = name + "(" + i + ")";
if (!this.validName(n, children)) {
continue;
}
namedNBT.setName(n);
break;
}
}
Node<NamedNBT> node = this.insert(namedNBT);
this.tree.addChildrenToTree(node);
this.tree.sort(node);
}
this.initGUI(true);
}
}
public void copy() {
if (this.focused != null) {
NamedNBT namedNBT = this.focused.getObject();
if (namedNBT.getNBT() instanceof NBTTagList) {
NBTTagList list = new NBTTagList();
this.tree.addChildrenToList(this.focused, list);
clipboard = new NamedNBT(namedNBT.getName(), list);
} else if (namedNBT.getNBT() instanceof NBTTagCompound) {
NBTTagCompound compound = new NBTTagCompound();
this.tree.addChildrenToTag(this.focused, compound);
clipboard = new NamedNBT(namedNBT.getName(), compound);
} else {
clipboard = this.focused.getObject().copy();
}
this.setFocused(this.focused);
}
}
public void cut() {
this.copy();
this.deleteSelected();
}
private void edit() {
NBTBase base = this.focused.getObject().getNBT();
NBTBase parent = this.focused.getParent().getObject().getNBT();
this.window = new GuiEditSingleNBT(this, this.focused, !(parent instanceof NBTTagList), !(base instanceof NBTTagCompound) && !(base instanceof NBTTagList));
this.window.initGUI((this.width - 178) / 2, (this.height - 93) / 2);
}
public void nodeEdited(Node<NamedNBT> node) {
Node<NamedNBT> parent = node.getParent();
Collections.sort(parent.getChildren(), NBTTree.SORTER);
this.initGUI(true);
}
public void arrowKeyPressed(boolean up) {
if (this.focused == null) {
this.shift(up ? this.Y_GAP : -this.Y_GAP);
} else {
this.shiftFocus(up);
}
}
private int indexOf(Node<NamedNBT> node) {
for (int i = 0; i < this.nodes.size(); ++i) {
if (this.nodes.get(i).getNode() != node) {
continue;
}
return i;
}
return -1;
}
private void shiftFocus(boolean up) {
int index = this.indexOf(this.focused);
if (index != -1 && (index += up ? -1 : 1) >= 0 && index < this.nodes.size()) {
this.setFocused(this.nodes.get(index).getNode());
this.shift(up ? this.Y_GAP : -this.Y_GAP);
}
}
private void shiftTo(Node<NamedNBT> node) {
int index = this.indexOf(node);
if (index != -1) {
GuiNBTNode gui = this.nodes.get(index);
this.shift((this.bottom + 30 + 1) / 2 - (gui.y + gui.height));
}
}
public void shift(int i) {
if (this.heightDiff <= 0 || this.window != null) {
return;
}
int dif = this.offset + i;
if (dif > 0) {
dif = 0;
}
if (dif < -this.heightDiff) {
dif = -this.heightDiff;
}
for (GuiNBTNode node : this.nodes) {
node.shift(dif - this.offset);
}
this.offset = dif;
}
public void closeWindow() {
this.window = null;
}
static {
clipboard = null;
}
}
| 23,620 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
GuiIconUtils.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/nbtedit/GuiIconUtils.java | package ehacks.mod.util.nbtedit;
import ehacks.mod.util.GLUtils;
public class GuiIconUtils {
public static void drawButtonBack(int x, int y) {
GLUtils.drawRect(x + 2, y + 2, x + 17, y + 17, GLUtils.getColor(139, 139, 139));
GLUtils.drawRect(x + 3, y + 1, x + 16, y + 2, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 1, y + 3, x + 2, y + 16, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 3, y + 17, x + 16, y + 18, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 17, y + 3, x + 18, y + 16, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 2, y + 2, x + 3, y + 3, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 2, y + 16, x + 3, y + 17, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 16, y + 2, x + 17, y + 3, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 16, y + 16, x + 17, y + 17, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 4, y + 3, x + 15, y + 4, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 3, y + 4, x + 4, y + 15, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 4, y + 15, x + 15, y + 16, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 15, y + 4, x + 16, y + 15, GLUtils.getColor(0, 0, 0));
}
public static int[] colors = new int[]{
GLUtils.getColor(97, 154, 54),
GLUtils.getColor(76, 76, 76),
GLUtils.getColor(255, 108, 106),
GLUtils.getColor(247, 146, 87),
GLUtils.getColor(215, 202, 55),
GLUtils.getColor(251, 97, 255),
GLUtils.getColor(225, 102, 255),
GLUtils.getColor(71, 225, 231),
GLUtils.getColor(81, 239, 78),
GLUtils.getColor(114, 145, 255),
GLUtils.getColor(183, 99, 80),};
public static void drawButtonIcon(int x, int y, int id) {
if (id < 11) {
GLUtils.drawRect(x + 4, y + 4, x + 15, y + 15, colors[id]);
}
switch (id) {
case 0:
GLUtils.drawRect(x + 5, y + 5, x + 9, y + 9, GLUtils.getColor(255, 108, 106));
GLUtils.drawRect(x + 5, y + 5, x + 9, y + 6, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 5, y + 5, x + 6, y + 9, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 8, y + 5, x + 9, y + 9, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 5, y + 8, x + 9, y + 9, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 10, y + 5, x + 14, y + 9, GLUtils.getColor(225, 102, 255));
GLUtils.drawRect(x + 10, y + 5, x + 14, y + 6, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 10, y + 5, x + 11, y + 9, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 13, y + 5, x + 14, y + 9, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 10, y + 8, x + 14, y + 9, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 5, y + 10, x + 9, y + 14, GLUtils.getColor(215, 202, 55));
GLUtils.drawRect(x + 5, y + 10, x + 9, y + 11, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 5, y + 10, x + 6, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 8, y + 10, x + 9, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 5, y + 13, x + 9, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 10, y + 10, x + 14, y + 14, GLUtils.getColor(71, 225, 231));
GLUtils.drawRect(x + 10, y + 10, x + 14, y + 11, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 10, y + 10, x + 11, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 13, y + 10, x + 14, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 10, y + 13, x + 14, y + 14, GLUtils.getColor(0, 0, 0));
break;
case 1:
GLUtils.drawRect(x + 6, y + 6, x + 12, y + 7, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 6, x + 7, y + 13, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 9, x + 12, y + 10, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 12, x + 12, y + 13, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 12, y + 7, x + 13, y + 9, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 12, y + 10, x + 13, y + 12, GLUtils.getColor(0, 0, 0));
break;
case 2:
GLUtils.drawRect(x + 7, y + 6, x + 13, y + 7, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 7, x + 7, y + 9, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 7, y + 9, x + 12, y + 10, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 12, y + 10, x + 13, y + 12, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 12, x + 12, y + 13, GLUtils.getColor(0, 0, 0));
break;
case 3:
GLUtils.drawRect(x + 6, y + 6, x + 13, y + 7, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 9, y + 7, x + 10, y + 12, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 12, x + 13, y + 13, GLUtils.getColor(0, 0, 0));
break;
case 4:
GLUtils.drawRect(x + 6, y + 6, x + 7, y + 12, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 12, x + 13, y + 13, GLUtils.getColor(0, 0, 0));
break;
case 5:
GLUtils.drawRect(x + 6, y + 6, x + 7, y + 13, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 7, y + 6, x + 13, y + 7, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 7, y + 9, x + 12, y + 10, GLUtils.getColor(0, 0, 0));
break;
case 6:
GLUtils.drawRect(x + 6, y + 6, x + 7, y + 13, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 6, x + 11, y + 7, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 12, x + 11, y + 13, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 11, y + 7, x + 12, y + 8, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 11, y + 11, x + 12, y + 12, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 12, y + 8, x + 13, y + 11, GLUtils.getColor(0, 0, 0));
break;
case 7:
GLUtils.drawRect(x + 6, y + 6, x + 13, y + 7, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 7, x + 7, y + 8, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 12, y + 7, x + 13, y + 8, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 9, y + 7, x + 10, y + 12, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 8, y + 12, x + 11, y + 13, GLUtils.getColor(0, 0, 0));
break;
case 8:
GLUtils.drawRect(x + 6, y + 6, x + 13, y + 7, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 8, x + 13, y + 9, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 10, x + 13, y + 11, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 6, y + 12, x + 13, y + 13, GLUtils.getColor(0, 0, 0));
break;
case 9:
GLUtils.drawRect(x + 5, y + 5, x + 7, y + 6, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 5, y + 5, x + 6, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 5, y + 13, x + 7, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 12, y + 5, x + 14, y + 6, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 13, y + 5, x + 14, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 12, y + 13, x + 14, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 7, y + 7, x + 8, y + 12, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 7, y + 7, x + 11, y + 8, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 7, y + 9, x + 11, y + 10, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 7, y + 11, x + 11, y + 12, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 11, y + 8, x + 12, y + 9, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 11, y + 10, x + 12, y + 11, GLUtils.getColor(0, 0, 0));
break;
case 10:
GLUtils.drawRect(x + 5, y + 5, x + 7, y + 6, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 5, y + 5, x + 6, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 5, y + 13, x + 7, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 12, y + 5, x + 14, y + 6, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 13, y + 5, x + 14, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 12, y + 13, x + 14, y + 14, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 7, y + 7, x + 12, y + 8, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 7, y + 11, x + 12, y + 12, GLUtils.getColor(0, 0, 0));
GLUtils.drawRect(x + 9, y + 8, x + 10, y + 11, GLUtils.getColor(0, 0, 0));
break;
}
}
}
| 9,263 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
AltAxisAlignedBB.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/axis/AltAxisAlignedBB.java | package ehacks.mod.util.axis;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
public class AltAxisAlignedBB {
private static final ThreadLocal theAABBLocalPool = new AltAABBLocalPool();
public double minX;
public double minY;
public double minZ;
public double maxX;
public double maxY;
public double maxZ;
public static AltAxisAlignedBB getBoundingBox(double par0, double par2, double par4, double par6, double par8, double par10) {
return new AltAxisAlignedBB(par0, par2, par4, par6, par8, par10);
}
public static AxisAlignedBB getAABBPool() {
return (AxisAlignedBB) theAABBLocalPool.get();
}
public AltAxisAlignedBB(double par1, double par3, double par5, double par7, double par9, double par11) {
this.minX = par1;
this.minY = par3;
this.minZ = par5;
this.maxX = par7;
this.maxY = par9;
this.maxZ = par11;
}
public AltAxisAlignedBB setBounds(double par1, double par3, double par5, double par7, double par9, double par11) {
this.minX = par1;
this.minY = par3;
this.minZ = par5;
this.maxX = par7;
this.maxY = par9;
this.maxZ = par11;
return this;
}
public AxisAlignedBB addCoord(double par1, double par3, double par5) {
double var7 = this.minX;
double var9 = this.minY;
double var11 = this.minZ;
double var13 = this.maxX;
double var15 = this.maxY;
double var17 = this.maxZ;
if (par1 < 0.0) {
var7 += par1;
}
if (par1 > 0.0) {
var13 += par1;
}
if (par3 < 0.0) {
var9 += par3;
}
if (par3 > 0.0) {
var15 += par3;
}
if (par5 < 0.0) {
var11 += par5;
}
if (par5 > 0.0) {
var17 += par5;
}
AltAxisAlignedBB.getAABBPool();
return AxisAlignedBB.getBoundingBox(var7, var9, var11, var13, var15, var17);
}
public AxisAlignedBB expand(double par1, double par3, double par5) {
double var7 = this.minX - par1;
double var9 = this.minY - par3;
double var11 = this.minZ - par5;
double var13 = this.maxX + par1;
double var15 = this.maxY + par3;
double var17 = this.maxZ + par5;
AltAxisAlignedBB.getAABBPool();
return AxisAlignedBB.getBoundingBox(var7, var9, var11, var13, var15, var17);
}
public AxisAlignedBB func_111270_a(AltAxisAlignedBB par1AxisAlignedBB) {
double var2 = Math.min(this.minX, par1AxisAlignedBB.minX);
double var4 = Math.min(this.minY, par1AxisAlignedBB.minY);
double var6 = Math.min(this.minZ, par1AxisAlignedBB.minZ);
double var8 = Math.max(this.maxX, par1AxisAlignedBB.maxX);
double var10 = Math.max(this.maxY, par1AxisAlignedBB.maxY);
double var12 = Math.max(this.maxZ, par1AxisAlignedBB.maxZ);
AltAxisAlignedBB.getAABBPool();
return AxisAlignedBB.getBoundingBox(var2, var4, var6, var8, var10, var12);
}
public AxisAlignedBB getOffsetBoundingBox(double par1, double par3, double par5) {
AltAxisAlignedBB.getAABBPool();
return AxisAlignedBB.getBoundingBox((this.minX + par1), (this.minY + par3), (this.minZ + par5), (this.maxX + par1), (this.maxY + par3), (this.maxZ + par5));
}
public double calculateXOffset(AltAxisAlignedBB par1AxisAlignedBB, double par2) {
if (par1AxisAlignedBB.maxY > this.minY && par1AxisAlignedBB.minY < this.maxY) {
if (par1AxisAlignedBB.maxZ > this.minZ && par1AxisAlignedBB.minZ < this.maxZ) {
double var4;
if (par2 > 0.0 && par1AxisAlignedBB.maxX <= this.minX && (var4 = this.minX - par1AxisAlignedBB.maxX) < par2) {
par2 = var4;
}
if (par2 < 0.0 && par1AxisAlignedBB.minX >= this.maxX && (var4 = this.maxX - par1AxisAlignedBB.minX) > par2) {
par2 = var4;
}
return par2;
}
return par2;
}
return par2;
}
public double calculateYOffset(AltAxisAlignedBB par1AxisAlignedBB, double par2) {
if (par1AxisAlignedBB.maxX > this.minX && par1AxisAlignedBB.minX < this.maxX) {
if (par1AxisAlignedBB.maxZ > this.minZ && par1AxisAlignedBB.minZ < this.maxZ) {
double var4;
if (par2 > 0.0 && par1AxisAlignedBB.maxY <= this.minY && (var4 = this.minY - par1AxisAlignedBB.maxY) < par2) {
par2 = var4;
}
if (par2 < 0.0 && par1AxisAlignedBB.minY >= this.maxY && (var4 = this.maxY - par1AxisAlignedBB.minY) > par2) {
par2 = var4;
}
return par2;
}
return par2;
}
return par2;
}
public double calculateZOffset(AltAxisAlignedBB par1AxisAlignedBB, double par2) {
if (par1AxisAlignedBB.maxX > this.minX && par1AxisAlignedBB.minX < this.maxX) {
if (par1AxisAlignedBB.maxY > this.minY && par1AxisAlignedBB.minY < this.maxY) {
double var4;
if (par2 > 0.0 && par1AxisAlignedBB.maxZ <= this.minZ && (var4 = this.minZ - par1AxisAlignedBB.maxZ) < par2) {
par2 = var4;
}
if (par2 < 0.0 && par1AxisAlignedBB.minZ >= this.maxZ && (var4 = this.maxZ - par1AxisAlignedBB.minZ) > par2) {
par2 = var4;
}
return par2;
}
return par2;
}
return par2;
}
public boolean intersectsWith(AltAxisAlignedBB par1AxisAlignedBB) {
return (par1AxisAlignedBB.maxX > this.minX && par1AxisAlignedBB.minX < this.maxX) && ((par1AxisAlignedBB.maxY > this.minY && par1AxisAlignedBB.minY < this.maxY) && (par1AxisAlignedBB.maxZ > this.minZ && par1AxisAlignedBB.minZ < this.maxZ));
}
public AltAxisAlignedBB offset(double par1, double par3, double par5) {
this.minX += par1;
this.minY += par3;
this.minZ += par5;
this.maxX += par1;
this.maxY += par3;
this.maxZ += par5;
return this;
}
public boolean isVecInside(Vec3 par1Vec3) {
return (par1Vec3.xCoord > this.minX && par1Vec3.xCoord < this.maxX) && ((par1Vec3.yCoord > this.minY && par1Vec3.yCoord < this.maxY) && (par1Vec3.zCoord > this.minZ && par1Vec3.zCoord < this.maxZ));
}
public double getAverageEdgeLength() {
double var1 = this.maxX - this.minX;
double var3 = this.maxY - this.minY;
double var5 = this.maxZ - this.minZ;
return (var1 + var3 + var5) / 3.0;
}
public AxisAlignedBB contract(double par1, double par3, double par5) {
double var7 = this.minX + par1;
double var9 = this.minY + par3;
double var11 = this.minZ + par5;
double var13 = this.maxX - par1;
double var15 = this.maxY - par3;
double var17 = this.maxZ - par5;
AltAxisAlignedBB.getAABBPool();
return AxisAlignedBB.getBoundingBox(var7, var9, var11, var13, var15, var17);
}
public AxisAlignedBB copy() {
AltAxisAlignedBB.getAABBPool();
return AxisAlignedBB.getBoundingBox(this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ);
}
public MovingObjectPosition calculateIntercept(Vec3 par1Vec3, Vec3 par2Vec3) {
Vec3 var3 = par1Vec3.getIntermediateWithXValue(par2Vec3, this.minX);
Vec3 var4 = par1Vec3.getIntermediateWithXValue(par2Vec3, this.maxX);
Vec3 var5 = par1Vec3.getIntermediateWithYValue(par2Vec3, this.minY);
Vec3 var6 = par1Vec3.getIntermediateWithYValue(par2Vec3, this.maxY);
Vec3 var7 = par1Vec3.getIntermediateWithZValue(par2Vec3, this.minZ);
Vec3 var8 = par1Vec3.getIntermediateWithZValue(par2Vec3, this.maxZ);
if (!this.isVecInYZ(var3)) {
var3 = null;
}
if (!this.isVecInYZ(var4)) {
var4 = null;
}
if (!this.isVecInXZ(var5)) {
var5 = null;
}
if (!this.isVecInXZ(var6)) {
var6 = null;
}
if (!this.isVecInXY(var7)) {
var7 = null;
}
if (!this.isVecInXY(var8)) {
var8 = null;
}
Vec3 var9 = null;
if (var3 != null) {
var9 = var3;
}
if (var4 != null && (var9 == null || par1Vec3.squareDistanceTo(var4) < par1Vec3.squareDistanceTo(var9))) {
var9 = var4;
}
if (var5 != null && (var9 == null || par1Vec3.squareDistanceTo(var5) < par1Vec3.squareDistanceTo(var9))) {
var9 = var5;
}
if (var6 != null && (var9 == null || par1Vec3.squareDistanceTo(var6) < par1Vec3.squareDistanceTo(var9))) {
var9 = var6;
}
if (var7 != null && (var9 == null || par1Vec3.squareDistanceTo(var7) < par1Vec3.squareDistanceTo(var9))) {
var9 = var7;
}
if (var8 != null && (var9 == null || par1Vec3.squareDistanceTo(var8) < par1Vec3.squareDistanceTo(var9))) {
var9 = var8;
}
if (var9 == null) {
return null;
}
int var10 = -1;
if (var9 == var3) {
var10 = 4;
}
if (var9 == var4) {
var10 = 5;
}
if (var9 == var5) {
var10 = 0;
}
if (var9 == var6) {
var10 = 1;
}
if (var9 == var7) {
var10 = 2;
}
if (var9 == var8) {
var10 = 3;
}
return new MovingObjectPosition(0, 0, 0, var10, var9);
}
private boolean isVecInYZ(Vec3 par1Vec3) {
return par1Vec3 != null && (par1Vec3.yCoord >= this.minY && par1Vec3.yCoord <= this.maxY && par1Vec3.zCoord >= this.minZ && par1Vec3.zCoord <= this.maxZ);
}
private boolean isVecInXZ(Vec3 par1Vec3) {
return par1Vec3 != null && (par1Vec3.xCoord >= this.minX && par1Vec3.xCoord <= this.maxX && par1Vec3.zCoord >= this.minZ && par1Vec3.zCoord <= this.maxZ);
}
private boolean isVecInXY(Vec3 par1Vec3) {
return par1Vec3 != null && (par1Vec3.xCoord >= this.minX && par1Vec3.xCoord <= this.maxX && par1Vec3.yCoord >= this.minY && par1Vec3.yCoord <= this.maxY);
}
public void setBB(AltAxisAlignedBB par1AxisAlignedBB) {
this.minX = par1AxisAlignedBB.minX;
this.minY = par1AxisAlignedBB.minY;
this.minZ = par1AxisAlignedBB.minZ;
this.maxX = par1AxisAlignedBB.maxX;
this.maxY = par1AxisAlignedBB.maxY;
this.maxZ = par1AxisAlignedBB.maxZ;
}
@Override
public String toString() {
return "box[" + this.minX + ", " + this.minY + ", " + this.minZ + " -> " + this.maxX + ", " + this.maxY + ", " + this.maxZ + "]";
}
}
| 10,964 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
AltAABBLocalPool.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/axis/AltAABBLocalPool.java | package ehacks.mod.util.axis;
import net.minecraft.util.AxisAlignedBB;
public class AltAABBLocalPool
extends ThreadLocal {
AxisAlignedBB createNewDefaultPool() {
return AxisAlignedBB.getBoundingBox(300.0, 2000.0, 0.0, 0.0, 0.0, 0.0);
}
Object sinitialValue() {
return this.createNewDefaultPool();
}
}
| 345 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Players.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/packetquery/Players.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.packetquery;
import java.util.Collections;
import java.util.List;
/**
*
* @author radioegor146
*/
public class Players {
private int max;
private int online;
private List<Player> sample;
public int getMax() {
return max;
}
public int getOnline() {
return online;
}
public List<Player> getSample() {
return Collections.unmodifiableList(sample);
}
}
| 626 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Player.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/packetquery/Player.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.packetquery;
/**
*
* @author radioegor146
*/
public class Player {
private String name;
private String id;
public String getName() {
return name;
}
public String getId() {
return id;
}
}
| 444 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Version.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/packetquery/Version.java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ehacks.mod.util.packetquery;
/**
*
* @author radioegor146
*/
public class Version {
private String name;
private String protocol;
public String getName() {
return name;
}
public String getProtocol() {
return protocol;
}
}
| 462 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
StatusResponse.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/util/packetquery/StatusResponse.java | package ehacks.mod.util.packetquery;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author radioegor146
*/
public class StatusResponse {
private String description;
private Players players;
private Version version;
private String favicon;
private int time;
public String getDescription() {
return description;
}
public Players getPlayers() {
return players;
}
public Version getVersion() {
return version;
}
public String getFavicon() {
return favicon;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
}
| 822 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
BSHForStatement.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/BSHForStatement.java | /** ***************************************************************************
* *
* This file is part of the BeanShell Java Scripting distribution. *
* Documentation and updates may be found at http://www.beanshell.org/ *
* *
* Sun Public License Notice: *
* *
* The contents of this file are subject to the Sun Public License Version *
* 1.0 (the "License"); you may not use this file except in compliance with *
* the License. A copy of the License is available at http://www.sun.com *
* *
* The Original Code is BeanShell. The Initial Developer of the Original *
* Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
* (C) 2000. All Rights Reserved. *
* *
* GNU Public License Notice: *
* *
* Alternatively, the contents of this file may be used under the terms of *
* the GNU Lesser General Public License (the "LGPL"), in which case the *
* provisions of LGPL are applicable instead of those above. If you wish to *
* allow use of your version of this file only under the terms of the LGPL *
* and not to allow others to use your version of this file under the SPL, *
* indicate your decision by deleting the provisions above and replace *
* them with the notice and other provisions required by the LGPL. If you *
* do not delete the provisions above, a recipient may use your version of *
* this file under either the SPL or the LGPL. *
* *
* Patrick Niemeyer ([email protected]) *
* Author of Learning Java, O'Reilly & Associates *
* http://www.pat.net/~pat/ *
* *
**************************************************************************** */
package ehacks.bsh;
/**
* Implementation of the for(;;) statement.
*/
class BSHForStatement extends SimpleNode implements ParserConstants {
public boolean hasForInit;
public boolean hasExpression;
public boolean hasForUpdate;
private SimpleNode forInit;
private SimpleNode expression;
private SimpleNode forUpdate;
private SimpleNode statement;
private boolean parsed;
BSHForStatement(int id) {
super(id);
}
@Override
public Object eval(CallStack callstack, Interpreter interpreter)
throws EvalError {
int i = 0;
if (hasForInit) {
forInit = ((SimpleNode) jjtGetChild(i++));
}
if (hasExpression) {
expression = ((SimpleNode) jjtGetChild(i++));
}
if (hasForUpdate) {
forUpdate = ((SimpleNode) jjtGetChild(i++));
}
if (i < jjtGetNumChildren()) // should normally be
{
statement = ((SimpleNode) jjtGetChild(i));
}
NameSpace enclosingNameSpace = callstack.top();
BlockNameSpace forNameSpace = new BlockNameSpace(enclosingNameSpace);
/*
Note: some interesting things are going on here.
1) We swap instead of push... The primary mode of operation
acts like we are in the enclosing namespace... (super must be
preserved, etc.)
2) We do *not* call the body block eval with the namespace
override. Instead we allow it to create a second subordinate
BlockNameSpace child of the forNameSpace. Variable propogation
still works through the chain, but the block's child cleans the
state between iteration.
(which is correct Java behavior... see forscope4.bsh)
*/
// put forNameSpace it on the top of the stack
// Note: it's important that there is only one exit point from this
// method so that we can swap back the namespace.
callstack.swap(forNameSpace);
// Do the for init
if (hasForInit) {
forInit.eval(callstack, interpreter);
}
Object returnControl = Primitive.VOID;
while (true) {
if (hasExpression) {
boolean cond = BSHIfStatement.evaluateCondition(
expression, callstack, interpreter);
if (!cond) {
break;
}
}
boolean breakout = false; // switch eats a multi-level break here?
if (statement != null) // not empty statement
{
// do *not* invoke special override for block... (see above)
Object ret = statement.eval(callstack, interpreter);
if (ret instanceof ReturnControl) {
switch (((ReturnControl) ret).kind) {
case RETURN:
returnControl = ret;
breakout = true;
break;
case CONTINUE:
break;
case BREAK:
breakout = true;
break;
}
}
}
if (breakout) {
break;
}
if (hasForUpdate) {
forUpdate.eval(callstack, interpreter);
}
}
callstack.swap(enclosingNameSpace); // put it back
return returnControl;
}
}
| 6,022 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ClassPathException.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/ClassPathException.java | /** ***************************************************************************
* *
* This file is part of the BeanShell Java Scripting distribution. *
* Documentation and updates may be found at http://www.beanshell.org/ *
* *
* Sun Public License Notice: *
* *
* The contents of this file are subject to the Sun Public License Version *
* 1.0 (the "License"); you may not use this file except in compliance with *
* the License. A copy of the License is available at http://www.sun.com *
* *
* The Original Code is BeanShell. The Initial Developer of the Original *
* Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
* (C) 2000. All Rights Reserved. *
* *
* GNU Public License Notice: *
* *
* Alternatively, the contents of this file may be used under the terms of *
* the GNU Lesser General Public License (the "LGPL"), in which case the *
* provisions of LGPL are applicable instead of those above. If you wish to *
* allow use of your version of this file only under the terms of the LGPL *
* and not to allow others to use your version of this file under the SPL, *
* indicate your decision by deleting the provisions above and replace *
* them with the notice and other provisions required by the LGPL. If you *
* do not delete the provisions above, a recipient may use your version of *
* this file under either the SPL or the LGPL. *
* *
* Patrick Niemeyer ([email protected]) *
* Author of Learning Java, O'Reilly & Associates *
* http://www.pat.net/~pat/ *
* *
**************************************************************************** */
package ehacks.bsh;
public class ClassPathException extends UtilEvalError {
public ClassPathException(String msg) {
super(msg);
}
}
| 2,681 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Label.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/Label.java | /** *
* ASM: a very small and fast Java bytecode manipulation framework
* Copyright (C) 2000 INRIA, France Telecom
* Copyright (C) 2002 France Telecom
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: [email protected]
*
* Author: Eric Bruneton
*/
package ehacks.bsh;
/**
* A label represents a position in the bytecode of a method. Labels are used
* for jump, goto, and switch instructions, and for try catch blocks.
*/
public class Label {
/**
* The code writer to which this label belongs, or <tt>null</tt> if unknown.
*/
CodeWriter owner;
/**
* Indicates if the position of this label is known.
*/
boolean resolved;
/**
* The position of this label in the code, if known.
*/
int position;
/**
* Number of forward references to this label, times two.
*/
private int referenceCount;
/**
* Informations about forward references. Each forward reference is
* described by two consecutive integers in this array: the first one is the
* position of the first byte of the bytecode instruction that contains the
* forward reference, while the second is the position of the first byte of
* the forward reference itself. In fact the sign of the first integer
* indicates if this reference uses 2 or 4 bytes, and its absolute value
* gives the position of the bytecode instruction.
*/
private int[] srcAndRefPositions;
// --------------------------------------------------------------------------
// Fields for the control flow graph analysis algorithm (used to compute the
// maximum stack size). A control flow graph contains one node per "basic
// block", and one edge per "jump" from one basic block to another. Each node
// (i.e., each basic block) is represented by the Label object that
// corresponds to the first instruction of this basic block. Each node also
// stores the list of it successors in the graph, as a linked list of Edge
// objects.
// --------------------------------------------------------------------------
/**
* The stack size at the beginning of this basic block. This size is
* initially unknown. It is computed by the control flow analysis algorithm
* (see {@link CodeWriter#visitMaxs visitMaxs}).
*/
int beginStackSize;
/**
* The (relative) maximum stack size corresponding to this basic block. This
* size is relative to the stack size at the beginning of the basic block,
* i.e., the true maximum stack size is equal to {@link #beginStackSize
* beginStackSize} + {@link #maxStackSize maxStackSize}.
*/
int maxStackSize;
/**
* The successors of this node in the control flow graph. These successors
* are stored in a linked list of {@link Edge Edge} objects, linked to each
* other by their {@link Edge#next} field.
*/
Edge successors;
/**
* The next basic block in the basic block stack. See
* {@link CodeWriter#visitMaxs visitMaxs}.
*/
Label next;
/**
* <tt>true</tt> if this basic block has been pushed in the basic block
* stack. See {@link CodeWriter#visitMaxs visitMaxs}.
*/
boolean pushed;
// --------------------------------------------------------------------------
// Constructor
// --------------------------------------------------------------------------
/**
* Constructs a new label.
*/
public Label() {
}
// --------------------------------------------------------------------------
// Methods to compute offsets and to manage forward references
// --------------------------------------------------------------------------
/**
* Puts a reference to this label in the bytecode of a method. If the
* position of the label is known, the offset is computed and written
* directly. Otherwise, a null offset is written and a new forward reference
* is declared for this label.
*
* @param owner the code writer that calls this method.
* @param out the bytecode of the method.
* @param source the position of first byte of the bytecode instruction that
* contains this label.
* @param wideOffset <tt>true</tt> if the reference must be stored in 4
* bytes, or <tt>false</tt> if it must be stored with 2 bytes.
* @throws IllegalArgumentException if this label has not been created by
* the given code writer.
*/
void put(
final CodeWriter owner,
final ByteVector out,
final int source,
final boolean wideOffset) {
if (CodeWriter.CHECK) {
if (this.owner == null) {
this.owner = owner;
} else if (this.owner != owner) {
throw new IllegalArgumentException();
}
}
if (resolved) {
if (wideOffset) {
out.put4(position - source);
} else {
out.put2(position - source);
}
} else {
if (wideOffset) {
addReference(-1 - source, out.length);
out.put4(-1);
} else {
addReference(source, out.length);
out.put2(-1);
}
}
}
/**
* Adds a forward reference to this label. This method must be called only
* for a true forward reference, i.e. only if this label is not resolved
* yet. For backward references, the offset of the reference can be, and
* must be, computed and stored directly.
*
* @param sourcePosition the position of the referencing instruction. This
* position will be used to compute the offset of this forward reference.
* @param referencePosition the position where the offset for this forward
* reference must be stored.
*/
private void addReference(
final int sourcePosition,
final int referencePosition) {
if (srcAndRefPositions == null) {
srcAndRefPositions = new int[6];
}
if (referenceCount >= srcAndRefPositions.length) {
int[] a = new int[srcAndRefPositions.length + 6];
System.arraycopy(srcAndRefPositions, 0, a, 0, srcAndRefPositions.length);
srcAndRefPositions = a;
}
srcAndRefPositions[referenceCount++] = sourcePosition;
srcAndRefPositions[referenceCount++] = referencePosition;
}
/**
* Resolves all forward references to this label. This method must be called
* when this label is added to the bytecode of the method, i.e. when its
* position becomes known. This method fills in the blanks that where left
* in the bytecode by each forward reference previously added to this label.
*
* @param owner the code writer that calls this method.
* @param position the position of this label in the bytecode.
* @param data the bytecode of the method.
* @return <tt>true</tt> if a blank that was left for this label was to
* small to store the offset. In such a case the corresponding jump
* instruction is replaced with a pseudo instruction (using unused opcodes)
* using an unsigned two bytes offset. These pseudo instructions will need
* to be replaced with true instructions with wider offsets (4 bytes instead
* of 2). This is done in {@link CodeWriter#resizeInstructions}.
* @throws IllegalArgumentException if this label has already been resolved,
* or if it has not been created by the given code writer.
*/
boolean resolve(
final CodeWriter owner,
final int position,
final byte[] data) {
if (CodeWriter.CHECK) {
if (this.owner == null) {
this.owner = owner;
}
if (resolved || this.owner != owner) {
throw new IllegalArgumentException();
}
}
boolean needUpdate = false;
this.resolved = true;
this.position = position;
int i = 0;
while (i < referenceCount) {
int source = srcAndRefPositions[i++];
int reference = srcAndRefPositions[i++];
int offset;
if (source >= 0) {
offset = position - source;
if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) {
// changes the opcode of the jump instruction, in order to be able to
// find it later (see resizeInstructions in CodeWriter). These
// temporary opcodes are similar to jump instruction opcodes, except
// that the 2 bytes offset is unsigned (and can therefore represent
// values from 0 to 65535, which is sufficient since the size of a
// method is limited to 65535 bytes).
int opcode = data[reference - 1] & 0xFF;
if (opcode <= Constants.JSR) {
// changes IFEQ ... JSR to opcodes 202 to 217 (inclusive)
data[reference - 1] = (byte) (opcode + 49);
} else {
// changes IFNULL and IFNONNULL to opcodes 218 and 219 (inclusive)
data[reference - 1] = (byte) (opcode + 20);
}
needUpdate = true;
}
data[reference++] = (byte) (offset >>> 8);
data[reference] = (byte) offset;
} else {
offset = position + source + 1;
data[reference++] = (byte) (offset >>> 24);
data[reference++] = (byte) (offset >>> 16);
data[reference++] = (byte) (offset >>> 8);
data[reference] = (byte) offset;
}
}
return needUpdate;
}
}
| 10,601 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ClassGeneratorImpl.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/ClassGeneratorImpl.java | package ehacks.bsh;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
public class ClassGeneratorImpl
extends ClassGenerator {
@Override
public Class generateClass(String string, Modifiers modifiers, Class[] arrclass, Class class_, BSHBlock bSHBlock, boolean bl, CallStack callStack, Interpreter interpreter) throws EvalError {
return ClassGeneratorImpl.generateClassImpl(string, modifiers, arrclass, class_, bSHBlock, bl, callStack, interpreter);
}
@Override
public Object invokeSuperclassMethod(BSHClassManager bshClassManager, Object object, String string, Object[] arrobject) throws UtilEvalError, ReflectError, InvocationTargetException {
return ClassGeneratorImpl.invokeSuperclassMethodImpl(bshClassManager, object, string, arrobject);
}
@Override
public void setInstanceNameSpaceParent(Object object, String string, NameSpace nameSpace) {
This this_ = ClassGeneratorUtil.getClassInstanceThis(object, string);
this_.getNameSpace().setParent(nameSpace);
}
public static Class generateClassImpl(String string, Modifiers modifiers, Class[] arrclass, Class class_, BSHBlock bSHBlock, boolean bl, CallStack callStack, Interpreter interpreter) throws EvalError {
try {
Capabilities.setAccessibility(true);
} catch (Capabilities.Unavailable unavailable) {
throw new EvalError("Defining classes currently requires reflective Accessibility.", bSHBlock, callStack);
}
NameSpace nameSpace = callStack.top();
String string2 = nameSpace.getPackage();
String string3 = nameSpace.isClass ? nameSpace.getName() + "$" + string : string;
String string4 = string2 == null ? string3 : string2 + "." + string3;
BSHClassManager bshClassManager = interpreter.getClassManager();
bshClassManager.definingClass(string4);
NameSpace nameSpace2 = new NameSpace(nameSpace, string3);
nameSpace2.isClass = true;
callStack.push(nameSpace2);
bSHBlock.evalBlock(callStack, interpreter, true, ClassNodeFilter.CLASSCLASSES);
Variable[] arrvariable = ClassGeneratorImpl.getDeclaredVariables(bSHBlock, callStack, interpreter, string2);
DelayedEvalBshMethod[] arrdelayedEvalBshMethod = ClassGeneratorImpl.getDeclaredMethods(bSHBlock, callStack, interpreter, string2);
ClassGeneratorUtil classGeneratorUtil = new ClassGeneratorUtil(modifiers, string3, string2, class_, arrclass, arrvariable, arrdelayedEvalBshMethod, nameSpace2, bl);
byte[] arrby = classGeneratorUtil.generateClass();
String string5 = System.getProperty("debugClasses");
if (string5 != null) {
try {
try (FileOutputStream object = new FileOutputStream(string5 + "/" + string3 + ".class")) {
object.write(arrby);
}
} catch (IOException iOException) {
// empty catch block
}
}
Class object1 = bshClassManager.defineClass(string4, arrby);
nameSpace.importClass(string4.replace('$', '.'));
try {
nameSpace2.setLocalVariable("_bshInstanceInitializer", bSHBlock, false);
} catch (UtilEvalError utilEvalError) {
throw new InterpreterError("unable to init static: " + utilEvalError);
}
nameSpace2.setClassStatic(object1);
bSHBlock.evalBlock(callStack, interpreter, true, ClassNodeFilter.CLASSSTATIC);
callStack.pop();
if (!object1.isInterface()) {
String string6 = "_bshStatic" + string3;
try {
LHS lHS = Reflect.getLHSStaticField(object1, string6);
lHS.assign(nameSpace2.getThis(interpreter), false);
} catch (Exception exception) {
throw new InterpreterError("Error in class gen setup: " + exception);
}
}
bshClassManager.doneDefiningClass(string4);
return object1;
}
static Variable[] getDeclaredVariables(BSHBlock bSHBlock, CallStack callStack, Interpreter interpreter, String string) {
ArrayList<Variable> arrayList = new ArrayList<>();
int n = 0;
while (n < bSHBlock.jjtGetNumChildren()) {
SimpleNode simpleNode = (SimpleNode) bSHBlock.jjtGetChild(n);
if (simpleNode instanceof BSHTypedVariableDeclaration) {
BSHTypedVariableDeclaration bSHTypedVariableDeclaration = (BSHTypedVariableDeclaration) simpleNode;
Modifiers modifiers = bSHTypedVariableDeclaration.modifiers;
String string2 = bSHTypedVariableDeclaration.getTypeDescriptor(callStack, interpreter, string);
BSHVariableDeclarator[] arrbSHVariableDeclarator = bSHTypedVariableDeclaration.getDeclarators();
int n2 = 0;
while (n2 < arrbSHVariableDeclarator.length) {
String string3 = arrbSHVariableDeclarator[n2].name;
try {
Variable variable = new Variable(string3, string2, null, modifiers);
arrayList.add(variable);
} catch (UtilEvalError utilEvalError) {
// empty catch block
}
++n2;
}
}
++n;
}
return arrayList.toArray(new Variable[arrayList.size()]);
}
static DelayedEvalBshMethod[] getDeclaredMethods(BSHBlock bSHBlock, CallStack callStack, Interpreter interpreter, String string) throws EvalError {
ArrayList<DelayedEvalBshMethod> arrayList = new ArrayList<>();
int n = 0;
while (n < bSHBlock.jjtGetNumChildren()) {
SimpleNode simpleNode = (SimpleNode) bSHBlock.jjtGetChild(n);
if (simpleNode instanceof BSHMethodDeclaration) {
BSHMethodDeclaration bSHMethodDeclaration = (BSHMethodDeclaration) simpleNode;
bSHMethodDeclaration.insureNodesParsed();
Modifiers modifiers = bSHMethodDeclaration.modifiers;
String string2 = bSHMethodDeclaration.name;
String string3 = bSHMethodDeclaration.getReturnTypeDescriptor(callStack, interpreter, string);
BSHReturnType bSHReturnType = bSHMethodDeclaration.getReturnTypeNode();
BSHFormalParameters bSHFormalParameters = bSHMethodDeclaration.paramsNode;
String[] arrstring = bSHFormalParameters.getTypeDescriptors(callStack, interpreter, string);
DelayedEvalBshMethod delayedEvalBshMethod = new DelayedEvalBshMethod(string2, string3, bSHReturnType, bSHMethodDeclaration.paramsNode.getParamNames(), arrstring, bSHFormalParameters, bSHMethodDeclaration.blockNode, null, modifiers, callStack, interpreter);
arrayList.add(delayedEvalBshMethod);
}
++n;
}
return arrayList.toArray(new DelayedEvalBshMethod[arrayList.size()]);
}
public static Object invokeSuperclassMethodImpl(BSHClassManager bshClassManager, Object object, String string, Object[] arrobject) throws UtilEvalError, ReflectError, InvocationTargetException {
String string2 = "_bshSuper" + string;
Class class_ = object.getClass();
Method method = Reflect.resolveJavaMethod(bshClassManager, class_, string2, Types.getTypes(arrobject), false);
if (method != null) {
return Reflect.invokeMethod(method, object, arrobject);
}
Class class_2 = class_.getSuperclass();
method = Reflect.resolveExpectedJavaMethod(bshClassManager, class_2, object, string, arrobject, false);
return Reflect.invokeMethod(method, object, arrobject);
}
static class ClassNodeFilter
implements BSHBlock.NodeFilter {
public static final int STATIC = 0;
public static final int INSTANCE = 1;
public static final int CLASSES = 2;
public static ClassNodeFilter CLASSSTATIC = new ClassNodeFilter(0);
public static ClassNodeFilter CLASSINSTANCE = new ClassNodeFilter(1);
public static ClassNodeFilter CLASSCLASSES = new ClassNodeFilter(2);
int context;
private ClassNodeFilter(int n) {
this.context = n;
}
@Override
public boolean isVisible(SimpleNode simpleNode) {
if (this.context == 2) {
return simpleNode instanceof BSHClassDeclaration;
}
if (simpleNode instanceof BSHClassDeclaration) {
return false;
}
if (this.context == 0) {
return this.isStatic(simpleNode);
}
if (this.context == 1) {
return !this.isStatic(simpleNode);
}
return true;
}
boolean isStatic(SimpleNode simpleNode) {
if (simpleNode instanceof BSHTypedVariableDeclaration) {
return ((BSHTypedVariableDeclaration) simpleNode).modifiers != null && ((BSHTypedVariableDeclaration) simpleNode).modifiers.hasModifier("static");
}
if (simpleNode instanceof BSHMethodDeclaration) {
return ((BSHMethodDeclaration) simpleNode).modifiers != null && ((BSHMethodDeclaration) simpleNode).modifiers.hasModifier("static");
}
if (simpleNode instanceof BSHBlock) {
return false;
}
return false;
}
}
}
| 9,599 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
BSHPrimarySuffix.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/BSHPrimarySuffix.java | /** ***************************************************************************
* *
* This file is part of the BeanShell Java Scripting distribution. *
* Documentation and updates may be found at http://www.beanshell.org/ *
* *
* Sun Public License Notice: *
* *
* The contents of this file are subject to the Sun Public License Version *
* 1.0 (the "License"); you may not use this file except in compliance with *
* the License. A copy of the License is available at http://www.sun.com *
* *
* The Original Code is BeanShell. The Initial Developer of the Original *
* Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
* (C) 2000. All Rights Reserved. *
* *
* GNU Public License Notice: *
* *
* Alternatively, the contents of this file may be used under the terms of *
* the GNU Lesser General Public License (the "LGPL"), in which case the *
* provisions of LGPL are applicable instead of those above. If you wish to *
* allow use of your version of this file only under the terms of the LGPL *
* and not to allow others to use your version of this file under the SPL, *
* indicate your decision by deleting the provisions above and replace *
* them with the notice and other provisions required by the LGPL. If you *
* do not delete the provisions above, a recipient may use your version of *
* this file under either the SPL or the LGPL. *
* *
* Patrick Niemeyer ([email protected]) *
* Author of Learning Java, O'Reilly & Associates *
* http://www.pat.net/~pat/ *
* *
**************************************************************************** */
package ehacks.bsh;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
class BSHPrimarySuffix extends SimpleNode {
public static final int CLASS = 0,
INDEX = 1,
NAME = 2,
PROPERTY = 3;
public int operation;
Object index;
public String field;
BSHPrimarySuffix(int id) {
super(id);
}
/*
Perform a suffix operation on the given object and return the
new value.
<p>
obj will be a Node when suffix evaluation begins, allowing us to
interpret it contextually. (e.g. for .class) Thereafter it will be
an value object or LHS (as determined by toLHS).
<p>
We must handle the toLHS case at each point here.
<p>
*/
public Object doSuffix(
Object obj, boolean toLHS,
CallStack callstack, Interpreter interpreter)
throws EvalError {
// Handle ".class" suffix operation
// Prefix must be a BSHType
if (operation == CLASS) {
if (obj instanceof BSHType) {
if (toLHS) {
throw new EvalError("Can't assign .class",
this, callstack);
}
NameSpace namespace = callstack.top();
return ((BSHType) obj).getType(callstack, interpreter);
} else {
throw new EvalError(
"Attempt to use .class suffix on non class.",
this, callstack);
}
}
/*
Evaluate our prefix if it needs evaluating first.
If this is the first evaluation our prefix mayb be a Node
(directly from the PrimaryPrefix) - eval() it to an object.
If it's an LHS, resolve to a value.
Note: The ambiguous name construct is now necessary where the node
may be an ambiguous name. If this becomes common we might want to
make a static method nodeToObject() or something. The point is
that we can't just eval() - we need to direct the evaluation to
the context sensitive type of result; namely object, class, etc.
*/
if (obj instanceof SimpleNode) {
if (obj instanceof BSHAmbiguousName) {
obj = ((BSHAmbiguousName) obj).toObject(callstack, interpreter);
} else {
obj = ((SimpleNode) obj).eval(callstack, interpreter);
}
} else if (obj instanceof LHS) {
try {
obj = ((LHS) obj).getValue();
} catch (UtilEvalError e) {
throw e.toEvalError(this, callstack);
}
}
try {
switch (operation) {
case INDEX:
return doIndex(obj, toLHS, callstack, interpreter);
case NAME:
return doName(obj, toLHS, callstack, interpreter);
case PROPERTY:
return doProperty(toLHS, obj, callstack, interpreter);
default:
throw new InterpreterError("Unknown suffix type");
}
} catch (ReflectError e) {
throw new EvalError("reflection error: " + e, this, callstack, e);
} catch (InvocationTargetException e) {
throw new TargetError("target exception", e.getTargetException(),
this, callstack, true);
}
}
/*
Field access, .length on array, or a method invocation
Must handle toLHS case for each.
*/
private Object doName(
Object obj, boolean toLHS,
CallStack callstack, Interpreter interpreter)
throws EvalError, ReflectError, InvocationTargetException {
try {
// .length on array
if (field.equals("length") && obj.getClass().isArray()) {
if (toLHS) {
throw new EvalError(
"Can't assign array length", this, callstack);
} else {
return new Primitive(Array.getLength(obj));
}
}
// field access
if (jjtGetNumChildren() == 0) {
if (toLHS) {
return Reflect.getLHSObjectField(obj, field);
} else {
return Reflect.getObjectFieldValue(obj, field);
}
}
// Method invocation
// (LHS or non LHS evaluation can both encounter method calls)
Object[] oa = ((BSHArguments) jjtGetChild(0)).getArguments(
callstack, interpreter);
// TODO:
// Note: this try/catch block is copied from BSHMethodInvocation
// we need to factor out this common functionality and make sure
// we handle all cases ... (e.g. property style access, etc.)
// maybe move this to Reflect ?
try {
return Reflect.invokeObjectMethod(
obj, field, oa, interpreter, callstack, this);
} catch (ReflectError e) {
throw new EvalError(
"Error in method invocation: " + e.getMessage(),
this, callstack, e);
} catch (InvocationTargetException e) {
String msg = "Method Invocation " + field;
Throwable te = e.getTargetException();
/*
Try to squeltch the native code stack trace if the exception
was caused by a reflective call back into the bsh interpreter
(e.g. eval() or source()
*/
boolean isNative = true;
if (te instanceof EvalError) {
if (te instanceof TargetError) {
isNative = ((TargetError) te).inNativeCode();
} else {
isNative = false;
}
}
throw new TargetError(msg, te, this, callstack, isNative);
}
} catch (UtilEvalError e) {
throw e.toEvalError(this, callstack);
}
}
/**
*/
static int getIndexAux(
Object obj, CallStack callstack, Interpreter interpreter,
SimpleNode callerInfo)
throws EvalError {
if (!obj.getClass().isArray()) {
throw new EvalError("Not an array", callerInfo, callstack);
}
int index;
try {
Object indexVal
= ((SimpleNode) callerInfo.jjtGetChild(0)).eval(
callstack, interpreter);
if (!(indexVal instanceof Primitive)) {
indexVal = Types.castObject(
indexVal, Integer.TYPE, Types.ASSIGNMENT);
}
index = ((Primitive) indexVal).intValue();
} catch (UtilEvalError e) {
Interpreter.debug("doIndex: " + e);
throw e.toEvalError(
"Arrays may only be indexed by integer types.",
callerInfo, callstack);
}
return index;
}
/**
* array index. Must handle toLHS case.
*/
private Object doIndex(
Object obj, boolean toLHS,
CallStack callstack, Interpreter interpreter)
throws EvalError, ReflectError {
int index = getIndexAux(obj, callstack, interpreter, this);
if (toLHS) {
return new LHS(obj, index);
} else {
try {
return Reflect.getIndex(obj, index);
} catch (UtilEvalError e) {
throw e.toEvalError(this, callstack);
}
}
}
/**
* Property access. Must handle toLHS case.
*/
private Object doProperty(boolean toLHS,
Object obj, CallStack callstack, Interpreter interpreter)
throws EvalError {
if (obj == Primitive.VOID) {
throw new EvalError(
"Attempt to access property on undefined variable or class name",
this, callstack);
}
if (obj instanceof Primitive) {
throw new EvalError("Attempt to access property on a primitive",
this, callstack);
}
Object value = ((SimpleNode) jjtGetChild(0)).eval(
callstack, interpreter);
if (!(value instanceof String)) {
throw new EvalError(
"Property expression must be a String or identifier.",
this, callstack);
}
if (toLHS) {
return new LHS(obj, (String) value);
}
// Property style access to Hashtable or Map
CollectionManager cm = CollectionManager.getCollectionManager();
if (cm.isMap(obj)) {
Object val = cm.getFromMap(obj, value/*key*/);
return (val == null ? val = Primitive.NULL : val);
}
try {
return Reflect.getObjectProperty(obj, (String) value);
} catch (UtilEvalError e) {
throw e.toEvalError("Property: " + value, this, callstack);
} catch (ReflectError e) {
throw new EvalError("No such property: " + value, this, callstack);
}
}
}
| 11,772 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
JJTParserState.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/JJTParserState.java | /* Generated By:JJTree: Do not edit this line. src/bsh/JJTParserState.java */
package ehacks.bsh;
class JJTParserState {
private final java.util.Stack nodes;
private final java.util.Stack marks;
private int sp; // number of nodes on stack
private int mk; // current mark
private boolean node_created;
JJTParserState() {
nodes = new java.util.Stack();
marks = new java.util.Stack();
sp = 0;
mk = 0;
}
/* Determines whether the current node was actually closed and
pushed. This should only be called in the final user action of a
node scope. */
boolean nodeCreated() {
return node_created;
}
/* Call this to reinitialize the node stack. It is called
automatically by the parser's ReInit() method. */
void reset() {
nodes.removeAllElements();
marks.removeAllElements();
sp = 0;
mk = 0;
}
/* Returns the root node of the AST. It only makes sense to call
this after a successful parse. */
Node rootNode() {
return (Node) nodes.elementAt(0);
}
/* Pushes a node on to the stack. */
void pushNode(Node n) {
nodes.push(n);
++sp;
}
/* Returns the node on the top of the stack, and remove it from the
stack. */
Node popNode() {
if (--sp < mk) {
mk = ((Integer) marks.pop()).intValue();
}
return (Node) nodes.pop();
}
/* Returns the node currently on the top of the stack. */
Node peekNode() {
return (Node) nodes.peek();
}
/* Returns the number of children on the stack in the current node
scope. */
int nodeArity() {
return sp - mk;
}
void clearNodeScope(Node n) {
while (sp > mk) {
popNode();
}
mk = ((Integer) marks.pop()).intValue();
}
void openNodeScope(Node n) {
marks.push(new Integer(mk));
mk = sp;
n.jjtOpen();
}
/* A definite node is constructed from a specified number of
children. That number of nodes are popped from the stack and
made the children of the definite node. Then the definite node
is pushed on to the stack. */
void closeNodeScope(Node n, int num) {
mk = ((Integer) marks.pop()).intValue();
while (num-- > 0) {
Node c = popNode();
c.jjtSetParent(n);
n.jjtAddChild(c, num);
}
n.jjtClose();
pushNode(n);
node_created = true;
}
/* A conditional node is constructed if its condition is true. All
the nodes that have been pushed since the node was opened are
made children of the the conditional node, which is then pushed
on to the stack. If the condition is false the node is not
constructed and they are left on the stack. */
void closeNodeScope(Node n, boolean condition) {
if (condition) {
int a = nodeArity();
mk = ((Integer) marks.pop()).intValue();
while (a-- > 0) {
Node c = popNode();
c.jjtSetParent(n);
n.jjtAddChild(c, a);
}
n.jjtClose();
pushNode(n);
node_created = true;
} else {
mk = ((Integer) marks.pop()).intValue();
node_created = false;
}
}
}
| 3,390 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
BSHAllocationExpression.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/BSHAllocationExpression.java | /** ***************************************************************************
* *
* This file is part of the BeanShell Java Scripting distribution. *
* Documentation and updates may be found at http://www.beanshell.org/ *
* *
* Sun Public License Notice: *
* *
* The contents of this file are subject to the Sun Public License Version *
* 1.0 (the "License"); you may not use this file except in compliance with *
* the License. A copy of the License is available at http://www.sun.com *
* *
* The Original Code is BeanShell. The Initial Developer of the Original *
* Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
* (C) 2000. All Rights Reserved. *
* *
* GNU Public License Notice: *
* *
* Alternatively, the contents of this file may be used under the terms of *
* the GNU Lesser General Public License (the "LGPL"), in which case the *
* provisions of LGPL are applicable instead of those above. If you wish to *
* allow use of your version of this file only under the terms of the LGPL *
* and not to allow others to use your version of this file under the SPL, *
* indicate your decision by deleting the provisions above and replace *
* them with the notice and other provisions required by the LGPL. If you *
* do not delete the provisions above, a recipient may use your version of *
* this file under either the SPL or the LGPL. *
* *
* Patrick Niemeyer ([email protected]) *
* Author of Learning Java, O'Reilly & Associates *
* http://www.pat.net/~pat/ *
* *
**************************************************************************** */
package ehacks.bsh;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
/**
* New object, new array, or inner class style allocation with body.
*/
class BSHAllocationExpression extends SimpleNode {
BSHAllocationExpression(int id) {
super(id);
}
private static int innerClassCount = 0;
@Override
public Object eval(CallStack callstack, Interpreter interpreter)
throws EvalError {
// type is either a class name or a primitive type
SimpleNode type = (SimpleNode) jjtGetChild(0);
// args is either constructor arguments or array dimensions
SimpleNode args = (SimpleNode) jjtGetChild(1);
if (type instanceof BSHAmbiguousName) {
BSHAmbiguousName name = (BSHAmbiguousName) type;
if (args instanceof BSHArguments) {
return objectAllocation(name, (BSHArguments) args,
callstack, interpreter);
} else {
return objectArrayAllocation(name, (BSHArrayDimensions) args,
callstack, interpreter);
}
} else {
return primitiveArrayAllocation((BSHPrimitiveType) type,
(BSHArrayDimensions) args, callstack, interpreter);
}
}
private Object objectAllocation(
BSHAmbiguousName nameNode, BSHArguments argumentsNode,
CallStack callstack, Interpreter interpreter
)
throws EvalError {
NameSpace namespace = callstack.top();
Object[] args = argumentsNode.getArguments(callstack, interpreter);
if (args == null) {
throw new EvalError("Null args in new.", this, callstack);
}
// Look for scripted class object
Object obj = nameNode.toObject(
callstack, interpreter, false/* force class*/);
// Try regular class
obj = nameNode.toObject(
callstack, interpreter, true/*force class*/);
Class type = null;
if (obj instanceof ClassIdentifier) {
type = ((ClassIdentifier) obj).getTargetClass();
} else {
throw new EvalError(
"Unknown class: " + nameNode.text, this, callstack);
}
// RRB: added for BEAST
// deal with BEASTObjects
/*if (BEASTObject.class.isAssignableFrom(type) ) {
try {
Object[] names = argumentsNode.getArgumentsNames( callstack, interpreter );
// by construction of the getArgumentsNames method,
// values.length == names.length;
Object[] args2 = new Object[names.length * 2];
BEASTObject bo = (BEASTObject) Class.forName(type.getName()).newInstance();
List<Input<?>> inputs = bo.listInputs();
int IDOffset = 0;
String ID = null;
for (int i = 0; i < names.length; i++) {
args2[i*2] = (names[i] != null ? names[i] : inputs.get(i).getName());
if (args[i].getClass().isArray()) {
// convert to list
List list = new ArrayList();
if (args[i] instanceof int[]) {
for (int o : (int []) args[i]) {
list.add(o);
}
} else if (args[i] instanceof double[]) {
for (double o : (double []) args[i]) {
list.add(o);
}
} else {
for (Object o : (Object []) args[i]) {
list.add(o);
}
}
args[i] = list;
}
// attempt to convert to correct type
Input<?> input = null;
boolean done = false;
if (names[i] != null) {
if (names[i].toString().equals("id")) {
ID = args[i].toString();
done = true;
Object[] tmp = new Object[names.length * 2 - 2];
System.arraycopy(args2, 0, tmp, 0, tmp.length);
args2 = tmp;
IDOffset = -2;
} else {
input = bo.getInput(names[i].toString());
}
} else {
input = inputs.get(i);
}
if (!done) {
Class inputType = input.getType();
if (inputType == null) {
input.determineClass(bo);
inputType = input.getType();
}
if (args[i] instanceof List) {
List list = (List) args[i];
if (list.size() > 0) {
List list2 = new ArrayList();
for (Object o : list) {
if (o == null) {
list2.add(o);
} else if (inputType == Integer.class && o instanceof Double) {
list2.add(new Integer((int) (double) ((Double) o)));
} else if (inputType == Double.class && (o instanceof Integer)) {
list2.add(new Double((int) (Integer) o));
} else if (o instanceof Primitive) {
list2.add(((Primitive)o).getValue());
} else {
list2.add(o);
}
}
// Object v = list.get(0);
// if (inputType == Integer.class && v instanceof Double) {
// List list2 = new ArrayList();
// for (Object o : list) {
// list2.add((int) (double) ((Double) o));
// }
// args[i] = list2;
// } else if (inputType == Double.class && (v instanceof Integer)) {
// List list2 = new ArrayList();
// for (Object o : list) {
// list2.add(new Double((int) (Integer) o));
// }
args[i] = list2;
// }
}
} else {
if (inputType == Integer.class && (args[i] instanceof Primitive &&
((Primitive)args[i]).getValue() instanceof Double)) {
Primitive p = (Primitive) args[i];
Double o = (Double) p.getValue();
args[i] = o.intValue();
} else if (inputType == Double.class && (args[i] instanceof Primitive &&
((Primitive)args[i]).getValue() instanceof Integer)) {
Primitive p = (Primitive) args[i];
Integer o = (Integer) p.getValue();
args[i] = o.doubleValue();
}
}
args2[i*2+1 - IDOffset] = args[i];
}
// end type conversion
}
Object o = constructObject( type, args2, callstack, interpreter );
if (ID != null){
((BEASTObject)o).setID(ID);
}
return o;
} catch (Exception e) {
//interpreter.print(e.getClass().getName() + " " + e.getMessage());
throw new EvalError(e.getClass().getName() + " " + e.getMessage(), nameNode, callstack);
// do not continue with the default assignment
}
}*/
// Is an inner class style object allocation
boolean hasBody = jjtGetNumChildren() > 2;
if (hasBody) {
BSHBlock body = (BSHBlock) jjtGetChild(2);
if (type.isInterface()) {
return constructWithInterfaceBody(
type, args, body, callstack, interpreter);
} else {
return constructWithClassBody(
type, args, body, callstack, interpreter);
}
} else {
return constructObject(type, args, callstack, interpreter);
}
}
private Object constructObject(Class<?> type, Object[] args, CallStack callstack, Interpreter interpreter) throws EvalError {
final boolean isGeneratedClass = GeneratedClass.class.isAssignableFrom(type);
if (isGeneratedClass) {
ClassGeneratorUtil.registerConstructorContext(callstack, interpreter);
}
Object obj;
try {
obj = Reflect.constructObject(type, args);
} catch (ReflectError e) {
throw new EvalError(
"Constructor error: " + e.getMessage(), this, callstack);
} catch (InvocationTargetException e) {
// No need to wrap this debug
Interpreter.debug("The constructor threw an exception:\n\t" + e.getTargetException());
throw new TargetError("Object constructor", e.getTargetException(), this, callstack, true);
} finally {
if (isGeneratedClass) {
ClassGeneratorUtil.registerConstructorContext(null, null); // clean up, prevent memory leak
}
}
String className = type.getName();
// Is it an inner class?
if (!className.contains("$")) {
return obj;
}
// Temporary hack to support inner classes
// If the obj is a non-static inner class then import the context...
// This is not a sufficient emulation of inner classes.
// Replace this later...
// work through to class 'this'
This ths = callstack.top().getThis(null);
NameSpace instanceNameSpace
= Name.getClassNameSpace(ths.getNameSpace());
// Change the parent (which was the class static) to the class instance
// We really need to check if we're a static inner class here first...
// but for some reason Java won't show the static modifier on our
// fake inner classes... could generate a flag field.
if (instanceNameSpace != null
&& className.startsWith(instanceNameSpace.getName() + "$")) {
ClassGenerator.getClassGenerator().setInstanceNameSpaceParent(
obj, className, instanceNameSpace);
}
return obj;
}
private Object constructWithClassBody(
Class type, Object[] args, BSHBlock block,
CallStack callstack, Interpreter interpreter)
throws EvalError {
String name = callstack.top().getName() + "$" + (++innerClassCount);
Modifiers modifiers = new Modifiers();
modifiers.addModifier(Modifiers.CLASS, "public");
Class clas = ClassGenerator.getClassGenerator().generateClass(
name, modifiers, null/*interfaces*/, type/*superClass*/,
block, false/*isInterface*/, callstack, interpreter);
try {
return Reflect.constructObject(clas, args);
} catch (Exception e) {
Throwable cause = e;
if (e instanceof InvocationTargetException) {
cause = ((InvocationTargetException) e).getTargetException();
}
throw new EvalError("Error constructing inner class instance: " + e, this, callstack, cause);
}
}
private Object constructWithInterfaceBody(
Class type, Object[] args, BSHBlock body,
CallStack callstack, Interpreter interpreter)
throws EvalError {
NameSpace namespace = callstack.top();
NameSpace local = new NameSpace(namespace, "AnonymousBlock");
callstack.push(local);
body.eval(callstack, interpreter, true/*overrideNamespace*/);
callstack.pop();
// statical import fields from the interface so that code inside
// can refer to the fields directly (e.g. HEIGHT)
local.importStatic(type);
return local.getThis(interpreter).getInterface(type);
}
private Object objectArrayAllocation(
BSHAmbiguousName nameNode, BSHArrayDimensions dimensionsNode,
CallStack callstack, Interpreter interpreter
)
throws EvalError {
NameSpace namespace = callstack.top();
Class type = nameNode.toClass(callstack, interpreter);
if (type == null) {
throw new EvalError("Class " + nameNode.getName(namespace)
+ " not found.", this, callstack);
}
return arrayAllocation(dimensionsNode, type, callstack, interpreter);
}
private Object primitiveArrayAllocation(
BSHPrimitiveType typeNode, BSHArrayDimensions dimensionsNode,
CallStack callstack, Interpreter interpreter
)
throws EvalError {
Class type = typeNode.getType();
return arrayAllocation(dimensionsNode, type, callstack, interpreter);
}
private Object arrayAllocation(
BSHArrayDimensions dimensionsNode, Class type,
CallStack callstack, Interpreter interpreter)
throws EvalError {
/*
dimensionsNode can return either a fully intialized array or VOID.
when VOID the prescribed array dimensions (defined and undefined)
are contained in the node.
*/
Object result = dimensionsNode.eval(type, callstack, interpreter);
if (result != Primitive.VOID) {
return result;
} else {
return arrayNewInstance(type, dimensionsNode, callstack);
}
}
/**
* Create an array of the dimensions specified in dimensionsNode.
* dimensionsNode may contain a number of "undefined" as well as "defined"
* dimensions.
* <p>
*
* Background: in Java arrays are implemented in arrays-of-arrays style
* where, for example, a two dimensional array is a an array of arrays of
* some base type. Each dimension-type has a Java class type associated with
* it... so if foo = new int[5][5] then the type of foo is int [][] and the
* type of foo[0] is int[], etc. Arrays may also be specified with undefined
* trailing dimensions - meaning that the lower order arrays are not
* allocated as objects. e.g. if foo = new int [5][]; then foo[0] == null
* //true; and can later be assigned with the appropriate type, e.g. foo[0]
* = new int[5]; (See Learning Java, O'Reilly & Associates more background).
* <p>
*
* To create an array with undefined trailing dimensions using the
* reflection API we must use an array type to represent the lower order
* (undefined) dimensions as the "base" type for the array creation... Java
* will then create the correct type by adding the dimensions of the base
* type to specified allocated dimensions yielding an array of
* dimensionality base + specified with the base dimensons unallocated. To
* create the "base" array type we simply create a prototype, zero length in
* each dimension, array and use it to get its class (Actually, I think
* there is a way we could do it with Class.forName() but I don't trust
* this). The code is simpler than the explanation... see below.
*/
private Object arrayNewInstance(
Class type, BSHArrayDimensions dimensionsNode, CallStack callstack)
throws EvalError {
if (dimensionsNode.numUndefinedDims > 0) {
Object proto = Array.newInstance(
type, new int[dimensionsNode.numUndefinedDims]); // zeros
type = proto.getClass();
}
try {
return Array.newInstance(
type, dimensionsNode.definedDimensions);
} catch (NegativeArraySizeException e1) {
throw new TargetError(e1, this, callstack);
} catch (Exception e) {
throw new EvalError("Can't construct primitive array: "
+ e.getMessage(), this, callstack);
}
}
}
| 17,843 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
EvalError.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/EvalError.java | /** ***************************************************************************
* *
* This file is part of the BeanShell Java Scripting distribution. *
* Documentation and updates may be found at http://www.beanshell.org/ *
* *
* Sun Public License Notice: *
* *
* The contents of this file are subject to the Sun Public License Version *
* 1.0 (the "License"); you may not use this file except in compliance with *
* the License. A copy of the License is available at http://www.sun.com *
* *
* The Original Code is BeanShell. The Initial Developer of the Original *
* Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
* (C) 2000. All Rights Reserved. *
* *
* GNU Public License Notice: *
* *
* Alternatively, the contents of this file may be used under the terms of *
* the GNU Lesser General Public License (the "LGPL"), in which case the *
* provisions of LGPL are applicable instead of those above. If you wish to *
* allow use of your version of this file only under the terms of the LGPL *
* and not to allow others to use your version of this file under the SPL, *
* indicate your decision by deleting the provisions above and replace *
* them with the notice and other provisions required by the LGPL. If you *
* do not delete the provisions above, a recipient may use your version of *
* this file under either the SPL or the LGPL. *
* *
* Patrick Niemeyer ([email protected]) *
* Author of Learning Java, O'Reilly & Associates *
* http://www.pat.net/~pat/ *
* *
**************************************************************************** */
package ehacks.bsh;
/**
* EvalError indicates that we cannot continue evaluating the script or the
* script has thrown an exception.
*
* EvalError may be thrown for a script syntax error, an evaluation error such
* as referring to an undefined variable, an internal error.
* <p>
*
* @see TargetError
*/
public class EvalError extends Exception {
private SimpleNode node;
// Note: no way to mutate the Throwable message, must maintain our own
private String message;
private final CallStack callstack;
public EvalError(String s, SimpleNode node, CallStack callstack, Throwable cause) {
this(s, node, callstack);
initCause(cause);
}
public EvalError(String s, SimpleNode node, CallStack callstack) {
this.message = s;
this.node = node;
// freeze the callstack for the stack trace.
this.callstack = callstack == null ? null : callstack.copy();
}
/**
* Print the error with line number and stack trace.
*/
@Override
public String getMessage() {
String trace;
if (node != null) {
trace = " : at Line: " + node.getLineNumber()
+ " : in file: " + node.getSourceFile()
+ " : " + node.getText();
} else // Users should not normally see this.
{
trace = ": <at unknown location>";
}
if (callstack != null) {
trace = trace + "\n" + getScriptStackTrace();
}
return getRawMessage() + trace;
}
/**
* Re-throw the error, prepending the specified message.
*/
public void reThrow(String msg)
throws EvalError {
prependMessage(msg);
throw this;
}
/**
* The error has trace info associated with it. i.e. It has an AST node that
* can print its location and source text.
*/
SimpleNode getNode() {
return node;
}
void setNode(SimpleNode node) {
this.node = node;
}
public String getErrorText() {
if (node != null) {
return node.getText();
} else {
return "<unknown error>";
}
}
public int getErrorLineNumber() {
if (node != null) {
return node.getLineNumber();
} else {
return -1;
}
}
public String getErrorSourceFile() {
if (node != null) {
return node.getSourceFile();
} else {
return "<unknown file>";
}
}
public String getScriptStackTrace() {
if (callstack == null) {
return "<Unknown>";
}
String trace = "";
CallStack stack = callstack.copy();
while (stack.depth() > 0) {
NameSpace ns = stack.pop();
SimpleNode node = ns.getNode();
if (ns.isMethod) {
trace = trace + "\nCalled from method: " + ns.getName();
if (node != null) {
trace += " : at Line: " + node.getLineNumber()
+ " : in file: " + node.getSourceFile()
+ " : " + node.getText();
}
}
}
return trace;
}
public String getRawMessage() {
return message;
}
/**
* Prepend the message if it is non-null.
*/
private void prependMessage(String s) {
if (s == null) {
return;
}
if (message == null) {
message = s;
} else {
message = s + " : " + message;
}
}
}
| 6,132 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
ScriptContextEngineView.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/ScriptContextEngineView.java | package ehacks.bsh;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.script.ScriptContext;
import static javax.script.ScriptContext.ENGINE_SCOPE;
// Adopted from http://ikayzo.org/svn/beanshell/BeanShell/engine/src/bsh/engine/ScriptContextEngineView.java
/**
* This class implements an ENGINE_SCOPE centric Map view of the ScriptContext
* for engine implementations. This class can be used to simplify engine
* implementations which have the capability to bind their namespaces to Maps or
* other external interfaces.
* <p/>
* Get operations on this view delegate to the ScriptContext inheriting get()
* method that automatically traverses the binding scopes in order or
* precedence. Put operations on this view always store values in the
* ENGINE_SCOPE bindings. Other operations such as size() and contains() are
* implemented appropriately, but perhaps not as efficiently as possible.
*/
public class ScriptContextEngineView implements Map<String, Object> {
ScriptContext context;
public ScriptContextEngineView(ScriptContext context) {
this.context = context;
}
/**
* Returns the number of unique object bindings in all scopes. (duplicate,
* shadowed, bindings count as a single binging).
*/
@Override
public int size() {
return totalKeySet().size();
}
/**
* Returns true if no bindings are present in any scope of the context.
*/
@Override
public boolean isEmpty() {
return totalKeySet().isEmpty();
}
/**
* Returns true if the key name is bound in any scope in the context. The
* key must be a String.
*
* @param key key whose presence in this map is to be tested.
* @return <tt>true</tt> if this map contains a mapping for the specified
* key.
* @throws ClassCastException if the key is of an inappropriate type for
* this map (optional).
* @throws NullPointerException if the key is <tt>null</tt> and this map
* does not permit <tt>null</tt> keys (optional).
*/
@Override
public boolean containsKey(Object key) {
if (key instanceof String) {
return context.getAttributesScope((String) key) != -1;
}
return false;
}
/**
* Returns <tt>true</tt> if this map maps one or more keys to the specified
* value. More formally, returns <tt>true</tt> if and only if this map
* contains at least one mapping to a value <tt>v</tt> such that
* <tt>(value==null ? v==null : value.equals(v))</tt>. This operation will
* probably require time linear in the map size for most implementations of
* the
* <tt>Map</tt> interface.
*
* @param value value whose presence in this map is to be tested.
* @return <tt>true</tt> if this map maps one or more keys to the specified
* value.
* @throws ClassCastException if the value is of an inappropriate type for
* this map (optional).
* @throws NullPointerException if the value is <tt>null</tt> and this map
* does not permit <tt>null</tt> values (optional).
*/
@Override
public boolean containsValue(Object value) {
Set values = totalValueSet();
return values.contains(value);
}
/**
* Returns the value bound in the most specific (lowest numbered) bindings
* space for this key. key must be a String.
*
* @param key key whose associated value is to be returned.
* @return the value to which this map maps the specified key, or
* <tt>null</tt>
* if the map contains no mapping for this key.
* @throws ClassCastException if the key is of an inappropriate type for
* this map (optional).
* @throws NullPointerException if the key is <tt>null</tt> and this map
* does not permit <tt>null</tt> keys (optional).
* @see #containsKey(Object)
*/
@Override
public Object get(Object key) {
return context.getAttribute((String) key);
}
/**
* Set the key, value binding in the ENGINE_SCOPE of the context.
*
* @param key key with which the specified value is to be associated.
* @param value value to be associated with the specified key.
* @return previous value associated with specified key, or <tt>null</tt> if
* there was no mapping for key. A <tt>null</tt> return can also indicate
* that the map previously associated <tt>null</tt> with the specified key,
* if the implementation supports <tt>null</tt> values.
* @throws UnsupportedOperationException if the <tt>put</tt> operation is
* not supported by this map.
* @throws ClassCastException if the class of the specified key or value
* prevents it from being stored in this map.
* @throws IllegalArgumentException if some aspect of this key or value
* prevents it from being stored in this map.
* @throws NullPointerException if this map does not permit <tt>null</tt>
* keys or values, and the specified key or value is <tt>null</tt>.
*/
@Override
public Object put(String key, Object value) {
Object oldValue = context.getAttribute(key, ENGINE_SCOPE);
context.setAttribute(key, value, ENGINE_SCOPE);
return oldValue;
}
/**
* Put the bindings into the ENGINE_SCOPE of the context.
*
* @param t Mappings to be stored in this map.
* @throws UnsupportedOperationException if the <tt>putAll</tt> method is
* not supported by this map.
* @throws ClassCastException if the class of a key or value in the
* specified map prevents it from being stored in this map.
* @throws IllegalArgumentException some aspect of a key or value in the
* specified map prevents it from being stored in this map.
* @throws NullPointerException if the specified map is <tt>null</tt>, or if
* this map does not permit <tt>null</tt> keys or values, and the specified
* map contains <tt>null</tt> keys or values.
*/
@Override
public void putAll(Map<? extends String, ? extends Object> t) {
context.getBindings(ENGINE_SCOPE).putAll(t);
}
/**
* Removes the mapping from the engine scope.
* <p/>
* <p>
* Returns the value to which the map previously associated the key, or
* <tt>null</tt> if the map contained no mapping for this key. (A
* <tt>null</tt> return can also indicate that the map previously associated
* <tt>null</tt> with the specified key if the implementation supports
* <tt>null</tt> values.) The map will not contain a mapping for the
* specified key once the call returns.
*
* @param okey key whose mapping is to be removed from the map.
* @return previous value associated with specified key, or <tt>null</tt> if
* there was no mapping for key.
* @throws ClassCastException if the key is of an inappropriate type for
* this map (optional).
* @throws NullPointerException if the key is <tt>null</tt> and this map
* does not permit <tt>null</tt> keys (optional).
* @throws UnsupportedOperationException if the <tt>remove</tt> method is
* not supported by this map.
*/
// Why is the compiler complaining about this?
//public Object remove( String key )
@Override
public Object remove(Object okey) {
// This shouldn't be necessary... we don't map Objects, Strings.
String key = (String) okey;
Object oldValue = context.getAttribute(key, ENGINE_SCOPE);
context.removeAttribute(key, ENGINE_SCOPE);
return oldValue;
}
/**
* Removes all mappings from this map (optional operation).
*
* @throws UnsupportedOperationException clear is not supported by this map.
*/
@Override
public void clear() {
context.getBindings(ENGINE_SCOPE).clear();
}
/**
* Returns the total key set of all scopes. This method violates the Map
* contract by returning an unmodifiable set.
*
* @return a set view of the keys contained in this map.
*/
@Override
public Set<String> keySet() {
return totalKeySet();
}
/**
* Returns the total values set of all scopes. This method violates the Map
* contract by returning an unmodifiable set.
*
* @return a collection view of the values contained in this map.
*/
@Override
public Collection<Object> values() {
return totalValueSet();
}
/**
* Returns a set view of the mappings contained in this map. Each element in
* the returned set is a {@link java.util.Map.Entry}. The set is backed by
* the map, so changes to the map are reflected in the set, and vice-versa.
* If the map is modified while an iteration over the set is in progress
* (except through the iterator's own <tt>remove</tt> operation, or through
* the
* <tt>setValue</tt> operation on a map entry returned by the iterator) the
* results of the iteration are undefined. The set supports element removal,
* which removes the corresponding mapping from the map, via the
* <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, <tt>removeAll</tt>,
* <tt>retainAll</tt> and <tt>clear</tt> operations. It does not support the
* <tt>add</tt> or <tt>addAll</tt> operations.
*
* @return a set view of the mappings contained in this map.
*/
@Override
public Set<Entry<String, Object>> entrySet() {
throw new Error("unimplemented");
}
private Set<String> totalKeySet() {
Set<String> keys = new HashSet<>();
List<Integer> scopes = context.getScopes();
scopes.forEach((i) -> {
keys.addAll(context.getBindings(i).keySet());
});
return Collections.unmodifiableSet(keys);
}
private Set<Object> totalValueSet() {
Set<Object> values = new HashSet<>();
List<Integer> scopes = context.getScopes();
scopes.forEach((i) -> {
values.addAll(context.getBindings(i).values());
});
return Collections.unmodifiableSet(values);
}
}
| 10,220 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
BSHMethodInvocation.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/BSHMethodInvocation.java | /** ***************************************************************************
* *
* This file is part of the BeanShell Java Scripting distribution. *
* Documentation and updates may be found at http://www.beanshell.org/ *
* *
* Sun Public License Notice: *
* *
* The contents of this file are subject to the Sun Public License Version *
* 1.0 (the "License"); you may not use this file except in compliance with *
* the License. A copy of the License is available at http://www.sun.com *
* *
* The Original Code is BeanShell. The Initial Developer of the Original *
* Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
* (C) 2000. All Rights Reserved. *
* *
* GNU Public License Notice: *
* *
* Alternatively, the contents of this file may be used under the terms of *
* the GNU Lesser General Public License (the "LGPL"), in which case the *
* provisions of LGPL are applicable instead of those above. If you wish to *
* allow use of your version of this file only under the terms of the LGPL *
* and not to allow others to use your version of this file under the SPL, *
* indicate your decision by deleting the provisions above and replace *
* them with the notice and other provisions required by the LGPL. If you *
* do not delete the provisions above, a recipient may use your version of *
* this file under either the SPL or the LGPL. *
* *
* Patrick Niemeyer ([email protected]) *
* Author of Learning Java, O'Reilly & Associates *
* http://www.pat.net/~pat/ *
* *
**************************************************************************** */
package ehacks.bsh;
import java.lang.reflect.InvocationTargetException;
class BSHMethodInvocation extends SimpleNode {
BSHMethodInvocation(int id) {
super(id);
}
BSHAmbiguousName getNameNode() {
return (BSHAmbiguousName) jjtGetChild(0);
}
BSHArguments getArgsNode() {
return (BSHArguments) jjtGetChild(1);
}
/**
* Evaluate the method invocation with the specified callstack and
* interpreter
*/
@Override
public Object eval(CallStack callstack, Interpreter interpreter)
throws EvalError {
NameSpace namespace = callstack.top();
BSHAmbiguousName nameNode = getNameNode();
// Do not evaluate methods this() or super() in class instance space
// (i.e. inside a constructor)
if (namespace.getParent() != null && namespace.getParent().isClass
&& (nameNode.text.equals("super") || nameNode.text.equals("this"))) {
return Primitive.VOID;
}
Name name = nameNode.getName(namespace);
Object[] args = getArgsNode().getArguments(callstack, interpreter);
// This try/catch block is replicated is BSHPrimarySuffix... need to
// factor out common functionality...
// Move to Reflect?
try {
return name.invokeMethod(interpreter, args, callstack, this);
} catch (ReflectError e) {
throw new EvalError(
"Error in method invocation: " + e.getMessage(),
this, callstack, e);
} catch (InvocationTargetException e) {
String msg = "Method Invocation " + name;
Throwable te = e.getTargetException();
/*
Try to squeltch the native code stack trace if the exception
was caused by a reflective call back into the bsh interpreter
(e.g. eval() or source()
*/
boolean isNative = true;
if (te instanceof EvalError) {
if (te instanceof TargetError) {
isNative = ((TargetError) te).inNativeCode();
} else {
isNative = false;
}
}
throw new TargetError(msg, te, this, callstack, isNative);
} catch (UtilEvalError e) {
throw e.toEvalError(this, callstack);
}
}
}
| 4,865 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
CallStack.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/CallStack.java | /** ***************************************************************************
* *
* This file is part of the BeanShell Java Scripting distribution. *
* Documentation and updates may be found at http://www.beanshell.org/ *
* *
* Sun Public License Notice: *
* *
* The contents of this file are subject to the Sun Public License Version *
* 1.0 (the "License"); you may not use this file except in compliance with *
* the License. A copy of the License is available at http://www.sun.com *
* *
* The Original Code is BeanShell. The Initial Developer of the Original *
* Code is Pat Niemeyer. Portions created by Pat Niemeyer are Copyright *
* (C) 2000. All Rights Reserved. *
* *
* GNU Public License Notice: *
* *
* Alternatively, the contents of this file may be used under the terms of *
* the GNU Lesser General Public License (the "LGPL"), in which case the *
* provisions of LGPL are applicable instead of those above. If you wish to *
* allow use of your version of this file only under the terms of the LGPL *
* and not to allow others to use your version of this file under the SPL, *
* indicate your decision by deleting the provisions above and replace *
* them with the notice and other provisions required by the LGPL. If you *
* do not delete the provisions above, a recipient may use your version of *
* this file under either the SPL or the LGPL. *
* *
* Patrick Niemeyer ([email protected]) *
* Author of Learning Java, O'Reilly & Associates *
* http://www.pat.net/~pat/ *
* *
**************************************************************************** */
package ehacks.bsh;
import java.io.Serializable;
import java.util.EmptyStackException;
import java.util.Stack;
/**
* A stack of NameSpaces representing the call path. Each method invocation, for
* example, pushes a new NameSpace onto the stack. The top of the stack is
* always the current namespace of evaluation.
* <p>
*
* This is used to support the this.caller magic reference and to print script
* "stack traces" when evaluation errors occur.
* <p>
*
* Note: How can this be thread safe, you might ask? Wouldn't a thread executing
* various beanshell methods be mutating the callstack? Don't we need one
* CallStack per Thread in the interpreter? The answer is that we do. Any
* java.lang.Thread enters our script via an external (hard) Java reference via
* a This type interface, e.g. the Runnable interface implemented by This or an
* arbitrary interface implemented by XThis. In that case the This
* invokeMethod() method (called by any interface that it exposes) creates a new
* CallStack for each external call.
* <p>
*/
public class CallStack implements Serializable {
private static final long serialVersionUID = 0L;
private final Stack<NameSpace> stack = new Stack<>();
public CallStack() {
}
public CallStack(NameSpace namespace) {
push(namespace);
}
public void clear() {
stack.removeAllElements();
}
public void push(NameSpace ns) {
stack.push(ns);
}
public NameSpace top() {
return stack.peek();
}
/**
* zero based.
*/
public NameSpace get(int depth) {
int size = stack.size();
if (depth >= size) {
return NameSpace.JAVACODE;
} else {
return stack.get(size - 1 - depth);
}
}
/**
* This is kind of crazy, but used by the setNameSpace command. zero based.
*/
public void set(int depth, NameSpace ns) {
stack.set(stack.size() - 1 - depth, ns);
}
public NameSpace pop() {
try {
return stack.pop();
} catch (EmptyStackException e) {
throw new InterpreterError("pop on empty CallStack");
}
}
/**
* Swap in the value as the new top of the stack and return the old value.
*/
public NameSpace swap(NameSpace newTop) {
int last = stack.size() - 1;
NameSpace oldTop = stack.get(last);
stack.set(last, newTop);
return oldTop;
}
public int depth() {
return stack.size();
}
/*
public NameSpace [] toArray() {
NameSpace [] nsa = new NameSpace [ depth() ];
stack.copyInto( nsa );
return nsa;
}
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("CallStack:\n");
for (int i = stack.size() - 1; i >= 0; i--) {
sb.append("\t").append(stack.get(i)).append("\n");
}
return sb.toString();
}
/**
* Occasionally we need to freeze the callstack for error reporting
* purposes, etc.
*/
public CallStack copy() {
CallStack cs = new CallStack();
cs.stack.addAll(this.stack);
return cs;
}
}
| 5,731 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Interpreter.java | /FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/bsh/Interpreter.java |
package ehacks.bsh;
import java.awt.Font;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.PrintStream;
import java.io.Reader;
import java.io.Serializable;
import java.io.StringReader;
import java.lang.reflect.Method;
/**
* The BeanShell script interpreter.
*
* An instance of Interpreter can be used to source scripts and evaluate
* statements or expressions.
* <p>
* Here are some examples:
*
* <p>
* <blockquote><pre>
* Interpeter bsh = new Interpreter();
*
* // Evaluate statements and expressions
* bsh.eval("foo=Math.sin(0.5)");
* bsh.eval("bar=foo*5; bar=Math.cos(bar);");
* bsh.eval("for(i=0; i<10; i++) { print(\"hello\"); }");
* // same as above using java syntax and apis only
* bsh.eval("for(int i=0; i<10; i++) { System.out.println(\"hello\"); }");
*
* // Source from files or streams
* bsh.source("myscript.bsh"); // or bsh.eval("source(\"myscript.bsh\")");
*
* // Use set() and get() to pass objects in and out of variables
* bsh.set( "date", new Date() );
* Date date = (Date)bsh.get( "date" );
* // This would also work:
* Date date = (Date)bsh.eval( "date" );
*
* bsh.eval("year = date.getYear()");
* Integer year = (Integer)bsh.get("year"); // primitives use wrappers
*
* // With Java1.3+ scripts can implement arbitrary interfaces...
* // Script an awt event handler (or source it from a file, more likely)
* bsh.eval( "actionPerformed( e ) { print( e ); }");
* // Get a reference to the script object (implementing the interface)
* ActionListener scriptedHandler =
* (ActionListener)bsh.eval("return (ActionListener)this");
* // Use the scripted event handler normally...
* new JButton.addActionListener( script );
* </pre></blockquote> <p>
*
* In the above examples we showed a single interpreter instance, however you
* may wish to use many instances, depending on the application and how you
* structure your scripts. Interpreter instances are very light weight to
* create, however if you are going to execute the same script repeatedly and
* require maximum performance you should consider scripting the code as a
* method and invoking the scripted method each time on the same interpreter
* instance (using eval()). <p>
*
* See the BeanShell User's Manual for more information.
*/
public class Interpreter
implements Runnable, ConsoleInterface, Serializable {
/* --- Begin static members --- */
/*
Debug utils are static so that they are reachable by code that doesn't
necessarily have an interpreter reference (e.g. tracing in utils).
In the future we may want to allow debug/trace to be turned on on
a per interpreter basis, in which case we'll need to use the parent
reference in some way to determine the scope of the command that
turns it on or off.
*/
public static boolean DEBUG, TRACE, LOCALSCOPING;
public static boolean COMPATIBIILTY;
// This should be per instance
transient static PrintStream debug;
static String systemLineSeparator = "\n"; // default
private static final This SYSTEM_OBJECT = This.getThis(new NameSpace(null, null, "bsh.system"), null);
static {
staticInit();
}
/**
* Strict Java mode
*
* @see #setStrictJava( boolean )
*/
private boolean strictJava = false;
/* --- End static members --- */
/* --- Instance data --- */
transient Parser parser;
NameSpace globalNameSpace;
transient Reader in;
transient PrintStream out;
transient PrintStream err;
ConsoleInterface console;
/**
* If this interpeter is a child of another, the parent
*/
Interpreter parent;
/**
* The name of the file or other source that this interpreter is reading
*/
String sourceFileInfo;
/**
* by default in interactive mode System.exit() on EOF
*/
private boolean exitOnEOF = true;
protected boolean evalOnly, // Interpreter has no input stream, use eval() only
interactive; // Interpreter has a user, print prompts, etc.
/**
* Control the verbose printing of results for the show() command.
*/
private boolean showResults;
/**
* Compatibility mode. When {@code true} missing classes are tried to create
* from corresponding java source files. Default value is {@code false},
* could be changed to {@code true} by setting the system property
* "bsh.compatibility" to "true".
*/
private boolean compatibility = COMPATIBIILTY;
/* --- End instance data --- */
/**
* The main constructor. All constructors should now pass through here.
*
* @param namespace If namespace is non-null then this interpreter's root
* namespace will be set to the one provided. If it is null a new one will
* be created for it.
* @param parent The parent interpreter if this interpreter is a child of
* another. May be null. Children share a BshClassManager with their parent
* instance.
* @param sourceFileInfo An informative string holding the filename or other
* description of the source from which this interpreter is reading... used
* for debugging. May be null.
*/
public Interpreter(
Reader in, PrintStream out, PrintStream err,
boolean interactive, NameSpace namespace,
Interpreter parent, String sourceFileInfo) {
//System.out.println("New Interpreter: "+this +", sourcefile = "+sourceFileInfo );
parser = new Parser(in);
long t1 = 0;
if (Interpreter.DEBUG) {
t1 = System.currentTimeMillis();
}
this.in = in;
this.out = out;
this.err = err;
this.interactive = interactive;
debug = err;
this.parent = parent;
if (parent != null) {
setStrictJava(parent.getStrictJava());
}
this.sourceFileInfo = sourceFileInfo;
BSHClassManager bcm = BSHClassManager.createClassManager(this);
if (namespace == null) {
globalNameSpace = new NameSpace(bcm, "global");
initRootSystemObject();
} else {
globalNameSpace = namespace;
try {
if (!(globalNameSpace.getVariable("bsh") instanceof This)) {
initRootSystemObject();
}
} catch (final UtilEvalError e) {
throw new IllegalStateException(e);
}
}
// now done in NameSpace automatically when root
// The classes which are imported by default
//globalNameSpace.loadDefaultImports();
if (interactive) {
loadRCFiles();
}
if (Interpreter.DEBUG) {
long t2 = System.currentTimeMillis();
Interpreter.debug("Time to initialize interpreter: " + (t2 - t1));
}
}
public Interpreter(
Reader in, PrintStream out, PrintStream err,
boolean interactive, NameSpace namespace) {
this(in, out, err, interactive, namespace, null, null);
}
public Interpreter(
Reader in, PrintStream out, PrintStream err, boolean interactive) {
this(in, out, err, interactive, null);
}
/**
* Construct a new interactive interpreter attached to the specified console
* using the specified parent namespace.
*/
public Interpreter(ConsoleInterface console, NameSpace globalNameSpace) {
this(console.getIn(), console.getOut(), console.getErr(),
true, globalNameSpace);
setConsole(console);
}
/**
* Construct a new interactive interpreter attached to the specified
* console.
*/
public Interpreter(ConsoleInterface console) {
this(console, null);
}
/**
* Create an interpreter for evaluation only.
*/
public Interpreter() {
this(new StringReader(""),
System.out, System.err, false, null);
evalOnly = true;
setu("bsh.evalOnly", new Primitive(true));
}
// End constructors
/**
* Attach a console Note: this method is incomplete.
*/
public void setConsole(ConsoleInterface console) {
this.console = console;
setu("bsh.console", console);
// redundant with constructor
setOut(console.getOut());
setErr(console.getErr());
// need to set the input stream - reinit the parser?
}
private void initRootSystemObject() {
BSHClassManager bcm = getClassManager();
// bsh
setu("bsh", new NameSpace(bcm, "Bsh Object").getThis(this));
setu("bsh.system", SYSTEM_OBJECT);
setu("bsh.shared", SYSTEM_OBJECT); // alias
// bsh.help
This helpText = new NameSpace(bcm, "Bsh Command Help Text").getThis(this);
setu("bsh.help", helpText);
// bsh.cwd
try {
setu("bsh.cwd", System.getProperty("user.dir"));
} catch (SecurityException e) {
// applets can't see sys props
setu("bsh.cwd", ".");
}
// bsh.interactive
setu("bsh.interactive", new Primitive(interactive));
// bsh.evalOnly
setu("bsh.evalOnly", new Primitive(evalOnly));
}
/**
* Set the global namespace for this interpreter.
* <p>
*
* Note: This is here for completeness. If you're using this a lot it may be
* an indication that you are doing more work than you have to. For example,
* caching the interpreter instance rather than the namespace should not add
* a significant overhead. No state other than the debug status is stored in
* the interpreter.
* <p>
*
* All features of the namespace can also be accessed using the interpreter
* via eval() and the script variable 'this.namespace' (or global.namespace
* as necessary).
*/
public void setNameSpace(NameSpace globalNameSpace) {
this.globalNameSpace = globalNameSpace;
}
/**
* Get the global namespace of this interpreter.
* <p>
*
* Note: This is here for completeness. If you're using this a lot it may be
* an indication that you are doing more work than you have to. For example,
* caching the interpreter instance rather than the namespace should not add
* a significant overhead. No state other than the debug status is stored in
* the interpreter.
* <p>
*
* All features of the namespace can also be accessed using the interpreter
* via eval() and the script variable 'this.namespace' (or global.namespace
* as necessary).
*/
public NameSpace getNameSpace() {
return globalNameSpace;
}
public static void invokeMain(Class clas, String[] args)
throws Exception {
Method main = Reflect.resolveJavaMethod(
null/*BshClassManager*/, clas, "main",
new Class[]{String[].class}, true/*onlyStatic*/);
if (main != null) {
main.invoke(null, new Object[]{args});
}
}
/**
* Run interactively. (printing prompts, etc.)
*/
@Override
public void run() {
if (evalOnly) {
throw new RuntimeException("bsh Interpreter: No stream");
}
/*
We'll print our banner using eval(String) in order to
exercise the parser and get the basic expression classes loaded...
This ameliorates the delay after typing the first statement.
*/
if (interactive) {
try {
eval("printBanner();");
} catch (EvalError e) {
}
}
// init the callstack.
CallStack callstack = new CallStack(globalNameSpace);
SimpleNode node = null;
boolean eof = false;
while (!eof) {
try {
// try to sync up the console
System.out.flush();
System.err.flush();
Thread.yield(); // this helps a little
if (interactive) {
print(getBshPrompt());
}
eof = Line();
if (get_jjtree().nodeArity() > 0) // number of child nodes
{
if (node != null) {
node.lastToken.next = null; // prevent OutOfMemoryError
}
node = (SimpleNode) (get_jjtree().rootNode());
if (DEBUG) {
node.dump(">");
}
Object ret = node.eval(callstack, this);
node.lastToken.next = null; // prevent OutOfMemoryError
// sanity check during development
if (callstack.depth() > 1) {
throw new InterpreterError(
"Callstack growing: " + callstack);
}
if (ret instanceof ReturnControl) {
ret = ((ReturnControl) ret).value;
}
if (ret != Primitive.VOID) {
setu("$_", ret);
if (showResults) {
println("<" + ret + ">");
}
}
}
} catch (ParseException e) {
error("Parser Error: " + e.getMessage(DEBUG));
if (DEBUG) {
e.printStackTrace();
}
if (!interactive) {
eof = true;
}
parser.reInitInput(in);
} catch (InterpreterError e) {
error("Internal Error: " + e.getMessage());
e.printStackTrace();
if (!interactive) {
eof = true;
}
} catch (TargetError e) {
error("// Uncaught Exception: " + e);
if (e.inNativeCode()) {
e.printStackTrace(DEBUG, err);
}
if (!interactive) {
eof = true;
}
setu("$_e", e.getTarget());
} catch (EvalError e) {
if (interactive) {
error("EvalError: " + e.getMessage());
} else {
error("EvalError: " + e.getRawMessage());
}
if (DEBUG) {
e.printStackTrace();
}
if (!interactive) {
eof = true;
}
} catch (Exception e) {
error("Unknown error: " + e);
if (DEBUG) {
e.printStackTrace();
}
if (!interactive) {
eof = true;
}
} catch (TokenMgrError e) {
error("Error parsing input: " + e);
/*
We get stuck in infinite loops here when unicode escapes
fail. Must re-init the char stream reader
(ASCII_UCodeESC_CharStream.java)
*/
parser.reInitTokenInput(in);
if (!interactive) {
eof = true;
}
} finally {
get_jjtree().reset();
// reinit the callstack
if (callstack.depth() > 1) {
callstack.clear();
callstack.push(globalNameSpace);
}
}
}
if (interactive && exitOnEOF) {
System.exit(0);
}
}
// begin source and eval
/**
* Read text from fileName and eval it.
*/
public Object source(String filename, NameSpace nameSpace)
throws FileNotFoundException, IOException, EvalError {
File file = pathToFile(filename);
if (Interpreter.DEBUG) {
debug("Sourcing file: " + file);
}
try (Reader sourceIn = new BufferedReader(new FileReader(file))) {
return eval(sourceIn, nameSpace, filename);
}
}
/**
* Read text from fileName and eval it. Convenience method. Use the global
* namespace.
*/
public Object source(String filename)
throws FileNotFoundException, IOException, EvalError {
return source(filename, globalNameSpace);
}
/**
* Spawn a non-interactive local interpreter to evaluate text in the
* specified namespace. * Return value is the evaluated object (or
* corresponding primitive wrapper).
*
* @param sourceFileInfo is for information purposes only. It is used to
* display error messages (and in the future may be made available to the
* script).
* @throws EvalError on script problems
* @throws TargetError on unhandled exceptions from the script
*/
/*
Note: we need a form of eval that passes the callstack through...
*/
/*
Can't this be combined with run() ?
run seems to have stuff in it for interactive vs. non-interactive...
compare them side by side and see what they do differently, aside from the
exception handling.
*/
public Object eval(
Reader in, NameSpace nameSpace, String sourceFileInfo
/*, CallStack callstack */)
throws EvalError {
Object retVal = null;
if (Interpreter.DEBUG) {
debug("eval: nameSpace = " + nameSpace);
}
/*
Create non-interactive local interpreter for this namespace
with source from the input stream and out/err same as
this interpreter.
*/
Interpreter localInterpreter
= new Interpreter(
in, out, err, false, nameSpace, this, sourceFileInfo);
CallStack callstack = new CallStack(nameSpace);
SimpleNode node = null;
boolean eof = false;
while (!eof) {
try {
eof = localInterpreter.Line();
if (localInterpreter.get_jjtree().nodeArity() > 0) {
if (node != null) {
node.lastToken.next = null; // prevent OutOfMemoryError
}
node = (SimpleNode) localInterpreter.get_jjtree().rootNode();
// nodes remember from where they were sourced
node.setSourceFile(sourceFileInfo);
if (TRACE) {
println("// " + node.getText());
}
retVal = node.eval(callstack, localInterpreter);
// sanity check during development
if (callstack.depth() > 1) {
throw new InterpreterError(
"Callstack growing: " + callstack);
}
if (retVal instanceof ReturnControl) {
retVal = ((ReturnControl) retVal).value;
break; // non-interactive, return control now
}
if (localInterpreter.showResults
&& retVal != Primitive.VOID) {
println("<" + retVal + ">");
}
}
} catch (ParseException e) {
/*
throw new EvalError(
"Sourced file: "+sourceFileInfo+" parser Error: "
+ e.getMessage( DEBUG ), node, callstack );
*/
if (DEBUG) // show extra "expecting..." info
{
error(e.getMessage(DEBUG));
}
// add the source file info and throw again
e.setErrorSourceFile(sourceFileInfo);
throw e;
} catch (InterpreterError e) {
e.printStackTrace();
throw new EvalError(
"Sourced file: " + sourceFileInfo + " internal Error: "
+ e.getMessage(), node, callstack);
} catch (TargetError e) {
// failsafe, set the Line as the origin of the error.
if (e.getNode() == null) {
e.setNode(node);
}
e.reThrow("Sourced file: " + sourceFileInfo);
} catch (EvalError e) {
if (DEBUG) {
e.printStackTrace();
}
// failsafe, set the Line as the origin of the error.
if (e.getNode() == null) {
e.setNode(node);
}
e.reThrow("Sourced file: " + sourceFileInfo);
} catch (Exception e) {
if (DEBUG) {
e.printStackTrace();
}
throw new EvalError(
"Sourced file: " + sourceFileInfo + " unknown error: "
+ e.getMessage(), node, callstack, e);
} catch (TokenMgrError e) {
throw new EvalError(
"Sourced file: " + sourceFileInfo + " Token Parsing Error: "
+ e.getMessage(), node, callstack, e);
} finally {
localInterpreter.get_jjtree().reset();
// reinit the callstack
if (callstack.depth() > 1) {
callstack.clear();
callstack.push(nameSpace);
}
}
}
return Primitive.unwrap(retVal);
}
/**
* Evaluate the inputstream in this interpreter's global namespace.
*/
public Object eval(Reader in) throws EvalError {
return eval(in, globalNameSpace, "eval stream");
}
/**
* Evaluate the string in this interpreter's global namespace.
*/
public Object eval(String statements) throws EvalError {
if (Interpreter.DEBUG) {
debug("eval(String): " + statements);
}
Object o = eval(statements, globalNameSpace);
return o;
}
/**
* Evaluate the string in the specified namespace.
*/
public Object eval(String statements, NameSpace nameSpace)
throws EvalError {
String s = (statements.endsWith(";") ? statements : statements + ";");
return eval(
new StringReader(s), nameSpace,
"inline evaluation of: ``" + showEvalString(s) + "''");
}
private String showEvalString(String s) {
s = s.replace('\n', ' ');
s = s.replace('\r', ' ');
if (s.length() > 80) {
s = s.substring(0, 80) + " . . . ";
}
return s;
}
// end source and eval
/**
* Print an error message in a standard format on the output stream
* associated with this interpreter. On the GUI console this will appear in
* red, etc.
*/
@Override
public void error(Object o) {
if (console != null) {
console.error("// Error: " + o + "\n");
} else {
err.println("// Error: " + o);
err.flush();
}
}
// ConsoleInterface
// The interpreter reflexively implements the console interface that it
// uses. Should clean this up by using an inner class to implement the
// console for us.
/**
* Get the input stream associated with this interpreter. This may be be
* stdin or the GUI console.
*/
@Override
public Reader getIn() {
return in;
}
/**
* Get the outptut stream associated with this interpreter. This may be be
* stdout or the GUI console.
*/
@Override
public PrintStream getOut() {
return out;
}
/**
* Get the error output stream associated with this interpreter. This may be
* be stderr or the GUI console.
*/
@Override
public PrintStream getErr() {
return err;
}
@Override
public void println(Object o) {
print(String.valueOf(o) + systemLineSeparator);
}
@Override
public void print(Object o) {
if (console != null) {
console.print(o);
} else {
out.print(o);
out.flush();
}
}
public void print(Object o, Font f) {
print(o);
}
// End ConsoleInterface
/**
* Print a debug message on debug stream associated with this interpreter
* only if debugging is turned on.
*/
public static void debug(String s) {
if (DEBUG) {
debug.println("// Debug: " + s);
}
}
/*
Primary interpreter set and get variable methods
Note: These are squeltching errors... should they?
*/
/**
* Get the value of the name. name may be any value. e.g. a variable or
* field
*/
public Object get(String name) throws EvalError {
try {
Object ret = globalNameSpace.get(name, this);
return Primitive.unwrap(ret);
} catch (UtilEvalError e) {
throw e.toEvalError(SimpleNode.JAVACODE, new CallStack());
}
}
/**
* Unchecked get for internal use
*/
Object getu(String name) {
try {
return get(name);
} catch (EvalError e) {
throw new InterpreterError("set: " + e);
}
}
/**
* Assign the value to the name. name may evaluate to anything assignable.
* e.g. a variable or field.
*/
public void set(String name, Object value)
throws EvalError {
// map null to Primtive.NULL coming in...
if (value == null) {
value = Primitive.NULL;
}
CallStack callstack = new CallStack();
try {
if (Name.isCompound(name)) {
LHS lhs = globalNameSpace.getNameResolver(name).toLHS(
callstack, this);
lhs.assign(value, false);
} else // optimization for common case
{
globalNameSpace.setVariable(name, value, false);
}
} catch (UtilEvalError e) {
throw e.toEvalError(SimpleNode.JAVACODE, callstack);
}
}
/**
* Unchecked set for internal use
*/
void setu(String name, Object value) {
try {
set(name, value);
} catch (EvalError e) {
throw new InterpreterError("set: " + e);
}
}
public void set(String name, long value) throws EvalError {
set(name, new Primitive(value));
}
public void set(String name, int value) throws EvalError {
set(name, new Primitive(value));
}
public void set(String name, double value) throws EvalError {
set(name, new Primitive(value));
}
public void set(String name, float value) throws EvalError {
set(name, new Primitive(value));
}
public void set(String name, boolean value) throws EvalError {
set(name, new Primitive(value));
}
/**
* Unassign the variable name. Name should evaluate to a variable.
*/
public void unset(String name)
throws EvalError {
/*
We jump through some hoops here to handle arbitrary cases like
unset("bsh.foo");
*/
CallStack callstack = new CallStack();
try {
LHS lhs = globalNameSpace.getNameResolver(name).toLHS(
callstack, this);
if (lhs.type != LHS.VARIABLE) {
throw new EvalError("Can't unset, not a variable: " + name,
SimpleNode.JAVACODE, new CallStack());
}
//lhs.assign( null, false );
lhs.nameSpace.unsetVariable(name);
} catch (UtilEvalError e) {
throw new EvalError(e.getMessage(),
SimpleNode.JAVACODE, new CallStack());
}
}
// end primary set and get methods
/**
* Get a reference to the interpreter (global namespace), cast to the
* specified interface type. Assuming the appropriate methods of the
* interface are defined in the interpreter, then you may use this interface
* from Java, just like any other Java object.
* <p>
*
* For example:
* <pre>
* Interpreter interpreter = new Interpreter();
* // define a method called run()
* interpreter.eval("run() { ... }");
*
* // Fetch a reference to the interpreter as a Runnable
* Runnable runnable =
* (Runnable)interpreter.getInterface( Runnable.class );
* </pre>
* <p>
*
* Note that the interpreter does *not* require that any or all of the
* methods of the interface be defined at the time the interface is
* generated. However if you attempt to invoke one that is not defined you
* will get a runtime exception.
* <p>
*
* Note also that this convenience method has exactly the same effect as
* evaluating the script:
* <pre>
* (Type)this;
* </pre>
* <p>
*
* For example, the following is identical to the previous example:
* <p>
*
* <pre>
* // Fetch a reference to the interpreter as a Runnable
* Runnable runnable =
* (Runnable)interpreter.eval( "(Runnable)this" );
* </pre>
* <p>
*
* <em>Version requirement</em> Although standard Java interface types are
* always available, to be used with arbitrary interfaces this feature
* requires that you are using Java 1.3 or greater.
* <p>
*
* @throws EvalError if the interface cannot be generated because the
* version of Java does not support the proxy mechanism.
*/
public Object getInterface(Class interf) throws EvalError {
return globalNameSpace.getThis(this).getInterface(interf);
}
/* Methods for interacting with Parser */
private JJTParserState get_jjtree() {
return parser.jjtree;
}
private JavaCharStream get_jj_input_stream() {
return parser.jj_input_stream;
}
private boolean Line() throws ParseException {
return parser.Line();
}
/* End methods for interacting with Parser */
void loadRCFiles() {
try {
String rcfile
= // Default is c:\windows under win98, $HOME under Unix
System.getProperty("user.home") + File.separator + ".bshrc";
source(rcfile, globalNameSpace);
} catch (Exception e) {
// squeltch security exception, filenotfoundexception
if (Interpreter.DEBUG) {
debug("Could not find rc file: " + e);
}
}
}
/**
* Localize a path to the file name based on the bsh.cwd interpreter working
* directory.
*/
public File pathToFile(String fileName)
throws IOException {
File file = new File(fileName);
// if relative, fix up to bsh.cwd
if (!file.isAbsolute()) {
String cwd = (String) getu("bsh.cwd");
file = new File(cwd + File.separator + fileName);
}
// The canonical file name is also absolute.
// No need for getAbsolutePath() here...
return new File(file.getCanonicalPath());
}
public static void redirectOutputToFile(String filename) {
try {
PrintStream pout = new PrintStream(
new FileOutputStream(filename));
System.setOut(pout);
System.setErr(pout);
} catch (IOException e) {
System.err.println("Can't redirect output to file: " + filename);
}
}
/**
* Set an external class loader to be used as the base classloader for
* BeanShell. The base classloader is used for all classloading unless/until
* the addClasspath()/setClasspath()/reloadClasses() commands are called to
* modify the interpreter's classpath. At that time the new paths /updated
* paths are added on top of the base classloader.
* <p>
*
* BeanShell will use this at the same point it would otherwise use the
* plain Class.forName(). i.e. if no explicit classpath management is done
* from the script (addClassPath(), setClassPath(), reloadClasses()) then
* BeanShell will only use the supplied classloader. If additional classpath
* management is done then BeanShell will perform that in addition to the
* supplied external classloader. However BeanShell is not currently able to
* reload classes supplied through the external classloader.
* <p>
*
* @see BshClassManager#setClassLoader( ClassLoader )
*/
public void setClassLoader(ClassLoader externalCL) {
getClassManager().setClassLoader(externalCL);
}
/**
* Get the class manager associated with this interpreter (the
* BshClassManager of this interpreter's global namespace). This is
* primarily a convenience method.
*/
public BSHClassManager getClassManager() {
return getNameSpace().getClassManager();
}
/**
* Set strict Java mode on or off. This mode attempts to make BeanShell
* syntax behave as Java syntax, eliminating conveniences like loose
* variables, etc. When enabled, variables are required to be declared or
* initialized before use and method arguments are reqired to have types.
* <p>
*
* This mode will become more strict in a future release when classes are
* interpreted and there is an alternative to scripting objects as method
* closures.
*/
public void setStrictJava(boolean b) {
this.strictJava = b;
}
/**
* @see #setStrictJava( boolean )
*/
public boolean getStrictJava() {
return this.strictJava;
}
static void staticInit() {
try {
systemLineSeparator = System.getProperty("line.separator");
debug = System.err;
DEBUG = Boolean.getBoolean("debug");
TRACE = Boolean.getBoolean("trace");
LOCALSCOPING = Boolean.getBoolean("localscoping");
COMPATIBIILTY = Boolean.getBoolean("bsh.compatibility");
String outfilename = System.getProperty("outfile");
if (outfilename != null) {
redirectOutputToFile(outfilename);
}
} catch (SecurityException e) {
System.err.println("Could not init static:" + e);
} catch (Exception e) {
System.err.println("Could not init static(2):" + e);
} catch (Throwable e) {
System.err.println("Could not init static(3):" + e);
}
// RRB: added for BEAST
}
/**
* Specify the source of the text from which this interpreter is reading.
* Note: there is a difference between what file the interrpeter is sourcing
* and from what file a method was originally parsed. One file may call a
* method sourced from another file. See SimpleNode for origination file
* info.
*
* @see bsh.SimpleNode#getSourceFile()
*/
public String getSourceFileInfo() {
if (sourceFileInfo != null) {
return sourceFileInfo;
} else {
return "<unknown source>";
}
}
/**
* Get the parent Interpreter of this interpreter, if any. Currently this
* relationship implies the following: 1) Parent and child share a
* BshClassManager 2) Children indicate the parent's source file information
* in error reporting. When created as part of a source() / eval() the child
* also shares the parent's namespace. But that is not necessary in general.
*/
public Interpreter getParent() {
return parent;
}
public void setOut(PrintStream out) {
this.out = out;
}
public void setErr(PrintStream err) {
this.err = err;
}
/**
* De-serialization setup. Default out and err streams to stdout, stderr if
* they are null.
*/
private void readObject(ObjectInputStream stream)
throws java.io.IOException, ClassNotFoundException {
stream.defaultReadObject();
// set transient fields
if (console != null) {
setOut(console.getOut());
setErr(console.getErr());
} else {
setOut(System.out);
setErr(System.err);
}
}
/**
* Get the prompt string defined by the getBshPrompt() method in the global
* namespace. This may be from the getBshPrompt() command or may be defined
* by the user as with any other method. Defaults to "bsh % " if the method
* is not defined or there is an error.
*/
private String getBshPrompt() {
try {
return (String) eval("getBshPrompt()");
} catch (Exception e) {
return "bsh % ";
}
}
/**
* Specify whether, in interactive mode, the interpreter exits Java upon end
* of input. If true, when in interactive mode the interpreter will issue a
* System.exit(0) upon eof. If false the interpreter no System.exit() will
* be done.
* <p/>
* Note: if you wish to cause an EOF externally you can try closing the
* input stream. This is not guaranteed to work in older versions of Java
* due to Java limitations, but should work in newer JDK/JREs. (That was the
* motivation for the Java NIO package).
*/
public void setExitOnEOF(boolean value) {
exitOnEOF = value; // ug
}
/**
* Turn on/off the verbose printing of results as for the show() command. If
* this interpreter has a parent the call is delegated. See the BeanShell
* show() command.
*/
public void setShowResults(boolean showResults) {
this.showResults = showResults;
}
/**
* Show on/off verbose printing status for the show() command. See the
* BeanShell show() command. If this interpreter has a parent the call is
* delegated.
*/
public boolean getShowResults() {
return showResults;
}
public static void setShutdownOnExit(final boolean value) {
try {
SYSTEM_OBJECT.getNameSpace().setVariable("shutdownOnExit", value, false);
} catch (final UtilEvalError utilEvalError) {
throw new IllegalStateException(utilEvalError);
}
}
/**
* Compatibility mode. When {@code true} missing classes are tried to create
* from corresponding java source files. The Default value is {@code false}.
* This could be changed to {@code true} by setting the system property
* "bsh.compatibility" to "true".
*
* @see #setCompatibility(boolean)
*/
public boolean getCompatibility() {
return compatibility;
}
/**
* Setting compatibility mode. When {@code true} missing classes are tried
* to create from corresponding java source files. The Default value is
* {@code false}. This could be changed to {@code true} by setting the
* system property "bsh.compatibility" to "true".
*
* @see #getCompatibility()
*/
public void setCompatibility(final boolean value) {
compatibility = value;
}
}
| 39,348 | Java | .java | radioegor146/ehacks-pro | 24 | 19 | 4 | 2018-07-08T13:24:10Z | 2022-12-06T08:08:58Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.