[BLEEDING] Make use of workarounds for a specific case, test-wise.
This commit is contained in:
parent
228ed2f74a
commit
02137600b7
|
@ -32,7 +32,8 @@ public interface IWorkaroundRegistry {
|
|||
public static class WorkaroundSet {
|
||||
|
||||
// TODO: getUseCount()
|
||||
// TODO: A list for ids of just used workarounds (reset externally. Add use(id) vs alter Workaround)?
|
||||
// TODO: A list of just used IStageWorkaround / maybe other extra, or a flag (reset externally).
|
||||
// TODO: Alternative: provide a use(Collection<String>) method to add the id to on accept.
|
||||
// TODO: Better optimized constructor (instanceof-decisions can be pre-cached).
|
||||
|
||||
/** Map workaround id to workaround. */
|
||||
|
@ -205,6 +206,16 @@ public interface IWorkaroundRegistry {
|
|||
*/
|
||||
public void setGroup(String groupId, Collection<String> workaroundIds);
|
||||
|
||||
/**
|
||||
* Specify what workaround ids belong to a certain group. Workarounds can be
|
||||
* in multiple groups. The workaroundIds must exist.
|
||||
*
|
||||
* @param groupId
|
||||
* @param bluePrints
|
||||
* The ids are used, must exist.
|
||||
*/
|
||||
public void setGroup(String groupId, IWorkaround... bluePrints);
|
||||
|
||||
/**
|
||||
* Define which workarounds and which groups belong to the WorkaroundSet of
|
||||
* the given workaroundSetId.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package fr.neatmonster.nocheatplus.workaround;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -63,6 +64,11 @@ public class SimpleWorkaroundRegistry implements IWorkaroundRegistry {
|
|||
groups.put(groupId, workaroundIds.toArray(new String[workaroundIds.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroup(String groupId, IWorkaround... bluePrints) {
|
||||
setGroup(groupId, getCheckedIdSet(Arrays.asList(bluePrints)));
|
||||
}
|
||||
|
||||
private void setWorkaroundSet(final String workaroundSetId, final Collection<IWorkaround> bluePrints, final String... groupIds) {
|
||||
final String[] ids = new String[bluePrints.size()];
|
||||
int i = 0;
|
||||
|
|
|
@ -2,6 +2,7 @@ package fr.neatmonster.nocheatplus.checks.moving;
|
|||
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.LiftOffEnvelope;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.MoveData;
|
||||
import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
|
||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||
|
||||
/**
|
||||
|
@ -92,8 +93,12 @@ public class Magic {
|
|||
|| yDistance == 0.0 && data.sfZeroVdist > 0 && data.sfZeroVdist < 10
|
||||
)
|
||||
// 0: Jumping on slimes, change viewing direction at the max. height.
|
||||
// TODO: Precondition bounced off or touched slime.
|
||||
// TODO: Once per jumpphase.
|
||||
|| yDistance == 0.0 && data.sfZeroVdist == 1
|
||||
&& (data.isVelocityJumpPhase() || data.hasSetBack() && to.getY() - data.getSetBackY() < 1.35);
|
||||
&& (data.isVelocityJumpPhase() || data.hasSetBack() && to.getY() - data.getSetBackY() < 1.35)
|
||||
&& data.ws.use(WRPT.W_M_SF_SLIME_JP_2X0)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,11 +22,13 @@ import fr.neatmonster.nocheatplus.checks.moving.velocity.AccountEntry;
|
|||
import fr.neatmonster.nocheatplus.checks.moving.velocity.FrictionAxisVelocity;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleAxisVelocity;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleEntry;
|
||||
import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
|
||||
import fr.neatmonster.nocheatplus.logging.Streams;
|
||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||
import fr.neatmonster.nocheatplus.utilities.ds.count.ActionAccumulator;
|
||||
import fr.neatmonster.nocheatplus.utilities.ds.count.ActionFrequency;
|
||||
import fr.neatmonster.nocheatplus.workaround.IWorkaroundRegistry.WorkaroundSet;
|
||||
|
||||
/**
|
||||
* Player specific data for the moving checks.
|
||||
|
@ -235,7 +237,8 @@ public class MovingData extends ACheckData {
|
|||
public double nextFrictionHorizontal = 0.0;
|
||||
/** Used during processing, no resetting necessary.*/
|
||||
public double nextFrictionVertical= 0.0;
|
||||
|
||||
/** Workarounds */
|
||||
public final WorkaroundSet ws;
|
||||
|
||||
// HOT FIX
|
||||
/** Inconsistency-flag. Set on moving inside of vehicles, reset on exiting properly. Workaround for VehicleLeaveEvent missing. */
|
||||
|
@ -249,6 +252,9 @@ public class MovingData extends ACheckData {
|
|||
morePacketsFreq = new ActionFrequency(config.morePacketsEPSBuckets, 500);
|
||||
morePacketsBurstFreq = new ActionFrequency(12, 5000);
|
||||
|
||||
// A new set of workaround conters.
|
||||
ws = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(WRPT.class).getWorkaroundSet(WRPT.WS_MOVING);
|
||||
|
||||
// Past moves data: initialize with dummies.
|
||||
for (int i = 0; i < 2; i++) { // Two past moves allow better workarounds than 1.
|
||||
moveData.add(new MoveData());
|
||||
|
|
|
@ -18,6 +18,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
|
|||
import fr.neatmonster.nocheatplus.checks.ViolationData;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.LiftOffEnvelope;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.model.MoveData;
|
||||
import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
|
||||
import fr.neatmonster.nocheatplus.compat.BridgeEnchant;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker.Direction;
|
||||
|
@ -468,6 +469,7 @@ public class SurvivalFly extends Check {
|
|||
}
|
||||
|
||||
// Apply reset conditions.
|
||||
boolean inAir = false; // Hack.
|
||||
if (resetTo) {
|
||||
// The player has moved onto ground.
|
||||
if (toOnGround) {
|
||||
|
@ -507,6 +509,11 @@ public class SurvivalFly extends Check {
|
|||
if (to.getY() < 0.0 && cc.sfSetBackPolicyVoid) {
|
||||
data.setSetBack(to);
|
||||
}
|
||||
inAir = true;
|
||||
}
|
||||
|
||||
if (!inAir) {
|
||||
data.ws.resetConditions(WRPT.G_RESET_NOTINAIR);
|
||||
}
|
||||
|
||||
// Horizontal velocity invalidation.
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package fr.neatmonster.nocheatplus.checks.workaround;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import fr.neatmonster.nocheatplus.workaround.IWorkaround;
|
||||
import fr.neatmonster.nocheatplus.workaround.SimpleWorkaroundRegistry;
|
||||
import fr.neatmonster.nocheatplus.workaround.WorkaroundCountDown;
|
||||
|
||||
/**
|
||||
* Workaround registry for primary thread use. Potentially cover all checks.
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public class WRPT extends SimpleWorkaroundRegistry {
|
||||
|
||||
///////////////////////
|
||||
// Workaround ids.
|
||||
///////////////////////
|
||||
|
||||
// MOVING_SURVIVALFLY
|
||||
// TODO: The use once thing could be shared by several spots (e.g. all double-0 top of slope).
|
||||
/** One time use max of jump phase twice zero dist. */
|
||||
public static final String W_M_SF_SLIME_JP_2X0 = "m.sf.slime.jp.2x0"; // hum. sha-1 instead?
|
||||
|
||||
///////////////////////
|
||||
// Group ids.
|
||||
///////////////////////
|
||||
|
||||
// MOVING_SURVIVALFLY
|
||||
public static final String G_RESET_NOTINAIR = "reset.notinair";
|
||||
|
||||
///////////////////////
|
||||
// WorkaroundSet ids.
|
||||
///////////////////////
|
||||
|
||||
// MOVING
|
||||
public static final String WS_MOVING = "moving";
|
||||
|
||||
public WRPT() {
|
||||
// Fill in blueprints, groups, workaround sets.
|
||||
|
||||
// MOVING
|
||||
final Collection<IWorkaround> ws_moving = new LinkedList<IWorkaround>();
|
||||
// MOVING_SURVIVALFLY
|
||||
// Reset once on ground or reset-condition.
|
||||
final WorkaroundCountDown[] resetNotInAir = new WorkaroundCountDown[] {
|
||||
new WorkaroundCountDown(W_M_SF_SLIME_JP_2X0, 1),
|
||||
};
|
||||
ws_moving.addAll(Arrays.asList(resetNotInAir));
|
||||
setWorkaroundBluePrint(resetNotInAir);
|
||||
setGroup(G_RESET_NOTINAIR, resetNotInAir);
|
||||
|
||||
// Finally register the set.
|
||||
setWorkaroundSetByIds(WS_MOVING, getCheckedIdSet(ws_moving), G_RESET_NOTINAIR);
|
||||
|
||||
// TODO: just counters
|
||||
|
||||
// TODO: Command to log.
|
||||
}
|
||||
|
||||
}
|
|
@ -44,6 +44,7 @@ import fr.neatmonster.nocheatplus.checks.combined.CombinedListener;
|
|||
import fr.neatmonster.nocheatplus.checks.fight.FightListener;
|
||||
import fr.neatmonster.nocheatplus.checks.inventory.InventoryListener;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
|
||||
import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
|
||||
import fr.neatmonster.nocheatplus.clients.ModUtil;
|
||||
import fr.neatmonster.nocheatplus.command.NoCheatPlusCommand;
|
||||
import fr.neatmonster.nocheatplus.command.admin.VersionCommand;
|
||||
|
@ -842,6 +843,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||
// Register some generic stuff.
|
||||
// Counters: debugging purposes, maybe integrated for statistics later.
|
||||
registerGenericInstance(new Counters());
|
||||
registerGenericInstance(new WRPT()); // Not entirely sure here.
|
||||
|
||||
// Initialize MCAccess.
|
||||
initMCAccess(config);
|
||||
|
|
Loading…
Reference in New Issue