Update to MC 1.14 / Fabric
This commit is contained in:
@@ -1,37 +1,26 @@
|
||||
package com.replaymod.extras;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.versions.MCVer.Keyboard;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.events.ReplayOpenEvent;
|
||||
import com.replaymod.replay.events.ReplayOpenedCallback;
|
||||
import com.replaymod.replay.gui.overlay.GuiReplayOverlay;
|
||||
import de.johni0702.minecraft.gui.element.GuiImage;
|
||||
import de.johni0702.minecraft.gui.element.IGuiImage;
|
||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||
|
||||
//#if MC>=11300
|
||||
import com.replaymod.core.versions.MCVer.Keyboard;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import net.minecraft.client.GameSettings;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.settings.GameSettings;
|
||||
//$$ import org.lwjgl.input.Keyboard;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
//#if MC>=11300
|
||||
//#if MC>=11400
|
||||
//$$ import com.replaymod.core.events.PreRenderCallback;
|
||||
//$$ import com.replaymod.core.events.PostRenderCallback;
|
||||
//#else
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
//$$ import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
//#endif
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
public class FullBrightness implements Extra {
|
||||
public class FullBrightness extends EventRegistrations implements Extra {
|
||||
private ReplayModReplay module;
|
||||
|
||||
private final IGuiImage indicator = new GuiImage().setTexture(ReplayMod.TEXTURE, 90, 20, 19, 13).setSize(19, 13);
|
||||
@@ -65,26 +54,37 @@ public class FullBrightness implements Extra {
|
||||
}
|
||||
});
|
||||
|
||||
FML_BUS.register(this);
|
||||
register();
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(PreRenderCallback.EVENT, this::preRender); }
|
||||
//$$ private void preRender() {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void preRender(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
//#endif
|
||||
if (active && module.getReplayHandler() != null) {
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
originalGamma = gameSettings.gammaSetting;
|
||||
gameSettings.gammaSetting = 1000;
|
||||
} else if (event.phase == TickEvent.Phase.END) {
|
||||
gameSettings.gammaSetting = originalGamma;
|
||||
}
|
||||
originalGamma = gameSettings.gammaSetting;
|
||||
gameSettings.gammaSetting = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(PostRenderCallback.EVENT, this::postRender); }
|
||||
//$$ private void postRender() {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void replayOpened(ReplayOpenEvent.Post event) {
|
||||
updateIndicator(event.getReplayHandler().getOverlay());
|
||||
public void postRender(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.END) return;
|
||||
//#endif
|
||||
if (active && module.getReplayHandler() != null) {
|
||||
gameSettings.gammaSetting = originalGamma;
|
||||
}
|
||||
}
|
||||
|
||||
{ on(ReplayOpenedCallback.EVENT, replayHandler -> updateIndicator(replayHandler.getOverlay())); }
|
||||
private void updateIndicator(GuiReplayOverlay overlay) {
|
||||
if (active) {
|
||||
overlay.statusIndicatorPanel.addElements(new HorizontalLayout.Data(1), indicator);
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.replaymod.extras;
|
||||
import com.replaymod.core.KeyBindingRegistry;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.mixin.KeyBindingAccessor;
|
||||
import com.replaymod.replay.events.ReplayOpenEvent;
|
||||
import com.replaymod.replay.events.ReplayOpenedCallback;
|
||||
import com.replaymod.replay.gui.overlay.GuiReplayOverlay;
|
||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||
import de.johni0702.minecraft.gui.RenderInfo;
|
||||
@@ -17,6 +17,7 @@ import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||
import de.johni0702.minecraft.gui.layout.GridLayout;
|
||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||
import de.johni0702.minecraft.gui.layout.LayoutData;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -26,39 +27,22 @@ import net.minecraft.client.resources.I18n;
|
||||
//$$ import org.lwjgl.input.Keyboard;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
//#if MC>=11300
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
public class HotkeyButtons implements Extra {
|
||||
public class HotkeyButtons extends EventRegistrations implements Extra {
|
||||
private ReplayMod mod;
|
||||
|
||||
@Override
|
||||
public void register(ReplayMod mod) throws Exception {
|
||||
public void register(ReplayMod mod) {
|
||||
this.mod = mod;
|
||||
|
||||
FML_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void postReplayOpen(ReplayOpenEvent.Post event) {
|
||||
GuiReplayOverlay overlay = event.getReplayHandler().getOverlay();
|
||||
new Gui(mod, overlay);
|
||||
register();
|
||||
}
|
||||
|
||||
{ on(ReplayOpenedCallback.EVENT, replayHandler -> new Gui(mod, replayHandler.getOverlay())); }
|
||||
public static final class Gui {
|
||||
private final GuiTexturedButton toggleButton;
|
||||
private final GridLayout panelLayout;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.replaymod.extras;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
||||
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||
@@ -15,16 +16,6 @@ import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
||||
import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
//#if MC>=11300
|
||||
import net.minecraftforge.fml.ModList;
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
//$$ import net.minecraftforge.fml.common.Loader;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.Loader;
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -45,11 +36,7 @@ public class OpenEyeExtra implements Extra {
|
||||
public void register(ReplayMod mod) throws Exception {
|
||||
this.mod = mod;
|
||||
|
||||
//#if MC>=11300
|
||||
boolean isOpenEyeLoaded = ModList.get().isLoaded("openeye");
|
||||
//#else
|
||||
//$$ boolean isOpenEyeLoaded = Loader.isModLoaded("OpenEye");
|
||||
//#endif
|
||||
boolean isOpenEyeLoaded = MCVer.isModLoaded("OpenEye");
|
||||
if (!isOpenEyeLoaded && mod.getSettingsRegistry().get(Setting.ASK_FOR_OPEN_EYE)) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.replaymod.extras.advancedscreenshots;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.extras.Extra;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
//#if MC<11300
|
||||
//$$ import com.replaymod.core.versions.MCVer;
|
||||
@@ -10,6 +9,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
//$$ import net.minecraft.client.Minecraft;
|
||||
//$$ import net.minecraft.client.gui.GuiControls;
|
||||
//$$ import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
//$$ import net.minecraftforge.common.MinecraftForge;
|
||||
//$$ import org.lwjgl.input.Keyboard;
|
||||
//#endif
|
||||
|
||||
@@ -29,7 +29,9 @@ public class AdvancedScreenshots implements Extra {
|
||||
@Override
|
||||
public void register(ReplayMod mod) {
|
||||
this.mod = mod;
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
//#if MC<11300
|
||||
//$$ MinecraftForge.EVENT_BUS.register(this);
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=11300
|
||||
|
||||
@@ -65,7 +65,11 @@ public class ScreenshotRenderer implements RenderInfo {
|
||||
MainWindowAccessor acc = (MainWindowAccessor) (Object) mc.mainWindow;
|
||||
acc.setFramebufferWidth(displayWidthBefore);
|
||||
acc.setFramebufferHeight(displayHeightBefore);
|
||||
mc.getFramebuffer().createBindFramebuffer(displayWidthBefore, displayHeightBefore);
|
||||
mc.getFramebuffer().createBindFramebuffer(displayWidthBefore, displayHeightBefore
|
||||
//#if MC>=11400
|
||||
//$$ , false
|
||||
//#endif
|
||||
);
|
||||
//#else
|
||||
//$$ mc.resize(displayWidthBefore, displayHeightBefore);
|
||||
//#endif
|
||||
|
||||
@@ -4,12 +4,19 @@ import com.google.common.base.Optional;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.utils.Utils;
|
||||
import com.replaymod.extras.Extra;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import com.replaymod.replay.events.ReplayCloseEvent;
|
||||
import com.replaymod.replay.events.ReplayOpenEvent;
|
||||
import com.replaymod.replay.events.ReplayClosedCallback;
|
||||
import com.replaymod.replay.events.ReplayOpenedCallback;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import com.replaymod.core.events.PreRenderHandCallback;
|
||||
//$$ import java.util.stream.Collectors;
|
||||
//#else
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
|
||||
//#if MC>=11300
|
||||
@@ -30,13 +37,14 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//$$ import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
//$$ import java.util.stream.Collectors;
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
public class PlayerOverview implements Extra {
|
||||
public class PlayerOverview extends EventRegistrations implements Extra {
|
||||
private ReplayModReplay module;
|
||||
|
||||
private final Set<UUID> hiddenPlayers = new HashSet<>();
|
||||
@@ -50,6 +58,13 @@ public class PlayerOverview implements Extra {
|
||||
@Override
|
||||
public void run() {
|
||||
if (module.getReplayHandler() != null) {
|
||||
//#if MC>=11400
|
||||
//$$ List<PlayerEntity> players = mod.getMinecraft().world.getPlayers()
|
||||
//$$ .stream()
|
||||
//$$ .map(it -> (PlayerEntity) it)
|
||||
//$$ .filter(it -> !(it instanceof CameraEntity))
|
||||
//$$ .collect(Collectors.toList());
|
||||
//#else
|
||||
@SuppressWarnings("unchecked")
|
||||
//#if MC>=10800
|
||||
List<EntityPlayer> players = mod.getMinecraft().world.getPlayers(EntityPlayer.class, new Predicate() {
|
||||
@@ -64,6 +79,7 @@ public class PlayerOverview implements Extra {
|
||||
//$$ .filter(it -> !(it instanceof CameraEntity)) // Exclude the camera entity
|
||||
//$$ .collect(Collectors.toList());
|
||||
//#endif
|
||||
//#endif
|
||||
if (!Utils.isCtrlDown()) {
|
||||
// Hide all players that have an UUID v2 (commonly used for NPCs)
|
||||
Iterator<EntityPlayer> iter = players.iterator();
|
||||
@@ -79,8 +95,12 @@ public class PlayerOverview implements Extra {
|
||||
}
|
||||
});
|
||||
|
||||
FML_BUS.register(this);
|
||||
ReplayOpenedCallback.EVENT.register(this::onReplayOpen);
|
||||
ReplayClosedCallback.EVENT.register(this::onReplayClose);
|
||||
//#if MC>=11400
|
||||
//#else
|
||||
FORGE_BUS.register(this);
|
||||
//#endif
|
||||
}
|
||||
|
||||
public boolean isHidden(UUID uuid) {
|
||||
@@ -95,9 +115,8 @@ public class PlayerOverview implements Extra {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onReplayOpen(ReplayOpenEvent.Pre event) throws IOException {
|
||||
Optional<Set<UUID>> savedData = event.getReplayHandler().getReplayFile().getInvisiblePlayers();
|
||||
private void onReplayOpen(ReplayHandler replayHandler) throws IOException {
|
||||
Optional<Set<UUID>> savedData = replayHandler.getReplayFile().getInvisiblePlayers();
|
||||
if (savedData.isPresent()) {
|
||||
hiddenPlayers.addAll(savedData.get());
|
||||
savingEnabled = true;
|
||||
@@ -106,18 +125,24 @@ public class PlayerOverview implements Extra {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onReplayClose(ReplayCloseEvent.Pre event) throws IOException {
|
||||
private void onReplayClose(ReplayHandler replayHandler) {
|
||||
hiddenPlayers.clear();
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(PreRenderHandCallback.EVENT, this::shouldHideHand); }
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void oRenderHand(RenderHandEvent event) {
|
||||
Entity view = getRenderViewEntity(module.getCore().getMinecraft());
|
||||
if (view != null && isHidden(view.getUniqueID())) {
|
||||
if (shouldHideHand()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
private boolean shouldHideHand() {
|
||||
Entity view = getRenderViewEntity(module.getCore().getMinecraft());
|
||||
return view != null && isHidden(view.getUniqueID());
|
||||
}
|
||||
|
||||
// See MixinRender for why this is 1.7.10 only
|
||||
//#if MC<=10710
|
||||
|
||||
@@ -218,11 +218,15 @@ public class GuiYoutubeUpload extends GuiScreen {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URL(url).toURI());
|
||||
} catch(Throwable throwable) {
|
||||
//#if MC>=11400
|
||||
//$$ SystemUtil.getOperatingSystem().open(url);
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
Util.getOSType().openURI(url);
|
||||
//#else
|
||||
//$$ Sys.openURL(url);
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
upload = null;
|
||||
progressBar.setLabel(I18n.format("replaymod.gui.ytuploadprogress.done", url));
|
||||
|
||||
@@ -5,31 +5,34 @@ import com.replaymod.extras.Extra;
|
||||
import com.replaymod.render.gui.GuiRenderingDone;
|
||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||
import de.johni0702.minecraft.gui.element.GuiButton;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
|
||||
//#if MC>=10800
|
||||
//#if MC>=11300
|
||||
//#if MC>=11400
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.OpenGuiScreenCallback;
|
||||
//$$ import net.minecraft.client.gui.Screen;
|
||||
//#else
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
public class YoutubeUpload implements Extra {
|
||||
public class YoutubeUpload extends EventRegistrations implements Extra {
|
||||
@Override
|
||||
public void register(ReplayMod mod) throws Exception {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
public void register(ReplayMod mod) {
|
||||
register();
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(OpenGuiScreenCallback.EVENT, this::onGuiOpen); }
|
||||
//$$ private void onGuiOpen(Screen vanillaGui) {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void onGuiOpen(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
if (GuiScreen.from(getGui(event)) instanceof GuiRenderingDone) {
|
||||
GuiRenderingDone gui = (GuiRenderingDone) GuiScreen.from(getGui(event));
|
||||
net.minecraft.client.gui.GuiScreen vanillaGui = getGui(event);
|
||||
//#endif
|
||||
if (GuiScreen.from(vanillaGui) instanceof GuiRenderingDone) {
|
||||
GuiRenderingDone gui = (GuiRenderingDone) GuiScreen.from(vanillaGui);
|
||||
// Check if there already is a youtube button
|
||||
if (gui.actionsPanel.getChildren().stream().anyMatch(it -> it instanceof YoutubeButton)) {
|
||||
return; // Button already added
|
||||
|
||||
Reference in New Issue
Block a user