Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
Fix #112
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekiplay committed Apr 11, 2024
1 parent 053eae4 commit 325c282
Show file tree
Hide file tree
Showing 26 changed files with 762 additions and 451 deletions.
12 changes: 8 additions & 4 deletions src/main/java/nekiplay/MixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@ public class MixinPlugin implements IMixinConfigPlugin {

private static final String mixinPackageMeteorPlus = "nekiplay.meteorplus.mixin";
private static final String mixinPackageBozePlus = "nekiplay.bozeplus.mixin";

public static boolean isMeteorClient = false;
public static boolean isMeteorRejects= false;

public static boolean isBozeAPI= false;
public static boolean isFutureClient = false;

public static boolean isBaritonePresent = false;
public static boolean isJourneyMapPresent = false;
public static boolean isXaeroWorldMapresent = false;
public static boolean isXaeroMiniMapresent= false;
public static boolean isXaeroPlusMapresent = false;
public static boolean isLitematicaMapresent = false;
public static boolean isWhereIsIt = false;
public static boolean isMeteorRejects= false;

public static boolean isBozeAPI= false;

@Override
public void onLoad(String mixinPackage) {
FabricLoader loader = FabricLoader.getInstance();

isMeteorClient = loader.isModLoaded("meteor-client");
isBozeAPI = loader.isModLoaded("boze-api");
isFutureClient = loader.isModLoaded("future");

isMeteorRejects = loader.isModLoaded("meteor-rejects");

Expand Down Expand Up @@ -78,7 +82,7 @@ else if (mixinClassName.startsWith(mixinPackageMeteorPlus + ".minecraft")) {
}

else if (mixinClassName.startsWith(mixinPackageBozePlus + ".minecraft")) {
return isBozeAPI;
return isBozeAPI && !isMeteorClient;
}

return false;
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/nekiplay/bozeplus/BozePlusAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import dev.boze.api.exception.AddonInitializationException;
import meteordevelopment.orbit.EventBus;
import meteordevelopment.orbit.IEventBus;
import nekiplay.MixinPlugin;
import nekiplay.bozeplus.features.modules.movement.spider.SpiderPlus;
import nekiplay.bozeplus.impl.BozePlusDispatcher;
import nekiplay.bozeplus.impl.BozePlusModule;
Expand All @@ -35,7 +34,7 @@ public static BozePlusAddon getInstance() {
public final AddonMetadata metadata = new AddonMetadata(
"boze-plus",
"Boze Plus",
"An example addon for Boze",
"Meteor Plus modules for Boze",
new AddonVersion(1, 0, 0));

private final ArrayList<AddonModule> modules = new ArrayList<>();
Expand All @@ -49,6 +48,11 @@ public void onInitialize() {
}
}

private void addModule(AddonModule module) {
modules.add(module);
EVENT_BUS.subscribe(module);
}

@Override
public AddonMetadata getMetadata() {
return metadata;
Expand All @@ -65,8 +69,7 @@ public boolean initialize() {

SpiderPlus spiderPlus = new SpiderPlus();

modules.add(spiderPlus);
EVENT_BUS.subscribe(spiderPlus);
addModule(spiderPlus);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package nekiplay.bozeplus.features.modules.movement.nofall;

import dev.boze.api.event.EventTick;
import nekiplay.bozeplus.events.packets.PacketEvent;
import nekiplay.bozeplus.features.modules.movement.spider.SpiderPlus;
import net.minecraft.client.MinecraftClient;

public class NoFallMode {
protected final MinecraftClient mc;
protected final NoFallPlus settings;
private final NoFallModes type;

public NoFallMode(NoFallModes type, NoFallPlus settings) {
this.settings = settings;
this.mc = MinecraftClient.getInstance();
this.type = type;
}

public void onSendPacket(PacketEvent.Send event) {}
public void onSentPacket(PacketEvent.Sent event) {}

public void onTickEventPre(EventTick.Pre event) {}
public void onTickEventPost(EventTick.Post event) {}

public void onActivate() {}
public void onDeactivate() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package nekiplay.bozeplus.features.modules.movement.nofall;

public enum NoFallModes {
MatrixNew,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package nekiplay.bozeplus.features.modules.movement.nofall;

import dev.boze.api.addon.module.ToggleableModule;
import dev.boze.api.event.EventTick;
import dev.boze.api.setting.SettingMode;
import meteordevelopment.orbit.EventHandler;
import nekiplay.bozeplus.events.packets.PacketEvent;
import nekiplay.bozeplus.features.modules.movement.nofall.modes.MatrixNew;

import java.util.ArrayList;

public class NoFallPlus extends ToggleableModule {
private final SettingMode mode = new SettingMode("Mode", "Bypass mode", new ArrayList<>() {{
add("Matrix");
}});

public NoFallPlus() {
super("No Fall+", "Bypass no fall");
elements.add(mode);
onNoFallModeChanged(mode.getMode());
}

@Override
protected void onEnable() {
onNoFallModeChanged(mode.getMode());
if (currentMode != null) {
currentMode.onActivate();
}
}

@EventHandler
public void onSendPacket(PacketEvent.Send event) {
if (currentMode != null) {
currentMode.onSendPacket(event);
}
}

@EventHandler
public void onSentPacket(PacketEvent.Sent event) {
if (currentMode != null) {
currentMode.onSentPacket(event);
}
}

@EventHandler
public void onTickEventPre(EventTick.Pre event) {
if (currentMode != null) {
currentMode.onTickEventPre(event);
}
}

@EventHandler
public void onTickEventPost(EventTick.Post event) {
if (currentMode != null) {
currentMode.onTickEventPost(event);
}
}
private NoFallMode currentMode = null;
private void onNoFallModeChanged(int mode) {
switch (mode) {
case 0 -> currentMode = new MatrixNew(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package nekiplay.bozeplus.features.modules.movement.nofall.modes;

import nekiplay.Main;
import nekiplay.bozeplus.features.modules.movement.nofall.NoFallMode;
import nekiplay.bozeplus.features.modules.movement.nofall.NoFallModes;
import nekiplay.bozeplus.features.modules.movement.nofall.NoFallPlus;
import nekiplay.bozeplus.features.modules.movement.spider.SpiderModes;
import nekiplay.bozeplus.features.modules.movement.spider.SpiderPlus;

public class MatrixNew extends NoFallMode {
public MatrixNew(NoFallPlus noFallPlus) {
super(NoFallModes.MatrixNew, noFallPlus);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package nekiplay.bozeplus.features.modules.movement.spider;
import dev.boze.api.event.EventTick;
import nekiplay.bozeplus.events.packets.PacketEvent;
import net.minecraft.client.MinecraftClient;

public class SpiderMode {
protected final MinecraftClient mc;
protected final SpiderPlus settings;
private final SpiderModes type;

public SpiderMode(SpiderModes type, SpiderPlus settings) {
this.settings = settings;
this.mc = MinecraftClient.getInstance();
this.type = type;
}

public void onSendPacket(PacketEvent.Send event) {}
public void onSentPacket(PacketEvent.Sent event) {}

public void onTickEventPre(EventTick.Pre event) {}
public void onTickEventPost(EventTick.Post event) {}

public void onActivate() {}
public void onDeactivate() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package nekiplay.bozeplus.features.modules.movement.spider;

public enum SpiderModes {
Matrix_Lower_7,
Vulcan,
Elytra_clip;

@Override
public String toString() {
return super.toString().replace('_', ' ').replaceAll("_Lower_", "<");
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
package nekiplay.bozeplus.features.modules.movement.spider;

import dev.boze.api.Globals;
import dev.boze.api.addon.module.ToggleableModule;
import dev.boze.api.event.EventTick;
import dev.boze.api.setting.SettingMode;
import dev.boze.api.setting.SettingToggle;
import meteordevelopment.orbit.EventHandler;
import nekiplay.bozeplus.events.packets.PacketEvent;
import nekiplay.bozeplus.mixin.minecraft.PlayerMoveC2SPacketAccessor;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.util.math.Vec3d;
import nekiplay.bozeplus.features.modules.movement.spider.modes.Matrix;

import java.util.ArrayList;

Expand All @@ -23,122 +15,51 @@ public class SpiderPlus extends ToggleableModule {
add("Matrix");
}});

private int tick = 0;
private boolean modify = false;
private boolean start = false;

private double startY = 0;
private double lastY = 0;

private double coff = 0.0000000000326;

public SpiderPlus() {
super("Spider", "Climb on walls");
elements.add(mode);
onSpiderModeChanged(mode.getMode());
}

@Override
protected void onEnable() {

}
private boolean YGround(double height, double min, double max) {
String yString = String.valueOf(height);
yString = yString.substring(yString.indexOf("."));
double y = Double.parseDouble(yString);
return y >= min && y <= max;
}

private double RGround(double height) {
String yString = String.valueOf(height);
yString = yString.substring(yString.indexOf("."));
return Double.parseDouble(yString);
}
private void work(Packet<?> packet) {
if (modify) {
if (packet instanceof PlayerMoveC2SPacket move) {
assert MinecraftClient.getInstance().player != null;
double y = MinecraftClient.getInstance().player.getY();
y = move.getY(y);

if (YGround(y, RGround(startY) - 0.1, RGround(startY) + 0.1)) {
((PlayerMoveC2SPacketAccessor) packet).setOnGround(true);
}
if (MinecraftClient.getInstance().player.isOnGround() && block) {
block = false;
startY = MinecraftClient.getInstance().player.getPos().y;
start = false;
}
}
} else {
assert MinecraftClient.getInstance().player != null;
if (MinecraftClient.getInstance().player.isOnGround() && block) {
block = false;
startY = MinecraftClient.getInstance().player.getPos().y;
start = false;
}
onSpiderModeChanged(mode.getMode());
if (currentMode != null) {
currentMode.onActivate();
}
}

@EventHandler
public void onSendPacket(PacketEvent.Send event) {
work(event.packet);
if (currentMode != null) {
currentMode.onSendPacket(event);
}
}

@EventHandler
public void onSentPacket(PacketEvent.Sent event) {
work(event.packet);
if (currentMode != null) {
currentMode.onSentPacket(event);
}
}

private boolean block = false;

@EventHandler
public void onTickEventPre(EventTick.Pre event) {
if (modify) {
ClientPlayerEntity player = MinecraftClient.getInstance().player;
double y = player.getPos().y;
if (lastY == y && tick > 1) {
block = true;
} else {
lastY = y;
}
if (currentMode != null) {
currentMode.onTickEventPre(event);
}
}

@EventHandler
public void onTickEventPost(EventTick.Post event) {
ClientPlayerEntity player = MinecraftClient.getInstance().player;
assert player != null;
Vec3d pl_velocity = player.getVelocity();
Vec3d pos = player.getPos();
ClientPlayNetworkHandler h = MinecraftClient.getInstance().getNetworkHandler();
modify = player.horizontalCollision;
if (MinecraftClient.getInstance().player.isOnGround()) {
block = false;
startY = MinecraftClient.getInstance().player.getPos().y;
start = false;
}
if (player.horizontalCollision) {
if (!start) {
start = true;
startY = MinecraftClient.getInstance().player.getPos().y;
lastY = MinecraftClient.getInstance().player.getY();
}
if (!block) {
if (tick == 0) {
MinecraftClient.getInstance().player.setVelocity(pl_velocity.x, 0.41999998688698, pl_velocity.z);
tick = 1;
} else if (tick == 1) {
MinecraftClient.getInstance().player.setVelocity(pl_velocity.x, 0.41999998688698 - 0.08679999325 - coff, pl_velocity.z);
tick = 2;
} else if (tick == 2) {
MinecraftClient.getInstance().player.setVelocity(pl_velocity.x, 0.41999998688698 - 0.17186398826 - coff, pl_velocity.z);
tick = 0;
}
}
if (currentMode != null) {
currentMode.onTickEventPost(event);
}
else {
modify = false;
tick = 0;
}
private SpiderMode currentMode = null;
private void onSpiderModeChanged(int mode) {
switch (mode) {
case 0 -> currentMode = new Matrix(this);
}
}
}
Loading

0 comments on commit 325c282

Please sign in to comment.