Update to Minecraft 1.9.4

This commit is contained in:
johni0702
2016-09-15 16:34:56 +02:00
parent 3f0f1752ae
commit a80a20c37a
59 changed files with 609 additions and 861 deletions

View File

@@ -2,7 +2,8 @@ package com.replaymod.online.api.replay.holders;
public enum MinecraftVersion {
MC_1_8("Minecraft 1.8", "1.8");
MC_1_8("Minecraft 1.8", "1.8"),
MC_1_9_4("Minecraft 1.9.4", "1.9.4");
private String niceName, apiName;

View File

@@ -20,6 +20,7 @@ import com.replaymod.online.api.replay.pagination.FavoritedFilePagination;
import com.replaymod.online.api.replay.pagination.Pagination;
import com.replaymod.online.api.replay.pagination.SearchPagination;
import com.replaymod.replaystudio.replay.ReplayMetaData;
import com.replaymod.replaystudio.studio.ReplayStudio;
import de.johni0702.minecraft.gui.container.AbstractGuiContainer;
import de.johni0702.minecraft.gui.container.GuiContainer;
import de.johni0702.minecraft.gui.container.GuiPanel;
@@ -115,6 +116,9 @@ public class GuiReplayCenter extends GuiScreen {
boolean disliked = dislikedReplays.contains(replayId);
loadButton.setI18nLabel(selected.downloaded ? "replaymod.gui.load" : "replaymod.gui.download");
if (selected.incompatible) {
loadButton.setDisabled();
}
favoriteButton.setI18nLabel("replaymod.gui.center." + (favorited ? "unfavorite" : "favorite"));
// Only allow button usage for either unfavorite or favorite after they've actually downloaded it
@@ -339,6 +343,7 @@ public class GuiReplayCenter extends GuiScreen {
public final GuiLabel author = new GuiLabel();
public final GuiLabel date = new GuiLabel().setColor(Colors.LIGHT_GRAY);
public final GuiLabel server = new GuiLabel().setColor(Colors.LIGHT_GRAY);
public final GuiLabel version = new GuiLabel().setColor(Colors.RED);
public final GuiLabel category = new GuiLabel().setColor(Colors.GREY);
public final GuiPanel stats = new GuiPanel().setLayout(new HorizontalLayout().setSpacing(3));
public final GuiLabel favorites = new GuiLabel(stats).setColor(Colors.ORANGE);
@@ -353,9 +358,10 @@ public class GuiReplayCenter extends GuiScreen {
pos(category, 0, y(server) + height(server) + 3);
pos(date, width - width(date), y(author));
pos(version, width - width(version), y(server));
pos(stats, width - width(stats), y(category));
}
}).addElements(null, name, author, date, server, category, stats);
}).addElements(null, name, author, date, server, version, category, stats);
public final GuiImage thumbnail;
public final GuiLabel duration = new GuiLabel();
public final GuiPanel durationPanel = new GuiPanel().setBackgroundColor(Colors.HALF_TRANSPARENT)
@@ -389,6 +395,7 @@ public class GuiReplayCenter extends GuiScreen {
private final long dateMillis;
private final int sortId;
private final boolean downloaded;
private final boolean incompatible;
public GuiReplayEntry(FileInfo fileInfo, BufferedImage thumbImage, int sortId, boolean downloaded) {
this.fileInfo = fileInfo;
@@ -404,6 +411,10 @@ public class GuiReplayCenter extends GuiScreen {
} else {
server.setText(metaData.getServerName());
}
incompatible = !new ReplayStudio().isCompatible(fileInfo.getMetadata().getFileFormatVersion());
if (incompatible) {
version.setText("Minecraft " + fileInfo.getMetadata().getMcVersion());
}
dateMillis = metaData.getDate();
date.setText(new SimpleDateFormat().format(new Date(dateMillis)));
if (thumbImage == null) {

View File

@@ -18,7 +18,6 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.io.File;
import java.util.List;
public class GuiHandler {
private static final int BUTTON_REPLAY_CENTER = 17890236;
@@ -36,20 +35,18 @@ public class GuiHandler {
@SubscribeEvent
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
if (!(event.gui instanceof GuiMainMenu)) {
if (!(event.getGui() instanceof GuiMainMenu)) {
return;
}
@SuppressWarnings("unchecked")
List<GuiButton> buttonList = event.buttonList;
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, event.gui.width / 2 - 100,
event.gui.height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
buttonList.add(button);
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, event.getGui().width / 2 - 100,
event.getGui().height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
event.getButtonList().add(button);
}
@SubscribeEvent
public void injectIntoReplayViewer(GuiScreenEvent.InitGuiEvent.Post event) {
AbstractGuiScreen guiScreen = GuiScreen.from(event.gui);
AbstractGuiScreen guiScreen = GuiScreen.from(event.getGui());
if (!(guiScreen instanceof GuiReplayViewer)) {
return;
}
@@ -75,15 +72,15 @@ public class GuiHandler {
@SubscribeEvent
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
if(!event.button.enabled) return;
if(!event.getButton().enabled) return;
if (event.gui instanceof GuiMainMenu) {
if (event.button.id == BUTTON_REPLAY_CENTER) {
if (event.getGui() instanceof GuiMainMenu) {
if (event.getButton().id == BUTTON_REPLAY_CENTER) {
GuiReplayCenter replayCenter = new GuiReplayCenter(mod);
if (mod.isLoggedIn()) {
replayCenter.display();
} else {
new GuiLoginPrompt(mod.getApiClient(), GuiScreen.wrap(event.gui), replayCenter, true).display();
new GuiLoginPrompt(mod.getApiClient(), GuiScreen.wrap(event.getGui()), replayCenter, true).display();
}
}
}