f36ebf1Merge branch 1.8 into 1.8.908170b3Downgrade FG to 2.1 because FG 2.2 is 1.9+ only41d2547Update translations00e999fFix replay not being closed when opened via URI scheme handler (fixes #92)767ea29Fix book gui not being suppressed during replay (fixes #90)5b04edbHide ReplayMod app entry from menus on Linux6aff99dFix livelock during netty write to embedded channel (fixes #85)703805fFix infinite loop in mc.scheduledTasks (fixes #86)7a4440cUpdate ReplayStudio0b9c56cFix resource packs not working after first time jumping back in time933ee5f[Compat] Fix camera entity with BetterSprinting prior to 2.0.0 (fixes #78)83b1090Fix hotbar being visible while spectating player (fixes #83)5c73117[Compat] Fix invisible entities with Orange's 1.7 Animations (fixes #78)4704b29Replace the RenderPlayer hook (used subclassing) with a mixin (fixes #79)0c226b0Fix path at end of replay resulting in constant reloading (fixes #56)1b9b13eRename render success sound to all lowercase (required for 1.11) (fixes #66)c2000b3Fix only front-facing chunks visible for ODS rendering (fixes #67)aafeeccFix initial login gui not closing on success (fixes #68)9292addUse percent-encoding for replay file names (fixes #71)8499c0fFix name of invis armor stand with CustomNameVisible not rendering (fixes #72)b9ea572Try to handle invalid ffmpeg arguments more gracefully (fixes #77)a2f8c88Fix compression packets being recorded (fixes #80)19629c3Replace usages of System.out with loggerfe1d9b8Stop Forge from allowing the mod to load on other MC versions (fixes #82)1a1e96cFix server with RM installed refusing clients without RM (fixes #76)35eb9caReplace usage of FMLLog with the mod logger
115 lines
3.9 KiB
Java
115 lines
3.9 KiB
Java
package com.replaymod.extras.playeroverview;
|
|
|
|
import com.google.common.base.Optional;
|
|
import com.google.common.base.Predicate;
|
|
import com.replaymod.core.ReplayMod;
|
|
import com.replaymod.core.utils.Utils;
|
|
import com.replaymod.extras.Extra;
|
|
import com.replaymod.replay.ReplayModReplay;
|
|
import com.replaymod.replay.camera.CameraEntity;
|
|
import com.replaymod.replay.events.ReplayCloseEvent;
|
|
import com.replaymod.replay.events.ReplayOpenEvent;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraftforge.client.event.RenderHandEvent;
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
|
|
public class PlayerOverview implements Extra {
|
|
private ReplayModReplay module;
|
|
|
|
private final Set<UUID> hiddenPlayers = new HashSet<>();
|
|
private boolean savingEnabled;
|
|
|
|
@Override
|
|
public void register(final ReplayMod mod) throws Exception {
|
|
this.module = ReplayModReplay.instance;
|
|
|
|
mod.getKeyBindingRegistry().registerKeyBinding("replaymod.input.playeroverview", Keyboard.KEY_B, new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
if (module.getReplayHandler() != null) {
|
|
@SuppressWarnings("unchecked")
|
|
List<EntityPlayer> players = mod.getMinecraft().theWorld.getPlayers(EntityPlayer.class, new Predicate() {
|
|
@Override
|
|
public boolean apply(Object input) {
|
|
return !(input instanceof CameraEntity); // Exclude the camera entity
|
|
}
|
|
});
|
|
if (!Utils.isCtrlDown()) {
|
|
// Hide all players that have an UUID v2 (commonly used for NPCs)
|
|
Iterator<EntityPlayer> iter = players.iterator();
|
|
while (iter.hasNext()) {
|
|
UUID uuid = iter.next().getGameProfile().getId();
|
|
if (uuid != null && uuid.version() == 2) {
|
|
iter.remove();
|
|
}
|
|
}
|
|
}
|
|
new PlayerOverviewGui(PlayerOverview.this, players).display();
|
|
}
|
|
}
|
|
});
|
|
|
|
MinecraftForge.EVENT_BUS.register(this);
|
|
}
|
|
|
|
public boolean isHidden(UUID uuid) {
|
|
return hiddenPlayers.contains(uuid);
|
|
}
|
|
|
|
public void setHidden(UUID uuid, boolean hidden) {
|
|
if (hidden) {
|
|
hiddenPlayers.add(uuid);
|
|
} else {
|
|
hiddenPlayers.remove(uuid);
|
|
}
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public void onReplayOpen(ReplayOpenEvent.Pre event) throws IOException {
|
|
Optional<Set<UUID>> savedData = event.getReplayHandler().getReplayFile().getInvisiblePlayers();
|
|
if (savedData.isPresent()) {
|
|
hiddenPlayers.addAll(savedData.get());
|
|
savingEnabled = true;
|
|
} else {
|
|
savingEnabled = false;
|
|
}
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public void onReplayClose(ReplayCloseEvent.Pre event) throws IOException {
|
|
hiddenPlayers.clear();
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public void oRenderHand(RenderHandEvent event) {
|
|
Entity view = module.getCore().getMinecraft().getRenderViewEntity();
|
|
if (view != null && isHidden(view.getUniqueID())) {
|
|
event.setCanceled(true);
|
|
}
|
|
}
|
|
|
|
public boolean isSavingEnabled() {
|
|
return savingEnabled;
|
|
}
|
|
|
|
public void setSavingEnabled(boolean savingEnabled) {
|
|
this.savingEnabled = savingEnabled;
|
|
}
|
|
|
|
public void saveHiddenPlayers() {
|
|
if (savingEnabled) {
|
|
try {
|
|
module.getReplayHandler().getReplayFile().writeInvisiblePlayers(hiddenPlayers);
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|