Skip to content

Commit

Permalink
Updated to Minecraft 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
joserobjr committed Nov 9, 2016
1 parent 4ae2a54 commit fec9d00
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ buildscript {

apply plugin: 'net.minecraftforge.gradle.forge'

version = "1.8.9.0"
version = "1.9.0.0"
group= "com.mcf.davidee"
archivesBaseName = "AutoJoin"

minecraft {
version = "1.8.9-11.15.1.1902-1.8.9"
version = "1.9-12.16.1.1887"
runDir = "run"
mappings = 'stable_22'
mappings = 'stable_24'
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/mcf/davidee/autojoin/AJLoginHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.network.NetHandlerLoginClient;
import net.minecraft.network.NetworkManager;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.text.ITextComponent;

import com.mcf.davidee.autojoin.gui.AutoJoinScreen;

Expand All @@ -14,7 +14,7 @@ public AJLoginHandler(NetworkManager manager, Minecraft mc, GuiScreen screen) {
super(manager, mc, screen);
}

public void onDisconnect(IChatComponent message) {
public void onDisconnect(ITextComponent message) {
Minecraft mc = Minecraft.getMinecraft();

if (mc.currentScreen instanceof AutoJoinScreen)
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/mcf/davidee/autojoin/AutoJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
@Mod(modid="AutoJoin", name="Auto Join", version=AutoJoin.VERSION, dependencies="after:guilib")
public class AutoJoin {

public static final int PROTOCOL_VER = 47;
public static final String VERSION = "1.8.9.0";
public static final int PROTOCOL_VER = 107;
public static final String VERSION = "1.9.0.0";

@Instance("AutoJoin")
public static AutoJoin instance;
Expand Down Expand Up @@ -72,10 +72,10 @@ public void clientTick(ClientTickEvent event) {

@SubscribeEvent
public void connectedToServer(ClientConnectedToServerEvent event) {
if (event.isLocal)
if (event.isLocal())
resetCache();
else
lastServer = ServerInfo.from((InetSocketAddress) event.manager.getRemoteAddress());
lastServer = ServerInfo.from((InetSocketAddress) event.getManager().getRemoteAddress());
}

public AJConfig getConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.network.NetworkManager;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.text.TextComponentString;

import com.mcf.davidee.autojoin.AutoJoin;
import com.mcf.davidee.autojoin.ServerInfo;
Expand Down Expand Up @@ -108,7 +108,7 @@ else if (manager.getExitMessage() != null) {
public void close() {
this.cancelled = true;
if (manager != null) {
manager.closeChannel(new ChatComponentText("Aborted"));
manager.closeChannel(new TextComponentString("Aborted"));
manager = null;
}
AutoJoin.instance.resetCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.client.gui.GuiDisconnected;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.text.ITextComponent;

import com.mcf.davidee.autojoin.AutoJoin;
import com.mcf.davidee.autojoin.ServerInfo;
Expand All @@ -18,7 +18,7 @@ public class DisconnectedScreen extends GuiScreen {
private final ServerInfo info;

public String errorMessage;
public IChatComponent errorDetail;
public ITextComponent errorDetail;

@SuppressWarnings("rawtypes")
public List list;
Expand All @@ -34,7 +34,7 @@ public DisconnectedScreen(ServerInfo info, GuiDisconnected disconnected) throws
for (Field f : fields)
f.setAccessible(true);
errorMessage = (String) fields[0].get(disconnected);
errorDetail = (IChatComponent) fields[1].get(disconnected);
errorDetail = (ITextComponent) fields[1].get(disconnected);
list = (List) fields[2].get(disconnected);
parent = (GuiScreen) fields[3].get(disconnected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.Arrays;

import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.MathHelper;

import com.mcf.davidee.autojoin.AutoJoin;
import com.mcf.davidee.autojoin.ServerSetting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.network.EnumConnectionState;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.handshake.client.C00Handshake;
import net.minecraft.network.login.client.C00PacketLoginStart;
import net.minecraft.network.login.client.CPacketLoginStart;

import com.mcf.davidee.autojoin.AJLoginHandler;
import com.mcf.davidee.autojoin.AutoJoin;
Expand All @@ -34,7 +34,7 @@ public void run() {
//TODO change this back to the AJ screen?
manager.setNetHandler(new AJLoginHandler(manager, mc, null));
manager.sendPacket(new C00Handshake(AutoJoin.PROTOCOL_VER, info.ip, info.port, EnumConnectionState.LOGIN));
manager.sendPacket(new C00PacketLoginStart(mc.getSession().getProfile()));
manager.sendPacket(new CPacketLoginStart(mc.getSession().getProfile()));
screen.setManager(manager);
}
catch(Exception e) {
Expand Down
32 changes: 16 additions & 16 deletions src/main/java/com/mcf/davidee/autojoin/thread/ThreadPingServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import net.minecraft.network.ServerStatusResponse;
import net.minecraft.network.handshake.client.C00Handshake;
import net.minecraft.network.status.INetHandlerStatusClient;
import net.minecraft.network.status.client.C00PacketServerQuery;
import net.minecraft.network.status.server.S00PacketServerInfo;
import net.minecraft.network.status.server.S01PacketPong;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import net.minecraft.network.status.client.CPacketServerQuery;
import net.minecraft.network.status.server.SPacketServerInfo;
import net.minecraft.network.status.server.SPacketPong;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;

import com.mcf.davidee.autojoin.AutoJoin;
import com.mcf.davidee.autojoin.ServerInfo;
Expand All @@ -35,19 +35,19 @@ public void newRun() throws UnknownHostException {
private boolean received = false;

@Override
public void handleServerInfo(S00PacketServerInfo packet) {
public void handleServerInfo(SPacketServerInfo packet) {
ServerStatusResponse response = packet.getResponse();

String version = "???";
int protocol = 0;
int curPlayers = -1, maxPlayers = -1;
if (response.getProtocolVersionInfo() != null) {
protocol = response.getProtocolVersionInfo().getProtocol();
version = response.getProtocolVersionInfo().getName();
if (response.getVersion() != null) {
protocol = response.getVersion().getProtocol();
version = response.getVersion().getName();
}
if (response.getPlayerCountData() != null) {
curPlayers = response.getPlayerCountData().getOnlinePlayerCount();
maxPlayers = response.getPlayerCountData().getMaxPlayers();
if (response.getPlayers() != null) {
curPlayers = response.getPlayers().getOnlinePlayerCount();
maxPlayers = response.getPlayers().getMaxPlayers();
}

if (protocol != AutoJoin.PROTOCOL_VER)
Expand All @@ -61,20 +61,20 @@ else if (curPlayers != -1 && maxPlayers != -1)
}

@Override
public void handlePong(S01PacketPong packet) {
manager.closeChannel(new ChatComponentText("Finished"));
public void handlePong(SPacketPong packet) {
manager.closeChannel(new TextComponentString("Finished"));
}

@Override
public void onDisconnect(IChatComponent p_147231_1_) {
public void onDisconnect(ITextComponent p_147231_1_) {
if (!received)
screen.pingFail(p_147231_1_.getFormattedText());
}
});

try {
manager.sendPacket(new C00Handshake(AutoJoin.PROTOCOL_VER, info.ip, info.port, EnumConnectionState.STATUS));
manager.sendPacket(new C00PacketServerQuery());
manager.sendPacket(new CPacketServerQuery());
screen.setManager(manager);
}
catch (Throwable throwable) {
Expand Down

0 comments on commit fec9d00

Please sign in to comment.