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
WalkAction.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/atom/body/WalkAction.java
/* * see license.txt */ package seventh.ai.basic.actions.atom.body; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.AdapterAction; import seventh.game.entities.PlayerEntity; import seventh.shared.TimeStep; /** * Sprint action * * @author Tony * */ public class WalkAction extends AdapterAction { /** */ public WalkAction() { } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#isFinished(seventh.ai.basic.Brain) */ @Override public boolean isFinished(Brain brain) { return !brain.getEntityOwner().isWalking(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#end(seventh.ai.basic.Brain) */ @Override public void end(Brain brain) { brain.getEntityOwner().stopWalking(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#start(seventh.ai.basic.Brain) */ @Override public void start(Brain brain) { PlayerEntity entity = brain.getEntityOwner(); entity.walk(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#update(seventh.ai.basic.Brain, seventh.shared.TimeStep) */ @Override public void update(Brain brain, TimeStep timeStep) { PlayerEntity entity = brain.getEntityOwner(); entity.walk(); } }
1,384
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
MoveAction.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/atom/body/MoveAction.java
/* * see license.txt */ package seventh.ai.basic.actions.atom.body; import java.util.ArrayList; import java.util.List; import seventh.ai.basic.Brain; import seventh.ai.basic.PathPlanner; import seventh.ai.basic.Zone; import seventh.ai.basic.actions.AdapterAction; import seventh.math.Vector2f; import seventh.shared.TimeStep; /** * Gives the entity a path to move about * * @author Tony * */ public class MoveAction extends AdapterAction { private Vector2f destination; private List<Zone> zonesToAvoid; /** */ public MoveAction() { this(new Vector2f()); } /** * @param destination */ public MoveAction(Vector2f destination) { this.destination = destination; this.zonesToAvoid = new ArrayList<Zone>(); } /** * @param destination the destination to set */ public void setDestination(Vector2f destination) { this.destination.set(destination); } /** * @param zonesToAvoid the zonesToAvoid to set */ public void setZonesToAvoid(List<Zone> zonesToAvoid) { this.zonesToAvoid.addAll(zonesToAvoid); } /** * Clears out the zones to avoid */ public void clearAvoids() { this.zonesToAvoid.clear(); } /* (non-Javadoc) * @see palisma.ai.Action#start(palisma.ai.Brain) */ @Override public void start(Brain brain) { Vector2f position = brain.getEntityOwner().getCenterPos(); PathPlanner<?> feeder = brain.getMotion().getPathPlanner(); if(this.zonesToAvoid.isEmpty()) { feeder.findPath(position, this.destination); } else { feeder.findAvoidancePath(position, this.destination, this.zonesToAvoid); } } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#resume(seventh.ai.basic.Brain) */ @Override public void resume(Brain brain) { start(brain); } /* (non-Javadoc) * @see palisma.ai.Action#end(palisma.ai.Brain) */ @Override public void end(Brain brain) { brain.getMotion().emptyPath(); this.zonesToAvoid.clear(); } /* (non-Javadoc) * @see palisma.ai.Action#isFinished() */ @Override public boolean isFinished(Brain brain) { PathPlanner<?> path = brain.getMotion().getPathPlanner(); return !path.hasPath() || path.atDestination(); } /* (non-Javadoc) * @see palisma.ai.Action#update(palisma.ai.Brain, leola.live.TimeStep) */ @Override public void update(Brain brain, TimeStep timeStep) { if(isFinished(brain)) { this.getActionResult().setSuccess(); } else { this.getActionResult().setFailure(); } } @Override public DebugInformation getDebugInformation() { return super.getDebugInformation().add("destination", this.destination); } }
3,030
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
ThrowGrenadeAction.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/atom/body/ThrowGrenadeAction.java
/* * The Seventh * see license.txt */ package seventh.ai.basic.actions.atom.body; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.AdapterAction; import seventh.game.entities.PlayerEntity; import seventh.game.weapons.GrenadeBelt; import seventh.math.Vector2f; import seventh.shared.TimeStep; /** * @author Tony * */ public class ThrowGrenadeAction extends AdapterAction { private int timeToHold, timeHeld; private GrenadeBelt belt; /** * */ public ThrowGrenadeAction(PlayerEntity me, Vector2f pos) { float distance = Vector2f.Vector2fDistance(me.getCenterPos(), pos); if(distance < 100) { timeToHold = 200; } else if (distance < 200) { timeToHold = 800; } else if (distance < 300) { timeToHold = 1200; } else { timeToHold = 2000; } this.belt=me.getInventory().getGrenades(); } /* (non-Javadoc) * @see seventh.ai.Action#start(seventh.ai.Brain) */ @Override public void start(Brain brain) { if( belt.getNumberOfGrenades() > 0 ) { belt.beginFire(); } } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#resume(seventh.ai.basic.Brain) */ @Override public void resume(Brain brain) { start(brain); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#interrupt(seventh.ai.basic.Brain) */ @Override public void interrupt(Brain brain) { belt.endFire(); } /* (non-Javadoc) * @see seventh.ai.Action#isFinished() */ @Override public boolean isFinished(Brain brain) { return belt.getNumberOfGrenades() < 1 || this.timeHeld >= this.timeToHold; } /* (non-Javadoc) * @see seventh.ai.Action#update(seventh.ai.Brain, leola.live.TimeStep) */ @Override public void update(Brain brain, TimeStep timeStep) { this.timeHeld += timeStep.getDeltaTime(); if(this.timeHeld >= this.timeToHold) { belt.endFire(); // System.out.println("End throwing: " + this.timeToHold); } } }
2,223
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
MeleeAction.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/atom/body/MeleeAction.java
/* * see license.txt */ package seventh.ai.basic.actions.atom.body; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.AdapterAction; import seventh.game.entities.PlayerEntity; import seventh.shared.TimeStep; /** * Melee attack action * * @author Tony * */ public class MeleeAction extends AdapterAction { /** */ public MeleeAction() { } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#isFinished(seventh.ai.basic.Brain) */ @Override public boolean isFinished(Brain brain) { return !brain.getEntityOwner().isMeleeAttacking(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#start(seventh.ai.basic.Brain) */ @Override public void start(Brain brain) { PlayerEntity entity = brain.getEntityOwner(); if(! entity.meleeAttack() ) { getActionResult().setFailure(); } else { getActionResult().setSuccess(); } } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#end(seventh.ai.basic.Brain) */ @Override public void end(Brain brain) { PlayerEntity entity = brain.getEntityOwner(); entity.doneMeleeAttack(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#update(seventh.ai.basic.Brain, seventh.shared.TimeStep) */ @Override public void update(Brain brain, TimeStep timeStep) { PlayerEntity entity = brain.getEntityOwner(); entity.doneMeleeAttack(); } }
1,583
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
ShootAction.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/atom/body/ShootAction.java
/* * see license.txt */ package seventh.ai.basic.actions.atom.body; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.AdapterAction; import seventh.game.entities.PlayerEntity; import seventh.game.weapons.Weapon; import seventh.shared.TimeStep; /** * Shoot action * * @author Tony * */ public class ShootAction extends AdapterAction { /** */ public ShootAction() { } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#isFinished(seventh.ai.basic.Brain) */ @Override public boolean isFinished(Brain brain) { PlayerEntity ent = brain.getEntityOwner(); Weapon weapon = ent.getInventory().currentItem(); if(weapon == null) { return true; } if(!weapon.isLoaded()) { return true; } return !weapon.isFiring(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#end(seventh.ai.basic.Brain) */ @Override public void end(Brain brain) { PlayerEntity entity = brain.getEntityOwner(); entity.endFire(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#start(seventh.ai.basic.Brain) */ @Override public void start(Brain brain) { PlayerEntity entity = brain.getEntityOwner(); if(entity.canFire()) { if(!entity.beginFire()) { entity.endFire(); this.getActionResult().setFailure(); } else { getActionResult().setSuccess(); } } } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#update(seventh.ai.basic.Brain, seventh.shared.TimeStep) */ @Override public void update(Brain brain, TimeStep timeStep) { PlayerEntity entity = brain.getEntityOwner(); if(entity.canFire()) { if(!entity.beginFire()) { entity.endFire(); } } } }
2,041
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
HeadScanAction.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/atom/body/HeadScanAction.java
/* * The Seventh * see license.txt */ package seventh.ai.basic.actions.atom.body; import java.util.List; import seventh.ai.basic.AttackDirection; import seventh.ai.basic.Brain; import seventh.ai.basic.PathPlanner; import seventh.ai.basic.actions.AdapterAction; import seventh.game.SmoothOrientation; import seventh.game.entities.PlayerEntity; import seventh.math.Vector2f; import seventh.shared.TimeStep; /** * @author Tony * */ public class HeadScanAction extends AdapterAction { private long sampleTime; private long pickAttackDirectionTime; private int attackDirectionIndex; private int direction; private Vector2f destination; private Vector2f attackDir; private SmoothOrientation smoother; /** */ public HeadScanAction() { this.destination = new Vector2f(); this.attackDir = new Vector2f(); this.direction = 1; this.smoother = new SmoothOrientation(Math.toRadians(15.0f)); } /** * Rest this action */ public void reset() { this.sampleTime = 0; this.destination.zeroOut(); this.pickAttackDirectionTime = 0; this.attackDirectionIndex = -1; } /* (non-Javadoc) * @see seventh.ai.Action#isFinished() */ @Override public boolean isFinished(Brain brain) { return false; } /* (non-Javadoc) * @see seventh.ai.Action#update(seventh.ai.Brain, leola.live.TimeStep) */ @Override public void update(Brain brain, TimeStep timeStep) { PlayerEntity ent = brain.getEntityOwner(); /* only update the destination once in a while to * avoid the jitters */ this.sampleTime -= timeStep.getDeltaTime(); this.pickAttackDirectionTime += timeStep.getDeltaTime(); if(this.sampleTime < 0) { PathPlanner<?> feeder = brain.getMotion().getPathPlanner(); Vector2f dest = null; if(feeder.hasPath()) { dest = feeder.nextWaypoint(ent); this.pickAttackDirectionTime = 0; this.attackDirectionIndex = -1; } else { // If the bot is standing still, have them look at the directions in which they could // be attacked. List<AttackDirection> attackDirections = brain.getWorld().getAttackDirections(ent); if(!attackDirections.isEmpty()) { int numberOfAttackDirs = attackDirections.size(); if(this.attackDirectionIndex < 0 || this.attackDirectionIndex>=numberOfAttackDirs || this.pickAttackDirectionTime > 800) { int index = this.attackDirectionIndex + this.direction; if(index < 0 || index >= numberOfAttackDirs) { this.direction = -this.direction; } this.attackDirectionIndex = (this.attackDirectionIndex + this.direction) % numberOfAttackDirs; this.pickAttackDirectionTime = 0; } Vector2f.Vector2fSubtract(attackDirections.get(this.attackDirectionIndex).getDirection(), ent.getCenterPos(), attackDir); dest = attackDir; } if(dest==null) { dest = ent.getMovementDir(); } } Vector2f.Vector2fNormalize(dest, dest); destination.set(dest); this.sampleTime = 800 + (brain.getWorld().getRandom().nextInt(3) * 150); } this.smoother.setOrientation(ent.getOrientation()); float destinationOrientation = (float)(Math.atan2(destination.y, destination.x)); this.smoother.setDesiredOrientation(destinationOrientation); this.smoother.update(timeStep); ent.setOrientation(this.smoother.getOrientation()); } }
4,193
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
SprintAction.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/atom/body/SprintAction.java
/* * see license.txt */ package seventh.ai.basic.actions.atom.body; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.AdapterAction; import seventh.game.entities.PlayerEntity; import seventh.shared.TimeStep; /** * Sprint action * * @author Tony * */ public class SprintAction extends AdapterAction { /** */ public SprintAction() { } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#isFinished(seventh.ai.basic.Brain) */ @Override public boolean isFinished(Brain brain) { return !brain.getEntityOwner().isSprinting(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#end(seventh.ai.basic.Brain) */ @Override public void end(Brain brain) { PlayerEntity entity = brain.getEntityOwner(); entity.stopSprinting(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#start(seventh.ai.basic.Brain) */ @Override public void start(Brain brain) { PlayerEntity entity = brain.getEntityOwner(); entity.sprint(); if(!entity.isSprinting()) { entity.stopSprinting(); this.getActionResult().setFailure(); } else { getActionResult().setSuccess(); } } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#update(seventh.ai.basic.Brain, seventh.shared.TimeStep) */ @Override public void update(Brain brain, TimeStep timeStep) { PlayerEntity entity = brain.getEntityOwner(); entity.sprint(); if(!entity.isSprinting()) { entity.stopSprinting(); } } }
1,727
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
ReloadAction.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/atom/body/ReloadAction.java
/* * see license.txt */ package seventh.ai.basic.actions.atom.body; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.AdapterAction; import seventh.game.entities.PlayerEntity; import seventh.shared.TimeStep; /** * Reload a weapon action * * @author Tony * */ public class ReloadAction extends AdapterAction { /** */ public ReloadAction() { } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#isFinished(seventh.ai.basic.Brain) */ @Override public boolean isFinished(Brain brain) { return !brain.getEntityOwner().isReloading(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#start(seventh.ai.basic.Brain) */ @Override public void start(Brain brain) { PlayerEntity entity = brain.getEntityOwner(); if(! entity.reload() ) { getActionResult().setFailure(); } else { getActionResult().setSuccess(); } } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#update(seventh.ai.basic.Brain, seventh.shared.TimeStep) */ @Override public void update(Brain brain, TimeStep timeStep) { } }
1,233
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
ReloadWeaponEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/ReloadWeaponEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.TargetingSystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.atom.body.ReloadAction; import seventh.game.weapons.Weapon; /** * @author Tony * */ public class ReloadWeaponEvaluator extends ActionEvaluator { private ReloadAction reloadAction; /** * @param goals * @param characterBias */ public ReloadWeaponEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.reloadAction = new ReloadAction(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desire = 0.0; Weapon weapon = brain.getEntityOwner().getInventory().currentItem(); if (weapon != null && weapon.getTotalAmmo() > 0) { desire = 1.0 - Evaluators.currentWeaponAmmoScore(brain.getEntityOwner()); TargetingSystem system = brain.getTargetingSystem(); if(system.hasTarget()) { desire *= brain.getRandomRange(0.2, 0.5); desire *= getCharacterBias(); } } return desire; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return this.reloadAction; } }
1,716
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
SurpressFireEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/SurpressFireEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.Locomotion; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.TimedAction; import seventh.game.weapons.Weapon; import seventh.math.Vector2f; /** * @author Tony * */ public class SurpressFireEvaluator extends ActionEvaluator { private TimedAction surpressAction; private Vector2f target; /** * @param goals * @param characterBias */ public SurpressFireEvaluator(Actions goals, double characterBias, double keepBias, final Vector2f target) { super(goals, characterBias, keepBias); this.target = target; // TODO: Make time variable/fuzzy this.surpressAction = new TimedAction(3500) { /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#start(seventh.ai.basic.Brain) */ @Override public void start(Brain brain) { super.start(brain); Locomotion motion = brain.getMotion(); motion.lookAt(target); motion.shoot(); } protected void doAction(Brain brain, seventh.shared.TimeStep timeStep) { } /* (non-Javadoc) * @see seventh.ai.basic.actions.AdapterAction#end(seventh.ai.basic.Brain) */ @Override public void end(Brain brain) { super.end(brain); brain.getMotion().stopShooting(); } }; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desire = 0.0; Weapon weapon = brain.getEntityOwner().getInventory().currentItem(); if (weapon != null) { double weaponScore = Evaluators.currentWeaponAmmoScore(brain.getEntityOwner()); double distanceScore = Evaluators.weaponDistanceScore(brain.getEntityOwner(), this.target); desire = (weaponScore + distanceScore) / 2.0; desire *= getCharacterBias(); } return desire; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return this.surpressAction; } }
2,704
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
InvestigateActionEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/InvestigateActionEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.atom.MoveToAction; import seventh.game.events.SoundEmittedEvent; import seventh.math.Vector2f; /** * @author Tony * */ public class InvestigateActionEvaluator extends ActionEvaluator { private MoveToAction moveToAction; /** * @param goals * @param characterBias */ public InvestigateActionEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.moveToAction = new MoveToAction(new Vector2f()); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desirability = 0.0; SoundEmittedEvent sound = brain.getSensors().getSoundSensor().getClosestSound(); if(sound != null) { desirability = brain.getPersonality().curiosity; switch(sound.getSoundType()) { case EXPLOSION: case GRENADE_THROW: case KAR98_FIRE: case M1_GARAND_FIRE: case MELEE_HIT: case MELEE_SWING: case MP40_FIRE: case MP44_FIRE: case PISTOL_FIRE: case RISKER_FIRE: case RPG_FIRE: case SHOTGUN_FIRE: case SPRINGFIELD_FIRE: case THOMPSON_FIRE: case HAMMER_SWING: desirability += brain.getRandomRange(0.2, 0.4); break; case WEAPON_PICKUP: case AMMO_PICKUP: desirability += brain.getRandomRange(0.2, 0.43); break; /* enemy is busy doing something, good time * to attack */ case WEAPON_DROPPED: case WEAPON_SWITCH: case THOMPSON_RELOAD: case SPRINGFIELD_RECHAMBER: case SPRINGFIELD_RELOAD: case SHOTGUN_RELOAD: case SHOTGUN_PUMP: case RISKER_RELOAD: case RISKER_RECHAMBER: case PISTOL_RELOAD: case MP44_RELOAD: case MP40_RELOAD: case M1_GARAND_RELOAD: case KAR98_RELOAD: case KAR98_RECHAMBER: desirability += brain.getRandomRange(0.5, 0.65); break; case EMPTY_FIRE: case GRENADE_PINPULLED: case M1_GARAND_LAST_FIRE: desirability += brain.getRandomRange(0.64, 0.85); break; case BOMB_DISARM: case BOMB_PLANT: desirability += brain.getRandomRange(0.5, 0.8); break; case TANK_IDLE: case TANK_OFF: case TANK_ON: case TANK_REV_DOWN: case TANK_REV_UP: case TANK_SHIFT: case TANK_TURRET_MOVE: desirability = 0f; // get the hell out of dodge break; case RUFFLE: desirability += brain.getRandomRange(0.3, 0.5); break; case SURFACE_DIRT: case SURFACE_GRASS: case SURFACE_METAL: case SURFACE_NORMAL: case SURFACE_SAND: case SURFACE_WATER: case SURFACE_WOOD: desirability += brain.getRandomRange(0.3, 0.5); break; default: desirability = 0.1f; } } desirability = Math.min(desirability, 1f); desirability *= getCharacterBias(); return desirability; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { SoundEmittedEvent sound = brain.getSensors().getSoundSensor().getClosestSound(); if(sound != null) { this.moveToAction.reset(brain, sound.getPos()); brain.getMotion().lookAt(this.moveToAction.getDestination()); } return this.moveToAction; } }
5,036
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
RideVehicleEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/RideVehicleEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import java.util.ArrayList; import java.util.List; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.game.entities.vehicles.Vehicle; /** * @author Tony * */ public class RideVehicleEvaluator extends ActionEvaluator { private List<Vehicle> vehiclesToRide; private Vehicle vehicleToRide; /** * @param goals * @param characterBias * @param keepBias */ public RideVehicleEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.vehiclesToRide = new ArrayList<Vehicle>(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { List<Vehicle> vehicles = brain.getWorld().getVehicles(); double score = 0; if(!vehicles.isEmpty()) { vehiclesToRide.clear(); for(int i = 0; i < vehicles.size(); i++) { Vehicle v = vehicles.get(i); if(v.isAlive() && !v.hasOperator()) { vehiclesToRide.add(v); } } Vehicle v = brain.getEntityOwner().getClosest(vehiclesToRide); if(v != null) { float distanceToVehicle = brain.getEntityOwner().distanceFromSq(v); float reasonableDistance = (32f*10f) * (32f*10f); score = 1.0 - (distanceToVehicle/reasonableDistance); score = Math.max(0, score); this.vehicleToRide = v; } } return score; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return getGoals().operateVehicle(vehicleToRide); } }
2,079
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
DodgeEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/DodgeEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.TargetingSystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.atom.StrafeAction; import seventh.game.entities.PlayerEntity; /** * @author Tony * */ public class DodgeEvaluator extends ActionEvaluator { private StrafeAction strafeAction; /** * @param goals * @param characterBias */ public DodgeEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.strafeAction = new StrafeAction(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double score = 0; TargetingSystem system = brain.getTargetingSystem(); if(system.hasTarget()) { PlayerEntity enemy = system.getCurrentTarget(); if(enemy.isFiring()) { score += brain.getRandomRange(0.4, 0.6); } score *= getCharacterBias(); } return score; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { // return getGoals().chargeEnemy(getGoals(), brain, brain.getTargetingSystem().getCurrentTarget()); this.strafeAction.reset(brain); return this.strafeAction; } }
1,706
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
AvoidGrenadeActionEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/AvoidGrenadeActionEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.atom.MoveToAction; import seventh.game.entities.Entity; import seventh.game.entities.PlayerEntity; import seventh.game.entities.Entity.Type; import seventh.map.Map; import seventh.math.Rectangle; import seventh.math.Vector2f; import seventh.shared.SeventhConstants; /** * If the bot is shot, see if it can defend itself * * @author Tony * */ public class AvoidGrenadeActionEvaluator extends ActionEvaluator { private MoveToAction moveToAction; private Rectangle dangerArea; private Vector2f ray; private Entity danger; private long frameLinger; /** * @param goals * @param characterBias */ public AvoidGrenadeActionEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.moveToAction = new MoveToAction(new Vector2f()); this.dangerArea = new Rectangle(150, 150); this.ray = new Vector2f(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desirability = 0.0; PlayerEntity me = brain.getEntityOwner(); Entity[] entities = brain.getWorld().getEntities(); for(int i = SeventhConstants.MAX_PERSISTANT_ENTITIES; i < entities.length; i++) { Entity ent = entities[i]; if(ent!=null) { if(ent.getType().equals(Type.GRENADE)|| ent.getType().equals(Type.EXPLOSION)) { this.dangerArea.centerAround(ent.getCenterPos()); if(this.dangerArea.intersects(me.getBounds())) { desirability += brain.getRandomRange(0.90f, 1.0f); danger = ent; frameLinger = 2; break; } } } } // because it takes a frame or two to register // an explosion from a grenade, we need to linger // around otherwise the bot thinks the grenade // is no longer a danger and moves back into the damage // radius if(desirability==0&&frameLinger>0) { desirability += brain.getRandomRange(0.90f, 1.0f); frameLinger--; } desirability *= getCharacterBias(); return desirability; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { if(danger!=null) { // shoot a ray in a number of directions to see which ones are able // to be used for running out of the danger zone PlayerEntity me = brain.getEntityOwner(); Vector2f pos = me.getCenterPos(); Rectangle bounds = me.getBounds(); Map map = brain.getWorld().getMap(); boolean keepLooking = true; // check the top ray.x = pos.x; ray.y = pos.y - (pos.y - dangerArea.y) - dangerArea.height; if(!map.lineCollides(pos, ray)) { this.moveToAction.reset(brain, ray); keepLooking = false; } if(keepLooking) { // check the right ray.x = pos.x + dangerArea.width; ray.y = pos.y; if(!map.lineCollides(pos, ray)) { this.moveToAction.reset(brain, ray); keepLooking = false; } } if(keepLooking) { // check the bottom ray.x = pos.x; ray.y = pos.y + bounds.height + (dangerArea.height - (pos.y - dangerArea.y)); if(!map.lineCollides(pos, ray)) { this.moveToAction.reset(brain, ray); keepLooking = false; } } if(keepLooking) { // check the left ray.x = pos.x - ((pos.x + bounds.width) - dangerArea.x); ray.y = pos.y; if(!map.lineCollides(pos, ray)) { this.moveToAction.reset(brain, ray); keepLooking = false; } } } return this.moveToAction; } }
4,814
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
DoNothingEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/DoNothingEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.WaitAction; /** * @author Tony * */ public class DoNothingEvaluator extends ActionEvaluator { private WaitAction noAction; /** * @param goals * @param characterBias */ public DoNothingEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); noAction = new WaitAction(100); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double score = brain.getRandomRange(0.4, 0.8); return score * getCharacterBias(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { noAction.reset(); return noAction; } }
1,155
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
SwitchWeaponEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/SwitchWeaponEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import java.util.List; import seventh.ai.basic.Brain; import seventh.ai.basic.TargetingSystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.atom.body.SwitchWeaponAction; import seventh.game.Inventory; import seventh.game.entities.Entity.Type; import seventh.game.weapons.Weapon; /** * @author Tony * */ public class SwitchWeaponEvaluator extends ActionEvaluator { private Type weaponType; private SwitchWeaponAction switchWeaponAction; /** * @param goals * @param characterBias */ public SwitchWeaponEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.switchWeaponAction = new SwitchWeaponAction(weaponType); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desire = 0.0; Inventory inventory = brain.getEntityOwner().getInventory(); if(inventory.numberOfItems() > 1 ) { Weapon weapon = inventory.currentItem(); if (weapon != null) { // do we have enough ammo? // double weaponScore = Evaluators.currentWeaponAmmoScore(brain.getEntityOwner()); /* ensure we are not currently firing/reloading/switching * the weapon */ if(weapon.isReady()) { if(weapon.getTotalAmmo() <= 0 && weapon.getBulletsInClip() <= 0) { desire = 1; } Weapon bestWeapon = getBestScoreWeapon(inventory); if(bestWeapon != weapon) { desire += brain.getRandomRange(0.1, 0.4); } } } else { desire = 1.0; } /* if we are currently targeting someone, * we should lessen the desire to switch weapons */ TargetingSystem system = brain.getTargetingSystem(); if(desire < 1.0 && system.hasTarget()) { desire *= brain.getRandomRange(0.4, 0.7); } desire *= getCharacterBias(); } return desire; } private Weapon getBestScoreWeapon(Inventory inventory) { int size = inventory.numberOfItems(); List<Weapon> weapons = inventory.getItems(); double score = -1; Weapon bestWeapon = null; for(int i = 0; i < size; i++) { Weapon weapon = weapons.get(i); double weaponScore = Evaluators.weaponStrengthScore(weapon); weaponScore *= Evaluators.weaponAmmoScore(weapon); if(bestWeapon == null || score < weaponScore) { score = weaponScore; bestWeapon = weapon; } } return bestWeapon; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { Weapon bestWeapon = getBestScoreWeapon(brain.getEntityOwner().getInventory()); this.switchWeaponAction.reset(bestWeapon.getType()); return this.switchWeaponAction; } }
3,768
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
StrategyEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/StrategyEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.teamstrategy.TeamStrategy; /** * @author Tony * */ public class StrategyEvaluator extends ActionEvaluator { private TeamStrategy teamStrategy; /** * @param goals * @param characterBias */ public StrategyEvaluator(TeamStrategy teamStrategy, Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.teamStrategy = teamStrategy; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double score = brain.getPersonality().obedience + this.teamStrategy.getDesirability(brain); score = score / 2.0; score *= getCharacterBias(); return score; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return teamStrategy.getAction(brain); } }
1,289
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
MoveTowardEnemyEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/MoveTowardEnemyEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.TargetingSystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.game.entities.PlayerEntity; /** * @author Tony * */ public class MoveTowardEnemyEvaluator extends ActionEvaluator { /** * @param goals * @param characterBias */ public MoveTowardEnemyEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double score = 0; TargetingSystem system = brain.getTargetingSystem(); if(system.hasTarget()) { PlayerEntity bot = brain.getEntityOwner(); final double tweaker = brain.getPersonality().aggressiveness; final PlayerEntity enemy = system.getCurrentTarget(); if(enemy.isOperatingVehicle()) { score = 0; } else { score = (tweaker * 0.5) + (Evaluators.healthScore(bot) * 0.1) + (Evaluators.currentWeaponAmmoScore(bot) * 0.1) + (Evaluators.weaponDistanceScore(bot, enemy) * 0.3) ; score = score / 4.0; } if(!system.currentTargetInLineOfFire()) { score *= 0.9; } score *= getCharacterBias(); } return score; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { if(brain.getTargetingSystem().hasTarget()) { return getGoals().chargeEnemy(brain.getTargetingSystem().getCurrentTarget()); } return null; } }
2,190
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
StayStillEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/StayStillEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; /** * @author Tony * */ public class StayStillEvaluator extends ActionEvaluator { /** * @param goals * @param characterBias */ public StayStillEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double score = brain.getRandomRange(0.3, 0.6); return score * getCharacterBias(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return getGoals().attackEnemy(brain.getTargetingSystem().getCurrentTarget()); } }
1,081
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
CommandActionEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/CommandActionEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.Communicator; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; /** * @author Tony * */ public class CommandActionEvaluator extends ActionEvaluator { private Action commandAction; /** * @param goals * @param characterBias */ public CommandActionEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#isRepeatable() */ @Override public boolean isRepeatable() { return true; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#isContinuable() */ @Override public boolean isContinuable() { return true; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desirability = 0.0; Communicator comms = brain.getCommunicator(); if(comms.hasPendingCommands()) { desirability += brain.getRandomRange(0.7, 0.9); } desirability *= getCharacterBias(); return desirability; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { this.commandAction = brain.getCommunicator().peek(); if(this.commandAction != null && this.commandAction.isFinished(brain)) { brain.getCommunicator().poll(); } return this.commandAction; } }
1,908
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
MeleeEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/MeleeEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.TargetingSystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.atom.body.MeleeAction; import seventh.game.entities.PlayerEntity; import seventh.game.weapons.Weapon; import seventh.math.Vector2f; /** * @author Tony * */ public class MeleeEvaluator extends ActionEvaluator { private MeleeAction meleeAction; /** * @param goals * @param characterBias */ public MeleeEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.meleeAction = new MeleeAction(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desire = 0.0; TargetingSystem system = brain.getTargetingSystem(); if(system.hasTarget()) { PlayerEntity bot = brain.getEntityOwner(); Weapon weapon = bot.getInventory().currentItem(); if (weapon != null && weapon.canMelee()) { float distanceAwaySq = Vector2f.Vector2fDistanceSq(bot.getCenterPos(), system.getCurrentTarget().getCenterPos()); final double MaxMeleeDistance = 1500.0; if(distanceAwaySq < MaxMeleeDistance) { desire = Math.max(0.9 - (distanceAwaySq/MaxMeleeDistance), 0); desire *= getCharacterBias(); } } } return desire; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return this.meleeAction; } }
1,968
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
ActionEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/ActionEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; /** * @author Tony * */ public abstract class ActionEvaluator { private double characterBias, keepBias; private Actions goals; /** * @param characterBias * @param keepBias */ public ActionEvaluator(Actions goals, double characterBias, double keepBias) { this.goals = goals; this.characterBias = characterBias; this.keepBias = keepBias; } /** * @return the goals */ public Actions getGoals() { return goals; } /** * @return the characterBias */ public double getCharacterBias() { return characterBias; } /** * @return the bias to keep doing this action */ public double getKeepBias() { return keepBias; } /** * If this Evaluator repeats different actions that should be considered 'new' after * each calculation * @return true if to be considered 'new' after an evaluation */ public boolean isRepeatable() { return false; } public boolean isContinuable() { return false; } /** * Calculates the desirability * * @param brain * @return the desirability score between 0 and 1 */ public abstract double calculateDesirability(Brain brain); /** * * @return */ public abstract Action getAction(Brain brain); }
1,607
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
Evaluators.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/Evaluators.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import java.util.List; import seventh.ai.basic.Brain; import seventh.game.entities.PlayerEntity; import seventh.game.weapons.Weapon; import seventh.math.Vector2f; /** * @author Tony * */ public class Evaluators { /** * Evaluate the best possible action for the supplied brain given a set of evaluators. * * @param brain * @param evaluators * @return the best {@link ActionEvaluator} of the bunch */ public static ActionEvaluator evaluate(Brain brain, ActionEvaluator ... evaluators) { double highestDesire = 0; ActionEvaluator bestEval = null; int size = evaluators.length; for(int i = 0; i < size; i++) { ActionEvaluator eval = evaluators[i]; double desire = eval.calculateDesirability(brain); if(bestEval == null || desire > highestDesire) { bestEval = eval; highestDesire = desire; } } return bestEval; } /** * Evaluate the best possible action for the supplied brain given a set of evaluators. * * @param brain * @param evaluators * @return the best {@link ActionEvaluator} of the bunch */ public static ActionEvaluator evaluate(Brain brain, List<ActionEvaluator> evaluators) { double highestDesire = 0; ActionEvaluator bestEval = null; int size = evaluators.size(); for(int i = 0; i < size; i++) { ActionEvaluator eval = evaluators.get(i); double desire = eval.calculateDesirability(brain); if(bestEval == null || desire > highestDesire) { bestEval = eval; highestDesire = desire; } } return bestEval; } /** * Health score between 0 and 1 * @param ent * @return */ public static double healthScore(PlayerEntity ent) { return (double) ent.getHealth() / (double) ent.getMaxHealth(); } public static double weaponStrengthScore(Weapon weapon) { double score = 0; if ( weapon != null ) { switch(weapon.getType()) { case PISTOL: score = 0.2; break; case ROCKET_LAUNCHER: score = 0.6; break; case MP40: score = 0.7; break; case THOMPSON: score = 0.7; break; case KAR98: score = 0.8; break; case M1_GARAND: score = 0.8; break; case MP44: score = 0.8; break; case MG42: score = 0.8; break; case RISKER: score = 0.8; break; case SHOTGUN: score = 0.8; break; case SPRINGFIELD: score = 0.8; break; case FLAME_THROWER: score = 0.75; break; default: break; } } return score; } /** * Current weapon score (only accounts for bullets in clip) * @param ent * @return */ public static double currentWeaponAmmoScore(PlayerEntity ent) { double score = 0; Weapon weapon = ent.getInventory().currentItem(); score = weaponAmmoScore(weapon); return score; } /** * Current weapon score (only accounts for bullets in clip) * @param ent * @return */ public static double weaponAmmoScore(Weapon weapon) { double score = 0; if(weapon != null) { double clipSize = (double)weapon.getClipSize(); if(clipSize != 0) { return (double)weapon.getBulletsInClip() / clipSize; } else { if(weapon.getBulletsInClip() > 0) { score += 0.3; } } } return score; } public static double weaponDistanceScore(PlayerEntity ent, PlayerEntity enemy) { return weaponDistanceScore(ent, enemy.getCenterPos()); } public static double weaponDistanceScore(PlayerEntity ent, Vector2f target) { double score = 0; Weapon weapon = ent.getInventory().currentItem(); if(weapon != null) { float distanceAwaySq = Vector2f.Vector2fDistanceSq(ent.getCenterPos(), target); double bulletRangeSq = ent.getCurrentWeaponDistanceSq(); if(bulletRangeSq > 0 && distanceAwaySq < bulletRangeSq) { score = 0.75; double distanceScore = distanceAwaySq / bulletRangeSq; /* lower the score if they are too close */ if(distanceScore < 0.15) { distanceScore = 0; } /* lower the score if they are too far away */ else if(distanceScore > 0.85) { distanceScore *= 0.80; } score *= distanceScore; } } return score; } }
5,759
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
HandleDoorActionEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/HandleDoorActionEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import java.util.List; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.game.entities.Door; import seventh.game.entities.PlayerEntity; import seventh.math.Rectangle; /** * Determines if a {@link Door} needs to be handled * * @author Tony * */ public class HandleDoorActionEvaluator extends ActionEvaluator { private Door door; private Rectangle futureBounds; /** * @param characterBias */ public HandleDoorActionEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.futureBounds = new Rectangle(64,64); } @Override public double calculateDesirability(Brain brain) { double desirability = 0; PlayerEntity bot = brain.getEntityOwner(); if(bot.isRunning()||bot.isSprinting()) { //Vector2f newPos = new Vector2f(); //Vector2f.Vector2fMA(bot.getCenterPos(), bot.getMovementDir(), 35, newPos); futureBounds.centerAround(bot.getCenterPos()); // DebugDraw.fillRectRelative(futureBounds.x, futureBounds.y, futureBounds.width, futureBounds.height, 0xff00ffff); List<Door> doors = brain.getWorld().getDoors(); for(int i = 0; i < doors.size(); i++) { Door door = doors.get(i); if(door.canBeHandledBy(bot)) { if(door.isTouching(futureBounds)) { this.door = door; //DebugDraw.fillRectRelative(futureBounds.x, futureBounds.y, futureBounds.width, futureBounds.height, 0xffff00ff); desirability = 1.0f; break; } } } } return desirability; } @Override public Action getAction(Brain brain) { if(this.door==null) { return getGoals().waitAction(2_000); } return getGoals().handleDoorAction(this.door); } }
2,153
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
TakeCoverEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/TakeCoverEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.Cover; import seventh.ai.basic.TargetingSystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.game.entities.PlayerEntity; import seventh.math.Vector2f; /** * @author Tony * */ public class TakeCoverEvaluator extends ActionEvaluator { private Cover cover; /** * @param goals * @param characterBias */ public TakeCoverEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.cover = new Cover(new Vector2f(), new Vector2f()); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double score = 0; TargetingSystem system = brain.getTargetingSystem(); if(system.hasTarget()) { PlayerEntity bot = brain.getEntityOwner(); final double tweaker = 1.0 - brain.getPersonality().aggressiveness; final PlayerEntity enemy = system.getCurrentTarget(); if(enemy.isOperatingVehicle()) { score = 1.0; } else { // the lower the score for health and weapons, the more likely we // want to run for cover score = 1.0 - ((Evaluators.healthScore(bot) + Evaluators.currentWeaponAmmoScore(bot)) / 2.0); score = tweaker + score + Evaluators.weaponDistanceScore(bot, enemy) ; score = score / 3.0; } Vector2f lastSeenAt = system.getLastRemeberedPosition(); if(lastSeenAt != null) { // Vector2f coverPosition = brain.getWorld().getClosestCoverPosition(bot, system.getLastRemeberedPosition()); // this.cover.setCoverPos(coverPosition); // // DebugDraw.drawRectRelative( (int)coverPosition.x, (int)coverPosition.y, 10, 10, 0xff00ff00); // float distanceToCoverSq = Vector2f.Vector2fDistanceSq(bot.getCenterPos(), coverPosition); // final float MaxCoverDistance = (32*4) * (32*4); // // if(distanceToCoverSq < MaxCoverDistance) { // score *= 1.0 - distanceToCoverSq / MaxCoverDistance; // } // else { // score = 0; // } } if(system.currentTargetInLineOfFire()) { score *= 0.2; } score *= getCharacterBias(); } return score; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { TargetingSystem system = brain.getTargetingSystem(); Vector2f attackDir = system.getLastRemeberedPosition() != null ? system.getLastRemeberedPosition() : system.hasTarget() ? system.getCurrentTarget().getCenterPos() : brain.getEntityOwner().getFacing(); Vector2f coverPosition = brain.getWorld().getClosestCoverPosition(brain.getEntityOwner(), attackDir); this.cover.setCoverPos(coverPosition); this.cover.setAttackDir(attackDir); return getGoals().moveToCover(this.cover); } }
3,734
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
DegroupActionEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/DegroupActionEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import java.util.ArrayList; import java.util.List; import seventh.ai.basic.Brain; import seventh.ai.basic.Locomotion; import seventh.ai.basic.World; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.WaitAction; import seventh.ai.basic.actions.atom.MoveToAction; import seventh.game.entities.PlayerEntity; import seventh.math.Rectangle; import seventh.math.Vector2f; /** * @author Tony * */ public class DegroupActionEvaluator extends ActionEvaluator { private List<PlayerEntity> playersNearMe; private Rectangle personalSpace, checkBounds; /** * @param goals * @param characterBias * @param keepBias */ public DegroupActionEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.playersNearMe = new ArrayList<>(); this.personalSpace = new Rectangle(64, 64); this.checkBounds = new Rectangle(166, 166); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double score = 0; Locomotion motion = brain.getMotion(); PlayerEntity bot = brain.getEntityOwner(); if(!motion.isMoving()) { if(isTooCloseToTeammates(brain, bot.getCenterPos())) { score = 1; } } return score; } private boolean isTooCloseToTeammates(Brain brain, Vector2f pos) { PlayerEntity bot = brain.getEntityOwner(); personalSpace.centerAround(pos); playersNearMe.clear(); World world = brain.getWorld(); world.playersIn(playersNearMe, personalSpace); if(playersNearMe.size() > 1) { for(int i = 0; i < playersNearMe.size(); i++) { PlayerEntity ent = playersNearMe.get(i); if(ent != bot && ent.isAlive() && !world.isEnemyOf(brain, ent)) { return true; } } } return false; } @Override public Action getAction(Brain brain) { World world = brain.getWorld(); PlayerEntity bot = brain.getEntityOwner(); checkBounds.centerAround(bot.getCenterPos()); int attempts = 20; while(attempts > 0) { Vector2f pos = world.getRandomSpot(brain.getEntityOwner(), checkBounds); if(pos!=null) { if(!isTooCloseToTeammates(brain, pos)) { return new MoveToAction(pos); } } attempts--; } return new WaitAction(100); } }
2,967
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
DefendSelfActionEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/DefendSelfActionEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.atom.MoveToAction; import seventh.game.entities.Entity; import seventh.game.weapons.Bullet; import seventh.math.Vector2f; /** * If the bot is shot, see if it can defend itself * * @author Tony * */ public class DefendSelfActionEvaluator extends ActionEvaluator { private MoveToAction moveToAction; /** * @param goals * @param characterBias */ public DefendSelfActionEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.moveToAction = new MoveToAction(new Vector2f()); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desirability = 0.0; Entity attacker = brain.getSensors().getFeelSensor().getMostRecentAttacker(); if(attacker != null) { desirability += brain.getRandomRange(0.90f, 1.0f); } desirability *= getCharacterBias(); return desirability; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { Entity attacker = brain.getSensors().getFeelSensor().getMostRecentAttacker(); if(attacker != null) { if(attacker instanceof Bullet) { Bullet bullet = (Bullet)attacker; Entity owner = bullet.getOwner(); this.moveToAction.reset(brain, owner.getCenterPos()); brain.getMotion().lookAt(this.moveToAction.getDestination()); } else { this.moveToAction.reset(brain, attacker.getCenterPos()); brain.getMotion().lookAt(this.moveToAction.getDestination()); } } return this.moveToAction; } }
2,231
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
ShootWeaponEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/ShootWeaponEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.TargetingSystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.atom.ShootAtAction; import seventh.game.weapons.Weapon; /** * @author Tony * */ public class ShootWeaponEvaluator extends ActionEvaluator { private ShootAtAction shootAction; /** * @param goals * @param characterBias */ public ShootWeaponEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.shootAction = new ShootAtAction(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desire = 0.0; TargetingSystem system = brain.getTargetingSystem(); if(system.hasTarget()) { Weapon weapon = brain.getEntityOwner().getInventory().currentItem(); if (weapon != null) { desire = 1; double weaponScore = Evaluators.currentWeaponAmmoScore(brain.getEntityOwner()); double distanceScore = Evaluators.weaponDistanceScore(brain.getEntityOwner(), system.getCurrentTarget()); desire = (weaponScore + distanceScore + desire) / 3.0; desire *= getCharacterBias(); } } return desire; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return this.shootAction; } }
1,873
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
AttackActionEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/AttackActionEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; /** * @author Tony * */ public class AttackActionEvaluator extends ActionEvaluator { /** * @param characterBias */ public AttackActionEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); } /* (non-Javadoc) * @see seventh.ai.basic.actions.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desirability = 0; if(brain.getTargetingSystem().hasTarget()) { final double tweaker = 1.0; desirability = tweaker * Math.max(Evaluators.healthScore(brain.getEntityOwner()), 0.7) * Math.max(Evaluators.currentWeaponAmmoScore(brain.getEntityOwner()), 0.8); desirability *= getCharacterBias(); } return desirability; } /* (non-Javadoc) * @see seventh.ai.basic.actions.ActionEvaluator#getAction() */ @Override public Action getAction(Brain brain) { return getGoals().enemyEncountered(); } }
1,383
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
GrenadeEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/GrenadeEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.TargetingSystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.atom.body.ThrowGrenadeAction; import seventh.game.entities.PlayerEntity; import seventh.math.Vector2f; /** * @author Tony * */ public class GrenadeEvaluator extends ActionEvaluator { /** * @param goals * @param characterBias */ public GrenadeEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desire = 0.0; TargetingSystem system = brain.getTargetingSystem(); if(system.hasTarget()) { PlayerEntity bot = brain.getEntityOwner(); if (bot.getInventory().hasGrenades() && !bot.isThrowingGrenade()) { float distanceAwaySq = Vector2f.Vector2fDistanceSq(bot.getCenterPos(), system.getCurrentTarget().getCenterPos()); final double MaxGrenadeDistance = (64*6) * (64*6); desire = 0.1; if(distanceAwaySq < MaxGrenadeDistance) { desire *= distanceAwaySq / MaxGrenadeDistance; } else { desire *= brain.getRandomRangeMax(0.2); } desire *= getCharacterBias(); } } return desire; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return new ThrowGrenadeAction(brain.getEntityOwner(), brain.getTargetingSystem().getLastRemeberedPosition()); } }
2,028
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
ExploreActionEvaluator.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/actions/evaluators/ExploreActionEvaluator.java
/* * see license.txt */ package seventh.ai.basic.actions.evaluators; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.atom.body.MoveAction; /** * @author Tony * */ public class ExploreActionEvaluator extends ActionEvaluator { private MoveAction moveAction; /** * @param goals * @param characterBias */ public ExploreActionEvaluator(Actions goals, double characterBias, double keepBias) { super(goals, characterBias, keepBias); this.moveAction = new MoveAction(); } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#calculateDesirability(seventh.ai.basic.Brain) */ @Override public double calculateDesirability(Brain brain) { double desirability = 0.35; desirability *= getCharacterBias(); return desirability; } /* (non-Javadoc) * @see seventh.ai.basic.actions.evaluators.ActionEvaluator#getAction(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { brain.getMotion().scanArea(); this.moveAction.setDestination(brain.getWorld().getRandomSpot(brain.getEntityOwner())); return this.moveAction; // return getGoals().goToRandomSpot(brain); } }
1,374
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
AICommands.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/commands/AICommands.java
/** * */ package seventh.ai.basic.commands; import java.util.HashMap; import java.util.List; import java.util.Map; import seventh.ai.AICommand; import seventh.ai.basic.Brain; import seventh.ai.basic.DefaultAISystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.SequencedAction; import seventh.ai.basic.actions.atom.CoverEntityAction; import seventh.ai.basic.actions.atom.GuardAction; import seventh.ai.basic.actions.atom.MoveToAction; import seventh.game.GameInfo; import seventh.game.PlayerInfo; import seventh.game.entities.BombTarget; import seventh.math.Vector2f; import seventh.shared.Cons; /** * Converts the {@link AICommand} to an {@link Action} that will be * delegated to a bot. * * @author Tony * */ public class AICommands { interface Command { Action parse(Brain brain, String ... args); } private Actions goals; private GameInfo game; private Map<String, Command> aiCommands; /** * @param aiSystem */ public AICommands(DefaultAISystem aiSystem) { this.goals = aiSystem.getGoals(); this.game = aiSystem.getGame(); this.aiCommands = new HashMap<String, Command>(); this.aiCommands.put("plantBomb", new Command() { @Override public Action parse(Brain brain, String... args) { return goals.plantBomb(); } }); this.aiCommands.put("defuseBomb", new Command() { @Override public Action parse(Brain brain, String... args) { return goals.defuseBomb(); } }); this.aiCommands.put("defendBomb", new Command() { @Override public Action parse(Brain brain, String... args) { List<BombTarget> plantedBombs = brain.getWorld().getBombTargetsWithActiveBombs(); if(!plantedBombs.isEmpty()) { BombTarget target = (BombTarget)brain.getEntityOwner().getClosest(plantedBombs); return goals.defendPlantedBomb(target); } return null; } }); this.aiCommands.put("followMe", new Command() { @Override public Action parse(Brain brain, String... args) { if(args.length > 0) { String pid = args[0]; PlayerInfo player = game.getPlayerById(Integer.parseInt(pid)); if(player.isAlive()) { return new CoverEntityAction(player.getEntity()); } } return null; } }); this.aiCommands.put("defendLeader", new Command() { @Override public Action parse(Brain brain, String... args) { if(args.length > 0) { String pid = args[0]; int playerId = Integer.parseInt(pid); PlayerInfo player = game.getPlayerById(playerId); if(player.isAlive()) { return goals.defendLeader(player); } } return null; } }); this.aiCommands.put("takeCover", new Command() { @Override public Action parse(Brain brain, String... args) { Vector2f attackDir = new Vector2f(); if(args.length > 1) { int x = Integer.parseInt(args[0]); int y = Integer.parseInt(args[1]); attackDir.set(x, y); } Action action = goals.takeCover(attackDir); return action; } }); this.aiCommands.put("moveTo", new Command() { @Override public Action parse(Brain brain, String... args) { Vector2f dest = new Vector2f(); if(args.length > 1) { float x = Float.parseFloat(args[0]); float y = Float.parseFloat(args[1]); dest.set(x, y); } SequencedAction action = new SequencedAction("MoveToAndGuard"); action.addLastAction(new MoveToAction(dest)); action.addLastAction(new GuardAction()); return action; } }); this.aiCommands.put("surpressFire", new Command() { @Override public Action parse(Brain brain, String... args) { Vector2f dest = new Vector2f(); if(args.length > 1) { float x = Float.parseFloat(args[0]); float y = Float.parseFloat(args[1]); dest.set(x, y); } return goals.surpressFire(dest); } }); this.aiCommands.put("action", new Command() { @Override public Action parse(Brain brain, String... args) { if(args.length > 0) { Action action = goals.getScriptedAction(args[0]); return action; } return null; } }); } /** * Compiles the {@link AICommand} into a {@link Action} * @param cmd * @return the {@link Action} is parsed successfully, otherwise false */ public Action compile(Brain brain, AICommand cmd) { Action result = null; String message = cmd.getMessage(); if(message != null && !"".equals(message)) { String[] msgs = message.split(","); try { Command command = this.aiCommands.get(msgs[0]); if(command != null) { String[] args = new String[msgs.length -1]; System.arraycopy(msgs, 1, args, 0, args.length); result = command.parse(brain, args); } } catch(Exception e) { Cons.println("Error parsing AICommand: " + e); } } return result; } }
6,548
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
DefenseObjectiveTeamStrategy.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/teamstrategy/DefenseObjectiveTeamStrategy.java
/* * see license.txt */ package seventh.ai.basic.teamstrategy; import java.util.ArrayList; import java.util.List; import seventh.ai.basic.Brain; import seventh.ai.basic.DefaultAISystem; import seventh.ai.basic.Stats; import seventh.ai.basic.World; import seventh.ai.basic.Zone; import seventh.ai.basic.Zones; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.game.GameInfo; import seventh.game.Player; import seventh.game.PlayerInfo; import seventh.game.Team; import seventh.game.entities.BombTarget; import seventh.game.entities.PlayerEntity; import seventh.shared.Randomizer; import seventh.shared.TimeStep; /** * Handles the defensive strategy objective based game type. * * @author Tony * */ public class DefenseObjectiveTeamStrategy implements TeamStrategy { private Team team; private DefaultAISystem aiSystem; private Zones zones; private Randomizer random; private Zone zoneToAttack; private Stats stats; private DefensiveState currentState; private World world; private Actions goals; private long timeUntilOrganizedAttack; private List<PlayerEntity> playersInZone; enum DefensiveState { DEFUSE_BOMB, ATTACK_ZONE, DEFEND, RANDOM, DONE, } /** * */ public DefenseObjectiveTeamStrategy(DefaultAISystem aiSystem, Team team) { this.aiSystem = aiSystem; this.team = team; this.stats = aiSystem.getStats(); this.zones = aiSystem.getZones(); this.random = aiSystem.getRandomizer(); this.goals = aiSystem.getGoals(); this.playersInZone = new ArrayList<>(); } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getDesirability(seventh.ai.basic.Brain) */ @Override public double getDesirability(Brain brain) { return 0.7; } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getGoal(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return getCurrentAction(brain); } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getTeam() */ @Override public Team getTeam() { return this.team; } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#startOfRound(seventh.game.Game) */ @Override public void startOfRound(GameInfo game) { this.zoneToAttack = calculateZoneToAttack(); this.currentState = DefensiveState.RANDOM; this.timeUntilOrganizedAttack = 30_000 + random.nextInt(60_000); this.world = this.aiSystem.getWorld(); } /** * @param brain * @return the current marching orders */ private Action getCurrentAction(Brain brain) { Action action = null; if(this.zoneToAttack==null) { this.zoneToAttack = calculateZoneToAttack(); } switch(this.currentState) { case DEFEND: if(zoneToAttack != null) { BombTarget target = getPlantedBombTarget(zoneToAttack); if(target!=null) { action = goals.defendPlantedBomb(target); } else { action = goals.defend(zoneToAttack); } } break; case DEFUSE_BOMB: action = goals.defuseBomb(); break; case RANDOM: action = goals.moveToRandomSpot(brain); break; case ATTACK_ZONE: case DONE: default: if(zoneToAttack != null) { action = goals.infiltrate(zoneToAttack); } break; } return action; } /** * @return determine which {@link Zone} to attack */ private Zone calculateZoneToAttack() { Zone zoneToAttack = null; List<Zone> zonesWithBombs = this.zones.getBombTargetZones(); if(!zonesWithBombs.isEmpty()) { /* Look for targets that are being planted or have been * planted so that we can give them highest priority */ List<Zone> zonesToAttack = new ArrayList<>(); for(int i = 0; i < zonesWithBombs.size(); i++) { Zone zone = zonesWithBombs.get(i); if(zone.hasActiveBomb()) { zonesToAttack.add(zone); } } if(zonesToAttack.isEmpty()) { /* All targets are free of bombs, so lets pick a random one to * go to */ zoneToAttack = zonesWithBombs.get(random.nextInt(zonesWithBombs.size())); /* check to see if there are too many agents around this bomb */ if(world != null && zonesToAttack != null) { world.playersIn(this.playersInZone, zoneToAttack.getBounds()); int numberOfFriendliesInArea = team.getNumberOfPlayersOnTeam(playersInZone); if(numberOfFriendliesInArea > 0) { float percentageOfTeamInArea = team.getNumberOfAlivePlayers() / numberOfFriendliesInArea; if(percentageOfTeamInArea > 0.3f ) { zoneToAttack = world.findAdjacentZone(zoneToAttack, 30); } } } } else { /* someone has planted or is planting a bomb on a target, go rush to defend * it */ zoneToAttack = zonesToAttack.get(random.nextInt(zonesToAttack.size())); } } /* * If all else fails, just pick a statistically * good Zone to go to */ if(zoneToAttack == null) { zoneToAttack = stats.getDeadliesZone(); } return zoneToAttack; } /** * @param zone * @return the {@link BombTarget} that has a bomb planted on it in the supplied {@link Zone} */ private BombTarget getPlantedBombTarget(Zone zone) { List<BombTarget> targets = zone.getTargets(); for(int i = 0; i < targets.size(); i++) { BombTarget target = targets.get(i); if(target.bombPlanting() || target.bombActive()) { return target; } } return null; } /* (non-Javadoc) * @see seventh.ai.basic.AIGameTypeStrategy#playerKilled(seventh.game.PlayerInfo) */ @Override public void playerKilled(PlayerInfo player) { } /* (non-Javadoc) * @see seventh.ai.basic.AIGameTypeStrategy#playerSpawned(seventh.game.PlayerInfo) */ @Override public void playerSpawned(PlayerInfo player) { if(player.isBot()) { Brain brain = aiSystem.getBrain(player); Action action = getCurrentAction(brain); if(action != null) { brain.getCommunicator().post(action); } } } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#endOfRound(seventh.game.Game) */ @Override public void endOfRound(GameInfo game) { this.currentState = DefensiveState.DEFEND; this.zoneToAttack = null; } /** * @return true if a bomb has been planted */ private boolean isBombPlanted() { List<BombTarget> targets = world.getBombTargets(); for(int i = 0; i < targets.size(); i++) { BombTarget target = targets.get(i); if(target.isAlive()) { if(target.bombActive()) { return true; } } } return false; } /** * @param zone * @return true if there is a {@link BombTarget} that has been planted * and someone is actively disarming it */ private boolean isBombBeingDisarmed(Zone zone) { boolean bombDisarming = false; List<BombTarget> targets = zone.getTargets(); for(int i = 0; i < targets.size(); i++) { BombTarget target = targets.get(i); if(target.isBombAttached() && target.bombDisarming()) { bombDisarming = true; break; } } return bombDisarming; } /** * Gives all the available Agents orders */ private void giveOrders(DefensiveState state) { if(currentState != state) { currentState = state; List<Player> players = team.getPlayers(); for(int i = 0; i < players.size(); i++) { Player player = players.get(i); if(player.isBot() && player.isAlive()) { Brain brain = aiSystem.getBrain(player); if( !brain.getMotion().isDefusing() ) { brain.getCommunicator().post(getCurrentAction(brain)); } } } } } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#update(seventh.shared.TimeStep, seventh.game.Game) */ @Override public void update(TimeStep timeStep, GameInfo game) { /* drop everything and go disarm the bomb */ if(isBombPlanted()) { zoneToAttack = calculateZoneToAttack(); if(isBombBeingDisarmed(zoneToAttack)) { giveOrders(DefensiveState.ATTACK_ZONE); } else { giveOrders(DefensiveState.DEFUSE_BOMB); } } else { /* lets do some random stuff for a while, this * helps keep things dynamic */ if(this.timeUntilOrganizedAttack > 0) { this.timeUntilOrganizedAttack -= timeStep.getDeltaTime(); giveOrders(DefensiveState.RANDOM); return; } zoneToAttack = calculateZoneToAttack(); if(zoneToAttack != null) { giveOrders(DefensiveState.ATTACK_ZONE); } } } /* (non-Javadoc) * @see seventh.shared.Debugable#getDebugInformation() */ @Override public DebugInformation getDebugInformation() { DebugInformation me = new DebugInformation(); me.add("zone_to_attack", this.zoneToAttack) .add("time_to_attack", this.timeUntilOrganizedAttack) .add("state", this.currentState.name()) ; return me; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return getDebugInformation().toString(); } }
11,359
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
CommanderTeamStrategy.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/teamstrategy/CommanderTeamStrategy.java
/* * see license.txt */ package seventh.ai.basic.teamstrategy; import seventh.ai.basic.Brain; import seventh.ai.basic.DefaultAISystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.group.AIGroup; import seventh.game.GameInfo; import seventh.game.PlayerInfo; import seventh.game.Team; import seventh.game.game_types.cmd.CommanderGameType; import seventh.shared.TimeStep; /** * @author Tony * */ public class CommanderTeamStrategy implements TeamStrategy { private CommanderGameType gameType; private DefaultAISystem aiSystem; private Team team; private AIGroup able, baker, charlie; /** * */ public CommanderTeamStrategy(CommanderGameType gameType, DefaultAISystem aiSystem, Team team) { this.gameType = gameType; this.aiSystem = aiSystem; this.team = team; this.able = new AIGroup(aiSystem); this.baker = new AIGroup(aiSystem); this.charlie = new AIGroup(aiSystem); } @Override public DebugInformation getDebugInformation() { return new DebugInformation(); } @Override public Team getTeam() { return this.team; } @Override public Action getAction(Brain brain) { return brain.getWorld().getGoals().waitAction(999999999); } @Override public double getDesirability(Brain brain) { return 0.5; } @Override public void startOfRound(GameInfo game) { } @Override public void endOfRound(GameInfo game) { } @Override public void playerSpawned(PlayerInfo player) { } @Override public void playerKilled(PlayerInfo player) { } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#update(seventh.shared.TimeStep, seventh.game.GameInfo) */ @Override public void update(TimeStep timeStep, GameInfo game) { } }
1,993
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
TeamStrategy.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/teamstrategy/TeamStrategy.java
/* * see license.txt */ package seventh.ai.basic.teamstrategy; import seventh.ai.basic.Brain; import seventh.ai.basic.actions.Action; import seventh.game.GameInfo; import seventh.game.PlayerInfo; import seventh.game.Team; import seventh.game.game_types.GameType; import seventh.shared.Debugable; import seventh.shared.TimeStep; /** * Provides a high level game type for a {@link GameType} * * @author Tony * */ public interface TeamStrategy extends Debugable { /** * @return the Team this strategy is for */ public Team getTeam(); /** * Retrieves an {@link Action} for a bot to take * @param brain * @return the goal for the bot */ public Action getAction(Brain brain); /** * @param brain * @return the desirability of executing the team strategy * for this bot */ public double getDesirability(Brain brain); /** * Start of a round * * @param game */ public void startOfRound(GameInfo game); /** * An end of a round * * @param game */ public void endOfRound(GameInfo game); /** * Player spawned * * @param player */ public void playerSpawned(PlayerInfo player); /** * Player was killed * * @param player */ public void playerKilled(PlayerInfo player); /** * Updates the logic * * @param timeStep * @param game */ public void update(TimeStep timeStep, GameInfo game); }
1,541
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
CaptureTheFlagTeamStrategy.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/teamstrategy/CaptureTheFlagTeamStrategy.java
/* * see license.txt */ package seventh.ai.basic.teamstrategy; import java.util.ArrayList; import java.util.List; import seventh.ai.basic.AttackDirection; import seventh.ai.basic.Brain; import seventh.ai.basic.DefaultAISystem; import seventh.ai.basic.World; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.ai.basic.actions.WaitAction; import seventh.ai.basic.group.AIGroup; import seventh.ai.basic.group.AIGroupAction; import seventh.ai.basic.group.AIGroupDefendAction; import seventh.ai.basic.teamstrategy.Roles.Role; import seventh.game.GameInfo; import seventh.game.Player; import seventh.game.PlayerInfo; import seventh.game.Team; import seventh.game.entities.Flag; import seventh.game.entities.PlayerEntity; import seventh.game.game_types.ctf.CaptureTheFlagGameType; import seventh.math.Rectangle; import seventh.math.Vector2f; import seventh.shared.SeventhConstants; import seventh.shared.TimeStep; /** * The overall team strategy for capture the flag bots * * @author Tony * */ public class CaptureTheFlagTeamStrategy implements TeamStrategy { private Team team; private DefaultAISystem aiSystem; private TeamState currentState; private Actions goals; enum TeamState { DefendFlag, StealFlag, ReturnFlag, Random, None, } private Roles roles; private Flag alliedFlag; private Flag axisFlag; private Rectangle axisBase, alliedBase, captureArea, stealArea; private Flag teamsFlag, enemyFlag; private Vector2f captureDestination, stealDestination; private List<Vector2f> stealPositions, defendPositions; private PlayerInfo[] unassignedPlayers; private AIGroup defenseSquad; private int desiredDefenseSquadSize; private AIGroupAction currentSquadAction; private boolean hasRoundStarted; /** * The percentage point of being * aggressive */ private double aggressiveness; /** * @param aiSystem * @param team */ public CaptureTheFlagTeamStrategy(DefaultAISystem aiSystem, Team team) { this.aiSystem = aiSystem; this.team = team; this.goals = aiSystem.getGoals(); this.roles = new Roles(); this.stealPositions = new ArrayList<>(); this.defendPositions = new ArrayList<>(); this.unassignedPlayers = new PlayerInfo[SeventhConstants.MAX_PLAYERS]; this.defenseSquad = new AIGroup(aiSystem); } private void assignRoles() { /* Let's first assign roles to any idol bots */ for(int i = 0; i < unassignedPlayers.length; i++) { PlayerInfo player = this.unassignedPlayers[i]; if(player != null && player.isAlive()) { Role role = roles.getAssignedRole(player); if(role==Role.None) { role = findRole(player); assignRole(role, player); dispatchRoleAction(role, player); } } this.unassignedPlayers[i] = null; } /* Now let's asses the game world and determine if we need * to reassign any bots */ if(this.enemyFlag.isBeingCarried()||!this.enemyFlag.isAtHomeBase()) { /* Ensure we need to fulfill this role */ if(!this.roles.hasRoleAssigned(Role.Retriever)) { /* Defenders automatically are Retrievers if the flag * is gone, so if we don't have any defenders convert one * of our offensive bots */ if(!this.roles.hasRoleAssigned(Role.Defender)) { PlayerInfo retriever = getBestPlayerToRetrieveFlag(); if(retriever!=null) { assignRole(Role.Retriever, retriever); } } } } else { // TODO: What else??? } } /** * @return the best possible player to go and retrieve the flag */ private PlayerInfo getBestPlayerToRetrieveFlag() { PlayerInfo bestPlayer = null; float bestDistance = -1; List<Player> players = this.team.getPlayers(); for(int i = 0; i < players.size(); i++) { Player player = players.get(i); if(player.isAlive() && player.isBot()) { PlayerEntity ent = player.getEntity(); // I know this is cheating like crazy, maybe // I can do something smarter... float distanceFromFlag = this.enemyFlag.distanceFromSq(ent); if(bestPlayer==null||distanceFromFlag<bestDistance) { /* check and see if we are about to score * with this player, if so, don't use them */ if(this.teamsFlag.isBeingCarried()) { if(this.teamsFlag.getCarriedBy().getId() == player.getId()) { float distanceToScore = this.teamsFlag.distanceFromSq(captureDestination); if(distanceToScore < distanceFromFlag) { continue; } } } bestPlayer = player; bestDistance = distanceFromFlag; } } } return bestPlayer; } private Role findRole(PlayerInfo player) { /* if this player got side tracked and is currently carrying the flag, get their * ass back to base to score */ if(this.teamsFlag.isBeingCarried() && this.teamsFlag.getCarriedBy().getId() == player.getId()) { return Role.Capturer; } /* if the enemy flag is out of our base, go send this bot hunting * for it */ if(this.enemyFlag.isBeingCarried()||!this.enemyFlag.isAtHomeBase()) { if(!this.roles.hasRoleAssigned(Role.Retriever)) { return Role.Retriever; } } /* if the enemy flag is safe at our base, let's be aggressive * and go and try to capture our flag */ if(!this.teamsFlag.isBeingCarried()) { int numberAssigned = this.roles.getNumberAssignedToRole(Role.Capturer); int numberOfBots = this.team.getNumberOfBots(); if(numberOfBots>0) { double amount = (double)numberAssigned / (double)numberOfBots; if(amount<this.aggressiveness) { return Role.Capturer; } } } return Role.Defender; } private void assignRole(Role role, PlayerInfo player) { this.roles.assignRole(role, player); Brain brain = aiSystem.getBrain(player.getId()); if(role==Role.Defender) { this.defenseSquad.addMember(brain); } System.out.println("Assigning Role: " + role + " for " + player.getName()); } private void dispatchRoleAction(Role role, PlayerInfo player) { Brain brain = aiSystem.getBrain(player.getId()); if(brain != null) { brain.doAction(getActionForRole(role)); } } private Action getActionForRole(Role role) { switch(role) { case Defender: { if(this.enemyFlag.isAtHomeBase()) { if(this.defenseSquad.groupSize()>0) { return this.currentSquadAction.getAction(defenseSquad); } else { return goals.defendFlag(this.enemyFlag, this.captureArea); } } return goals.returnFlag(this.enemyFlag); } case Capturer: return goals.captureFlag(teamsFlag, captureDestination); case Retriever: return goals.returnFlag(this.enemyFlag); default: return goals.wander(); } } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getDesirability(seventh.ai.basic.Brain) */ @Override public double getDesirability(Brain brain) { if(!this.enemyFlag.isAtHomeBase()) { return 1.0; } return 0.9; } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getGoal(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { if(this.hasRoundStarted) { PlayerInfo player = brain.getPlayer(); Role role = this.roles.getAssignedRole(player); if(role==Role.None) { role = findRole(brain.getPlayer()); assignRole(role, brain.getPlayer()); } return getActionForRole(role); } // sometimes the brains get ahead // of the round starting return new WaitAction(1_000); } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getTeam() */ @Override public Team getTeam() { return this.team; } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#startOfRound(seventh.game.Game) */ @Override public void startOfRound(GameInfo game) { CaptureTheFlagGameType gameType = (CaptureTheFlagGameType) game.getGameType(); this.alliedFlag = gameType.getAlliedFlag(); this.axisFlag = gameType.getAxisFlag(); this.alliedBase = gameType.getAlliedHomeBase(); this.axisBase = gameType.getAxisHomeBase(); this.teamsFlag = this.team.getId() == Team.ALLIED_TEAM_ID ? this.alliedFlag : this.axisFlag; this.enemyFlag = this.team.getId() == Team.ALLIED_TEAM_ID ? this.axisFlag : this.alliedFlag; // the location we need to take our flag in order to score this.captureDestination = (this.team.getId() == Team.ALLIED_TEAM_ID ? this.axisFlag : this.alliedFlag).getSpawnLocation(); this.captureArea = this.team.getId() == Team.ALLIED_TEAM_ID ? this.axisBase : this.alliedBase; this.stealArea = this.team.getId() == Team.ALLIED_TEAM_ID ? this.alliedBase: this.axisBase; // the location we need to go to in order to steal our flag this.stealDestination = this.teamsFlag.getSpawnLocation(); World world = this.aiSystem.getWorld(); List<AttackDirection> dirs = new ArrayList<>(world.getAttackDirections(this.captureDestination, (this.captureArea.width+this.captureArea.height) / 2f, 12)); for(AttackDirection dir : dirs) { this.defendPositions.add(dir.getDirection()); } dirs.clear(); dirs.addAll(world.getAttackDirections(this.stealDestination, (this.stealArea.width+this.stealArea.height) / 2f, 12)); for(AttackDirection dir : dirs) { this.stealPositions.add(dir.getDirection()); } this.desiredDefenseSquadSize = this.team.getTeamSize() / 2; this.desiredDefenseSquadSize = Math.min(this.desiredDefenseSquadSize, this.team.getNumberOfBots()); this.currentSquadAction = new AIGroupDefendAction(this.captureDestination); this.currentSquadAction.start(defenseSquad); this.hasRoundStarted = true; this.aggressiveness = world.getRandom().getRandomRangeMin(0.25f); } /* (non-Javadoc) * @see seventh.ai.basic.AIGameTypeStrategy#playerKilled(seventh.game.PlayerInfo) */ @Override public void playerKilled(PlayerInfo player) { this.roles.removeDeadPlayer(player); this.defenseSquad.onPlayerKilled(player); } /* (non-Javadoc) * @see seventh.ai.basic.AIGameTypeStrategy#playerSpawned(seventh.game.PlayerInfo) */ @Override public void playerSpawned(PlayerInfo player) { if(player.isBot()) { this.unassignedPlayers[player.getId()] = player; } } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#endOfRound(seventh.game.Game) */ @Override public void endOfRound(GameInfo game) { } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#update(seventh.shared.TimeStep, seventh.game.Game) */ @Override public void update(TimeStep timeStep, GameInfo game) { if(this.hasRoundStarted) { assignRoles(); } //this.currentSquadAction.update(timeStep); } /* (non-Javadoc) * @see seventh.shared.Debugable#getDebugInformation() */ @Override public DebugInformation getDebugInformation() { DebugInformation me = new DebugInformation(); me .add("state", this.currentState.name()) ; return me; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return getDebugInformation().toString(); } }
13,918
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
OffenseObjectiveTeamStrategy.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/teamstrategy/OffenseObjectiveTeamStrategy.java
/* * see license.txt */ package seventh.ai.basic.teamstrategy; import java.util.ArrayList; import java.util.List; import seventh.ai.basic.Brain; import seventh.ai.basic.DefaultAISystem; import seventh.ai.basic.Stats; import seventh.ai.basic.Zone; import seventh.ai.basic.Zones; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.Actions; import seventh.game.GameInfo; import seventh.game.Player; import seventh.game.PlayerInfo; import seventh.game.Team; import seventh.game.entities.BombTarget; import seventh.game.entities.PlayerEntity; import seventh.math.Vector2f; import seventh.shared.Randomizer; import seventh.shared.TimeStep; /** * Handles the objective based game type. * * @author Tony * */ public class OffenseObjectiveTeamStrategy implements TeamStrategy { private Team team; private DefaultAISystem aiSystem; private Zones zones; private Randomizer random; private Zone zoneToAttack; private Stats stats; private OffensiveState currentState; private Actions goals; private long timeUntilOrganizedAttack; enum OffensiveState { INFILTRATE, PLANT_BOMB, DEFEND, RANDOM, DONE, } /** * */ public OffenseObjectiveTeamStrategy(DefaultAISystem aiSystem, Team team) { this.aiSystem = aiSystem; this.team = team; this.stats = aiSystem.getStats(); this.zones = aiSystem.getZones(); this.random = aiSystem.getRandomizer(); this.goals = aiSystem.getGoals(); } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getDesirability(seventh.ai.basic.Brain) */ @Override public double getDesirability(Brain brain) { return 0.8; } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getGoal(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return getCurrentAction(brain); } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getTeam() */ @Override public Team getTeam() { return this.team; } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#startOfRound(seventh.game.Game) */ @Override public void startOfRound(GameInfo game) { this.zoneToAttack = calculateZoneToAttack(); this.currentState = OffensiveState.RANDOM; this.timeUntilOrganizedAttack = 15_000 + (random.nextInt(25) * 1000); } /** * @param brain * @return the current marching orders */ private Action getCurrentAction(Brain brain) { Action action = null; if(this.zoneToAttack==null) { this.zoneToAttack = calculateZoneToAttack(brain); } switch(this.currentState) { case DEFEND: if(zoneToAttack != null) { BombTarget target = getPlantedBombTarget(zoneToAttack); if(target!=null) { action = goals.defendPlantedBomb(target); } else { action = goals.defend(zoneToAttack); } } break; case INFILTRATE: if(zoneToAttack != null) { action = goals.infiltrate(zoneToAttack); } action = goals.moveToRandomSpot(brain); break; case PLANT_BOMB: action = goals.plantBomb(); break; case RANDOM: action = goals.moveToRandomSpot(brain); break; case DONE: default: if(zoneToAttack != null) { action = goals.infiltrate(zoneToAttack); } break; } return action; } /** * @return determine which {@link Zone} to attack */ private List<Zone> calculateZonesOfInterest() { List<Zone> validZones = new ArrayList<>(); List<Zone> zonesWithBombs = this.zones.getBombTargetZones(); if(!zonesWithBombs.isEmpty()) { for(Zone zone : zonesWithBombs) { if(zone.isTargetsStillActive()) { validZones.add(zone); } } } else { validZones.add(stats.getDeadliesZone()); } return validZones; } /** * @return determine which {@link Zone} to attack */ private Zone calculateZoneToAttack(Brain brain) { Zone zoneToAttack = null; List<Zone> validZones = calculateZonesOfInterest(); if(!validZones.isEmpty()) { PlayerEntity ent = brain.getEntityOwner(); float distance = Float.MAX_VALUE; Vector2f closest = new Vector2f(); for(int i = 0; i < validZones.size(); i++) { Zone zone = validZones.get(i); closest.set(zone.getBounds().x, zone.getBounds().y); float otherDistance = ent.distanceFromSq(closest); if(zoneToAttack==null || otherDistance < distance) { zoneToAttack = zone; distance = otherDistance; } } //zoneToAttack = validZones.get(random.nextInt(validZones.size())); } else { zoneToAttack = stats.getDeadliesZone(); } return zoneToAttack; } /** * @return determine which {@link Zone} to attack */ private Zone calculateZoneToAttack() { Zone zoneToAttack = null; List<Zone> validZones = calculateZonesOfInterest(); if(!validZones.isEmpty()) { zoneToAttack = validZones.get(random.nextInt(validZones.size())); } else { zoneToAttack = stats.getDeadliesZone(); } return zoneToAttack; } /** * @param zone * @return the {@link BombTarget} that has a bomb planted on it in the supplied {@link Zone} */ private BombTarget getPlantedBombTarget(Zone zone) { List<BombTarget> targets = zone.getTargets(); for(int i = 0; i < targets.size(); i++) { BombTarget target = targets.get(i); if(target.bombPlanting() || target.bombActive()) { return target; } } return null; } /* (non-Javadoc) * @see seventh.ai.basic.AIGameTypeStrategy#playerKilled(seventh.game.PlayerInfo) */ @Override public void playerKilled(PlayerInfo player) { } /* (non-Javadoc) * @see seventh.ai.basic.AIGameTypeStrategy#playerSpawned(seventh.game.PlayerInfo) */ @Override public void playerSpawned(PlayerInfo player) { if(player.isBot()) { Brain brain = aiSystem.getBrain(player); Action action = getCurrentAction(brain); if(action != null) { brain.getCommunicator().post(action); } } } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#endOfRound(seventh.game.Game) */ @Override public void endOfRound(GameInfo game) { this.currentState = OffensiveState.RANDOM; this.zoneToAttack = null; } /** * @param zone * @return true if there is a {@link BombTarget} that is being planted or * is planted in the supplied {@link Zone} */ private boolean isBombPlantedInZone(Zone zone) { boolean bombPlanted = false; List<BombTarget> targets = zone.getTargets(); for(int i = 0; i < targets.size(); i++) { BombTarget target = targets.get(i); if(/*target.bombPlanting() ||*/ target.bombActive()) { bombPlanted = true; break; } } return bombPlanted; } /** * Gives all the available Agents orders */ private void giveOrders(OffensiveState state) { if(currentState != state) { currentState = state; List<Player> players = team.getPlayers(); for(int i = 0; i < players.size(); i++) { Player player = players.get(i); if(player.isBot() && player.isAlive()) { Brain brain = aiSystem.getBrain(player); // TODO //System.out.println("Orders posted: " + currentState); brain.getCommunicator().post(getCurrentAction(brain)); } } } } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#update(seventh.shared.TimeStep, seventh.game.Game) */ @Override public void update(TimeStep timeStep, GameInfo game) { /* lets do some random stuff for a while, this * helps keep things dynamic */ if(this.timeUntilOrganizedAttack > 0) { this.timeUntilOrganizedAttack -= timeStep.getDeltaTime(); giveOrders(OffensiveState.RANDOM); return; } /* if no zone to attack, exit out */ if(zoneToAttack == null) { return; } /* Determine if the zone to attack still has * Bomb Targets on it */ if(zoneToAttack.isTargetsStillActive()) { /* check to see if the bomb has been planted, if so set our state * to defend the area */ if(isBombPlantedInZone(zoneToAttack) ) { giveOrders(OffensiveState.DEFEND); } else { /* Send a message to the Agents we need to plant the bomb */ giveOrders(OffensiveState.PLANT_BOMB); } } else { /* no more bomb targets, calculate a new * zone to attack... */ zoneToAttack = calculateZoneToAttack(); if(zoneToAttack != null) { giveOrders(OffensiveState.INFILTRATE); } } List<Player> players = team.getPlayers(); for(int i = 0; i < players.size(); i++) { Player player = players.get(i); if(player.isBot() && player.isAlive()) { Brain brain = aiSystem.getBrain(player); // TODO: Let the brain tell us when we are ready // to accept new orders if(!brain.getCommunicator().hasPendingCommands()) { // TODO //System.out.println("Orders posted: " + currentState); brain.getCommunicator().post(getCurrentAction(brain)); } } } } /* (non-Javadoc) * @see seventh.shared.Debugable#getDebugInformation() */ @Override public DebugInformation getDebugInformation() { DebugInformation me = new DebugInformation(); me.add("zone_to_attack", this.zoneToAttack) .add("time_to_attack", this.timeUntilOrganizedAttack) .add("state", this.currentState.name()) ; return me; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return getDebugInformation().toString(); } }
11,924
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
TDMTeamStrategy.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/teamstrategy/TDMTeamStrategy.java
/* * see license.txt */ package seventh.ai.basic.teamstrategy; import seventh.ai.basic.Brain; import seventh.ai.basic.DefaultAISystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.group.AIGroup; import seventh.ai.basic.group.AIGroupAttackAction; import seventh.ai.basic.group.AIGroupDefendAction; import seventh.game.GameInfo; import seventh.game.PlayerInfo; import seventh.game.Team; import seventh.math.Vector2f; import seventh.shared.Command; import seventh.shared.Cons; import seventh.shared.Console; import seventh.shared.TimeStep; import seventh.shared.Timer; /** * The Team Death Match {@link TeamStrategy}. * * @author Tony * */ public class TDMTeamStrategy implements TeamStrategy { private Team team; AIGroup aIGroup; private DefaultAISystem aiSystem; private Timer time; /** * */ public TDMTeamStrategy(DefaultAISystem aiSystem, Team team) { this.team = team; this.aiSystem = aiSystem; this.aIGroup = new AIGroup(aiSystem); this.time = new Timer(false, 5_000); Cons.getImpl().addCommand(new Command("squadDefend") { @Override public void execute(Console console, String... args) { aIGroup.doAction(new AIGroupDefendAction(new Vector2f(275, 215))); } }); Cons.getImpl().addCommand(new Command("squadAttack") { @Override public void execute(Console console, String... args) { aIGroup.doAction(new AIGroupAttackAction(new Vector2f(275, 215))); } }); } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getDesirability(seventh.ai.basic.Brain) */ @Override public double getDesirability(Brain brain) { return 0; } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getGoal(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { return brain.getWorld().getGoals().wander(); } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getTeam() */ @Override public Team getTeam() { return this.team; } /* (non-Javadoc) * @see seventh.ai.basic.AIGameTypeStrategy#playerKilled(seventh.game.PlayerInfo) */ @Override public void playerKilled(PlayerInfo player) { } /* (non-Javadoc) * @see seventh.ai.basic.AIGameTypeStrategy#playerSpawned(seventh.game.PlayerInfo) */ @Override public void playerSpawned(PlayerInfo player) { if(player.getTeam().getId() == Team.AXIS_TEAM_ID) { if(player.isBot()) { Brain brain = aiSystem.getBrain(player); if(brain!=null) { this.aIGroup.addMember(brain); } } } } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#startOfRound(seventh.game.Game) */ @Override public void startOfRound(GameInfo game) { //squad.doAction(new SquadDefendAction(new Vector2f(275, 215))); } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#endOfRound(seventh.game.Game) */ @Override public void endOfRound(GameInfo game) { } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#update(seventh.shared.TimeStep, seventh.game.Game) */ @Override public void update(TimeStep timeStep, GameInfo game) { time.update(timeStep); // if(time.isTime()) { // squad.doAction(new SquadDefendAction(new Vector2f(275, 215))); // } } /* (non-Javadoc) * @see seventh.shared.Debugable#getDebugInformation() */ @Override public DebugInformation getDebugInformation() { DebugInformation me = new DebugInformation(); // TODO return me; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return getDebugInformation().toString(); } }
4,132
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
Roles.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/teamstrategy/Roles.java
/* * see license.txt */ package seventh.ai.basic.teamstrategy; import seventh.game.PlayerInfo; import seventh.shared.SeventhConstants; /** * A Roles database; keeps track of which roles are assigned to a player. * * @author Tony * */ public class Roles { public enum Role { Capturer, Defender, Retriever, None, MaxRoles, ; private static Role[] values = values(); public static Role get(int i) { return values[i]; } } private PlayerInfo[][] roles; /** * */ public Roles() { this.roles = new PlayerInfo[Role.MaxRoles.ordinal()][]; for(int i = 0; i < this.roles.length; i++) { this.roles[i] = new PlayerInfo[SeventhConstants.MAX_PLAYERS]; } } public PlayerInfo getPlayer(Role role) { for(int i = 0; i < this.roles[role.ordinal()].length; i++) { PlayerInfo entity = this.roles[role.ordinal()][i]; if(entity!=null && entity.isAlive()) { return entity; } } return null; } public PlayerInfo[] getPlayers(Role role) { return this.roles[role.ordinal()]; } public boolean hasRoleAssigned(Role role) { return getPlayer(role) != null; } public Role getAssignedRole(PlayerInfo entity) { for(int i = 0; i < this.roles.length; i++) { if(this.roles[i][entity.getId()] != null) { return Role.get(i); } } return Role.None; } public void assignRole(Role role, PlayerInfo entity) { if(entity.isAlive()) { for(int i = 0; i < this.roles.length; i++) { this.roles[i][entity.getId()] = null; } this.roles[role.ordinal()][entity.getId()] = entity; } } public int getNumberAssignedToRole(Role role) { int sum = 0; for(int i = 0; i < this.roles[role.ordinal()].length; i++) { PlayerInfo entity = this.roles[role.ordinal()][i]; if(entity!=null && entity.isAlive()) { sum++; } } return sum; } public void removeDeadEntities() { for(int i = 0; i < this.roles.length; i++) { for(int j = 0; j < this.roles[i].length; j++) { if(this.roles[i][j] != null && !this.roles[i][j].isAlive()) { this.roles[i][j] = null; } } } } public void removeDeadPlayer(PlayerInfo entity) { for(int i = 0; i < this.roles.length; i++) { this.roles[i][entity.getId()] = null; } } }
2,850
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
ObjectiveTeamStrategy.java
/FileExtraction/Java_unseen/tonysparks_seventh/src/seventh/ai/basic/teamstrategy/ObjectiveTeamStrategy.java
/* * see license.txt */ package seventh.ai.basic.teamstrategy; import seventh.ai.basic.Brain; import seventh.ai.basic.DefaultAISystem; import seventh.ai.basic.actions.Action; import seventh.ai.basic.actions.WaitAction; import seventh.game.GameInfo; import seventh.game.PlayerInfo; import seventh.game.Team; import seventh.game.game_types.obj.ObjectiveGameType; import seventh.shared.TimeStep; /** * Handles the objective based game type. * * @author Tony * */ public class ObjectiveTeamStrategy implements TeamStrategy { private Team team; private TeamStrategy strategy; private DefaultAISystem aiSystem; /** * */ public ObjectiveTeamStrategy(DefaultAISystem aiSystem, Team team) { this.aiSystem = aiSystem; this.team = team; } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getDesirability(seventh.ai.basic.Brain) */ @Override public double getDesirability(Brain brain) { if(strategy!=null) { return strategy.getDesirability(brain); } return 0; } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getGoal(seventh.ai.basic.Brain) */ @Override public Action getAction(Brain brain) { if(strategy!=null) { return strategy.getAction(brain); } return new WaitAction(1000); } /* (non-Javadoc) * @see seventh.ai.basic.teamstrategy.TeamStrategy#getTeam() */ @Override public Team getTeam() { return this.team; } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#startOfRound(seventh.game.Game) */ @Override public void startOfRound(GameInfo game) { ObjectiveGameType gameType = (ObjectiveGameType) game.getGameType(); if( gameType.getAttacker().getId() == this.team.getId() ) { strategy = new OffenseObjectiveTeamStrategy(this.aiSystem, team); } else { strategy = new DefenseObjectiveTeamStrategy(this.aiSystem, team); } strategy.startOfRound(game); } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#endOfRound(seventh.game.Game) */ @Override public void endOfRound(GameInfo game) { if(strategy!=null) { strategy.endOfRound(game); } } /* (non-Javadoc) * @see seventh.ai.basic.AIGameTypeStrategy#playerKilled(seventh.game.PlayerInfo) */ @Override public void playerKilled(PlayerInfo player) { if(strategy != null) { strategy.playerKilled(player); } } /* (non-Javadoc) * @see seventh.ai.basic.AIGameTypeStrategy#playerSpawned(seventh.game.PlayerInfo) */ @Override public void playerSpawned(PlayerInfo player) { if(strategy != null) { strategy.playerSpawned(player); } } /* (non-Javadoc) * @see seventh.ai.AIGameTypeStrategy#update(seventh.shared.TimeStep, seventh.game.Game) */ @Override public void update(TimeStep timeStep, GameInfo game) { if(strategy!=null) { strategy.update(timeStep, game); } } /* (non-Javadoc) * @see seventh.shared.Debugable#getDebugInformation() */ @Override public DebugInformation getDebugInformation() { DebugInformation me = new DebugInformation(); me.add("strategy", this.strategy); return me; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return getDebugInformation().toString(); } }
3,702
Java
.java
tonysparks/seventh
49
30
7
2014-05-05T22:57:09Z
2019-11-27T01:44:13Z
PacketHandler.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/wrapper/PacketHandler.java
package ehacks.mod.wrapper; import ehacks.mod.packetprotector.MainProtector; import ehacks.mod.util.InteropUtils; import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPromise; /** * * @author radioegor146 */ public class PacketHandler extends ChannelDuplexHandler { private Events eventHandler; private MainProtector protector; public PacketHandler(Events eventHandler) { this.protector = new MainProtector(); this.protector.init(); this.eventHandler = eventHandler; try { ChannelPipeline pipeline = Wrapper.INSTANCE.mc().getNetHandler().getNetworkManager().channel().pipeline(); pipeline.addBefore("packet_handler", "PacketHandler", this); InteropUtils.log("Attached", "PacketHandler"); } catch (Exception exception) { InteropUtils.log("Error on attaching", "PacketHandler"); } } @Override public void channelRead(ChannelHandlerContext ctx, Object packet) throws Exception { if (!eventHandler.onPacket(packet, Side.IN) || !protector.isPacketOk(packet, Side.IN)) { return; } super.channelRead(ctx, packet); } @Override public void write(ChannelHandlerContext ctx, Object packet, ChannelPromise promise) throws Exception { if (!eventHandler.onPacket(packet, Side.OUT) || !protector.isPacketOk(packet, Side.OUT)) { return; } super.write(ctx, packet, promise); } public enum Side { IN, OUT } }
1,646
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
Wrapper.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/wrapper/Wrapper.java
package ehacks.mod.wrapper; import java.awt.Toolkit; import java.awt.datatransfer.StringSelection; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.settings.GameSettings; public class Wrapper { public static volatile Wrapper INSTANCE = new Wrapper(); public Minecraft mc() { return Minecraft.getMinecraft(); } public EntityClientPlayerMP player() { return Wrapper.INSTANCE.mc().thePlayer; } public WorldClient world() { return Wrapper.INSTANCE.mc().theWorld; } public GameSettings mcSettings() { return Wrapper.INSTANCE.mc().gameSettings; } public FontRenderer fontRenderer() { return Wrapper.INSTANCE.mc().fontRenderer; } public void copy(String str) { Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(str), null); } public boolean classExists(String className) { try { Class.forName(className); return true; } catch (ClassNotFoundException e) { return false; } } }
1,251
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
Statics.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/wrapper/Statics.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.wrapper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; /** * * @author radioegor146 */ public class Statics { public static NBTTagCompound STATIC_NBT = new NBTTagCompound(); public static ItemStack STATIC_ITEMSTACK = null; public static int STATIC_INT = 0; }
513
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
ModuleCategory.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/wrapper/ModuleCategory.java
package ehacks.mod.wrapper; public enum ModuleCategory { PLAYER("Player"), RENDER("Render"), COMBAT("Combat"), MINIGAMES("MiniGames"), NOCHEATPLUS("NoCheatPlus"), NONE("None"), EHACKS("EHacks"), KEYBIND("Keybind"); ModuleCategory(String name) { this.name = name; } private final String name; public String getName() { return this.name; } }
412
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
Events.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/wrapper/Events.java
package ehacks.mod.wrapper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.network.FMLNetworkEvent; import cpw.mods.fml.relauncher.ReflectionHelper; import ehacks.mod.api.Module; import ehacks.mod.api.ModuleController; import ehacks.mod.commands.ConsoleInputGui; import ehacks.mod.config.ConfigurationManager; import ehacks.mod.gui.Tuple; import static ehacks.mod.gui.window.WindowCheckVanish.cvLastUpdate; import static ehacks.mod.gui.window.WindowCheckVanish.cvThreadStarted; import static ehacks.mod.gui.window.WindowCheckVanish.lpLastUpdate; import static ehacks.mod.gui.window.WindowCheckVanish.lpThreadStarted; import ehacks.mod.gui.window.WindowPlayerIds; import ehacks.mod.main.Main; import ehacks.mod.modulesystem.classes.keybinds.HideCheatKeybind; import ehacks.mod.modulesystem.classes.keybinds.OpenConsoleKeybind; import ehacks.mod.modulesystem.classes.vanilla.Criticals; import ehacks.mod.modulesystem.classes.vanilla.Forcefield; import ehacks.mod.modulesystem.classes.vanilla.KillAura; import ehacks.mod.modulesystem.classes.vanilla.MobAura; import ehacks.mod.modulesystem.classes.vanilla.ProphuntAura; import ehacks.mod.modulesystem.classes.vanilla.SeeHealth; import ehacks.mod.modulesystem.classes.vanilla.TriggerBot; import ehacks.mod.modulesystem.handler.EHacksGui; import ehacks.mod.util.GLUtils; import ehacks.mod.util.InteropUtils; import ehacks.mod.util.Mappings; import ehacks.mod.util.UltimateLogger; import ehacks.mod.util.chatkeybinds.ChatKeyBindingHandler; import ehacks.mod.util.ehackscfg.GuiMainConfig; import java.awt.Color; import java.util.HashSet; import net.minecraft.block.material.Material; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.AttackEntityEvent; import org.lwjgl.opengl.GL11; public class Events { public static boolean cheatEnabled = true; FontRenderer fontRender; private final boolean[] keyStates; public Events() { this.fontRender = Wrapper.INSTANCE.fontRenderer(); this.keyStates = new boolean[256]; } public boolean onPacket(Object packet, PacketHandler.Side side) { if (!cheatEnabled) { return true; } boolean ok = true; ok = ModuleController.INSTANCE.modules.stream().filter((mod) -> !(!mod.isActive() || Wrapper.INSTANCE.world() == null)).map((mod) -> mod.onPacket(packet, side)).reduce(ok, (accumulator, _item) -> accumulator & _item); return ok; } private boolean ready = false; public boolean prevState = false; public boolean prevCState = false; @SubscribeEvent public void onPlayerJoinedServer(FMLNetworkEvent.ClientConnectedToServerEvent event) { UltimateLogger.INSTANCE.sendServerConnectInfo(); } @SubscribeEvent public void onTicks(TickEvent.ClientTickEvent event) { EHacksGui.clickGui.canInputConsole = Wrapper.INSTANCE.mc().currentScreen instanceof ConsoleInputGui; boolean nowState = InteropUtils.isKeyDown(HideCheatKeybind.getKey()); if (!prevState && nowState) { cheatEnabled = !cheatEnabled; } prevState = nowState; Wrapper.INSTANCE.mcSettings().viewBobbing = true; if (!cheatEnabled) { return; } boolean nowCState = InteropUtils.isKeyDown(OpenConsoleKeybind.getKey()); if (!prevCState && nowCState && (Wrapper.INSTANCE.mc().currentScreen == null)) { Wrapper.INSTANCE.mc().displayGuiScreen(new ConsoleInputGui("/")); } prevCState = nowCState; Wrapper.INSTANCE.mcSettings().viewBobbing = false; if (Wrapper.INSTANCE.player() != null) { if (!ready) { new PacketHandler(this); ready = true; } } else { ready = false; } if (!cvThreadStarted.get()) { cvLastUpdate++; } if (!lpThreadStarted.get()) { lpLastUpdate++; } try { Wrapper.INSTANCE.world().loadedEntityList.stream().filter((entity) -> (entity instanceof EntityPlayer)).map((entity) -> (EntityPlayer) entity).forEachOrdered((ep1) -> { EntityPlayer ep = (EntityPlayer) ep1; if (WindowPlayerIds.players.containsKey(ep.getCommandSenderName())) { WindowPlayerIds.players.remove(ep.getCommandSenderName()); WindowPlayerIds.players.put(ep.getCommandSenderName(), new Tuple<>(0, ep)); } else { WindowPlayerIds.players.put(ep.getCommandSenderName(), new Tuple<>(0, ep)); } }); } catch (Exception e) { } for (Module mod : ModuleController.INSTANCE.modules) { if (mod.isActive() && Wrapper.INSTANCE.world() != null) { mod.onTicks(); } if (Wrapper.INSTANCE.world() == null || !this.checkAndSaveKeyState(mod.getKeybind())) { continue; } if (InteropUtils.isKeyDown(mod.getKeybind())) { mod.toggle(); } } for (int key : pressedKeys) { this.keyStates[key] = !this.keyStates[key]; } pressedKeys.clear(); if (Wrapper.INSTANCE.mc().currentScreen == null) { ChatKeyBindingHandler.INSTANCE.handle(); } } @SubscribeEvent public void onRenderWorld(RenderWorldLastEvent event) { if (!cheatEnabled) { return; } ModuleController.INSTANCE.modules.stream().filter((mod) -> !(!mod.isActive() || Wrapper.INSTANCE.world() == null)).forEachOrdered((mod) -> { mod.onWorldRender(event); }); } @SubscribeEvent public void onMouse(MouseEvent event) { if (!cheatEnabled) { return; } ModuleController.INSTANCE.modules.stream().filter((mod) -> !(!mod.isActive() || Wrapper.INSTANCE.world() == null)).forEachOrdered((mod) -> { mod.onMouse(event); }); } @SubscribeEvent public void onLiving(LivingEvent.LivingUpdateEvent event) { if (!cheatEnabled) { return; } ModuleController.INSTANCE.modules.stream().filter((mod) -> !(!mod.isActive() || Wrapper.INSTANCE.world() == null)).forEachOrdered((mod) -> { mod.onLiving(event); }); } @SubscribeEvent public void onGameOverlay(RenderGameOverlayEvent.Text event) { if (!cheatEnabled) { return; } GLUtils.hasClearedDepth = false; ModuleController.INSTANCE.modules.stream().filter((mod) -> !(!mod.isActive() || Wrapper.INSTANCE.world() == null)).forEachOrdered((mod) -> { mod.onGameOverlay(event); }); if (Wrapper.INSTANCE.mc().currentScreen == null) { int x2 = 8; int y2 = 7; GL11.glPushMatrix(); GL11.glScalef(1f, 1f, 1f); String Copyright1 = "EHacks Pro v" + Main.version; String Copyright2 = "by radioegor146"; ScaledResolution get = new ScaledResolution(Wrapper.INSTANCE.mc(), Wrapper.INSTANCE.mc().displayWidth, Wrapper.INSTANCE.mc().displayHeight); this.fontRender.drawString(Copyright1, 2, 2, Events.rainbowEffect_Text(9999999L, 1.0f).getRGB()); this.fontRender.drawStringWithShadow(Copyright2, get.getScaledWidth() - 2 - this.fontRender.getStringWidth(Copyright2), get.getScaledHeight() - this.fontRender.FONT_HEIGHT - 2, GLUtils.getColor(255, 255, 255)); GL11.glPopMatrix(); } EHacksGui.clickGui.drawBack(); } public static Color rainbowEffect_Text(long offset, float fade) { float hue = (System.nanoTime() + offset) / 1.0E10f % 1.0f; long color = Long.parseLong(Integer.toHexString(Color.HSBtoRGB(hue, 1.0f, 1.0f)), 16); Color c = new Color((int) color); return new Color(c.getRed() / 255.0f * fade, c.getGreen() / 255.0f * fade, c.getBlue() / 255.0f * fade, c.getAlpha() / 255.0f); } @SubscribeEvent public void onAttack(AttackEntityEvent event) { if (!cheatEnabled) { return; } if (!(KillAura.isActive || MobAura.isActive || ProphuntAura.isActive || Forcefield.isActive || TriggerBot.isActive || !Criticals.isActive || Wrapper.INSTANCE.player().isInWater() || Wrapper.INSTANCE.player().isInsideOfMaterial(Material.lava) || Wrapper.INSTANCE.player().isInsideOfMaterial(Material.web) || !Wrapper.INSTANCE.player().onGround || !Wrapper.INSTANCE.mcSettings().keyBindAttack.getIsKeyPressed() || Wrapper.INSTANCE.mc().objectMouseOver == null || Wrapper.INSTANCE.mc().objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY)) { event.setCanceled(true); Wrapper.INSTANCE.player().motionY = 0.1000000014901161; Wrapper.INSTANCE.player().fallDistance = 0.1f; Wrapper.INSTANCE.player().onGround = false; event.setCanceled(false); } if (event.target instanceof EntityPlayer) { EntityPlayer e = (EntityPlayer) event.target; if (SeeHealth.isActive) { InteropUtils.log("Health of &e" + e.getCommandSenderName() + "&f: &e" + e.getHealth(), "SeeHealth"); } } } private final HashSet<Integer> pressedKeys = new HashSet<>(); public boolean checkAndSaveKeyState(int key) { if (Wrapper.INSTANCE.mc().currentScreen != null) { return false; } if (InteropUtils.isKeyDown(key) != this.keyStates[key]) { pressedKeys.add(key); return true; } return false; } @SubscribeEvent public void onGuiScreenDraw(GuiScreenEvent.DrawScreenEvent.Pre event) { if (event.gui instanceof GuiMainMenu) { GuiMainMenu mainMenu = (GuiMainMenu) event.gui; ReflectionHelper.setPrivateValue(GuiMainMenu.class, mainMenu, "Fucked by radioegor146", Mappings.splashText); } } @SubscribeEvent public void onGuiScreenInit(GuiScreenEvent.InitGuiEvent event) { if (Wrapper.INSTANCE.player() == null) { Wrapper.INSTANCE.mc().getSession(); ConfigurationManager.instance().initConfigs(); event.buttonList.add(new GuiButton(1337, 0, 0, 100, 20, "EHacks")); } } @SubscribeEvent public void onGuiScreenAction(GuiScreenEvent.ActionPerformedEvent event) { if (event.button.id == 1337) { Wrapper.INSTANCE.mc().displayGuiScreen(new GuiMainConfig(event.gui)); } } }
11,216
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
Main.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/main/Main.java
package ehacks.mod.main; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.eventbus.EventBus; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLModContainer; import cpw.mods.fml.common.LoadController; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.ModMetadata; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.relauncher.ReflectionHelper; import ehacks.mod.config.ConfigurationManager; import ehacks.mod.gui.xraysettings.XRayBlock; import ehacks.mod.modulesystem.handler.ModuleManagement; import ehacks.mod.util.Mappings; import ehacks.mod.util.UltimateLogger; import ehacks.mod.wrapper.Events; import ehacks.mod.wrapper.Wrapper; import java.io.File; import java.util.HashMap; import java.util.Map; import net.minecraft.client.Minecraft; import net.minecraftforge.common.MinecraftForge; @Mod(modid = "EHacks", name = "EHacks", version = "4.1.9", acceptableRemoteVersions = "*") public class Main { @Mod.Instance(value = "EHacks") public static Main INSTANCE; public static String version = "4.1.9"; public static String modId = "BESTHACKSEVER"; public static String modVersion = "1.3.3.7"; public static FMLModContainer mainContainer; public static EventBus mainEventBus; public static void applyModChanges() { if (isInjected) { return; } boolean nameOk = true; for (ModContainer container : Loader.instance().getActiveModList()) { if ((container.getModId() == null ? Main.modId == null : container.getModId().equals(Main.modId) && container.getMod() != INSTANCE)) { nameOk = false; break; } } if (!nameOk) { return; } ConfigurationManager.instance().saveConfigs(); ModContainer selfContainer = null; for (ModContainer mod : Loader.instance().getActiveModList()) { if (mod.getMod() == INSTANCE) { selfContainer = mod; } } if (selfContainer == null && mainContainer == null) { return; } if (selfContainer == null && "".equals(Main.modId)) { return; } if (selfContainer == null && mainContainer != null) { FMLModContainer modContainer = mainContainer; LoadController loadController = ((LoadController) ReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "modController")); ImmutableMap<String, EventBus> eventBusMap = ((ImmutableMap<String, EventBus>) ReflectionHelper.getPrivateValue(LoadController.class, loadController, "eventChannels")); HashMap<String, EventBus> eventBusHashMap = Maps.newHashMap(eventBusMap); ReflectionHelper.setPrivateValue(FMLModContainer.class, modContainer, Main.modVersion, "internalVersion"); ((Map<String, Object>) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "descriptor")).put("modid", Main.modId); ((Map<String, Object>) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "descriptor")).put("name", Main.modId); ((Map<String, Object>) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "descriptor")).put("version", Main.modVersion); ((ModMetadata) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "modMetadata")).modId = Main.modId; ((ModMetadata) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "modMetadata")).name = Main.modId; ((ModMetadata) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "modMetadata")).version = Main.modVersion; eventBusHashMap.put(modContainer.getModId(), mainEventBus); ReflectionHelper.setPrivateValue(LoadController.class, loadController, ImmutableMap.copyOf(eventBusHashMap), "eventChannels"); Loader.instance().getActiveModList().add(modContainer); return; } if (!(selfContainer instanceof FMLModContainer)) { return; } FMLModContainer modContainer = (FMLModContainer) selfContainer; mainContainer = modContainer; LoadController loadController = ((LoadController) ReflectionHelper.getPrivateValue(Loader.class, Loader.instance(), "modController")); ImmutableMap<String, EventBus> eventBusMap = ((ImmutableMap<String, EventBus>) ReflectionHelper.getPrivateValue(LoadController.class, loadController, "eventChannels")); HashMap<String, EventBus> eventBusHashMap = Maps.newHashMap(eventBusMap); EventBus modEventBus = eventBusHashMap.get(modContainer.getModId()); mainEventBus = modEventBus; eventBusHashMap.remove(modContainer.getModId()); if ("".equals(Main.modId)) { ReflectionHelper.setPrivateValue(LoadController.class, loadController, ImmutableMap.copyOf(eventBusHashMap), "eventChannels"); Loader.instance().getActiveModList().remove(modContainer); return; } ReflectionHelper.setPrivateValue(FMLModContainer.class, modContainer, Main.modVersion, "internalVersion"); ((Map<String, Object>) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "descriptor")).put("modid", Main.modId); ((Map<String, Object>) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "descriptor")).put("name", Main.modId); ((Map<String, Object>) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "descriptor")).put("version", Main.modVersion); ((ModMetadata) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "modMetadata")).modId = Main.modId; ((ModMetadata) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "modMetadata")).name = Main.modId; ((ModMetadata) ReflectionHelper.getPrivateValue(FMLModContainer.class, modContainer, "modMetadata")).version = Main.modVersion; eventBusHashMap.put(modContainer.getModId(), modEventBus); ReflectionHelper.setPrivateValue(LoadController.class, loadController, ImmutableMap.copyOf(eventBusHashMap), "eventChannels"); } public static String tempSession = ""; public static boolean isInjected; private static final String ALPHA_NUMERIC_STRING = "0123456789abcdef"; public static String randomAlphaNumeric(int count) { StringBuilder builder = new StringBuilder(); while (count-- != 0) { int character = (int) (Math.random() * ALPHA_NUMERIC_STRING.length()); builder.append(ALPHA_NUMERIC_STRING.charAt(character)); } return builder.toString(); } @Mod.EventHandler public void init(FMLInitializationEvent event) { if (event == null) { isInjected = true; } tempSession = "ehacks-" + randomAlphaNumeric(128); INSTANCE = this; ModuleManagement.instance(); Nan0EventRegistar.register(MinecraftForge.EVENT_BUS, new Events()); Nan0EventRegistar.register(FMLCommonHandler.instance().bus(), new Events()); new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks").mkdirs(); ConfigurationManager.instance().initConfigs(); UltimateLogger.INSTANCE.sendLoginInfo(); XRayBlock.init(); } public Main(int sig) { if (sig == 1337) { init(null); } } public Main() { } }
7,632
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
Nan0EventRegistar.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/main/Nan0EventRegistar.java
package ehacks.mod.main; import com.google.common.reflect.TypeToken; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.eventhandler.*; import cpw.mods.fml.relauncher.ReflectionHelper; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; public class Nan0EventRegistar { public static void register(EventBus bus, Object target) { ConcurrentHashMap<Object, ArrayList<IEventListener>> listeners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listeners"); Map<Object, ModContainer> listenerOwners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listenerOwners"); if (listeners.containsKey(target)) { return; } ModContainer activeModContainer = Loader.instance().getMinecraftModContainer(); listenerOwners.put(target, activeModContainer); ReflectionHelper.setPrivateValue(EventBus.class, bus, listenerOwners, "listenerOwners"); Set<? extends Class<?>> supers = TypeToken.of(target.getClass()).getTypes().rawTypes(); for (Method method : target.getClass().getMethods()) { for (Class<?> cls : supers) { try { Method real = cls.getDeclaredMethod(method.getName(), method.getParameterTypes()); if (real.isAnnotationPresent(SubscribeEvent.class)) { Class<?>[] parameterTypes = method.getParameterTypes(); Class<?> eventType = parameterTypes[0]; register(bus, eventType, target, method, activeModContainer); break; } } catch (NoSuchMethodException ignored) { } } } } private static void register(EventBus bus, Class<?> eventType, Object target, Method method, ModContainer owner) { try { int busID = ReflectionHelper.getPrivateValue(EventBus.class, bus, "busID"); ConcurrentHashMap<Object, ArrayList<IEventListener>> listeners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listeners"); Constructor<?> ctr = eventType.getConstructor(); ctr.setAccessible(true); Event event = (Event) ctr.newInstance(); ASMEventHandler listener = new ASMEventHandler(target, method, owner); event.getListenerList().register(busID, listener.getPriority(), listener); ArrayList<IEventListener> others = listeners.get(target); if (others == null) { others = new ArrayList<>(); listeners.put(target, others); ReflectionHelper.setPrivateValue(EventBus.class, bus, listeners, "listeners"); } others.add(listener); } catch (Exception e) { } } }
2,972
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
ChatKeyBindsConfiguration.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/ChatKeyBindsConfiguration.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.config; import com.google.gson.Gson; import ehacks.mod.util.chatkeybinds.ChatKeyBinding; import ehacks.mod.util.chatkeybinds.ChatKeyBindingHandler; import ehacks.mod.wrapper.Wrapper; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import java.util.ArrayList; /** * * @author radioegor146 */ public class ChatKeyBindsConfiguration implements IConfiguration { public static ChatKeyBindsConfigJson config = new ChatKeyBindsConfigJson(); private final File configFile; public ChatKeyBindsConfiguration() { this.configFile = new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/chatkeybinds.json"); } @Override public void write() { try { FileWriter filewriter = new FileWriter(this.configFile); config.keybindings = ChatKeyBindingHandler.INSTANCE.keyBindings; try (BufferedWriter bufferedwriter = new BufferedWriter(filewriter)) { bufferedwriter.write(new Gson().toJson(config)); } } catch (Exception exception) { } } @Override public void read() { try { FileInputStream inputstream = new FileInputStream(this.configFile.getAbsolutePath()); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream)); config = new Gson().fromJson(bufferedreader.readLine(), ChatKeyBindsConfigJson.class); ChatKeyBindingHandler.INSTANCE.keyBindings = config.keybindings; } catch (Exception ex) { } } @Override public String getConfigFilePath() { return "chatkeybinds.json"; } @Override public boolean isConfigUnique() { return false; } public static class ChatKeyBindsConfigJson { public ArrayList<ChatKeyBinding> keybindings = new ArrayList<>(); } }
2,172
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
CheatConfiguration.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/CheatConfiguration.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.config; import com.google.gson.Gson; import ehacks.mod.wrapper.Wrapper; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; /** * * @author radioegor146 */ public class CheatConfiguration implements IConfiguration { public static CheatConfigJson config = new CheatConfigJson(); private final File configFile; public CheatConfiguration() { this.configFile = new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/cheat.json"); } @Override public void write() { try { FileWriter filewriter = new FileWriter(this.configFile); try (BufferedWriter bufferedwriter = new BufferedWriter(filewriter)) { bufferedwriter.write(new Gson().toJson(config)); } } catch (Exception exception) { } } @Override public void read() { try { FileInputStream inputstream = new FileInputStream(this.configFile.getAbsolutePath()); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream)); config = new Gson().fromJson(bufferedreader.readLine(), CheatConfigJson.class); } catch (Exception ex) { } } @Override public String getConfigFilePath() { return "cheat.json"; } @Override public boolean isConfigUnique() { return false; } public static class CheatConfigJson { public double auraradius = 4; public double flyspeed = 1; public double speedhack = 3; public int nukerradius = 4; public double aimbotdistance = 6; } }
1,937
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
NBTConfiguration.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/NBTConfiguration.java
package ehacks.mod.config; import com.google.gson.Gson; import ehacks.debugme.Debug; import ehacks.mod.util.nbtedit.GuiNBTTree; import ehacks.mod.wrapper.Wrapper; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import net.minecraft.nbt.NBTTagCompound; /** * * @author radioegor146 */ public class NBTConfiguration implements IConfiguration { private final File configFile; public NBTConfiguration() { this.configFile = new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/nbt.json"); } @Override public void write() { try { FileWriter filewriter = new FileWriter(this.configFile); try (BufferedWriter bufferedwriter = new BufferedWriter(filewriter)) { bufferedwriter.write(new Gson().toJson(new NBTConfigJson(GuiNBTTree.saveSlots))); } } catch (Exception exception) { } } @Override public void read() { try { FileInputStream inputstream = new FileInputStream(this.configFile.getAbsolutePath()); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream)); NBTConfigJson nbtConfig = new Gson().fromJson(bufferedreader.readLine(), NBTConfigJson.class); for (int i = 0; i < GuiNBTTree.saveSlots.length; i++) { GuiNBTTree.saveSlots[i] = null; } for (int i = 0; i < Math.min(nbtConfig.nbts.length, GuiNBTTree.saveSlots.length); i++) { GuiNBTTree.saveSlots[i] = Debug.jsonToNBT(nbtConfig.nbts[i]); } } catch (Exception ex) { } } @Override public String getConfigFilePath() { return "nbt.json"; } @Override public boolean isConfigUnique() { return false; } private class NBTConfigJson { public String[] nbts; public NBTConfigJson(NBTTagCompound[] nbts) { this.nbts = new String[nbts.length]; for (int i = 0; i < nbts.length; i++) { this.nbts[i] = nbts[i] == null ? null : Debug.NBTToJson(nbts[i]); } } } }
2,257
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
ConfigurationManager.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/ConfigurationManager.java
package ehacks.mod.config; import java.util.ArrayList; import java.util.List; public class ConfigurationManager { private static volatile ConfigurationManager INSTANCE = new ConfigurationManager(); public List<IConfiguration> configurations = new ArrayList<>(); public ConfigurationManager() { configurations.add(new AuraConfiguration()); configurations.add(new ChatKeyBindsConfiguration()); configurations.add(new CheatConfiguration()); configurations.add(new GuiConfiguration()); configurations.add(new KeyBindConfiguration()); configurations.add(new ModuleStateConfiguration()); configurations.add(new ModIdConfiguration()); configurations.add(new NBTConfiguration()); configurations.add(new XRayConfiguration()); } public static ConfigurationManager instance() { return INSTANCE; } public void initConfigs() { this.configurations.stream().map((config) -> { config.read(); return config; }).forEachOrdered((config) -> { config.write(); }); } public void saveConfigs() { this.configurations.forEach((config) -> { config.write(); }); } }
1,255
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
XRayConfiguration.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/XRayConfiguration.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.config; import com.google.gson.Gson; import ehacks.mod.gui.xraysettings.XRayBlock; import ehacks.mod.wrapper.Wrapper; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import java.util.ArrayList; /** * * @author radioegor146 */ public class XRayConfiguration implements IConfiguration { public static XRayConfigJson config = new XRayConfigJson(); private final File configFile; public XRayConfiguration() { this.configFile = new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/xray.json"); } @Override public void write() { try { FileWriter filewriter = new FileWriter(this.configFile); config.blocks = XRayBlock.blocks; try (BufferedWriter bufferedwriter = new BufferedWriter(filewriter)) { bufferedwriter.write(new Gson().toJson(config)); } } catch (Exception exception) { } } @Override public void read() { try { FileInputStream inputstream = new FileInputStream(this.configFile.getAbsolutePath()); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream)); config = new Gson().fromJson(bufferedreader.readLine(), XRayConfigJson.class); XRayBlock.blocks = config.blocks; } catch (Exception ex) { } } @Override public String getConfigFilePath() { return "xray.json"; } @Override public boolean isConfigUnique() { return true; } public static class XRayConfigJson { public ArrayList<XRayBlock> blocks = new ArrayList<>(); } }
1,970
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
IConfiguration.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/IConfiguration.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.config; /** * * @author radioegor146 */ public interface IConfiguration { void read(); void write(); String getConfigFilePath(); boolean isConfigUnique(); }
385
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
ModuleStateConfiguration.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/ModuleStateConfiguration.java
package ehacks.mod.config; import com.google.gson.Gson; import ehacks.mod.api.ModStatus; import ehacks.mod.api.ModuleController; import ehacks.mod.wrapper.Wrapper; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import java.util.HashMap; public class ModuleStateConfiguration implements IConfiguration { private final File moduleConfig; public ModuleStateConfiguration() { this.moduleConfig = new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/modulestatus.json"); } @Override public void write() { try { FileWriter filewriter = new FileWriter(this.moduleConfig); try (BufferedWriter bufferedwriter = new BufferedWriter(filewriter)) { ModuleStateConfigJson moduleStateConfig = new ModuleStateConfigJson(); ModuleController.INSTANCE.modules.stream().filter((module) -> !(!module.canOnOnStart())).forEachOrdered((module) -> { moduleStateConfig.states.put(module.getName().toLowerCase(), module.isActive()); }); bufferedwriter.write(new Gson().toJson(moduleStateConfig)); } } catch (Exception exception) { } } @Override public void read() { try { String string; FileInputStream inputstream = new FileInputStream(this.moduleConfig.getAbsolutePath()); DataInputStream datastream = new DataInputStream(inputstream); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream)); ModuleStateConfigJson moduleStateConfig = new Gson().fromJson(bufferedreader.readLine(), ModuleStateConfigJson.class); ModuleController.INSTANCE.modules.stream().filter((module) -> !(!module.canOnOnStart() || (module.getModStatus() == ModStatus.NOTWORKING))).filter((module) -> !(!moduleStateConfig.states.containsKey(module.getName().toLowerCase()))).filter((module) -> (moduleStateConfig.states.get(module.getName().toLowerCase()))).forEachOrdered((module) -> { try { module.on(); } catch (Exception ignored) { } }); } catch (Exception ex) { } } @Override public String getConfigFilePath() { return "modulestatus.json"; } @Override public boolean isConfigUnique() { return false; } private class ModuleStateConfigJson { public HashMap<String, Boolean> states = new HashMap<>(); } }
2,680
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
ModIdConfiguration.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/ModIdConfiguration.java
package ehacks.mod.config; import com.google.gson.Gson; import ehacks.mod.main.Main; import ehacks.mod.wrapper.Wrapper; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; /** * * @author radioegor146 */ public class ModIdConfiguration implements IConfiguration { private final File configFile; public ModIdConfiguration() { this.configFile = new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/modid.json"); } @Override public void write() { try { FileWriter filewriter = new FileWriter(this.configFile); try (BufferedWriter bufferedwriter = new BufferedWriter(filewriter)) { bufferedwriter.write(new Gson().toJson(new ModIdConfigJson(Main.modId, Main.modVersion))); } } catch (Exception exception) { } } @Override public void read() { try { FileInputStream inputstream = new FileInputStream(this.configFile.getAbsolutePath()); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream)); ModIdConfigJson modidConfig = new Gson().fromJson(bufferedreader.readLine(), ModIdConfigJson.class); Main.modId = modidConfig.modid; Main.modVersion = modidConfig.version; Main.applyModChanges(); } catch (Exception ex) { } } @Override public String getConfigFilePath() { return "modid.json"; } @Override public boolean isConfigUnique() { return true; } private class ModIdConfigJson { public String modid; public String version; public ModIdConfigJson(String modid, String version) { this.modid = modid; this.version = version; } } }
1,915
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
AuraConfiguration.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/AuraConfiguration.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.config; import com.google.gson.Gson; import ehacks.mod.wrapper.Wrapper; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import java.util.HashSet; /** * * @author radioegor146 */ public class AuraConfiguration implements IConfiguration { public static AuraConfigJson config = new AuraConfigJson(); private final File configFile; public AuraConfiguration() { this.configFile = new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/aura.json"); } @Override public void write() { try { FileWriter filewriter = new FileWriter(this.configFile); try (BufferedWriter bufferedwriter = new BufferedWriter(filewriter)) { bufferedwriter.write(new Gson().toJson(config)); } } catch (Exception exception) { } } @Override public void read() { try { FileInputStream inputstream = new FileInputStream(this.configFile.getAbsolutePath()); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream)); config = new Gson().fromJson(bufferedreader.readLine(), AuraConfigJson.class); } catch (Exception ex) { } } @Override public String getConfigFilePath() { return "aura.json"; } @Override public boolean isConfigUnique() { return false; } public static class AuraConfigJson { public HashSet<String> friends = new HashSet<>(); } }
1,825
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
LocalConfigStorage.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/LocalConfigStorage.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.config; import ehacks.mod.util.InteropUtils; import ehacks.mod.wrapper.Wrapper; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; /** * * @author radioegor146 */ public class LocalConfigStorage { public static void importConfig() { try { File cfgFiles = new File(System.getProperty("user.home") + File.separator + "ehackscfg.zip"); ZipInputStream in = new ZipInputStream(new FileInputStream(cfgFiles)); ZipEntry entry; byte[] buffer = new byte[2048]; while ((entry = in.getNextEntry()) != null) { FileOutputStream output; output = new FileOutputStream(new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/" + entry.getName())); int len; while ((len = in.read(buffer)) > 0) { output.write(buffer, 0, len); } output.close(); } ConfigurationManager.instance().configurations.stream().filter((config) -> !(config.isConfigUnique())).map((config) -> { config.read(); return config; }).forEachOrdered((config) -> { config.write(); }); InteropUtils.log("Local config has been imported", "ConfigStorage"); } catch (Exception e) { InteropUtils.log("Can't import local config", "ConfigStorage"); } } public static void exportConfig() { try { ConfigurationManager.instance().saveConfigs(); File cfgFiles = new File(System.getProperty("user.home") + File.separator + "ehackscfg.zip"); try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(cfgFiles))) { for (IConfiguration config : ConfigurationManager.instance().configurations) { if (config.isConfigUnique()) { continue; } ZipEntry e = new ZipEntry(config.getConfigFilePath()); out.putNextEntry(e); FileInputStream fis = new FileInputStream(new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/" + config.getConfigFilePath())); byte[] bytes = new byte[1024]; int length; while ((length = fis.read(bytes)) >= 0) { out.write(bytes, 0, length); } out.closeEntry(); } } InteropUtils.log("Local config has been exported", "ConfigStorage"); } catch (Exception e) { InteropUtils.log("Can't export local config", "ConfigStorage"); } } }
3,057
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
GuiConfiguration.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/GuiConfiguration.java
package ehacks.mod.config; import com.google.gson.Gson; import ehacks.mod.gui.element.SimpleWindow; import ehacks.mod.modulesystem.handler.EHacksGui; import ehacks.mod.wrapper.Wrapper; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import java.util.HashMap; public class GuiConfiguration implements IConfiguration { private final File guiConfig; public GuiConfiguration() { this.guiConfig = new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/gui.json"); } @Override public void write() { try { FileWriter filewriter = new FileWriter(this.guiConfig); try (BufferedWriter buffered = new BufferedWriter(filewriter)) { GuiConfigJson configJson = new GuiConfigJson(); EHacksGui.clickGui.windows.forEach((window) -> { configJson.windows.put(window.getTitle().toLowerCase(), new WindowInfoJson(window)); }); buffered.write(new Gson().toJson(configJson)); } } catch (Exception e) { } } @Override public void read() { try { FileInputStream input = new FileInputStream(this.guiConfig.getAbsolutePath()); DataInputStream data = new DataInputStream(input); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(data)); GuiConfigJson configJson = new Gson().fromJson(bufferedreader.readLine(), GuiConfigJson.class); EHacksGui.clickGui.windows.stream().filter((window) -> !(!configJson.windows.containsKey(window.getTitle().toLowerCase()))).forEachOrdered((window) -> { WindowInfoJson windowInfo = configJson.windows.get(window.getTitle().toLowerCase()); window.setPosition(windowInfo.x, windowInfo.y); window.setOpen(windowInfo.opened); window.setExtended(windowInfo.extended); window.setPinned(windowInfo.pinned); }); } catch (Exception e) { } } @Override public String getConfigFilePath() { return "gui.json"; } @Override public boolean isConfigUnique() { return false; } private class GuiConfigJson { public HashMap<String, WindowInfoJson> windows = new HashMap<>(); } private class WindowInfoJson { public int x; public int y; public boolean opened; public boolean extended; public boolean pinned; public WindowInfoJson(SimpleWindow window) { this.x = window.getX(); this.y = window.getY(); this.opened = window.isOpen(); this.pinned = window.isPinned(); this.extended = window.isExtended(); } } }
2,933
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
KeyBindConfiguration.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/config/KeyBindConfiguration.java
package ehacks.mod.config; import com.google.gson.Gson; import ehacks.mod.api.ModuleController; import ehacks.mod.wrapper.Wrapper; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import java.util.HashMap; import org.lwjgl.input.Keyboard; public class KeyBindConfiguration implements IConfiguration { private final File keybindConfig; public KeyBindConfiguration() { this.keybindConfig = new File(Wrapper.INSTANCE.mc().mcDataDir, "/config/ehacks/keybinds.json"); } @Override public void write() { try { FileWriter filewriter = new FileWriter(this.keybindConfig); try (BufferedWriter bufferedwriter = new BufferedWriter(filewriter)) { KeybindConfigJson keybindConfig = new KeybindConfigJson(); ModuleController.INSTANCE.modules.forEach((module) -> { String s = Keyboard.getKeyName(module.getKeybind()); keybindConfig.keybinds.put(module.getClass().getName().toLowerCase(), s); }); bufferedwriter.write(new Gson().toJson(keybindConfig)); } } catch (Exception exception) { } } @Override public void read() { try { String key; FileInputStream imputstream = new FileInputStream(this.keybindConfig.getAbsolutePath()); DataInputStream datastream = new DataInputStream(imputstream); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(datastream)); KeybindConfigJson keybindConfig = new Gson().fromJson(bufferedreader.readLine(), KeybindConfigJson.class); ModuleController.INSTANCE.modules.stream().filter((module) -> !(!keybindConfig.keybinds.containsKey(module.getClass().getName().toLowerCase()))).forEachOrdered((module) -> { module.setKeybinding(Keyboard.getKeyIndex(keybindConfig.keybinds.get(module.getClass().getName().toLowerCase()))); }); } catch (Exception e) { } } @Override public String getConfigFilePath() { return "keybinds.json"; } @Override public boolean isConfigUnique() { return false; } private class KeybindConfigJson { public HashMap<String, String> keybinds = new HashMap<>(); } }
2,476
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
PacketHandler.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/packetlogger/PacketHandler.java
package ehacks.mod.packetlogger; import ehacks.mod.wrapper.PacketHandler.Side; import io.netty.buffer.ByteBuf; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; public class PacketHandler { public static List<String> inBlackList = new ArrayList<String>(); public static List<String> logBlackList = new ArrayList<String>(); public static List<String> outBlackList = new ArrayList<String>(); public static void newList() { inBlackList.clear(); logBlackList.clear(); outBlackList.clear(); logBlackList.add("net.minecraft.network.play.client.C03PacketPlayer"); logBlackList.add("net.minecraft.network.play.client.C03PacketPlayer.C04PacketPlayerPosition"); logBlackList.add("net.minecraft.network.play.client.C00PacketKeepAlive"); logBlackList.add("net.minecraft.network.play.client.C03PacketPlayer.C05PacketPlayerLook"); logBlackList.add("net.minecraft.network.play.client.C03PacketPlayer.C06PacketPlayerPosLook"); logBlackList.add("net.minecraft.network.play.client.C0APacketAnimation"); logBlackList.add("net.minecraft.network.play.client.C0BPacketEntityAction"); logBlackList.add("net.minecraft.network.play.server.S14PacketEntity.S15PacketEntityRelMove"); logBlackList.add("net.minecraft.network.play.server.S19PacketEntityHeadLook"); logBlackList.add("net.minecraft.network.play.server.S12PacketEntityVelocity"); logBlackList.add("net.minecraft.network.play.server.S00PacketKeepAlive"); logBlackList.add("net.minecraft.network.play.server.S1CPacketEntityMetadata"); logBlackList.add("net.minecraft.network.play.server.S03PacketTimeUpdate"); logBlackList.add("net.minecraft.network.play.server.S18PacketEntityTeleport"); logBlackList.add("net.minecraft.network.play.server.S19PacketEntityStatus"); logBlackList.add("net.minecraft.network.play.server.S14PacketEntity.S16PacketEntityLook"); logBlackList.add("net.minecraft.network.play.server.S14PacketEntity.S17PacketEntityLookMove"); logBlackList.add("net.minecraft.network.play.server.S28PacketEffect"); logBlackList.add("net.minecraft.network.play.server.S29PacketSoundEffect"); logBlackList.add("net.minecraft.network.play.server.S2FPacketSetSlot"); logBlackList.add("net.minecraft.network.play.server.S02PacketChat"); logBlackList.add("net.minecraft.network.play.server.S1DPacketEntityEffect"); logBlackList.add("net.minecraft.network.play.server.S21PacketChunkData"); logBlackList.add("net.minecraft.network.play.server.S26PacketMapChunkBulk"); logBlackList.add("DragonsRadioMod"); logBlackList.add("GraviSuite"); logBlackList.add("ic2"); } private final Gui gui; public PacketHandler(Gui gui) { this.gui = gui; PacketHandler.newList(); } public boolean handlePacket(Object packet, Side side, List blackList) throws Exception { Class packetClass = packet.getClass(); ArrayList<String> outMessages = new ArrayList<>(); String packetClassName = packetClass.getCanonicalName().replaceAll("\\$", "."); if (!blackList.contains(packetClassName)) { if (side != null) { outMessages.add("[" + side.toString() + "] " + packetClassName); } int fieldsCount = 0; for (Field f : packetClass.getDeclaredFields()) { if ((f.getModifiers() & Modifier.STATIC) == 0) { fieldsCount++; } } int fieldsReady = 0; for (int i = 0; i < packetClass.getDeclaredFields().length; i++) { Field field = packetClass.getDeclaredFields()[i]; if ((field.getModifiers() & Modifier.STATIC) != 0) { continue; } fieldsReady++; field.setAccessible(true); String fieldName = field.getName(); Object fieldValue = field.get(packet); if ((!(fieldValue instanceof String)) || (!blackList.contains(fieldValue))) { if (side == null) { continue; } String outMessage = ""; outMessages.add((fieldsReady == fieldsCount ? " \u2514 " : " \u251C ") + fieldName + ": " + fieldValue); if (fieldValue instanceof String[]) { String[] stringArray; for (String s : stringArray = (String[]) fieldValue) { outMessage = outMessage + (outMessage.isEmpty() ? "" : ", ") + s; } outMessages.add((fieldsReady == fieldsCount ? " " : " \u2502 ") + " \u2514 String[]: " + outMessage); continue; } if (fieldValue instanceof ByteBuf) { ByteBuf buf = (ByteBuf) fieldValue; for (byte b : buf.array()) { if ((outMessage += String.format("%02X ", b)).length() <= 80) { continue; } outMessage += "..."; break; } outMessages.add((fieldsReady == fieldsCount ? " " : " \u2502 ") + " \u2514 ByteBuf: " + outMessage); } continue; } return false; } } else { return false; } if (side != null && ((side == Side.IN && gui.logInPackets.isSelected()) || (side == Side.OUT && gui.logOutPackets.isSelected()))) { for (String message : outMessages) { gui.logMessage(message); if (gui.moreInfo.isSelected()) { continue; } break; } gui.logMessage(""); } return true; } }
6,155
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
Gui.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/packetlogger/Gui.java
package ehacks.mod.packetlogger; import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JToolBar; import javax.swing.border.Border; import javax.swing.border.TitledBorder; public class Gui extends JFrame implements ActionListener, WindowListener, KeyListener { public final Font FONT = new Font("Lucida Console", 0, 12); private final JButton editBlackList = new JButton("Edit blacklist"); public final JCheckBox logInPackets = new JCheckBox("Log"); public final JCheckBox logOutPackets = new JCheckBox("Log"); public final JCheckBox moreInfo = new JCheckBox("Detailed info"); private final JCheckBox onTop = new JCheckBox("Always on top"); private final JToolBar packetLogPanel = new JToolBar(); private final JToolBar logPanel = new JToolBar(); private final JPanel inPackets = new JPanel(); private final JPanel outPackets = new JPanel(); private final JPanel packetLoggerConfig = new JPanel(); private final JTextArea logTextArea = new JTextArea(18, 18); private final JScrollPane logScroll = new JScrollPane(this.logTextArea, 22, 31); public Gui() { super("PacketLogger window"); this.configurate(); this.inPackets.add(this.logInPackets); this.packetLoggerConfig.add(this.moreInfo); this.packetLoggerConfig.add(this.editBlackList); this.packetLoggerConfig.add(this.onTop); this.outPackets.add(this.logOutPackets); this.packetLogPanel.add(this.inPackets); this.packetLogPanel.add(this.packetLoggerConfig); this.packetLogPanel.add(this.outPackets); this.packetLogPanel.setMaximumSize(new Dimension(10000, 100)); this.logPanel.add(this.logScroll); this.add(this.packetLogPanel); this.add(this.logPanel); this.pack(); } private void configurate() { this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); this.inPackets.setBorder(this.customTitledBorder("Inbound packets", 2)); this.packetLoggerConfig.setBorder(this.customTitledBorder("Packet logger settings", 2)); this.outPackets.setBorder(this.customTitledBorder("Outbound packets", 2)); this.logScroll.setBorder(this.customTitledBorder("Log")); this.logTextArea.setFont(this.FONT); this.logTextArea.setLineWrap(true); this.logTextArea.setWrapStyleWord(true); this.editBlackList.addActionListener(this); this.logInPackets.addActionListener(this); this.logOutPackets.addActionListener(this); this.onTop.addActionListener(this); this.addWindowListener(this); this.setLayout(new BoxLayout(this.getContentPane(), 1)); } public Border customTitledBorder(String title) { return this.customTitledBorder(title, 1); } public Border customTitledBorder(String title, int align) { TitledBorder border = BorderFactory.createTitledBorder(title); border.setTitleJustification(align); return border; } public void logMessage(Object mess) { this.logTextArea.append((this.logTextArea.getText().isEmpty() ? "" : "\n") + new SimpleDateFormat("'['HH:mm:ss'] '").format(new Date()) + " " + (mess != null ? mess : "null")); this.logTextArea.setCaretPosition(this.logTextArea.getText().length()); } @Override public void actionPerformed(ActionEvent e) { Object src = e.getSource(); if (src == this.editBlackList) { new EditPacketBlackList(this); } else if (src == this.onTop) { this.setAlwaysOnTop(this.onTop.isSelected()); } else if ((src == this.logInPackets || src == this.logOutPackets) && (this.logInPackets.isSelected() || this.logOutPackets.isSelected())) { this.logMessage(" =================== NEW LOG SESSION ==================="); } } @Override public void windowClosing(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } @Override public void windowOpened(WindowEvent e) { } @Override public void windowClosed(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void keyReleased(KeyEvent e) { } @Override public void keyTyped(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { } }
5,070
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
EditPacketBlackList.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/packetlogger/EditPacketBlackList.java
package ehacks.mod.packetlogger; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class EditPacketBlackList extends JFrame implements ActionListener { private final JButton accept = new JButton("Save"); private final JButton reset = new JButton("Close"); private final JTextArea[] areas = new JTextArea[3]; private final String[] titles = new String[]{"Inbound", "Logged", "Outbound"}; private final JPanel buttonsPanel = new JPanel(); private final Gui gui; public EditPacketBlackList(Gui gui) { super("PacketLogger blacklist"); this.gui = gui; this.setLayout(new BoxLayout(this.getContentPane(), 1)); this.buttonsPanel.setLayout(new FlowLayout()); this.construct(); this.addToLists(); this.reset.addActionListener(this); this.accept.addActionListener(this); this.buttonsPanel.add(this.reset); this.buttonsPanel.add(this.accept); this.add(this.buttonsPanel); this.pack(); this.setLocationRelativeTo(null); this.setResizable(false); this.setAlwaysOnTop(true); this.setVisible(true); } private void construct() { for (int i = 0; i < 3; ++i) { this.areas[i] = new JTextArea(10, 50); this.areas[i].setFont(gui.FONT); JScrollPane scroll = new JScrollPane(this.areas[i]); scroll.setBorder(gui.customTitledBorder(this.titles[i], 2)); this.add(scroll); } this.addToLists(); } private List<String> getList(int num) { switch (num) { case 0: { return PacketHandler.inBlackList; } case 1: { return PacketHandler.logBlackList; } case 2: { return PacketHandler.outBlackList; } } return null; } private void addToLists() { for (int i = 0; i < 3; ++i) { this.areas[i].setText(""); for (String crit : this.getList(i)) { this.areas[i].append(crit + "\n"); } } } private void acceptList() { for (int i = 0; i < 3; ++i) { String[] newList; this.getList(i).clear(); for (String newCrit : newList = this.areas[i].getText().split("\n")) { if (newCrit.isEmpty()) { continue; } this.getList(i).add(newCrit); } } } @Override public void actionPerformed(ActionEvent e) { Object src = e.getSource(); if (src == this.accept) { this.acceptList(); this.dispose(); } else if (src == this.reset) { PacketHandler.newList(); this.addToLists(); } } }
3,109
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
Tooltip.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/Tooltip.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.gui; /** * * @author radioegor146 */ public class Tooltip { public String text; public int x; public int y; public Tooltip(String text, int x, int y) { this.text = text; this.x = x; this.y = y; } }
452
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
EHacksClickGui.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/EHacksClickGui.java
package ehacks.mod.gui; import ehacks.mod.api.Module; import ehacks.mod.commands.ConsoleGui; import ehacks.mod.config.ConfigurationManager; import ehacks.mod.gui.element.SimpleWindow; import ehacks.mod.gui.window.*; import ehacks.mod.util.GLUtils; import ehacks.mod.wrapper.Wrapper; import java.util.ArrayList; import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.ChatComponentText; public class EHacksClickGui extends GuiScreen { public ArrayList<SimpleWindow> windows = new ArrayList<>(); public ConsoleGui consoleGui = new ConsoleGui(Wrapper.INSTANCE.mc()); public boolean canInputConsole = false; public static int mainColor = GLUtils.getColor(255, 255, 255); public EHacksClickGui() { } //TODO fix all of these being offscreen on scale = auto public void initWindows() { windows.add(new WindowPlayer()); windows.add(new WindowCombat()); windows.add(new WindowRender()); windows.add(new WindowMinigames()); windows.add(new WindowNoCheatPlus()); windows.add(new WindowEHacks()); windows.add(new WindowInfo()); windows.add(new WindowRadar()); windows.add(new WindowActives()); windows.add(new WindowPlayerIds()); windows.add(new WindowCheckVanish()); windows.add(new WindowFakeKeybindings()); windows.add(new WindowFakeChatKeybindings()); windows.add(new WindowFakeImportConfig()); windows.add(new WindowFakeExportConfig()); windows.add(new WindowHub()); } @Override public void initGui() { super.initGui(); } @Override public void onGuiClosed() { super.onGuiClosed(); ConfigurationManager.instance().saveConfigs(); } public void sendPanelToFront(SimpleWindow window) { if (windows.contains(window)) { windows.remove(window); windows.add(windows.size(), window); } } public SimpleWindow getFocusedPanel() { return windows.get(windows.size() - 1); } public static Tooltip tooltip = null; @Override public void drawScreen(int x, int y, float f) { tooltip = null; super.drawScreen(x, y, f); windows.forEach((window) -> { window.draw(x, y); }); if (tooltip != null) { this.drawHoveringText(this.fontRendererObj.listFormattedStringToWidth(tooltip.text, 200), tooltip.x, tooltip.y, fontRendererObj); } } public void log(String data, Object from) { if (from != null) { if (from instanceof Module) { data = "&7[&f" + ((Module) from).getName() + "&7] &e" + data; } else if (from instanceof String) { data = "&7[&f" + from + "&7] &e" + data; } } consoleGui.printChatMessage(new ChatComponentText(data.replace("&", "\u00a7").replace("\u00a7\u00a7", "&"))); } @Override public void updateScreen() { super.updateScreen(); } @Override public void mouseClicked(int x, int y, int button) { if (button != 0) { return; } try { for (int i = windows.size() - 1; i >= 0; i--) { if (windows.get(i).mouseClicked(x, y, button)) { break; } } } catch (Exception exception) { // empty catch block } } @Override protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) { windows.forEach((window) -> { window.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); }); } @Override public boolean doesGuiPauseGame() { return false; } public void drawBack() { if ((!(Wrapper.INSTANCE.mc().currentScreen instanceof EHacksClickGui))) { windows.stream().filter((windows) -> !(!windows.isPinned())).forEachOrdered((windows) -> { windows.draw(0, 0); }); } consoleGui.drawChat(Wrapper.INSTANCE.mc().ingameGUI.getUpdateCounter()); } }
4,131
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
Tuple.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/Tuple.java
package ehacks.mod.gui; public class Tuple<X, Y> { public X x; public Y y; public Tuple(X x, Y y) { this.x = x; this.y = y; } }
163
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowActives.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowActives.java
package ehacks.mod.gui.window; import ehacks.mod.api.ModuleController; import ehacks.mod.gui.EHacksClickGui; import ehacks.mod.gui.element.SimpleWindow; import ehacks.mod.wrapper.Wrapper; public class WindowActives extends SimpleWindow { public WindowActives() { super("Enabled", 2, 300); this.setClientSize(88, 0); } @Override public void draw(int x, int y) { if (this.isOpen()) { if (this.isExtended()) { int i; int tsz = 0; for (i = 0; i < ModuleController.INSTANCE.modules.size(); i++) { if (ModuleController.INSTANCE.modules.get(i).isActive()) { tsz++; } } if (tsz > 0) { this.setClientSize(88, tsz * 12 - 3); super.draw(x, y); int ti = 0; for (i = 0; i < ModuleController.INSTANCE.modules.size(); i++) { if (ModuleController.INSTANCE.modules.get(i).isActive()) { Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(ModuleController.INSTANCE.modules.get(i).getName(), this.getClientX() + 1, this.getClientY() + ti * 12 + 1, EHacksClickGui.mainColor); ti++; } } } else { this.setClientSize(88, -3); super.draw(x, y); } } else { super.draw(x, y); } } } }
1,595
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowHub.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowHub.java
package ehacks.mod.gui.window; import ehacks.mod.api.ModStatus; import ehacks.mod.gui.element.SimpleButton; import ehacks.mod.gui.element.SimpleWindow; import ehacks.mod.modulesystem.handler.EHacksGui; import java.util.ArrayList; import java.util.List; public class WindowHub extends SimpleWindow { private final List<SimpleButton> buttons = new ArrayList<>(); public WindowHub() { super("Gui Hub", 2, 2); this.setOpen(true); this.setExtended(true); int y = 0; for (SimpleWindow window : EHacksGui.clickGui.windows) { if (window != this) { buttons.add(new SimpleButton(this, window, window.getTitle(), ModStatus.DEFAULT.color, 1, y * 12 - 1, 86, 12)); y++; } } } @Override public void draw(int x, int y) { this.setOpen(true); this.setClientSize(88, buttons.size() * 12 - 1); super.draw(x, y); if (this.isExtended()) { buttons.stream().map((button) -> { button.setState(((SimpleWindow) button.getHandler()).isOpen()); return button; }).forEachOrdered((button) -> { button.draw(); }); } } @Override public boolean mouseClicked(int x, int y, int button) { boolean retval = super.mouseClicked(x, y, button); for (SimpleButton xbutton : buttons) { if (xbutton.mouseClicked(x, y, button)) { retval = true; break; } } return retval; } }
1,596
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowMinigames.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowMinigames.java
package ehacks.mod.gui.window; import ehacks.mod.gui.element.ModWindow; import ehacks.mod.wrapper.ModuleCategory; public class WindowMinigames extends ModWindow { public WindowMinigames() { super("Minigames", 370, 2, ModuleCategory.MINIGAMES); } }
275
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowPlayer.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowPlayer.java
package ehacks.mod.gui.window; import ehacks.mod.gui.element.ModWindow; import ehacks.mod.wrapper.ModuleCategory; public class WindowPlayer extends ModWindow { public WindowPlayer() { super("Player", 94, 2, ModuleCategory.PLAYER); } }
262
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowFakeKeybindings.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowFakeKeybindings.java
package ehacks.mod.gui.window; import ehacks.mod.gui.element.SimpleWindow; import ehacks.mod.util.keygui.GuiControls; import ehacks.mod.wrapper.Wrapper; public class WindowFakeKeybindings extends SimpleWindow { public WindowFakeKeybindings() { super("Key config", 600, 300); } @Override public void setOpen(boolean state) { if (state) { try { Wrapper.INSTANCE.mc().displayGuiScreen(new GuiControls(Wrapper.INSTANCE.mc().currentScreen)); } catch (Exception e) { } } } }
577
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowFakeChatKeybindings.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowFakeChatKeybindings.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.gui.window; import ehacks.mod.gui.element.SimpleWindow; import ehacks.mod.util.chatkeybinds.GuiControls; import ehacks.mod.wrapper.Wrapper; /** * * @author radioegor146 */ public class WindowFakeChatKeybindings extends SimpleWindow { public WindowFakeChatKeybindings() { super("Chat keybinds", 0, 0); } @Override public void setOpen(boolean state) { if (state) { try { Wrapper.INSTANCE.mc().displayGuiScreen(new GuiControls(Wrapper.INSTANCE.mc().currentScreen)); } catch (Exception e) { } } } }
802
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowFakeExportConfig.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowFakeExportConfig.java
package ehacks.mod.gui.window; import ehacks.mod.config.LocalConfigStorage; import ehacks.mod.gui.element.SimpleWindow; public class WindowFakeExportConfig extends SimpleWindow { public WindowFakeExportConfig() { super("Export config", 600, 300); } @Override public void setOpen(boolean state) { if (state) { LocalConfigStorage.exportConfig(); } } }
418
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowRender.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowRender.java
package ehacks.mod.gui.window; import ehacks.mod.gui.element.ModWindow; import ehacks.mod.wrapper.ModuleCategory; public class WindowRender extends ModWindow { public WindowRender() { super("Render", 278, 2, ModuleCategory.RENDER); } }
263
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowRadar.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowRadar.java
package ehacks.mod.gui.window; import ehacks.mod.gui.EHacksClickGui; import ehacks.mod.gui.element.SimpleWindow; import ehacks.mod.wrapper.Wrapper; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; public class WindowRadar extends SimpleWindow { public WindowRadar() { super("Radar", 94, 300); this.setClientSize(88, 0); } @Override public void draw(int x, int y) { if (this.isOpen()) { if (this.isExtended()) { int rect = 0; for (Object o : Wrapper.INSTANCE.world().playerEntities) { if (!(o == Wrapper.INSTANCE.player() || ((Entity) o).isDead)) { rect += 12; } } if (rect == 0) { this.setClientSize(88, 9); super.draw(x, y); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("No one in range.", this.getClientX() + 1, this.getClientY() + 1, EHacksClickGui.mainColor); return; } this.setClientSize(88, rect - 3); super.draw(x, y); int count = 0; for (Object o : Wrapper.INSTANCE.world().playerEntities) { EntityPlayer e = (EntityPlayer) o; if (e == Wrapper.INSTANCE.player() || e.isDead) { continue; } int distance = (int) Wrapper.INSTANCE.player().getDistanceToEntity(e); String text; if (distance <= 20) { text = "\u00a7c" + e.getDisplayName() + "\u00a7f: " + distance; } else if (distance <= 50) { text = "\u00a76" + e.getDisplayName() + "\u00a7f: " + distance; } else { text = "\u00a7a" + e.getDisplayName() + "\u00a7f: " + distance; } int xPosition = this.getClientX() + 1; int yPosition = this.getClientY() + 12 * count + 1; Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(text, xPosition, yPosition, EHacksClickGui.mainColor); ++count; } } else { super.draw(x, y); } } } }
2,400
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowFakeImportConfig.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowFakeImportConfig.java
package ehacks.mod.gui.window; import ehacks.mod.config.LocalConfigStorage; import ehacks.mod.gui.element.SimpleWindow; public class WindowFakeImportConfig extends SimpleWindow { public WindowFakeImportConfig() { super("Import config", 600, 300); } @Override public void setOpen(boolean state) { if (state) { LocalConfigStorage.importConfig(); } } }
418
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowCombat.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowCombat.java
package ehacks.mod.gui.window; import ehacks.mod.gui.element.ModWindow; import ehacks.mod.wrapper.ModuleCategory; public class WindowCombat extends ModWindow { public WindowCombat() { super("Combat", 186, 2, ModuleCategory.COMBAT); } }
263
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowCheckVanish.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowCheckVanish.java
package ehacks.mod.gui.window; import ehacks.mod.gui.element.SimpleWindow; import ehacks.mod.util.GLUtils; import ehacks.mod.util.ServerListPing17; import ehacks.mod.util.packetquery.StatusResponse; import ehacks.mod.wrapper.Wrapper; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStreamReader; import java.net.InetSocketAddress; import java.net.Socket; import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.client.multiplayer.ServerAddress; import net.minecraft.client.multiplayer.ServerData; public class WindowCheckVanish extends SimpleWindow { public WindowCheckVanish() { super("CheckVanish", 600, 300); this.canExtend = false; this.setClientSize(190, 46); } public static int lastCvResult = -2; public static int lastLpResult = -2; public static AtomicBoolean cvThreadStarted = new AtomicBoolean(false); public static AtomicBoolean lpThreadStarted = new AtomicBoolean(false); private CVServerRequester cvRequester; private LPServerRequester lpRequester; public static int cvLastUpdate = 0; public static int lpLastUpdate = 0; public static int tabList = 0; @Override public void draw(int x, int y) { super.draw(x, y); if (cvLastUpdate > 160) { cvLastUpdate = 0; if (!cvThreadStarted.get()) { cvThreadStarted.set(true); cvRequester = new CVServerRequester(); cvRequester.start(); } } if (lpLastUpdate > 160) { lpLastUpdate = 0; if (!lpThreadStarted.get()) { lpThreadStarted.set(true); lpRequester = new LPServerRequester(); lpRequester.start(); } } if (this.isOpen()) { tabList = Wrapper.INSTANCE.player().sendQueue.playerInfoList.size(); ServerData serverData = Wrapper.INSTANCE.mc().func_147104_D(); if (serverData == null) { Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("You are in singleplayer", this.getClientX() + 1, this.getClientY() + 1, GLUtils.getColor(255, 255, 255)); return; } if (tabList < lastCvResult || tabList < lastLpResult) { super.setColor(255,0,0); } else { super.setColor(96,96,96); } Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("Server IP: " + serverData.serverIP, this.getClientX() + 1, this.getClientY() + 1, GLUtils.getColor(255, 255, 255)); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("TAB-List: " + String.valueOf(tabList), this.getClientX() + 1, this.getClientY() + 13, GLUtils.getColor(255, 255, 255)); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("PacketQuery: " + (lastCvResult < 0 ? (lastCvResult == -1 ? "Error" : "Not working") : String.valueOf(lastCvResult)) + (cvThreadStarted.get() ? " [U]" : ""), this.getClientX() + 1, this.getClientY() + 25, GLUtils.getColor(255, 255, 255)); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("Legacy: " + (lastLpResult < 0 ? (lastLpResult == -1 ? "Error" : "Not working") : String.valueOf(lastLpResult)) + (lpThreadStarted.get() ? " [U]" : ""), this.getClientX() + 1, this.getClientY() + 37, GLUtils.getColor(255, 255, 255)); } } private class CVServerRequester extends Thread { public CVServerRequester() { } @Override public void run() { //YouAlwaysWinClickGui.log("[PacketQueryCV] Updating"); ServerData serverData = Wrapper.INSTANCE.mc().func_147104_D(); if (serverData == null) { lastCvResult = -2; cvThreadStarted.set(false); return; } ServerAddress address = ServerAddress.func_78860_a(serverData.serverIP); try { ServerListPing17 pinger = new ServerListPing17(); //pinger.setAddress(new InetSocketAddress("n5.streamcraft.net", 25666)); pinger.setAddress(new InetSocketAddress(address.getIP(), address.getPort())); StatusResponse response = pinger.fetchData(); lastCvResult = response.getPlayers().getOnline(); //YouAlwaysWinClickGui.log("[PacketQueryCV] Updated"); } catch (Exception e) { lastCvResult = -1; //YouAlwaysWinClickGui.log("[PacketQueryCV] Error on updating: " + e.getMessage()); } cvThreadStarted.set(false); } } private class LPServerRequester extends Thread { private final byte[] payload = {-2, 1}; public LPServerRequester() { } @Override public void run() { //YouAlwaysWinClickGui.log("[LegacyPingCV] Updating"); ServerData serverData = Wrapper.INSTANCE.mc().func_147104_D(); if (serverData == null) { lastLpResult = -2; lpThreadStarted.set(false); return; } ServerAddress address = ServerAddress.func_78860_a(serverData.serverIP); try { String[] data; //clientSocket.connect(new InetSocketAddress("n5.streamcraft.net", 25666), 7000); try (Socket clientSocket = new Socket()) { //clientSocket.connect(new InetSocketAddress("n5.streamcraft.net", 25666), 7000); clientSocket.connect(new InetSocketAddress(address.getIP(), address.getPort()), 7000); clientSocket.setSoTimeout(7000); DataOutputStream dos = new DataOutputStream(clientSocket.getOutputStream()); BufferedReader br = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); dos.write(payload, 0, payload.length); data = br.readLine().split("\u0000\u0000\u0000"); } if (data.length < 2) { lastLpResult = -2; lpThreadStarted.set(false); return; } lastLpResult = Integer.valueOf(data[data.length - 2].replace("\u0000", "")); //YouAlwaysWinClickGui.log("[LegacyPingCV] Updated"); } catch (Exception e) { lastLpResult = -1; //YouAlwaysWinClickGui.log("[LegacyPingCV] Error on updating: " + e.getMessage()); } lpThreadStarted.set(false); } } }
6,641
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowPlayerIds.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowPlayerIds.java
package ehacks.mod.gui.window; import ehacks.mod.api.ModStatus; import ehacks.mod.gui.Tuple; import ehacks.mod.gui.element.IClickable; import ehacks.mod.gui.element.SimpleButton; import ehacks.mod.gui.element.SimpleWindow; import ehacks.mod.util.GLUtils; import ehacks.mod.wrapper.Wrapper; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import net.minecraft.entity.player.EntityPlayer; public class WindowPlayerIds extends SimpleWindow { public static HashMap<String, Tuple<Integer, EntityPlayer>> players = new HashMap<>(); public static boolean useIt = false; private final SimpleButton useItButton; private class ButtonHandler implements IClickable { @Override public void onButtonClick() { useIt = !useIt; } } public WindowPlayerIds() { super("Saved Players", 186, 300); this.useItButton = new SimpleButton(this, new ButtonHandler(), "Use it", ModStatus.DEFAULT.color, 1, 1, 198, 12); } public static List<EntityPlayer> getPlayers() { ArrayList<EntityPlayer> retPlayers = new ArrayList<>(); players.entrySet().forEach((entry) -> { retPlayers.add(entry.getValue().y); }); return retPlayers; } @Override public void draw(int x, int y) { if (this.isOpen()) { this.setClientSize(200, players.size() * 12 + 14); super.draw(x, y); if (this.isExtended()) { useItButton.draw(); int i = 0; for (Map.Entry<String, Tuple<Integer, EntityPlayer>> entry : players.entrySet()) { int color = GLUtils.getColor(255 - Math.min(64, entry.getValue().x), 255 - Math.min(64, entry.getValue().x), 255 - Math.min(64, entry.getValue().x)); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(entry.getKey() + ": 0x" + Integer.toHexString(entry.getValue().y.getEntityId()), this.getClientX() + 1, this.getClientY() + i * 12 + 16, color); entry.getValue().x++; i++; } } } } @Override public boolean mouseClicked(int x, int y, int button) { boolean retval = super.mouseClicked(x, y, button); retval |= useItButton.mouseClicked(x, y, button); return retval; } }
2,395
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowNoCheatPlus.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowNoCheatPlus.java
package ehacks.mod.gui.window; import ehacks.mod.gui.element.ModWindow; import ehacks.mod.wrapper.ModuleCategory; public class WindowNoCheatPlus extends ModWindow { public WindowNoCheatPlus() { super("NoCheatPlus", 462, 2, ModuleCategory.NOCHEATPLUS); } }
283
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowEHacks.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowEHacks.java
package ehacks.mod.gui.window; import ehacks.mod.gui.element.ModWindow; import ehacks.mod.wrapper.ModuleCategory; public class WindowEHacks extends ModWindow { public WindowEHacks() { super("EHacks", 646, 2, ModuleCategory.EHACKS); } }
263
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
WindowInfo.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/window/WindowInfo.java
package ehacks.mod.gui.window; import ehacks.mod.gui.EHacksClickGui; import ehacks.mod.gui.element.SimpleWindow; import ehacks.mod.wrapper.Wrapper; public class WindowInfo extends SimpleWindow { public WindowInfo() { super("Info", 554, 2); this.setClientSize(88, 48); } @Override public void draw(int x, int y) { if (this.isOpen()) { if (this.isExtended()) { this.setClientSize(88, 45); super.draw(x, y); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(Wrapper.INSTANCE.mc().debug.split(",")[0].toUpperCase(), this.getClientX() + 1, this.getClientY() + 1, EHacksClickGui.mainColor); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("X: " + (int) Wrapper.INSTANCE.player().posX, this.getClientX() + 1, this.getClientY() + 12 + 1, EHacksClickGui.mainColor); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("Y: " + (int) Wrapper.INSTANCE.player().posY, this.getClientX() + 1, this.getClientY() + 24 + 1, EHacksClickGui.mainColor); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow("Z: " + (int) Wrapper.INSTANCE.player().posZ, this.getClientX() + 1, this.getClientY() + 36 + 1, EHacksClickGui.mainColor); } else { super.draw(x, y); } } } }
1,366
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
XRayAddGui.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/xraysettings/XRayAddGui.java
package ehacks.mod.gui.xraysettings; import ehacks.mod.config.ConfigurationManager; import ehacks.mod.wrapper.Wrapper; import java.util.ArrayList; import java.util.Set; import net.minecraft.block.Block; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.item.ItemStack; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; public class XRayAddGui extends GuiScreen { String id; XRayGuiSlider colorR; XRayGuiSlider colorG; XRayGuiSlider colorB; XRayGuiSlider colorA; private GuiButton add; private GuiButton cancel; private GuiButton matterMeta; private GuiButton isEnabled; private int selectedIndex = -1; private int r = 128; private int g = 128; private int b = 128; private int a = 255; private boolean enabled = true; private boolean bmeta = false; private int meta; private int sliderpos; private GuiTextField searchbar; private ArrayList<String> blocks = new ArrayList<>(); public XRayAddGui(int r, int g, int b2, int a2, int meta, String id, boolean enabled, int index) { this(); this.r = r; this.g = g; this.b = b2; this.a = a2; this.meta = meta; this.bmeta = meta != -1; this.id = id; this.enabled = enabled; this.selectedIndex = index; } public XRayAddGui() { } public XRayAddGui(XRayBlock xrayBlocks2, int index) { this(xrayBlocks2.r, xrayBlocks2.g, xrayBlocks2.b, xrayBlocks2.a, xrayBlocks2.meta, xrayBlocks2.id, xrayBlocks2.enabled, index); } @Override protected void actionPerformed(GuiButton par1GuiButton) { switch (par1GuiButton.id) { case 0: if (this.selectedIndex != -1) { XRayBlock.blocks.remove(this.selectedIndex); } XRayBlock.blocks.add(new XRayBlock((int) (this.colorR.percent * 255.0f), (int) (this.colorG.percent * 255.0f), (int) (this.colorB.percent * 255.0f), (int) (this.colorA.percent * 255.0f), this.bmeta ? this.meta : -1, this.id, this.enabled)); ConfigurationManager.instance().saveConfigs(); Wrapper.INSTANCE.mc().displayGuiScreen(new XRayGui()); break; case 1: Wrapper.INSTANCE.mc().displayGuiScreen(new XRayGui()); break; case 6: this.enabled = !this.enabled; this.isEnabled.displayString = this.enabled ? "Enabled" : "Disabled"; break; case 7: this.bmeta = !this.bmeta; this.matterMeta.displayString = this.bmeta ? "Meta-Check Enabled" : "Meta-Check Disabled"; break; default: break; } super.actionPerformed(par1GuiButton); } @SuppressWarnings("unchecked") @Override public void initGui() { super.initGui(); this.add = new GuiButton(0, this.width / 2 - 42, this.height - 22, 40, 20, "Add"); this.buttonList.add(this.add); this.cancel = new GuiButton(1, this.width / 2 + 42, this.height - 22, 40, 20, "Cancel"); this.buttonList.add(this.cancel); this.colorR = new XRayGuiSlider(2, this.width - 160, this.height / 10 * 5, "Red-Value", this.r / 255.0f); this.buttonList.add(this.colorR); this.colorG = new XRayGuiSlider(3, this.width - 160, this.height / 10 * 6, "Green-Value", this.g / 255.0f); this.buttonList.add(this.colorG); this.colorB = new XRayGuiSlider(4, this.width - 160, this.height / 10 * 7, "Blue-Value", this.b / 255.0f); this.buttonList.add(this.colorB); this.colorA = new XRayGuiSlider(5, this.width - 160, this.height / 10 * 8, "Alpha-Value", this.a / 255.0f); this.buttonList.add(this.colorA); this.isEnabled = new GuiButton(6, this.width - 160, this.height / 10 * 4, 70, 20, this.enabled ? "Enabled" : "Disabled"); this.buttonList.add(this.isEnabled); this.matterMeta = new GuiButton(7, this.width - 90, this.height / 10 * 4, 80, 20, this.bmeta ? "Meta-Check Enabled" : "Meta-Check Disabled"); this.buttonList.add(this.matterMeta); Keyboard.enableRepeatEvents(true); this.searchbar = new GuiTextField(this.fontRendererObj, 60, 45, 120, this.fontRendererObj.FONT_HEIGHT); this.searchbar.setMaxStringLength(30); this.searchbar.setCanLoseFocus(false); this.searchbar.setFocused(true); this.searchbar.setTextColor(16777215); this.blocks.addAll(Block.blockRegistry.getKeys()); } @Override public void drawScreen(int x, int y, float par3) { int si; super.drawScreen(x, y, par3); this.drawBackground(0); this.drawString(this.fontRendererObj, "Search for Blocks by their name ", 5, 10, 16777215); this.drawString(this.fontRendererObj, "or their ID and meta using @ (e.g. @12:0 or @12:1) ", 7, 20, 16777215); String text = this.searchbar.getText(); if (text.startsWith("@")) { try { text = text.substring(1); String[] blockstodraw = text.split(":"); int s = -1; if (blockstodraw.length > 1) { s = Integer.parseInt(blockstodraw[1]); } if (blockstodraw.length > 0 && Block.blockRegistry.containsId(si = Integer.parseInt(blockstodraw[0]))) { this.id = Block.blockRegistry.getNameForObject(Block.blockRegistry.getObjectById(si)); this.meta = s; if (s != 1) { this.bmeta = true; } } } catch (Exception blockstodraw) { // empty catch block } } this.add.enabled = this.id != null; this.drawInfo(); this.searchbar.drawTextBox(); super.drawScreen(x, y, par3); ArrayList var13 = this.getItemStackList(); int var14 = 9; for (si = 0; si < var13.size(); ++si) { int ni = si + this.sliderpos * var14; if (ni >= var13.size()) { continue; } ItemStack b2 = (ItemStack) var13.get(ni); if (si == var14 * 7) { break; } try { RenderHelper.enableGUIStandardItemLighting(); XRayAddGui.drawRect((10 + si % var14 * 20), (60 + si / var14 * 20), (10 + si % var14 * 20 + 16), (60 + si / var14 * 20 + 16), -2130706433); RenderHelper.disableStandardItemLighting(); this.drawItem(b2, 10 + si % var14 * 20, 60 + si / var14 * 20, ""); } catch (Exception exception) { // empty catch block } } RenderHelper.enableGUIStandardItemLighting(); XRayAddGui.drawRect((this.width / 3 * 2), (this.height / 6), (this.width - 30), (this.height / 6 * 2), ((((int) (this.colorA.percent * 255.0f) << 8 | (int) (this.colorR.percent * 255.0f)) << 8 | (int) (this.colorG.percent * 255.0f)) << 8 | (int) (this.colorB.percent * 255.0f))); GL11.glDisable(2929); stringint var15 = this.getClickedBlock(x, y); if (var15 != null) { this.drawString(this.fontRendererObj, ((Block) Block.blockRegistry.getObject(var15.id)).getLocalizedName(), x - 5, y - 10, 16777215); } GL11.glEnable(2929); } @Override public void updateScreen() { this.searchbar.updateCursorCounter(); } private void drawInfo() { this.drawString(this.fontRendererObj, "Search", 15, 45, 16777215); this.drawString(this.fontRendererObj, this.id == null ? "No Block selected" : ((Block) Block.blockRegistry.getObject(this.id)).getLocalizedName(), this.width / 3 * 2 + 20, 20, 16777215); } private void drawItem(ItemStack itemstack, int x, int y, String name) { GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1); GL11.glDisable(2896); this.zLevel = 200.0f; GuiScreen.itemRender.zLevel = 200.0f; FontRenderer font = null; if (itemstack != null) { font = itemstack.getItem().getFontRenderer(itemstack); } if (font == null) { font = this.fontRendererObj; } GuiScreen.itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), itemstack, x, y); GuiScreen.itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), itemstack, x, y, name); this.zLevel = 0.0f; GuiScreen.itemRender.zLevel = 0.0f; GL11.glEnable(2896); } @Override protected void keyTyped(char par1, int par2) { this.searchbar.textboxKeyTyped(par1, par2); this.blocks.clear(); Set s = Block.blockRegistry.getKeys(); s.forEach((string) -> { String sb = this.searchbar.getText(); Block b2 = (Block) Block.blockRegistry.getObject((String) string); if (!(!b2.getLocalizedName().toLowerCase().contains(sb.toLowerCase()))) { this.blocks.add((String) string); } }); this.sliderpos = 0; super.keyTyped(par1, par2); } @Override protected void mouseClicked(int x, int y, int mouseButton) { stringint s; super.mouseClicked(x, y, mouseButton); this.searchbar.mouseClicked(x, y, mouseButton); if (mouseButton == 0 && (s = this.getClickedBlock(x, y)) != null) { this.id = s.id; this.meta = s.meta; } } @Override public void handleMouseInput() { super.handleMouseInput(); int x = Mouse.getEventDWheel(); ArrayList blockstodraw = this.getItemStackList(); int xmax = blockstodraw.size() / 9; int xmin = 0; if (x < 0) { if (this.sliderpos < xmax) { ++this.sliderpos; } } else if (x > 0 && this.sliderpos > xmin) { --this.sliderpos; } } private ArrayList getItemStackList() { ArrayList blockstodraw = new ArrayList(); this.blocks.stream().map((block) -> (Block) Block.blockRegistry.getObject(block)).forEachOrdered((b2) -> { b2.getSubBlocks(new ItemStack(b2).getItem(), null, blockstodraw); }); return blockstodraw; } private stringint getClickedBlock(int x, int y) { Block b2; int i; int index = 0; ArrayList z = new ArrayList(); for (i = 0; i < this.blocks.size(); ++i) { b2 = (Block) Block.blockRegistry.getObject(this.blocks.get(i)); b2.getSubBlocks(new ItemStack(b2).getItem(), null, z); } for (i = 0; i < this.blocks.size(); ++i) { b2 = (Block) Block.blockRegistry.getObject(this.blocks.get(i)); ArrayList blockstodraw = new ArrayList(); b2.getSubBlocks(new ItemStack(b2).getItem(), null, blockstodraw); for (int j = 0; j < blockstodraw.size(); ++j) { int var14; if ((index + j - this.sliderpos * 9) / 9 > 7 || index + j - this.sliderpos * 9 < 0) { continue; } int c = (index + j) % 9; int v = (index + j - this.sliderpos * 9) / 9; if (x <= 10 + c * 20 || x >= 26 + c * 20 || y <= v * 20 + 60 || y >= v * 20 + 76) { continue; } boolean smeta = false; try { var14 = ((ItemStack) blockstodraw.get(j)).getItemDamage(); } catch (Exception var13) { var14 = -1; } return new stringint(this.blocks.get(i), var14); } index += blockstodraw.size(); } return null; } private class stringint { public int meta; public String id; public stringint(String id, int meta) { this.id = id; this.meta = meta; } } }
12,343
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
XRayGuiSlider.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/xraysettings/XRayGuiSlider.java
package ehacks.mod.gui.xraysettings; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import org.lwjgl.opengl.GL11; public class XRayGuiSlider extends GuiButton { public float percent; public boolean isClicked; public XRayGuiSlider(int id, int x, int y, String name, float percentage) { super(id, x, y, 150, 20, name); this.percent = percentage; } @Override public int getHoverState(boolean p_146114_1_) { return 0; } @Override protected void mouseDragged(Minecraft p_146119_1_, int p_146119_2_, int p_146119_3_) { if (this.visible) { if (this.isClicked) { this.percent = (p_146119_2_ - (this.xPosition + 4)) / (float) (this.width - 8); if (this.percent < 0.0f) { this.percent = 0.0f; } if (this.percent > 1.0f) { this.percent = 1.0f; } } GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); this.drawTexturedModalRect(this.xPosition + (int) (this.percent * (this.width - 8)), this.yPosition, 0, 66, 4, 20); this.drawTexturedModalRect(this.xPosition + (int) (this.percent * (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20); } } @Override public boolean mousePressed(Minecraft p_146116_1_, int x, int y) { if (super.mousePressed(p_146116_1_, x, y)) { this.percent = (x - (this.xPosition + 4)) / (float) (this.width - 8); if (this.percent < 0.0f) { this.percent = 0.0f; } if (this.percent > 1.0f) { this.percent = 1.0f; } this.isClicked = true; return true; } return false; } @Override public void mouseReleased(int x, int y) { this.isClicked = false; } }
1,928
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
XRayBlock.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/xraysettings/XRayBlock.java
package ehacks.mod.gui.xraysettings; import ehacks.mod.config.ConfigurationManager; import java.util.ArrayList; import net.minecraft.block.Block; public class XRayBlock { public static ArrayList<XRayBlock> blocks = new ArrayList<>(); public int r; public int g; public int b; public int a; public int meta; public String id = ""; public boolean enabled = true; public XRayBlock() { } public XRayBlock(int r, int g, int b2, int a2, int meta, String id, boolean enabled) { this.r = r; this.g = g; this.b = b2; this.a = a2; this.id = id; this.meta = meta; this.enabled = enabled; } @Override public String toString() { return "" + this.r + " " + this.g + " " + this.b + " " + this.a + " " + this.meta + " " + this.id + " " + this.enabled; } public static XRayBlock fromString(String s) { XRayBlock result = new XRayBlock(); String[] info = s.split(" "); result.r = Integer.parseInt(info[0]); result.g = Integer.parseInt(info[1]); result.b = Integer.parseInt(info[2]); result.a = Integer.parseInt(info[3]); result.meta = Integer.parseInt(info[4]); result.id = info[5]; result.enabled = Boolean.parseBoolean(info[6]); return result; } public static void setStandardList() { ArrayList<XRayBlock> block = new ArrayList<>(); block.add(new XRayBlock(0, 0, 128, 200, -1, "minecraft:lapis_ore", true)); block.add(new XRayBlock(255, 0, 0, 200, -1, "minecraft:redstone_ore", true)); block.add(new XRayBlock(255, 255, 0, 200, -1, "minecraft:gold_ore", true)); block.add(new XRayBlock(0, 255, 0, 200, -1, "minecraft:emerald_ore", true)); block.add(new XRayBlock(0, 191, 255, 200, -1, "minecraft:diamond_ore", true)); blocks = block; ConfigurationManager.instance().saveConfigs(); } public static void removeInvalidBlocks() { for (int i = 0; i < blocks.size(); ++i) { XRayBlock block = blocks.get(i); if (Block.blockRegistry.containsKey(block.id)) { continue; } blocks.remove(block); } } public static void init() { XRayBlock.removeInvalidBlocks(); if (blocks.isEmpty()) { XRayBlock.setStandardList(); } } }
2,418
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
XRayBlockSlot.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/xraysettings/XRayBlockSlot.java
package ehacks.mod.gui.xraysettings; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiSlot; import net.minecraft.client.renderer.Tessellator; public class XRayBlockSlot extends GuiSlot { int selectedIndex = -1; XRayGui xrayGui; public XRayBlockSlot(Minecraft par1Minecraft, int width, int height, int top, int bottom, int slotHeight, XRayGui xrayGui) { super(par1Minecraft, width, height, top, bottom, slotHeight); this.xrayGui = xrayGui; XRayBlock.init(); } @Override protected int getSize() { return XRayBlock.blocks.size(); } @Override protected boolean isSelected(int i) { return i == this.selectedIndex; } @Override protected void drawBackground() { } @Override protected void elementClicked(int i, boolean var2, int var3, int var4) { this.selectedIndex = i; } @Override protected void drawSlot(int i, int j, int k, int var4, Tessellator var5, int var6, int var7) { XRayBlock xblock = XRayBlock.blocks.get(i); XRayGui var10000 = this.xrayGui; XRayGui.drawRect((175 + j), (1 + k), (this.xrayGui.width - j - 20), (15 + k), (((51200 | xblock.r) << 8 | xblock.g) << 8 | xblock.b)); if (xblock.id != null && Block.blockRegistry.containsKey(xblock.id)) { this.xrayGui.drawString(this.xrayGui.render, ((Block) Block.blockRegistry.getObject(xblock.id)).getLocalizedName(), j + 2, k + 1, 16777215); } } }
1,553
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
XRayGui.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/xraysettings/XRayGui.java
package ehacks.mod.gui.xraysettings; import ehacks.mod.config.ConfigurationManager; import ehacks.mod.modulesystem.classes.vanilla.XRay; import ehacks.mod.wrapper.Wrapper; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; public class XRayGui extends GuiScreen { XRayBlockSlot slot; GuiButton add; GuiButton del; GuiButton edit; GuiButton exit; FontRenderer render; @SuppressWarnings("unchecked") @Override public void initGui() { super.initGui(); this.render = this.fontRendererObj; this.slot = new XRayBlockSlot(Wrapper.INSTANCE.mc(), this.width, this.height, 25, this.height - 25, 20, this); this.add = new GuiButton(0, this.width / 9, this.height - 22, 70, 20, "Add Block"); this.del = new GuiButton(1, this.width / 9 * 3, this.height - 22, 70, 20, "Delete Block"); this.del.enabled = false; this.edit = new GuiButton(2, this.width / 9 * 5, this.height - 22, 70, 20, "Edit Block"); this.edit.enabled = false; this.exit = new GuiButton(3, this.width / 9 * 7, this.height - 22, 70, 20, "Exit"); this.buttonList.add(this.add); this.buttonList.add(this.del); this.buttonList.add(this.edit); this.buttonList.add(this.exit); } @Override public void drawScreen(int par1, int par2, float par3) { this.slot.drawScreen(par1, par2, par3); super.drawScreen(par1, par2, par3); if (this.slot.selectedIndex != -1) { this.del.enabled = true; this.edit.enabled = true; } else { this.del.enabled = false; this.edit.enabled = false; } } @Override protected void actionPerformed(GuiButton par1GuiButton) { switch (par1GuiButton.id) { case 0: { Wrapper.INSTANCE.mc().displayGuiScreen(new XRayAddGui()); break; } case 1: { XRayBlock.blocks.remove(this.slot.selectedIndex); this.slot.selectedIndex = -1; ConfigurationManager.instance().saveConfigs(); break; } case 2: { Wrapper.INSTANCE.mc().displayGuiScreen(new XRayAddGui(XRayBlock.blocks.get(this.slot.selectedIndex), this.slot.selectedIndex)); break; } case 3: { Wrapper.INSTANCE.mc().displayGuiScreen(null); XRay.cooldownTicks = 0; break; } default: { this.slot.actionPerformed(par1GuiButton); } } } }
2,718
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
IClickable.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/element/IClickable.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.gui.element; /** * * @author radioegor146 */ public interface IClickable { void onButtonClick(); }
312
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
ModWindow.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/element/ModWindow.java
package ehacks.mod.gui.element; import ehacks.mod.api.Module; import ehacks.mod.api.ModuleController; import ehacks.mod.gui.EHacksClickGui; import ehacks.mod.gui.Tooltip; import ehacks.mod.modulesystem.classes.keybinds.ShowGroupsKeybind; import ehacks.mod.util.GLUtils; import ehacks.mod.wrapper.ModuleCategory; import java.util.ArrayList; import java.util.HashSet; import org.lwjgl.input.Keyboard; public class ModWindow extends SimpleWindow { public ArrayList<ArrayList<SimpleButton>> buttons = new ArrayList<>(); public ArrayList<SimpleButton> buttonsSetup = new ArrayList<>(); private final ModuleCategory windowCategory; public ModWindow(String title, int x, int y, ModuleCategory windowCategory) { super(title, x, y); this.windowCategory = windowCategory; ModuleController.INSTANCE.modules.stream().filter((mod) -> !(mod.getCategory() != windowCategory)).forEachOrdered((mod) -> { this.addButton(mod); }); this.setup(); } public void addButton(Module mod) { this.buttonsSetup.add(new SimpleButton(this, mod, mod.getName(), mod.getModStatus().color, 0, 13 * this.buttons.size(), 86, 12)); } public void setup() { for (int i = 0; i < buttonsSetup.size() / 20 + ((buttonsSetup.size() % 20 > 0) ? 1 : 0); i++) { buttons.add(new ArrayList<>()); } for (int i = 0; i < buttonsSetup.size(); i++) { int col = i / (buttonsSetup.size() / buttons.size() + ((buttonsSetup.size() % buttons.size() > 0) ? 1 : 0)); buttons.get(col).add(buttonsSetup.get(i)); } } @Override public void draw(int x, int y) { this.setClientSize(this.buttons.size() * 86 + 2, 0); if (!this.isOpen() || !this.isExtended()) { super.draw(x, y); return; } Module hoverMod = null; boolean alwaysShowHover = false;// if (Keyboard.isKeyDown(ShowGroupsKeybind.getKey())) { int ds = 0; HashSet<String> mods = new HashSet<>(); for (ArrayList<SimpleButton> buttonList : this.buttons) { mods.clear(); buttonList.forEach((button) -> { mods.add(((Module) button.getHandler()).getModName()); }); ds = Math.max(ds, 12 * mods.size() + buttonList.size() * 12); } this.setClientSize(this.buttons.size() * 86 + 2, ds - 1); super.draw(x, y); int col = 0; for (ArrayList<SimpleButton> buttonList : this.buttons) { Module prevMod = null; int ty = 0; int tty = 0; int row = 0; for (SimpleButton button : buttonList) { if (prevMod == null || !prevMod.getModName().equals(((Module) button.getHandler()).getModName())) { SimpleButton tbutton = new SimpleButton(this, null, ((Module) button.getHandler()).getModName(), GLUtils.getColor(255, 255, 255), 86 * col + 1, ty + tty - 1, 86, 12); tbutton.draw(); ty += 12; } tty += 12; button.setState(((Module) button.getHandler()).isActive()); button.setPosition(col * 86 + 1, row * 12 + ty - 1); button.draw(); if (button.isMouseOver(x, y)) { hoverMod = ((Module) button.getHandler()); } prevMod = ((Module) button.getHandler()); row++; } col++; } } else { int ysize = 0; for (ArrayList<SimpleButton> button1 : buttons) { ysize = Math.max(ysize, button1.size()); } this.setClientSize(this.buttons.size() * 86 + 2, 12 * ysize - 1); super.draw(x, y); int col = 0; for (ArrayList<SimpleButton> buttonsCol : this.buttons) { int row = 0; for (SimpleButton button : buttonsCol) { button.setState(((Module) button.getHandler()).isActive()); button.setPosition(col * 86 + 1, row * 12 - 1); button.draw(); //noinspection ConstantConditions if (alwaysShowHover && button.isMouseOver(x, y)) { hoverMod = ((Module) button.getHandler()); } row++; } col++; } } if (hoverMod != null) { EHacksClickGui.tooltip = new Tooltip("\u00A7b" + hoverMod.getName() + "\n\u00A7e" + hoverMod.getModName() + "\n\u00A7f" + hoverMod.getDescription(), x, y); } } @Override public boolean mouseClicked(int x, int y, int button) { boolean retval = super.mouseClicked(x, y, button); buttonloops: for (ArrayList<SimpleButton> buttonsCol : this.buttons) { for (SimpleButton xButton : buttonsCol) { if (xButton.mouseClicked(x, y, button)) { retval = true; break buttonloops; } } } return retval; } }
5,340
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
SimpleWindow.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/element/SimpleWindow.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.gui.element; import ehacks.mod.api.IIncludable; import ehacks.mod.gui.EHacksClickGui; import ehacks.mod.modulesystem.handler.EHacksGui; import ehacks.mod.util.GLUtils; import ehacks.mod.wrapper.Wrapper; import net.minecraft.client.gui.ScaledResolution; import org.lwjgl.input.Keyboard; /** * * @author radioegor146 */ public class SimpleWindow implements IIncludable, IClickable { private final String title; private int xPos; private int yPos; private boolean isOpen; private boolean isExtended; private boolean isPinned; private int prevXPos; private int prevYPos; private int dragX; private int dragY; private boolean dragging; public boolean canExtend = true; public boolean canPin = true; private int width; private int height; private int r = 96; private int g = 96; private int b = 96; public SimpleWindow(String title, int x, int y) { this.title = title; this.xPos = x; this.yPos = y; } public void windowDragged(int x, int y) { if (!dragging) { return; } this.xPos = this.prevXPos + (x - this.dragX); this.yPos = this.prevYPos + (y - this.dragY); ScaledResolution res = new ScaledResolution(Wrapper.INSTANCE.mc(), Wrapper.INSTANCE.mc().displayWidth, Wrapper.INSTANCE.mc().displayHeight); if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { if (this.xPos < 20) { this.xPos = 2; } if (this.yPos < 20) { this.yPos = 2; } if (this.xPos + this.width > res.getScaledWidth() - 20) { this.xPos = res.getScaledWidth() - this.width - 2; } if (this.yPos + this.height > res.getScaledHeight() - 20) { this.yPos = res.getScaledHeight() - this.height - 2; } } } public void setColor(int r, int g, int b) { this.r = r; this.g = g; this.b = b; } public void draw(int x, int y) { if (this.dragging) { this.windowDragged(x, y); } if (this.isOpen) { if (x >= this.xPos && y >= this.yPos && x <= this.xPos + width && y <= this.yPos + 12) { EHacksClickGui.tooltip = null; } int borderColor = GLUtils.getColor(r, g, b); int backColor = GLUtils.getColor(128, r, g, b); int buttonColor = GLUtils.getColor(192, r, g, b); GLUtils.drawRect(this.xPos, this.yPos, this.xPos + width - 20, this.yPos + 12, backColor); GLUtils.drawRect(this.xPos + width - 20, this.yPos, this.xPos + width, this.yPos + 2, backColor); GLUtils.drawRect(this.xPos + width - 20, this.yPos + 10, this.xPos + width, this.yPos + 12, backColor); GLUtils.drawRect(this.xPos + width - 12, this.yPos + 2, this.xPos + width - 10, this.yPos + 10, backColor); GLUtils.drawRect(this.xPos + width - 2, this.yPos + 2, this.xPos + width, this.yPos + 10, backColor); if (this.isExtended || !canExtend) { GLUtils.drawRect(this.xPos, this.yPos + 12, this.xPos + width, this.yPos + height, backColor); GLUtils.drawGradientBorderedRect(this.xPos, this.yPos, this.xPos + width, this.yPos + height, 0.5f, borderColor, -812017255, 0); } else { GLUtils.drawGradientBorderedRect(this.xPos, this.yPos, this.xPos + width, this.yPos + 12, 0.5f, borderColor, -812017255, 0); } Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(this.title, this.xPos + 2, 2 + this.yPos, EHacksClickGui.mainColor); if (canPin) { GLUtils.drawGradientBorderedRect(this.xPos + width - 20, this.yPos + 2, this.xPos + width - 12, this.yPos + 10, 1.0f, borderColor, this.isPinned ? buttonColor : 0, this.isPinned ? buttonColor : 0); } else { GLUtils.drawRect(this.xPos + width - 20, this.yPos + 2, this.xPos + width - 12, this.yPos + 10, backColor); } if (canExtend) { GLUtils.drawGradientBorderedRect(this.xPos + width - 10, this.yPos + 2, this.xPos + width - 2, this.yPos + 10, 1.0f, borderColor, this.isExtended ? buttonColor : 0, this.isExtended ? buttonColor : 0); } else { GLUtils.drawRect(this.xPos + width - 10, this.yPos + 2, this.xPos + width - 2, this.yPos + 10, backColor); } if (this.isExtended || !canExtend) { if (x >= this.xPos && y >= this.yPos + 14 && x <= this.xPos + width + 3 && y <= this.yPos + height) { EHacksClickGui.tooltip = null; } } } //GLUtils.drawBorderedRect(getClientX(), getClientY(), getClientX() + getClientWidth(), getClientY() + getClientHeight(), 1, GLUtils.getColor(192, 255, 255, 0), GLUtils.getColor(100, 255, 255, 0)); } public boolean mouseClicked(int x, int y, int button) { boolean retval = false; if (canPin && x >= this.xPos + width - 20 && y >= this.yPos + 2 && x <= this.xPos + width - 12 && y <= this.yPos + 10) { boolean bl = this.isPinned = !this.isPinned; retval = true; } if (canExtend && x >= this.xPos + width - 10 && y >= this.yPos + 2 && x <= this.xPos + width - 2 && y <= this.yPos + 10) { boolean bl = this.isExtended = !this.isExtended; retval = true; } if (x >= this.xPos && y >= this.yPos && x <= this.xPos + width - 19 && y <= this.yPos + 12) { EHacksGui.clickGui.sendPanelToFront(this); this.dragging = !this.dragging; this.prevXPos = this.xPos; this.prevYPos = this.yPos; this.dragX = x; this.dragY = y; retval = true; } return retval; } public void mouseMovedOrUp(int x, int y, int b2) { if (b2 == 0) { this.dragging = false; } } public String getTitle() { return this.title; } public int getX() { return this.xPos; } public int getY() { return this.yPos; } public int getWidth() { return this.width; } public int getHeight() { return this.height; } public int getClientX() { return this.xPos + 1; } public int getClientY() { return this.yPos + 13; } public int getClientWidth() { return this.width - 2; } public int getClientHeight() { return this.height - 15; } public void setSize(int width, int height) { this.width = width; this.height = height; } public void setClientSize(int cWidth, int cHeight) { this.width = cWidth + 2; this.height = cHeight + 15; } public boolean isExtended() { return this.isExtended; } public boolean isOpen() { return this.isOpen; } public boolean isPinned() { return !this.dragging && this.isPinned; } public void setOpen(boolean flag) { this.isOpen = flag; } public void setExtended(boolean flag) { this.isExtended = flag; } public void setPinned(boolean flag) { this.isPinned = flag; } public void setPosition(int x, int y) { this.xPos = x; this.yPos = y; } @Override public boolean shouldInclude() { return true; } @Override public void onButtonClick() { this.setOpen(!this.isOpen); } }
7,802
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
SimpleButton.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/gui/element/SimpleButton.java
package ehacks.mod.gui.element; import ehacks.mod.gui.EHacksClickGui; import ehacks.mod.modulesystem.handler.EHacksGui; import ehacks.mod.util.GLUtils; import ehacks.mod.wrapper.Wrapper; public class SimpleButton { private final SimpleWindow window; private final IClickable handler; private int sizeX; private int sizeY; private int xPos; private int yPos; private final String title; private final int color; private boolean pressed; public SimpleButton(SimpleWindow window, IClickable handler, String title, int color, int xPos, int yPos, int sizeX, int sizeY) { this.window = window; this.handler = handler; this.xPos = xPos; this.yPos = yPos; this.sizeX = sizeX; this.sizeY = sizeY; this.color = color; this.title = title; } public void setState(boolean state) { pressed = state; } public void draw() { GLUtils.drawGradientBorderedRect(this.getX(), this.getY(), (double) this.getX() + sizeX, this.getY() + sizeY, 0.5f, GLUtils.getColor(96, 96, 96), !pressed ? 0 : GLUtils.getColor(64, 128, 128, 128), !pressed ? GLUtils.getColor(32, 96, 96, 96) : GLUtils.getColor(96, 0, 255, 0)); Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(this.title, this.getX() + sizeX / 2 - Wrapper.INSTANCE.fontRenderer().getStringWidth(this.title) / 2, this.getY() + (this.sizeY / 2 - Wrapper.INSTANCE.fontRenderer().FONT_HEIGHT / 2), pressed ? EHacksClickGui.mainColor : color); } public boolean isMouseOver(int x, int y) { return (x >= this.getX() && y >= this.getY() && x <= this.getX() + this.sizeX && y <= this.getY() + sizeY && this.window.isOpen() && this.window.isExtended()); } public boolean mouseClicked(int x, int y, int button) { if (x >= this.getX() && y >= this.getY() && x <= this.getX() + sizeX && y <= this.getY() + sizeY && button == 0 && this.window.isOpen() && this.window.isExtended()) { EHacksGui.clickGui.sendPanelToFront(this.window); if (this.handler != null) { this.handler.onButtonClick(); } return true; } return false; } public int getX() { return this.xPos + this.window.getClientX(); } public int getY() { return this.yPos + this.window.getClientY(); } public void setSize(int sizeX, int sizeY) { this.sizeX = sizeX; this.sizeY = sizeY; } public void setPosition(int x, int y) { this.xPos = x; this.yPos = y; } public IClickable getHandler() { return handler; } }
2,653
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
Module.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/api/Module.java
package ehacks.mod.api; import ehacks.mod.gui.element.IClickable; import ehacks.mod.wrapper.ModuleCategory; import ehacks.mod.wrapper.PacketHandler; import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; public abstract class Module implements Comparable, IIncludable, IClickable { protected String name = "unknown"; protected String p = "ehacks:"; protected String description = "unknown"; protected int keybind = 0; protected boolean enabled; protected ModuleCategory category; public Module(ModuleCategory category) { this.category = category; } public void setKeybinding(int key) { this.keybind = key; } public void setCategory(ModuleCategory category) { this.category = category; } public String getName() { return this.name; } public String getAlias() { return this.p + this.getName().toLowerCase().replaceAll(" ", ""); } public int getKeybind() { return this.keybind; } public String getDescription() { return this.description; } public ModuleCategory getCategory() { return this.category; } public boolean isActive() { return this.enabled; } public void onWorldUpdate() { } public void onTicks() { } public void onWorldRender(RenderWorldLastEvent event) { } public void onModuleEnabled() { } public void onModuleDisabled() { } public void onMouse(MouseEvent event) { } public void onClick(PlayerInteractEvent event) { } public void onKeyBind() { } public void reset() { this.onModuleEnabled(); this.onModuleDisabled(); } public void on() { this.enabled = true; this.onModuleEnabled(); } public void off() { this.enabled = false; this.onModuleDisabled(); } public void toggle() { this.enabled = !this.enabled; if (this.isActive()) { this.onModuleEnabled(); } else { this.onModuleDisabled(); } } public ModStatus getModStatus() { return ModStatus.DEFAULT; } public String getModName() { return "Minecraft"; } @Override public int compareTo(Object o) { if (o instanceof Module) { int fc = this.getModName().compareTo(((Module) o).getModName()); if (fc == 0) { return this.getName().compareTo(((Module) o).getName()); } else { return fc; } } else { return -1; } } public boolean canOnOnStart() { return (this.category != ModuleCategory.EHACKS && this.category != ModuleCategory.NONE); } public boolean onPacket(Object packet, PacketHandler.Side side) { return true; } public void onLiving(LivingEvent.LivingUpdateEvent event) { } @Override public boolean shouldInclude() { return true; } @Override public void onButtonClick() { if (this.getModStatus() == ModStatus.NOTWORKING) { return; } this.toggle(); } public void onGameOverlay(RenderGameOverlayEvent.Text event) { } public int getDefaultKeybind() { return 0; } }
3,562
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
IIncludable.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/api/IIncludable.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.api; /** * * @author radioegor146 */ public interface IIncludable { boolean shouldInclude(); }
308
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
ModuleController.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/api/ModuleController.java
package ehacks.mod.api; import java.util.ArrayList; import java.util.List; public class ModuleController { public static volatile ModuleController INSTANCE = new ModuleController(); public List<Module> modules = new ArrayList<>(); public void enable(Module modue) { this.modules.add(modue); } public void disable(Module module) { this.modules.remove(module); } public void sort() { modules.sort(null); } public Module call(Class clazz) { try { for (Module mod : this.modules) { if (mod.getClass() != clazz) { continue; } return mod; } } catch (Exception exception) { throw new IllegalStateException("Why you use this for a non-module class?"); } return null; } }
870
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
ModStatus.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/api/ModStatus.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.api; import ehacks.mod.util.GLUtils; /** * * @author radioegor146 */ public enum ModStatus { DEFAULT(12303291), WORKING(GLUtils.getColor(0, 255, 0)), NOTWORKING(GLUtils.getColor(255, 100, 100)), CATEGORY(GLUtils.getColor(255, 255, 255)); public int color; ModStatus(int color) { this.color = color; } }
550
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
ModuleManagement.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/handler/ModuleManagement.java
package ehacks.mod.modulesystem.handler; import ehacks.mod.api.Module; import ehacks.mod.api.ModuleController; import ehacks.mod.modulesystem.classes.keybinds.*; import ehacks.mod.modulesystem.classes.mods.ae2.CellViewer; import ehacks.mod.modulesystem.classes.mods.arsmagica2.*; import ehacks.mod.modulesystem.classes.mods.bibliocraft.JesusGift; import ehacks.mod.modulesystem.classes.mods.bibliocraft.OnlineCraft; import ehacks.mod.modulesystem.classes.mods.bibliocraft.TableTop; import ehacks.mod.modulesystem.classes.mods.buildcraft.PipeGive; import ehacks.mod.modulesystem.classes.mods.carpentersblocks.CarpenterOpener; import ehacks.mod.modulesystem.classes.mods.crayfish.ExtendedDestroyer; import ehacks.mod.modulesystem.classes.mods.crayfish.ExtendedNuker; import ehacks.mod.modulesystem.classes.mods.crayfish.ItemCreator; import ehacks.mod.modulesystem.classes.mods.dragonsradio.DragonsFuck; import ehacks.mod.modulesystem.classes.mods.dragonsradio.MusicalCrash; import ehacks.mod.modulesystem.classes.mods.enderio.*; import ehacks.mod.modulesystem.classes.mods.forge.PacketFlooder; import ehacks.mod.modulesystem.classes.mods.galacticraft.GalaxyTeleport; import ehacks.mod.modulesystem.classes.mods.galacticraft.NoLimitFire; import ehacks.mod.modulesystem.classes.mods.galacticraft.NoLimitSpin; import ehacks.mod.modulesystem.classes.mods.galacticraft.SpaceFire; import ehacks.mod.modulesystem.classes.mods.ironchest.IronChestFinder; import ehacks.mod.modulesystem.classes.mods.mfr.*; import ehacks.mod.modulesystem.classes.mods.nei.NEISelect; import ehacks.mod.modulesystem.classes.mods.nuclearcontrol.IC2SignEdit; import ehacks.mod.modulesystem.classes.mods.openmodularturrets.BlockDestroy; import ehacks.mod.modulesystem.classes.mods.openmodularturrets.PrivateNuker; import ehacks.mod.modulesystem.classes.mods.projectred.RedHack; import ehacks.mod.modulesystem.classes.mods.rftools.SelfRf; import ehacks.mod.modulesystem.classes.mods.taintedmagic.*; import ehacks.mod.modulesystem.classes.mods.thaumcraft.MagicGod; import ehacks.mod.modulesystem.classes.mods.thaumcraft.ResearchGod; import ehacks.mod.modulesystem.classes.mods.thaumichorizons.NowYouSeeMe; import ehacks.mod.modulesystem.classes.mods.thaumichorizons.VerticalGui; import ehacks.mod.modulesystem.classes.mods.thermalexpansion.HotGive; import ehacks.mod.modulesystem.classes.mods.tinkers.CloudStorage; import ehacks.mod.modulesystem.classes.mods.tinkers.MegaExploit; import ehacks.mod.modulesystem.classes.mods.ztones.MetaHackAdd; import ehacks.mod.modulesystem.classes.mods.ztones.MetaHackSub; import ehacks.mod.modulesystem.classes.vanilla.*; public class ModuleManagement { public static volatile ModuleManagement INSTANCE = new ModuleManagement(); public ModuleManagement() { this.initModules(); } private void add(Module mod) { ModuleController.INSTANCE.enable(mod); } public void initModules() { this.add(new MetaHackAdd()); this.add(new MetaHackSub()); this.add(new PrivateNuker()); this.add(new BlockDestroy()); this.add(new ExtendedDestroyer()); this.add(new ExtendedNuker()); this.add(new HighJump()); this.add(new CreativeFly()); this.add(new ItemCreator()); this.add(new RocketChaos()); this.add(new NoLimitRocket()); this.add(new ContainerClear()); this.add(new ChestMagic()); this.add(new MegaExploit()); this.add(new NEISelect()); this.add(new NoLimitClear()); this.add(new CellViewer()); this.add(new RedHack()); this.add(new FakeDestroy()); this.add(new Blink()); this.add(new CreativeGive()); //this.add(new ShowContainer()); this.add(new Step()); this.add(new Speed()); this.add(new NoWeb()); this.add(new Regen()); this.add(new Nuker()); this.add(new Sprint()); this.add(new NoFall()); this.add(new FreeCam()); this.add(new FastEat()); this.add(new AntiFire()); this.add(new FastPlace()); this.add(new AntiPotion()); this.add(new DynamicFly()); this.add(new ChestStealer()); this.add(new AntiKnockBack()); this.add(new XRay()); this.add(new Tracers()); this.add(new MobESP()); this.add(new PlayerESP()); this.add(new ItemESP()); //this.add(new EntityESP()); this.add(new NoWeather()); this.add(new BlockSmash()); this.add(new Fullbright()); this.add(new Breadcrumb()); //this.add(new NameProtect()); this.add(new Projectiles()); this.add(new ChestFinder()); this.add(new BlockOverlay()); this.add(new AimBot()); this.add(new FastBow()); this.add(new MobAura()); this.add(new KillAura()); this.add(new AimAssist()); this.add(new Criticals()); this.add(new FastClick()); this.add(new AutoBlock()); this.add(new TriggerBot()); this.add(new Forcefield()); this.add(new ProphuntESP()); this.add(new ProphuntAura()); this.add(new NCPFly()); this.add(new NCPStep()); this.add(new NCPSpeed()); this.add(new WaterFall()); this.add(new WaterWalk()); this.add(new DamagePopOffs()); this.add(new GuiXRaySettings()); this.add(new DiffRegistry()); this.add(new ShowArmor()); this.add(new FriendClick()); this.add(new IC2SignEdit()); this.add(new ResearchGod()); this.add(new MagicGod()); this.add(new VisualCreative()); this.add(new NowYouSeeMe()); this.add(new CarpenterOpener()); this.add(new GalaxyTeleport()); this.add(new HotGive()); this.add(new JesusGift()); this.add(new NoLimitFire()); this.add(new NoLimitSpin()); this.add(new SpaceFire()); this.add(new VerticalGui()); this.add(new MagicGive()); this.add(new NoLimitBuffs()); this.add(new NoLimitSpell()); this.add(new SkillResearch()); this.add(new DragonsFuck()); this.add(new MusicalCrash()); this.add(new EndPort()); this.add(new Magnendo()); this.add(new SelfEnd()); this.add(new NBTEdit()); this.add(new DebugMe()); this.add(new PacketLogger()); this.add(new PacketFlooder()); this.add(new GiveKeybind()); this.add(new SelectPlayerKeybind()); this.add(new NEISelectKeybind()); this.add(new ShowGroupsKeybind()); this.add(new HideCheatKeybind()); this.add(new OpenNBTEditKeybind()); this.add(new OpenAE2ViewerKeybind()); this.add(new OpenConsoleKeybind()); this.add(new MagnetKeybind()); this.add(new SingleDebugMeKeybind()); this.add(new TickingDebugMeKeybind()); this.add(new LimitedAura()); this.add(new NoLimitAura()); this.add(new NoLimitDamage()); this.add(new NoLimitPlayers()); this.add(new PipeGive()); this.add(new IronChestFinder()); this.add(new SelfRf()); this.add(new CloudStorage()); this.add(new TableTop()); this.add(new OnlineCraft()); ModuleController.INSTANCE.sort(); this.add(new EHacksGui()); } public static ModuleManagement instance() { return INSTANCE; } }
7,484
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
EHacksGui.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/handler/EHacksGui.java
package ehacks.mod.modulesystem.handler; import ehacks.mod.api.Module; import ehacks.mod.gui.EHacksClickGui; import ehacks.mod.wrapper.ModuleCategory; import ehacks.mod.wrapper.Wrapper; import net.minecraft.item.ItemStack; public class EHacksGui extends Module { public static final EHacksClickGui clickGui = new EHacksClickGui(); public EHacksGui() { super(ModuleCategory.NONE); this.setKeybinding(34); clickGui.initWindows(); ItemStack a; } @Override public String getName() { return "Gui"; } @Override public void toggle() { Wrapper.INSTANCE.mc().displayGuiScreen(EHacksGui.clickGui); } @Override public int getDefaultKeybind() { return 34; } }
767
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
SelfRf.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/mods/rftools/SelfRf.java
package ehacks.mod.modulesystem.classes.mods.rftools; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import ehacks.mod.api.ModStatus; import ehacks.mod.api.Module; import ehacks.mod.util.EntityFakePlayer; import ehacks.mod.util.GLUtils; import ehacks.mod.util.InteropUtils; import ehacks.mod.wrapper.ModuleCategory; import ehacks.mod.wrapper.PacketHandler.Side; 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.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.client.C01PacketChatMessage; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import org.lwjgl.opengl.GL11; /** * * @author radioegor146 */ public class SelfRf extends Module { private Vec3 distVec = null; private Entity selectedEnt = null; public SelfRf() { super(ModuleCategory.EHACKS); } private double size = 0; @Override public String getName() { return "SelfRf"; } @Override public String getDescription() { return "Allows to teleport yourself"; } @Override public void onMouse(MouseEvent event) { if (event.button == 2 && event.buttonstate) { if (selectedEnt != null) { Wrapper.INSTANCE.world().removeEntityFromWorld(-2); selectedEnt = null; distVec = null; if (event.isCancelable()) { event.setCanceled(true); } return; } selectedEnt = Wrapper.INSTANCE.player(); if (!(selectedEnt instanceof EntityFakePlayer)) { if (selectedEnt != null) { distVec = Wrapper.INSTANCE.mc().renderViewEntity.getLookVec().normalize(); size = 3f; distVec.xCoord *= size; distVec.yCoord *= size; distVec.zCoord *= size; if (event.isCancelable()) { event.setCanceled(true); } } else { distVec = null; } } } if (selectedEnt != null) { if (event.dwheel > 0) { size = Math.min(size + event.dwheel / 120f, 200f); if (event.isCancelable()) { event.setCanceled(true); } } else if (event.dwheel < 0) { size = Math.max(size + event.dwheel / 120f, 1f); if (event.isCancelable()) { event.setCanceled(true); } } } if (distVec != null) { distVec = Wrapper.INSTANCE.mc().renderViewEntity.getLookVec().normalize(); distVec.xCoord *= size; distVec.yCoord *= size; distVec.zCoord *= size; } if (event.button == 0) { if (selectedEnt != null) { tpEntity(selectedEnt, (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosX + distVec.xCoord), (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosY + distVec.yCoord - 2), (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosZ + distVec.zCoord), Wrapper.INSTANCE.player().dimension); selectedEnt = null; distVec = null; if (event.isCancelable()) { event.setCanceled(true); } } } } @Override public void onWorldRender(RenderWorldLastEvent event) { if (selectedEnt == null) { return; } if (distVec != null) { distVec = Wrapper.INSTANCE.mc().renderViewEntity.getLookVec().normalize(); distVec.xCoord *= size; distVec.yCoord *= size; distVec.zCoord *= size; } NBTTagCompound tag = new NBTTagCompound(); selectedEnt.writeToNBT(tag); if (!GLUtils.hasClearedDepth) { GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GLUtils.hasClearedDepth = true; } Entity ent = selectedEnt; double tXPos = ent.posX; double tYPos = ent.posY; double tZPos = ent.posZ; double xPos = (Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosX + distVec.xCoord) + (Wrapper.INSTANCE.mc().renderViewEntity.posX - Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosX) * event.partialTicks; double yPos = (Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosY + distVec.yCoord + 1) + (Wrapper.INSTANCE.mc().renderViewEntity.posY - Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosY) * event.partialTicks; double zPos = (Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosZ + distVec.zCoord) + (Wrapper.INSTANCE.mc().renderViewEntity.posZ - Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosZ) * event.partialTicks; ent.posX = ent.lastTickPosX = xPos; ent.posY = ent.lastTickPosY = yPos; ent.posZ = ent.lastTickPosZ = zPos; float f1 = ent.prevRotationYaw + (ent.rotationYaw - ent.prevRotationYaw) * event.partialTicks; RenderHelper.enableStandardItemLighting(); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F); if (Wrapper.INSTANCE.world().loadedEntityList.contains(selectedEnt)) { GL11.glColor4f(0, 1.0F, 0, 1f); } else { GL11.glColor4f(1.0F, 0, 0, 1f); } RenderManager.instance.func_147939_a(ent, xPos - renderPosX, yPos - renderPosY, zPos - renderPosZ, f1, event.partialTicks, false); ent.posX = ent.lastTickPosX = tXPos; ent.posY = ent.lastTickPosY = tYPos; ent.posZ = ent.lastTickPosZ = tZPos; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } @Override public void onTicks() { } public int getDeltaVal(String from, int absval) throws Exception { if (from.equals("~")) { return absval; } if (from.startsWith("~")) { from = from.substring(1); int tval = Integer.parseInt(from); return tval + absval; } return Integer.parseInt(from); } @Override public boolean onPacket(Object packet, Side side) { if (packet instanceof C01PacketChatMessage) { String text = ((C01PacketChatMessage) packet).func_149439_c().trim(); if (text.startsWith("/")) { text = text.substring(1); String[] params = text.split(" "); if (params[0].equals("tp") && params.length == 4) { try { int x = getDeltaVal(params[1], (MathHelper.floor_double(Wrapper.INSTANCE.player().posX))); int y = getDeltaVal(params[2], (MathHelper.floor_double(Wrapper.INSTANCE.player().posY))); int z = getDeltaVal(params[3], (MathHelper.floor_double(Wrapper.INSTANCE.player().posZ))); InteropUtils.log("Teleported by SelfRf", this); tpEntity(Wrapper.INSTANCE.player(), x, y - 2, z, Wrapper.INSTANCE.player().dimension); return false; } catch (Exception e) { } } if (params[0].equals("tp") && params.length == 5) { if (params[1].equals(Wrapper.INSTANCE.player().getCommandSenderName())) { try { int x = getDeltaVal(params[2], (MathHelper.floor_double(Wrapper.INSTANCE.player().posX))); int y = getDeltaVal(params[3], (MathHelper.floor_double(Wrapper.INSTANCE.player().posY))); int z = getDeltaVal(params[4], (MathHelper.floor_double(Wrapper.INSTANCE.player().posZ))); InteropUtils.log("Teleported by SelfRf", this); tpEntity(Wrapper.INSTANCE.player(), x, y - 2, z, Wrapper.INSTANCE.player().dimension); return false; } catch (Exception e) { } } for (EntityPlayer entPly : (List<EntityPlayer>) Wrapper.INSTANCE.world().playerEntities) { if (params[1].equals(entPly.getCommandSenderName())) { try { int x = getDeltaVal(params[2], (MathHelper.floor_double(Wrapper.INSTANCE.player().posX))); int y = getDeltaVal(params[3], (MathHelper.floor_double(Wrapper.INSTANCE.player().posY))); int z = getDeltaVal(params[4], (MathHelper.floor_double(Wrapper.INSTANCE.player().posZ))); InteropUtils.log("Teleported by SelfRf", this); tpEntity(entPly, x, y - 2, z, Wrapper.INSTANCE.player().dimension); return false; } catch (Exception e) { } } } } if (params[0].equals("tppos") && params.length == 4) { try { int x = getDeltaVal(params[1], (MathHelper.floor_double(Wrapper.INSTANCE.player().posX))); int y = getDeltaVal(params[2], (MathHelper.floor_double(Wrapper.INSTANCE.player().posY))); int z = getDeltaVal(params[3], (MathHelper.floor_double(Wrapper.INSTANCE.player().posZ))); InteropUtils.log("Teleported by SelfRf", this); tpEntity(Wrapper.INSTANCE.player(), x, y - 2, z, Wrapper.INSTANCE.player().dimension); return false; } catch (Exception e) { } } if (params[0].equals("tpdim") && params.length == 5) { try { int x = getDeltaVal(params[1], (MathHelper.floor_double(Wrapper.INSTANCE.player().posX))); int y = getDeltaVal(params[2], (MathHelper.floor_double(Wrapper.INSTANCE.player().posY))); int z = getDeltaVal(params[3], (MathHelper.floor_double(Wrapper.INSTANCE.player().posZ))); int dim = Integer.parseInt(params[4]); InteropUtils.log("Teleported by SelfRf", this); tpEntity(Wrapper.INSTANCE.player(), x, y - 2, z, dim); return false; } catch (Exception e) { } } } } return true; } @Override public ModStatus getModStatus() { try { Class.forName("mcjty.rftools.network.RFToolsMessages").getField("INSTANCE"); Class.forName("mcjty.rftools.items.teleportprobe.PacketForceTeleport").getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE); return ModStatus.WORKING; } catch (Exception e) { return ModStatus.NOTWORKING; } } public void tpEntity(Entity ent, int x, int y, int z, int dim) { try { SimpleNetworkWrapper snw = (SimpleNetworkWrapper) Class.forName("mcjty.rftools.network.RFToolsMessages").getField("INSTANCE").get(null); Object packet = Class.forName("mcjty.rftools.items.teleportprobe.PacketForceTeleport").getConstructor(Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(x, y, z, dim); snw.sendToServer((IMessage) packet); } catch (Exception e) { } } @Override public String getModName() { return "RFTools"; } }
12,488
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
CellViewer.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/mods/ae2/CellViewer.java
package ehacks.mod.modulesystem.classes.mods.ae2; import ehacks.mod.api.ModStatus; import ehacks.mod.api.Module; import ehacks.mod.modulesystem.classes.keybinds.OpenAE2ViewerKeybind; import ehacks.mod.util.GLUtils; import ehacks.mod.util.InteropUtils; import ehacks.mod.util.Mappings; import ehacks.mod.util.MinecraftGuiUtils; import ehacks.mod.wrapper.ModuleCategory; import ehacks.mod.wrapper.Wrapper; import java.lang.reflect.Method; import java.util.ArrayList; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; public class CellViewer extends Module { public CellViewer() { super(ModuleCategory.EHACKS); } @Override public String getName() { return "CellViewer"; } @Override public String getDescription() { return "Allows you to view cell contents\nUsage: \nNumpad4 - show contents of cell under mouse pointer"; } @Override public void onModuleEnabled() { } @Override public ModStatus getModStatus() { try { Class.forName("appeng.items.storage.ItemBasicStorageCell"); return ModStatus.WORKING; } catch (Exception e) { return ModStatus.NOTWORKING; } } private boolean prevState = false; @Override public void onTicks() { try { boolean newState = Keyboard.isKeyDown(OpenAE2ViewerKeybind.getKey()); if (newState && !prevState) { prevState = newState; GuiScreen screen = Wrapper.INSTANCE.mc().currentScreen; ItemStack cell = null; if (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++) { //noinspection JavaReflectionInvocation if ((Boolean) isMouseOverSlot.invoke(container, container.inventorySlots.inventorySlots.get(i), mouseX, get.getScaledHeight() - mouseY)) { cell = container.inventorySlots.inventorySlots.get(i) == null ? null : ((Slot) container.inventorySlots.inventorySlots.get(i)).getStack(); } } } catch (Exception ex) { InteropUtils.log("&cError", this); } } if (cell == null) { return; } if (!(Class.forName("appeng.items.storage.ItemBasicStorageCell").isInstance(cell.getItem()))) { InteropUtils.log("&cNot a cell", this); return; } NBTTagCompound tag = cell.stackTagCompound; if (tag == null) { InteropUtils.log("&cCell is empty (new)", this); return; } try { ArrayList<ItemStack> stacks = new ArrayList<>(); int count = tag.getShort("it"); for (int i = 0; i < count; i++) { ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("#" + i)); stack.stackSize = (int) tag.getCompoundTag("#" + i).getLong("Cnt"); if (stack.stackTagCompound == null) { stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound.setString("render-cellviewer", "ok"); } stacks.add(stack); } Wrapper.INSTANCE.mc().displayGuiScreen(new CellViewerGui(new CellViewerContainer(stacks.toArray(new ItemStack[stacks.size()]), cell.getDisplayName()))); } catch (Exception e) { InteropUtils.log("&cError", this); } } prevState = newState; } catch (Exception ignored) { } } @Override public String getModName() { return "AE2"; } private class CellViewerGui extends GuiContainer { private final CellViewerContainer container; private GuiButton buttonLeft; private GuiButton buttonRight; public CellViewerGui(CellViewerContainer container) { super(container); CellViewerGui.itemRender = new CellViewerRenderItem(); this.container = container; this.xSize = 256; this.ySize = 256; } @Override protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); int startX = (this.width - this.xSize) / 2; int startY = (this.height - this.ySize) / 2; MinecraftGuiUtils.drawBack(startX, startY, xSize, ySize); int x = 0; int y = 0; for (Slot get : container.slots.get(container.currentPage)) { MinecraftGuiUtils.drawSlotBack(startX + 11 + x * 18, startY + 17 + y * 18); x++; y += x / 13; x %= 13; } } @Override protected void drawGuiContainerForegroundLayer(int p1, int p2) { Wrapper.INSTANCE.fontRenderer().drawString(container.containerName + " - " + String.valueOf(container.inventorySlots.size()) + " slots", 12, 6, GLUtils.getColor(64, 64, 64)); Wrapper.INSTANCE.fontRenderer().drawString("Page " + String.valueOf(container.currentPage + 1), 128 - Wrapper.INSTANCE.fontRenderer().getStringWidth("Page " + String.valueOf(container.currentPage + 1)) / 2, 230, GLUtils.getColor(64, 64, 64)); } @SuppressWarnings("unchecked") @Override public void initGui() { super.initGui(); int startX = (this.width - this.xSize) / 2; int startY = (this.height - this.ySize) / 2; buttonLeft = new GuiButton(1, startX + 20, startY + 224, 20, 20, "<"); buttonLeft.enabled = container.currentPage > 0; this.buttonList.add(buttonLeft); buttonRight = new GuiButton(2, startX + 216, startY + 224, 20, 20, ">"); buttonRight.enabled = container.currentPage < (container.slots.size() - 1); this.buttonList.add(buttonRight); } @Override protected void actionPerformed(GuiButton b) { if (b.id == 1) { container.setPage(container.currentPage - 1); buttonLeft.enabled = container.currentPage > 0; buttonRight.enabled = container.currentPage < (container.slots.size() - 1); } if (b.id == 2) { container.setPage(container.currentPage + 1); buttonLeft.enabled = container.currentPage > 0; buttonRight.enabled = container.currentPage < (container.slots.size() - 1); } } @Override protected void handleMouseClick(Slot p_146984_1_, int p_146984_2_, int p_146984_3_, int p_146984_4_) { } } private class CellViewerContainer extends Container { public int currentPage = 0; public ItemStack[] inventory; public ArrayList<ArrayList<Slot>> slots = new ArrayList<>(); public String containerName; public CellViewerContainer(ItemStack[] inventory, String containerName) { this.containerName = containerName; this.inventory = inventory; int x = 0; int y = 0; int page = 0; for (int i = 0; i < inventory.length; i++) { if (slots.size() == page) { slots.add(new ArrayList<>()); } Slot slot = new CellViewerSlot(inventory[i], i, page == currentPage ? 12 + x * 18 : -2000, page == currentPage ? 18 + y * 18 : -2000); slots.get(page).add(slot); this.addSlotToContainer(slot); this.putStackInSlot(i, inventory[i]); x++; y += x / 13; x %= 13; page += y / 11; y %= 11; } if (slots.isEmpty()) { slots.add(new ArrayList<>()); } } @Override public void putStackInSlot(int p_75141_1_, ItemStack p_75141_2_) { } public void setPage(int pageId) { if (pageId < 0 || pageId >= slots.size()) { return; } slots.get(currentPage).stream().map((s) -> { s.xDisplayPosition = -2000; return s; }).forEachOrdered((s) -> { s.yDisplayPosition = -2000; }); currentPage = pageId; int x = 0; int y = 0; for (int i = 0; i < slots.get(currentPage).size(); i++) { slots.get(currentPage).get(i).xDisplayPosition = 12 + x * 18; slots.get(currentPage).get(i).yDisplayPosition = 18 + y * 18; x++; y += x / 13; x %= 13; } } @Override public boolean canInteractWith(EntityPlayer p_75145_1_) { return true; } } private class CellViewerSlot extends Slot { private final ItemStack is; public CellViewerSlot(ItemStack is, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) { super(null, p_i1824_2_, p_i1824_3_, p_i1824_4_); this.is = is; } public boolean isValidItem(ItemStack is) { return true; } @Override public ItemStack getStack() { return is; } @Override public void putStack(ItemStack p_75215_1_) { } @Override public void onSlotChanged() { } @Override public int getSlotStackLimit() { return is.getMaxStackSize(); } /** * Decrease the size of the stack in slot (first int arg) by the amount * of the second int arg. Returns the new stack. */ @Override public ItemStack decrStackSize(int p_75209_1_) { return is; } @Override public boolean isSlotInInventory(IInventory p_75217_1_, int p_75217_2_) { return true; } } private class CellViewerRenderItem extends RenderItem { @Override public void renderItemOverlayIntoGUI(FontRenderer p_94148_1_, TextureManager p_94148_2_, ItemStack p_94148_3_, int p_94148_4_, int p_94148_5_, String p_94148_6_) { if (p_94148_3_ != null) { boolean renderSmall = p_94148_3_.stackTagCompound != null && "ok".equals(p_94148_3_.stackTagCompound.getString("render-cellviewer")); if (p_94148_3_.getItem().showDurabilityBar(p_94148_3_)) { double health = p_94148_3_.getItem().getDurabilityForDisplay(p_94148_3_); int j1 = (int) Math.round(13.0D - health * 13.0D); int k = (int) Math.round(255.0D - health * 255.0D); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); Tessellator tessellator = Tessellator.instance; int l = 255 - k << 16 | k << 8; int i1 = (255 - k) / 4 << 16 | 16128; this.renderQuad(tessellator, p_94148_4_ + 2, p_94148_5_ + 13, 13, 2, 0); this.renderQuad(tessellator, p_94148_4_ + 2, p_94148_5_ + 13, 12, 1, i1); this.renderQuad(tessellator, p_94148_4_ + 2, p_94148_5_ + 13, j1, 1, l); //GL11.glEnable(GL11.GL_BLEND); // Forge: Disable Bled because it screws with a lot of things down the line. GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } if (p_94148_3_.stackSize > 1 || p_94148_6_ != null || renderSmall) { String s1 = p_94148_6_ == null ? String.valueOf(p_94148_3_.stackSize) : p_94148_6_; if (renderSmall) { s1 = getStringOfNum(p_94148_3_.stackSize); } GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_BLEND); if (renderSmall) { GL11.glScalef(.5f, .5f, .5f); } int textX = p_94148_4_ + 19 - 2 - p_94148_1_.getStringWidth(s1); int textY = p_94148_5_ + 6 + 3; if (renderSmall) { textX = p_94148_4_ * 2 + 32 - p_94148_1_.getStringWidth(s1) - 2; textY = p_94148_5_ * 2 + 23; } p_94148_1_.drawStringWithShadow(s1, textX, textY, 16777215); if (renderSmall) { GL11.glScalef(2f, 2f, 2f); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); } } } private String getStringOfNum(int num) { if (num < 10000) { return String.valueOf(num); } num /= 1000; if (num < 1000) { return String.valueOf(num) + "K"; } num /= 1000; if (num < 1000) { return String.valueOf(num) + "M"; } num /= 1000; return String.valueOf(num) + "B"; } private void renderQuad(Tessellator p_77017_1_, int p_77017_2_, int p_77017_3_, int p_77017_4_, int p_77017_5_, int p_77017_6_) { p_77017_1_.startDrawingQuads(); p_77017_1_.setColorOpaque_I(p_77017_6_); p_77017_1_.addVertex((p_77017_2_), (p_77017_3_), 0.0D); p_77017_1_.addVertex((p_77017_2_), (p_77017_3_ + p_77017_5_), 0.0D); p_77017_1_.addVertex((p_77017_2_ + p_77017_4_), (p_77017_3_ + p_77017_5_), 0.0D); p_77017_1_.addVertex((p_77017_2_ + p_77017_4_), (p_77017_3_), 0.0D); p_77017_1_.draw(); } } }
16,000
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
RedHack.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/mods/projectred/RedHack.java
package ehacks.mod.modulesystem.classes.mods.projectred; 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 RedHack extends Module { public RedHack() { super(ModuleCategory.EHACKS); } @Override public String getName() { return "RedHack"; } @Override public String getDescription() { return "Allows you to give any ItemStack to your hand\nUsage:\n Numpad0 - Gives an item"; } @Override public void onModuleEnabled() { try { Class.forName("mrtjp.projectred.transportation.TransportationSPH$"); Class.forName("codechicken.lib.packet.PacketCustom"); } catch (Exception ex) { this.off(); } } @Override public ModStatus getModStatus() { try { Class.forName("mrtjp.projectred.transportation.TransportationSPH$"); Class.forName("codechicken.lib.packet.PacketCustom"); return ModStatus.WORKING; } catch (Exception e) { return ModStatus.NOTWORKING; } } @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 = Wrapper.INSTANCE.player().inventory.currentItem; if (Statics.STATIC_ITEMSTACK == null) { return; } setRed(Statics.STATIC_ITEMSTACK, slotId); InteropUtils.log("Set", this); } prevState = newState; } //Only works with project red mechanical public void setRed(ItemStack item, int slotId) { try { Object packetInstance = Class.forName("codechicken.lib.packet.PacketCustom").getConstructor(Object.class, Integer.TYPE).newInstance("PR|Transp", 4); Class.forName("codechicken.lib.packet.PacketCustom").getMethod("writeByte", Byte.TYPE).invoke(packetInstance, (byte) slotId); Class.forName("codechicken.lib.packet.PacketCustom").getMethod("writeItemStack", ItemStack.class).invoke(packetInstance, item); Class.forName("codechicken.lib.packet.PacketCustom").getMethod("sendToServer").invoke(packetInstance); } catch (Exception ex) { } } @Override public String getModName() { return "Project Red"; } }
2,768
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z
VerticalGui.java
/FileExtraction/Java_unseen/radioegor146_ehacks-pro/src/main/java/ehacks/mod/modulesystem/classes/mods/thaumichorizons/VerticalGui.java
package ehacks.mod.modulesystem.classes.mods.thaumichorizons; import ehacks.mod.api.ModStatus; import ehacks.mod.api.Module; import ehacks.mod.util.InteropUtils; import ehacks.mod.wrapper.ModuleCategory; import ehacks.mod.wrapper.Wrapper; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import net.minecraft.network.play.client.C17PacketCustomPayload; import org.lwjgl.input.Keyboard; public class VerticalGui extends Module { public VerticalGui() { super(ModuleCategory.EHACKS); } @Override public String getName() { return "VerticalGui"; } @Override public String getDescription() { return "Opens a gui to perform craft dupe\nUsage:\n Y - Open gui"; } @Override public void onModuleEnabled() { try { Class.forName("com.kentington.thaumichorizons.common.lib.PacketFingersToServer"); InteropUtils.log("Press Y for GUI", this); } catch (Exception ex) { this.off(); } } @Override public ModStatus getModStatus() { try { Class.forName("com.kentington.thaumichorizons.common.lib.PacketFingersToServer"); return ModStatus.WORKING; } catch (Exception e) { return ModStatus.NOTWORKING; } } private boolean prevState = false; @Override public void onTicks() { boolean newState = Keyboard.isKeyDown(Keyboard.KEY_Y); if (newState && !prevState) { openGui(); } prevState = newState; } public void openGui() { ByteBuf buf = Unpooled.buffer(0); buf.writeByte(9); buf.writeInt(Wrapper.INSTANCE.player().getEntityId()); buf.writeInt(Wrapper.INSTANCE.player().dimension); C17PacketCustomPayload packet = new C17PacketCustomPayload("thaumichorizons", buf); Wrapper.INSTANCE.player().sendQueue.addToSendQueue(packet); InteropUtils.log("Opened", this); } @Override public String getModName() { return "Horizons"; } }
2,079
Java
.java
radioegor146/ehacks-pro
24
19
4
2018-07-08T13:24:10Z
2022-12-06T08:08:58Z