Skip to content

Commit

Permalink
meow meow new updates
Browse files Browse the repository at this point in the history
  • Loading branch information
soshimee committed Jun 28, 2024
1 parent 38b5e3b commit b94b339
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 25 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.1
version = 1.0.2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.soshimee.secretguide.config.SecretGuideConfig;
import com.github.soshimee.secretguide.features.AutoClose;
import com.github.soshimee.secretguide.features.SecretAura;
import com.github.soshimee.secretguide.utils.DungeonLocationUtils;
import com.github.soshimee.secretguide.utils.LocationUtils;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
Expand All @@ -20,6 +21,7 @@ public void init(FMLInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new SecretAura());
MinecraftForge.EVENT_BUS.register(new AutoClose());
MinecraftForge.EVENT_BUS.register(new LocationUtils());
MinecraftForge.EVENT_BUS.register(new DungeonLocationUtils());
ClientCommandHandler.instance.registerCommand(new SgCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import com.github.soshimee.secretguide.config.SecretGuideConfig;
import com.github.soshimee.secretguide.features.SecretAura;
import com.github.soshimee.secretguide.utils.ChatUtils;
import com.github.soshimee.secretguide.utils.DungeonLocationUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

public class SgCommand extends CommandBase {
@Override
Expand All @@ -26,17 +29,15 @@ public void processCommand(ICommandSender sender, String[] args) {
if (args.length < 1) {
SecretGuide.config.openGui();
ChatUtils.sendModMessage("/sg t | /sg c");
return;
}
if (args[0].startsWith("t")) {
} else if (Objects.equals(args[0], "roomid")) {
Minecraft mc = Minecraft.getMinecraft();
ChatUtils.sendModMessage(String.valueOf(DungeonLocationUtils.getCurrentRoomId()));
} else if (args[0].startsWith("t")) {
SecretGuideConfig.secretAuraEnabled = !SecretGuideConfig.secretAuraEnabled;
ChatUtils.sendModMessage(SecretGuideConfig.secretAuraEnabled ? "Secret Aura enabled!" : "Secret Aura disabled!");
return;
}
if (args[0].startsWith("c")) {
} else if (args[0].startsWith("c")) {
SecretAura.clearBlocks();
ChatUtils.sendModMessage("Blocks cleared!");
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import cc.polyfrost.oneconfig.events.event.ReceivePacketEvent;
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
import com.github.soshimee.secretguide.config.SecretGuideConfig;
import com.github.soshimee.secretguide.utils.BlockUtils;
import com.github.soshimee.secretguide.utils.LocationUtils;
import com.github.soshimee.secretguide.utils.PacketUtils;
import com.github.soshimee.secretguide.utils.*;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.BlockLever;
import net.minecraft.block.BlockSkull;
Expand Down Expand Up @@ -55,11 +53,13 @@ public void onTick(TickEvent.ClientTickEvent event) {
BlockPos blockPos2 = new BlockPos(eyePos.xCoord + SecretGuideConfig.secretAuraRange, eyePos.yCoord + SecretGuideConfig.secretAuraRange, eyePos.zCoord + SecretGuideConfig.secretAuraRange);
Iterable<BlockPos> positions = BlockPos.getAllInBox(blockPos1, blockPos2);
long time = new Date().getTime();
int roomId = DungeonLocationUtils.getCurrentRoomId();
for (BlockPos position : positions) {
if (blocksDone.contains(position)) continue;
if (blocksCooldown.containsKey(position) && blocksCooldown.get(position) + 500 > time) continue;
IBlockState blockState = world.getBlockState(position);
if (blockState.getBlock() == Blocks.chest || blockState.getBlock() == Blocks.trapped_chest) {
if (roomId == 2051424561 || roomId == 884728242 || roomId == -269974565 || roomId == 1262122263 || roomId == 1073658098 || roomId == -476788643) continue;
Vec3 centerPos = new Vec3(position.getX() + 0.5, position.getY() + 0.4375, position.getZ() + 0.5);
if (eyePos.distanceTo(centerPos) <= SecretGuideConfig.secretAuraRange) {
MovingObjectPosition movingObjectPosition = BlockUtils.collisionRayTrace(position, 0.0625, 0, 0.0625, 0.9375, 0.875, 0.9375, eyePos, centerPos);
Expand All @@ -70,6 +70,7 @@ public void onTick(TickEvent.ClientTickEvent event) {
break;
}
} 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;
BlockLever.EnumOrientation orientation = (BlockLever.EnumOrientation) blockState.getProperties().get(BlockLever.FACING);
float minX, minY, minZ, maxX, maxY, maxZ;
if (orientation == BlockLever.EnumOrientation.EAST) {
Expand Down Expand Up @@ -187,6 +188,7 @@ public void onTick(TickEvent.ClientTickEvent event) {
if (eyePos.distanceTo(centerPos) <= SecretGuideConfig.secretAuraRange) {
MovingObjectPosition movingObjectPosition = BlockUtils.collisionRayTrace(position, 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) {
player.inventory.currentItem = SecretGuideConfig.secretAuraSlot - 1;
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.github.soshimee.secretguide.utils;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class DungeonLocationUtils {
private static int roomX = -1;
private static int roomZ = -1;
private static int currentRoomId = 0;

@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase != TickEvent.Phase.END) return;
if (LocationUtils.getCurrentLocation() != LocationUtils.LocationType.DUNGEONS) {
roomX = -1;
roomZ = -1;
currentRoomId = 0;
return;
}
Minecraft mc = Minecraft.getMinecraft();
EntityPlayerSP player = mc.thePlayer;
int prevRoomX = roomX, prevRoomZ = roomZ;
roomX = (int) ((player.posX + 200) / 32);
roomZ = (int) ((player.posZ + 200) / 32);
if (prevRoomX != roomX || prevRoomZ != roomZ) {
int cx = -185 + roomX * 32;
int cz = -185 + roomZ * 32;
List<Integer> blocks = new ArrayList<>();
WorldClient world = mc.theWorld;
for (int y = 140; y > 11; --y) {
int id = Block.getIdFromBlock(world.getBlockState(new BlockPos(cx, y, cz)).getBlock());
if (id != 5 && id != 54) blocks.add(id);
}
currentRoomId = blocks.stream().map(String::valueOf).collect(Collectors.joining()).hashCode();
}
}

public static int getCurrentRoomId() {
return currentRoomId;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
package com.github.soshimee.secretguide.utils;

import cc.polyfrost.oneconfig.events.EventManager;
import cc.polyfrost.oneconfig.events.event.LocrawEvent;
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
import cc.polyfrost.oneconfig.utils.hypixel.LocrawInfo;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.scoreboard.Score;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
Expand All @@ -22,15 +16,13 @@ public enum LocationType {
OTHER
}

private static LocationType currentLocation = LocationType.OTHER;

@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
currentLocation = LocationType.OTHER;
public LocationUtils() {
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
executor.schedule(() -> {
executor.scheduleAtFixedRate(() -> {
currentLocation = LocationType.OTHER;
Minecraft mc = Minecraft.getMinecraft();
WorldClient world = mc.theWorld;
if (world == null) return;
Scoreboard scoreboard = world.getScoreboard();
if (scoreboard == null) return;
for (String line : ScoreboardUtils.getSidebarScores(scoreboard)) {
Expand All @@ -39,8 +31,14 @@ public void onWorldLoad(WorldEvent.Load event) {
return;
}
}
currentLocation = LocationType.OTHER;
}, 2500, TimeUnit.MILLISECONDS);
}, 1000, 1000, TimeUnit.MILLISECONDS);
}

private static LocationType currentLocation = LocationType.OTHER;

@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
currentLocation = LocationType.OTHER;
}

public static LocationType getCurrentLocation() {
Expand Down

0 comments on commit b94b339

Please sign in to comment.