@FunctionRegister(
name = "Criticals",
description = "Позволяет бить критами с места",
type = Category.Combat
)
public class Criticals extends Function {
private final Minecraft mc = Minecraft.getInstance();
public final ModeSetting modeSetting = new ModeSetting("Режим", "Web", "Web");
private int webTicks = 0;
public Criticals() {
this.addSettings(new Setting[]{this.modeSetting});
}
@EventTarget
public void onEvent(EventAttack event) {
if (!this.isState()) {
return;
}
Vector3d pos = mc.player.getPositionVec();
if (this.modeSetting.is("Web")) {
if (!this.isInWeb()) {
return;
}
this.webTicks = (this.webTicks + 1) % 2;
if (this.webTicks == 1) {
mc.player.connection.sendPacket(new CPlayerPacket.PositionRotationPacket(pos.x, pos.y - 1.0E-6, pos.z, mc.player.rotationYaw, mc.player.rotationPitch, false));
}
}
}
private boolean isInWeb() {
boolean inWeb = false;
for(double x = -0.3; x <= 0.3; x += 0.3) {
for(double z = -0.3; z <= 0.3; z += 0.3) {
for(double y = (double)mc.player.getEyeHeight(); y >= (double)0.0F; y -= 0.1) {
if (mc.world.getBlockState(new BlockPos(mc.player.getPosX() + x, mc.player.getPosY() + y, mc.player.getPosZ() + z)).getBlock() == Blocks.COBWEB) {
inWeb = true;
break;
}
}
if (mc.world.getBlockState(new BlockPos(mc.player.getPosX() + x, mc.player.getPosY(), mc.player.getPosZ() + z)).getBlock() == Blocks.COBWEB) {
inWeb = true;
break;
}
}
}
if (!inWeb && mc.world.getBlockState(new BlockPos(mc.player.getPosX(), mc.player.getPosY() + (double)mc.player.getEyeHeight() + 1.65, mc.player.getPosZ())).getBlock() == Blocks.COBWEB) {
inWeb = true;
}
return inWeb;
}
}