Skip to content
This repository was archived by the owner on May 1, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/main/java/me/bebeli555/autobot/mixin/MixinLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public String getSetupClass () {

@Override
public void injectData (Map<String, Object> data) {

}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package me.bebeli555.autobot.mixin.mixins;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import me.bebeli555.autobot.utils.ICPacketUseEntity;
import net.minecraft.network.play.client.CPacketUseEntity;

@Mixin(CPacketUseEntity.class)
public abstract class MixinCPacketUseEntity implements ICPacketUseEntity {

@Shadow
protected CPacketUseEntity.Action action;

@Shadow
protected int entityId;

@Override
public void setEntityId(int entityId) {
this.entityId = entityId;
}

@Override
public void setAction(CPacketUseEntity.Action action) {
this.action = action;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
package me.bebeli555.autobot.mods.bots.crystalpvpbot;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import me.bebeli555.autobot.AutoBot;
import me.bebeli555.autobot.events.PacketEvent;
import me.bebeli555.autobot.utils.BaritoneUtil;
import me.bebeli555.autobot.utils.BlockUtil;
import me.bebeli555.autobot.utils.CrystalUtil;
import me.bebeli555.autobot.utils.ICPacketUseEntity;
import me.bebeli555.autobot.utils.InventoryUtil;
import me.bebeli555.autobot.utils.MiningUtil;
import me.bebeli555.autobot.utils.RotationUtil;
import me.zero.alpine.listener.EventHandler;
import me.zero.alpine.listener.Listener;
import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.network.play.client.CPacketUseEntity;
import net.minecraft.network.play.server.SPacketSpawnObject;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
Expand All @@ -19,6 +28,7 @@ public class AutoCrystal extends AutoBot {
public Thread thread;
public static BlockPos placed;
public static boolean dontToggle;
private final List<BlockPos> placePosList = new CopyOnWriteArrayList<BlockPos>();

public AutoCrystal(EntityPlayer target) {
this.target = target;
Expand Down Expand Up @@ -73,6 +83,7 @@ public void loop() {
if (placeCrystal != null) {
BlockUtil.placeItem(Items.END_CRYSTAL, placeCrystal, false);
placed = placeCrystal;
this.placePosList.add(placeCrystal);
AutoBot.sleep(CrystalPvPBot.autoCrystalDelay.intValue());
}
}
Expand Down Expand Up @@ -161,4 +172,24 @@ public EntityEnderCrystal getBestCrystal() {
public static BlockPos getMostDamageSpot(EntityPlayer target) {
return new AutoCrystal(target).getBestCrystalSpot(false);
}


/**
* Shitty predict :^)
*/
@EventHandler
private Listener<PacketEvent> packetEvent = new Listener<>(event -> {
if (event.packet instanceof SPacketSpawnObject && CrystalPvPBot.autoCrystalPredict.booleanValue()) {
final SPacketSpawnObject packet2 = (SPacketSpawnObject) event.packet;
if (packet2.getType() == 51) {
final BlockPos pos = new BlockPos(packet2.getX(), packet2.getY(), packet2.getZ());
if (placePosList.contains(pos.down())) {
CPacketUseEntity useEntity = new CPacketUseEntity();
((ICPacketUseEntity)useEntity).setEntityId(packet2.getEntityID());
((ICPacketUseEntity)useEntity).setAction(CPacketUseEntity.Action.ATTACK);
mc.getConnection().sendPacket(useEntity);
}
}
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class CrystalPvPBot extends AutoBot {
public static Setting autoCrystalMinTargetDmg = new Setting(autoCrystalSetting, Mode.INTEGER, "MinTargetDmg", 5, "Minimum damage to do to target to active auto crystal");
public static Setting autoCrystalRange = new Setting(autoCrystalSetting, Mode.INTEGER, "Range", 4, "The range how far it can place and break crystals");
public static Setting autoCrystalDelay = new Setting(autoCrystalSetting, Mode.INTEGER, "Delay", 50, "Delay in ms it will wait after a place/break");
public static Setting autoCrystalPredict = new Setting(autoCrystalSetting, Mode.BOOLEAN, "Predict", true, "Predicts crystal spawn");
public static Setting autoTrap = new Setting(Mode.LABEL, "AutoTrap", true, "AutoTrap for the bot");
public static Setting autoTrapDelay = new Setting(autoTrap, Mode.INTEGER, "Delay", 50, "Delay in ms it will wait after a successful place");
public static Setting autoTrapDistance = new Setting(autoTrap, Mode.INTEGER, "Distance", 4, "Allowed place distance");
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/me/bebeli555/autobot/utils/ICPacketUseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package me.bebeli555.autobot.utils;

import net.minecraft.network.play.client.CPacketUseEntity;

public interface ICPacketUseEntity {

void getEntityId(int entityId);

void getEntityAction(CPacketUseEntity.Action action);

void setEntityId(int entityId);

void setAction(CPacketUseEntity.Action action);
}

3 changes: 2 additions & 1 deletion src/main/resources/mixins.autobot.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"MixinEntityPlayer",
"MixinEntityPlayerSP",
"MixinNetworkManager",
"MixinPlayerControllerMP"
"MixinPlayerControllerMP",
"MixinCPacketUseEntity"
]
}