diff --git a/gradle.properties b/gradle.properties index a7bacea..4f1e1ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/com/github/soshimee/secretguide/config/SecretGuideConfig.java b/src/main/java/com/github/soshimee/secretguide/config/SecretGuideConfig.java index 0ce079e..5b42023 100644 --- a/src/main/java/com/github/soshimee/secretguide/config/SecretGuideConfig.java +++ b/src/main/java/com/github/soshimee/secretguide/config/SecretGuideConfig.java @@ -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; @@ -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; @@ -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"); diff --git a/src/main/java/com/github/soshimee/secretguide/features/SecretAura.java b/src/main/java/com/github/soshimee/secretguide/features/SecretAura.java index 279f4fd..ce6487b 100644 --- a/src/main/java/com/github/soshimee/secretguide/features/SecretAura.java +++ b/src/main/java/com/github/soshimee/secretguide/features/SecretAura.java @@ -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.*; @@ -31,6 +32,7 @@ public class SecretAura { private static final List blocksDone = new LinkedList<>(); private static final Map blocksCooldown = new HashMap<>(); private static boolean redstoneKey = false; + private static int prevSlot = -1; public SecretAura() { EventManager.INSTANCE.register(this); @@ -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; @@ -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); @@ -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; @@ -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 @@ -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;