Fixed a nullptr in PingComponent, Fixed a bug with LogoutSpots where the model would appear red because their hurttime was > 0, Added end portals to portal finder

This commit is contained in:
Rigamortis 2019-12-01 17:10:12 -09:00
parent cc453c8739
commit d004aeaf46
4 changed files with 50 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package me.rigamortis.seppuku.impl.gui.hud.component;
import me.rigamortis.seppuku.api.gui.hud.component.DraggableHudComponent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetworkPlayerInfo;
/**
* Author Seth
@ -19,10 +20,15 @@ public final class PingComponent extends DraggableHudComponent {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.getConnection() == null || mc.player == null)
if (mc.world == null || mc.player == null || mc.player.getUniqueID() == null)
return;
final String ping = "MS: " + mc.getConnection().getPlayerInfo(mc.player.getUniqueID()).getResponseTime();
final NetworkPlayerInfo playerInfo = mc.getConnection().getPlayerInfo(mc.player.getUniqueID());
if (playerInfo == null)
return;
final String ping = "MS: " + playerInfo.getResponseTime();
this.setW(Minecraft.getMinecraft().fontRenderer.getStringWidth(ping));
this.setH(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT);

View File

@ -157,4 +157,4 @@ public final class JesusModule extends Module {
return false;
}
}
}

View File

@ -69,6 +69,7 @@ public final class LogoutSpotsModule extends Module {
data.ghost.prevLimbSwingAmount = 0;
data.ghost.limbSwing = 0;
data.ghost.limbSwingAmount = 0;
data.ghost.hurtTime = 0;
GlStateManager.pushMatrix();
GlStateManager.enableLighting();
@ -159,6 +160,14 @@ public final class LogoutSpotsModule extends Module {
return Minecraft.getMinecraft().player.getDistance(position.x, position.y, position.z) > this.removeDistance.getValue();
}
public Map<String, EntityPlayer> getPlayerCache() {
return playerCache;
}
public Map<String, PlayerData> getLogoutCache() {
return logoutCache;
}
private class PlayerData {
Vec3d position;
GameProfile profile;
@ -170,4 +179,4 @@ public final class LogoutSpotsModule extends Module {
this.ghost = ghost;
}
}
}
}

View File

@ -156,7 +156,7 @@ public final class PortalFinderModule extends Module {
final int worldY = y + extendedBlockStorage.getYLocation();
if (blockState.getBlock().equals(Blocks.PORTAL)) {
BlockPos position = new BlockPos(event.getChunk().getPos().getXStart() + x, worldY, event.getChunk().getPos().getZStart() + z);
if (!isPortalCached(position.getX(), position.getY(), position.getZ())) {
if (!isPortalCached(position.getX(), position.getY(), position.getZ(), 0)) {
final Vec3d portal = new Vec3d(position.getX(), position.getY(), position.getZ());
this.portals.add(portal);
if (this.chat.getValue()) {
@ -165,6 +165,17 @@ public final class PortalFinderModule extends Module {
return;
}
}
if (blockState.getBlock().equals(Blocks.END_PORTAL)) {
BlockPos position = new BlockPos(event.getChunk().getPos().getXStart() + x, worldY, event.getChunk().getPos().getZStart() + z);
if (!isPortalCached(position.getX(), position.getY(), position.getZ(), 3)) {
final Vec3d portal = new Vec3d(position.getX(), position.getY(), position.getZ());
this.portals.add(portal);
if (this.chat.getValue()) {
this.printEndPortalToChat(portal);
}
return;
}
}
}
}
}
@ -182,15 +193,32 @@ public final class PortalFinderModule extends Module {
}
}
private boolean isPortalCached(int x, int y, int z) {
private boolean isPortalCached(int x, int y, int z, float dist) {
for (int i = this.portals.size() - 1; i >= 0; i--) {
Vec3d searchPortal = this.portals.get(i);
if (searchPortal.distanceTo(new Vec3d(x, y, z)) <= dist)
return true;
if (searchPortal.x == x && searchPortal.y == y && searchPortal.z == z)
return true;
}
return false;
}
private void printEndPortalToChat(Vec3d portal) {
final TextComponentString portalTextComponent = new TextComponentString("End Portal found!");
String coords = String.format("X: %s, Y: %s, Z: %s", (int) portal.x, (int) portal.y, (int) portal.z);
int playerDistance = (int) Minecraft.getMinecraft().player.getDistance(portal.x, portal.y, portal.z);
String distance = ChatFormatting.GRAY + "" + playerDistance + "m away";
String hoverText = coords + "\n" + distance;
portalTextComponent.setStyle(new Style().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(hoverText))));
Seppuku.INSTANCE.logcChat(portalTextComponent);
}
private void printPortalToChat(Vec3d portal) {
final TextComponentString portalTextComponent = new TextComponentString("Portal found!");
@ -221,4 +249,4 @@ public final class PortalFinderModule extends Module {
public List<Vec3d> getPortals() {
return portals;
}
}
}