Skip to content

Commit

Permalink
quality of life changes
Browse files Browse the repository at this point in the history
  • Loading branch information
soshimee committed Aug 8, 2024
1 parent b68ddc4 commit 73c35e3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx2g
baseGroup = com.github.soshimee.secretguide
mcVersion = 1.8.9
modid = secretguide
version = 1.0.9
version = 1.1.0
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.soshimee.secretguide.config;

import cc.polyfrost.oneconfig.config.Config;
import cc.polyfrost.oneconfig.config.annotations.Dropdown;
import cc.polyfrost.oneconfig.config.annotations.KeyBind;
import cc.polyfrost.oneconfig.config.annotations.Slider;
import cc.polyfrost.oneconfig.config.annotations.Switch;
Expand Down Expand Up @@ -31,7 +32,7 @@ public class SecretGuideConfig extends Config {
@Slider(
name = "Skull Range",
min = 2.1f,
max = 4.5f
max = 5.0f
)
public static float secretAuraSkullRange = 2.1f;

Expand All @@ -55,12 +56,23 @@ public class SecretGuideConfig extends Config {
)
public static OneKeyBind secretAuraClearKeyBind = new OneKeyBind();

@Dropdown(
name = "Swap On",
options = {"None", "Skulls", "All"}
)
public static int secretAuraSwapOn = 0;

@Switch(
name = "Swap Back"
)
public static boolean secretAuraSwapBack = true;

@Slider(
name = "Slot",
min = 0,
min = 1,
max = 9
)
public static int secretAuraSlot = 0;
public static int secretAuraSlot = 1;

public SecretGuideConfig() {
super(new Mod("secretguide", ModType.SKYBLOCK), "config.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
import net.minecraft.network.play.server.S02PacketChat;
import net.minecraft.network.play.server.S22PacketMultiBlockChange;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.network.play.server.S24PacketBlockAction;
import net.minecraft.network.play.server.*;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.util.*;
Expand All @@ -31,6 +32,7 @@ public class SecretAura {
private static final List<BlockPos> blocksDone = new LinkedList<>();
private static final Map<BlockPos, Long> blocksCooldown = new HashMap<>();
private static boolean redstoneKey = false;
private static int prevSlot = -1;

public SecretAura() {
EventManager.INSTANCE.register(this);
Expand Down Expand Up @@ -62,10 +64,15 @@ public void onTick(TickEvent.ClientTickEvent event) {
if (eyePos.distanceTo(new Vec3(position)) <= SecretGuideConfig.secretAuraRange) {
MovingObjectPosition movingObjectPosition = BlockUtils.collisionRayTrace(position, new AxisAlignedBB(0.0625, 0, 0.0625, 0.9375, 0.875, 0.9375), eyePos, centerPos);
if (movingObjectPosition == null) continue;
if (SecretGuideConfig.secretAuraSwapOn >= 2 && player.inventory.currentItem != SecretGuideConfig.secretAuraSlot - 1) {
prevSlot = player.inventory.currentItem;
player.inventory.currentItem = SecretGuideConfig.secretAuraSlot - 1;
return;
}
PacketUtils.sendPacket(new C08PacketPlayerBlockPlacement(position, movingObjectPosition.sideHit.getIndex(), player.getHeldItem(), (float) movingObjectPosition.hitVec.xCoord, (float) movingObjectPosition.hitVec.yCoord, (float) movingObjectPosition.hitVec.zCoord));
if (!player.isSneaking() && SecretGuideConfig.secretAuraSwingHand) player.swingItem();
blocksCooldown.put(position, new Date().getTime());
break;
return;
}
} else if (blockState.getBlock() == Blocks.lever) {
if (roomId == -109725212 || roomId == -353291158 || roomId == 1998063202 || roomId == 660384222 || roomId == -1012522341 || roomId == 660396563 || roomId == 1980639456 || roomId == 43497702 || roomId == 2014437159 || roomId == 1513261276 || roomId == 862140000 || roomId == -364886424 || roomId == -714138899 || roomId == -1489069695 || roomId == -685683836) continue;
Expand All @@ -88,10 +95,15 @@ public void onTick(TickEvent.ClientTickEvent event) {
if (eyePos.distanceTo(new Vec3(position)) <= SecretGuideConfig.secretAuraRange) {
MovingObjectPosition movingObjectPosition = BlockUtils.collisionRayTrace(position, aabb, eyePos, centerPos);
if (movingObjectPosition == null) continue;
if (SecretGuideConfig.secretAuraSwapOn >= 2 && player.inventory.currentItem != SecretGuideConfig.secretAuraSlot - 1) {
prevSlot = player.inventory.currentItem;
player.inventory.currentItem = SecretGuideConfig.secretAuraSlot - 1;
return;
}
PacketUtils.sendPacket(new C08PacketPlayerBlockPlacement(position, movingObjectPosition.sideHit.getIndex(), player.getHeldItem(), (float) movingObjectPosition.hitVec.xCoord, (float) movingObjectPosition.hitVec.yCoord, (float) movingObjectPosition.hitVec.zCoord));
if (!player.isSneaking() && SecretGuideConfig.secretAuraSwingHand) player.swingItem();
blocksCooldown.put(position, new Date().getTime());
break;
return;
}
} else if (blockState.getBlock() == Blocks.skull) {
TileEntity tileEntity = world.getTileEntity(position);
Expand Down Expand Up @@ -124,13 +136,14 @@ else if (world.getBlockState(position.down()).getBlock() == Blocks.redstone_bloc
if (eyePos.distanceTo(centerPos) <= SecretGuideConfig.secretAuraSkullRange) {
MovingObjectPosition movingObjectPosition = BlockUtils.collisionRayTrace(position, aabb, eyePos, centerPos);
if (movingObjectPosition == null) continue;
if (SecretGuideConfig.secretAuraSlot > 0 && player.inventory.currentItem != SecretGuideConfig.secretAuraSlot - 1) {
if (SecretGuideConfig.secretAuraSwapOn >= 1 && player.inventory.currentItem != SecretGuideConfig.secretAuraSlot - 1) {
prevSlot = player.inventory.currentItem;
player.inventory.currentItem = SecretGuideConfig.secretAuraSlot - 1;
break;
return;
}
PacketUtils.sendPacket(new C08PacketPlayerBlockPlacement(position, movingObjectPosition.sideHit.getIndex(), player.getHeldItem(), (float) movingObjectPosition.hitVec.xCoord, (float) movingObjectPosition.hitVec.yCoord, (float) movingObjectPosition.hitVec.zCoord));
blocksCooldown.put(position, new Date().getTime());
break;
return;
}
} else if (blockState.getBlock() == Blocks.redstone_block) {
if (!redstoneKey) continue;
Expand All @@ -145,16 +158,21 @@ else if (world.getBlockState(position.down()).getBlock() == Blocks.redstone_bloc
MovingObjectPosition movingObjectPosition = BlockUtils.collisionRayTrace(position, new AxisAlignedBB(0,0,0, 1,1,1), eyePos, centerPos);
if (movingObjectPosition == null) continue;
if (movingObjectPosition.sideHit == EnumFacing.DOWN) continue;
if (SecretGuideConfig.secretAuraSlot > 0 && player.inventory.currentItem != SecretGuideConfig.secretAuraSlot - 1) {
if (SecretGuideConfig.secretAuraSwapOn >= 1 && player.inventory.currentItem != SecretGuideConfig.secretAuraSlot - 1) {
prevSlot = player.inventory.currentItem;
player.inventory.currentItem = SecretGuideConfig.secretAuraSlot - 1;
break;
return;
}
PacketUtils.sendPacket(new C08PacketPlayerBlockPlacement(position, movingObjectPosition.sideHit.getIndex(), player.getHeldItem(), (float) movingObjectPosition.hitVec.xCoord, (float) movingObjectPosition.hitVec.yCoord, (float) movingObjectPosition.hitVec.zCoord));
blocksCooldown.put(position, new Date().getTime());
break;
return;
}
}
}
if (SecretGuideConfig.secretAuraSwapBack && prevSlot >= 0) {
player.inventory.currentItem = prevSlot;
}
prevSlot = -1;
}

@SubscribeEvent
Expand Down Expand Up @@ -214,6 +232,20 @@ public void onPacketReceive(ReceivePacketEvent event) {
blocksDone.add(blockPos);
}
}
} else if (event.packet instanceof S04PacketEntityEquipment) {
S04PacketEntityEquipment packet = (S04PacketEntityEquipment) event.packet;
Minecraft mc = Minecraft.getMinecraft();
WorldClient world = mc.theWorld;
Entity entity = world.getEntityByID(packet.getEntityID());
if (!(entity instanceof EntityArmorStand)) return;
if (packet.getEquipmentSlot() != 4) return;
ItemStack itemStack = packet.getItemStack();
if (itemStack == null) return;
if (itemStack.getItem() != Items.skull) return;
if (!itemStack.hasTagCompound()) return;
String profileId = itemStack.getTagCompound().getCompoundTag("SkullOwner").getString("Id");
if (!profileId.equals("26bb1a8d-7c66-31c6-82d5-a9c04c94fb02")) return;
blocksDone.add(new BlockPos(entity.posX, entity.posY + 2, entity.posZ));
} else if (event.packet instanceof S02PacketChat) {
S02PacketChat packet = (S02PacketChat) event.packet;
if (packet.getType() == 2) return;
Expand Down

0 comments on commit 73c35e3

Please sign in to comment.