Remove lots of old code
Add some additional config settings Update jGui and ReplayStudio
This commit is contained in:
@@ -9,9 +9,8 @@ import com.replaymod.replay.events.ReplayOpenEvent;
|
||||
import com.replaymod.replay.gui.overlay.GuiReplayOverlay;
|
||||
import com.replaymod.replaystudio.data.Marker;
|
||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
||||
import eu.crushedpixel.replaymod.registry.ReplayGuiRegistry;
|
||||
import com.replaymod.core.utils.Restrictions;
|
||||
import com.replaymod.replaystudio.util.Location;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
@@ -69,7 +68,7 @@ public class ReplayHandler {
|
||||
/**
|
||||
* The position at which the camera should be located after the next jump.
|
||||
*/
|
||||
private AdvancedPosition targetCameraPosition;
|
||||
private Location targetCameraPosition;
|
||||
|
||||
private UUID spectating;
|
||||
|
||||
@@ -123,9 +122,6 @@ public class ReplayHandler {
|
||||
mc.timer.timerSpeed = 1;
|
||||
overlay.setVisible(false);
|
||||
|
||||
// These might have been hidden by the overlay, so we have to make sure they're visible again
|
||||
ReplayGuiRegistry.show();
|
||||
|
||||
ReplayModReplay.instance.replayHandler = null;
|
||||
|
||||
FMLCommonHandler.instance().bus().post(new ReplayCloseEvent.Post(this));
|
||||
@@ -256,7 +252,7 @@ public class ReplayHandler {
|
||||
return spectating;
|
||||
}
|
||||
|
||||
public void setTargetPosition(AdvancedPosition pos) {
|
||||
public void setTargetPosition(Location pos) {
|
||||
targetCameraPosition = pos;
|
||||
}
|
||||
|
||||
@@ -279,8 +275,8 @@ public class ReplayHandler {
|
||||
if (retainCameraPosition) {
|
||||
CameraEntity cam = getCameraEntity();
|
||||
if (cam != null) {
|
||||
targetCameraPosition = new AdvancedPosition(cam.posX, cam.posY, cam.posZ,
|
||||
cam.rotationPitch, cam.rotationYaw, cam.roll);
|
||||
targetCameraPosition = new Location(cam.posX, cam.posY, cam.posZ,
|
||||
cam.rotationPitch, cam.rotationYaw);
|
||||
} else {
|
||||
targetCameraPosition = null;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,8 @@ import com.google.common.util.concurrent.ListenableFutureTask;
|
||||
import com.replaymod.core.utils.Restrictions;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import eu.crushedpixel.replaymod.holders.PacketData;
|
||||
import eu.crushedpixel.replaymod.settings.ReplaySettings;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
@@ -17,9 +16,7 @@ import net.minecraft.client.gui.GuiDownloadTerrain;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.EnumConnectionState;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.*;
|
||||
import net.minecraft.network.play.server.*;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
@@ -253,7 +250,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
|
||||
if (msg instanceof byte[]) {
|
||||
try {
|
||||
Packet p = ReplayFileIO.deserializePacket((byte[]) msg);
|
||||
Packet p = deserializePacket((byte[]) msg);
|
||||
|
||||
if (p != null) {
|
||||
p = processPacket(p);
|
||||
@@ -299,6 +296,18 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
|
||||
}
|
||||
|
||||
private Packet deserializePacket(byte[] bytes) throws IOException, IllegalAccessException, InstantiationException {
|
||||
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
int i = pb.readVarIntFromBuffer();
|
||||
|
||||
Packet p = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||
p.readPacketData(pb);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a packet and return the result.
|
||||
* @param p The packet to process
|
||||
@@ -453,7 +462,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
if (p instanceof S02PacketChat) {
|
||||
if (ReplaySettings.ReplayOptions.showChat.getValue() != Boolean.TRUE) {
|
||||
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -558,10 +567,10 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
|
||||
// Read the next packet if we don't already have one
|
||||
if (nextPacket == null) {
|
||||
nextPacket = ReplayFileIO.readPacketData(dis);
|
||||
nextPacket = new PacketData(dis);
|
||||
}
|
||||
|
||||
int nextTimeStamp = nextPacket.getTimestamp();
|
||||
int nextTimeStamp = nextPacket.timestamp;
|
||||
|
||||
// If we aren't jumping and the world has already been loaded (no dirt-screens) then wait
|
||||
// the required amount to get proper packet timing
|
||||
@@ -578,7 +587,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
// Process packet
|
||||
channelRead(ctx, nextPacket.getByteArray());
|
||||
channelRead(ctx, nextPacket.bytes);
|
||||
nextPacket = null;
|
||||
|
||||
lastTimeStamp = nextTimeStamp;
|
||||
@@ -725,10 +734,10 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
nextPacket = null;
|
||||
} else {
|
||||
// Otherwise read one from the input stream
|
||||
pd = ReplayFileIO.readPacketData(dis);
|
||||
pd = new PacketData(dis);
|
||||
}
|
||||
|
||||
int nextTimeStamp = pd.getTimestamp();
|
||||
int nextTimeStamp = pd.timestamp;
|
||||
if (nextTimeStamp > timestamp) {
|
||||
// We are done sending all packets
|
||||
nextPacket = pd;
|
||||
@@ -736,7 +745,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
// Process packet
|
||||
channelRead(ctx, pd.getByteArray());
|
||||
channelRead(ctx, pd.bytes);
|
||||
|
||||
// Store last timestamp
|
||||
lastTimeStamp = nextTimeStamp;
|
||||
@@ -823,4 +832,15 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class PacketData {
|
||||
private final int timestamp;
|
||||
private final byte[] bytes;
|
||||
|
||||
public PacketData(DataInputStream in) throws IOException {
|
||||
timestamp = in.readInt();
|
||||
bytes = new byte[in.readInt()];
|
||||
in.readFully(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@ package com.replaymod.replay;
|
||||
import com.replaymod.core.SettingsRegistry;
|
||||
|
||||
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
||||
public static final Setting<Boolean> RECORD_SINGLEPLAYER = make("recordSingleplayer", "recordsingleplayer", true);
|
||||
public static final Setting<Boolean> RECORD_SERVER = make("recordServer", "recordserver", true);
|
||||
public static final Setting<Boolean> INDICATOR = make("indicator", "indicator", true);
|
||||
public static final Setting<Boolean> SHOW_CHAT = make("showChat", "showchat", true);
|
||||
public static final SettingsRegistry.MultipleChoiceSettingKeys<String> CAMERA =
|
||||
new SettingsRegistry.MultipleChoiceSettingKeys<>(
|
||||
"replay", "camera", "replaymod.gui.settings.camera", "replaymod.camera.classic");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.replaymod.replay.camera;
|
||||
|
||||
import com.replaymod.core.events.SettingsChangedEvent;
|
||||
import com.replaymod.core.utils.Utils;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.Setting;
|
||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
||||
import eu.crushedpixel.replaymod.utils.SkinProvider;
|
||||
import com.replaymod.replaystudio.util.Location;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -107,8 +107,8 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
* Sets the camera position and rotation to that of the specified AdvancedPosition
|
||||
* @param pos The position and rotation to set
|
||||
*/
|
||||
public void setCameraPosRot(AdvancedPosition pos) {
|
||||
setCameraRotation((float) pos.getYaw(), (float) pos.getPitch(), (float) pos.getRoll());
|
||||
public void setCameraPosRot(Location pos) {
|
||||
setCameraRotation(pos.getYaw(), pos.getPitch(), roll);
|
||||
setCameraPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
public ResourceLocation getLocationSkin() {
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
if (view != this && view instanceof EntityPlayer) {
|
||||
return SkinProvider.getResourceLocationForPlayerUUID(view.getUniqueID());
|
||||
return Utils.getResourceLocationForPlayerUUID(view.getUniqueID());
|
||||
}
|
||||
return super.getLocationSkin();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.replaymod.replay.gui.overlay;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.util.Location;
|
||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||
import de.johni0702.minecraft.gui.RenderInfo;
|
||||
import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline;
|
||||
import de.johni0702.minecraft.gui.function.Draggable;
|
||||
import com.replaymod.replaystudio.data.Marker;
|
||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.lwjgl.util.Point;
|
||||
@@ -126,9 +126,9 @@ public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> im
|
||||
lastClickTime = now;
|
||||
} else if (button == 1) { // Right click
|
||||
selectedMarker = null;
|
||||
replayHandler.setTargetPosition(new AdvancedPosition(
|
||||
replayHandler.setTargetPosition(new Location(
|
||||
marker.getX(), marker.getY(), marker.getZ(),
|
||||
marker.getPitch(), marker.getYaw(), marker.getRoll()
|
||||
marker.getPitch(), marker.getYaw()
|
||||
));
|
||||
replayHandler.doJump(marker.getTime(), false);
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
||||
import eu.crushedpixel.replaymod.utils.DurationUtils;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import com.replaymod.core.utils.Utils;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.Util;
|
||||
@@ -162,11 +160,9 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
popup.getYesButton().onClick();
|
||||
}
|
||||
}
|
||||
}).onTextChanged(new Consumer<String>() {
|
||||
@Override
|
||||
public void consume(String obj) {
|
||||
popup.getYesButton().setEnabled(!nameField.getText().isEmpty());
|
||||
}
|
||||
}).onTextChanged(obj -> {
|
||||
popup.getYesButton().setEnabled(!nameField.getText().isEmpty()
|
||||
&& !new File(file.getParentFile(), nameField.getText() + ".mcpr").exists());
|
||||
});
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||
@Override
|
||||
@@ -176,11 +172,9 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
String name = nameField.getText().trim().replace("[^a-zA-Z0-9\\.\\- ]", "_");
|
||||
// This file is what they want
|
||||
File targetFile = new File(file.getParentFile(), name + ".mcpr");
|
||||
// But if it's already used, this is what they get
|
||||
File renamed = ReplayFileIO.getNextFreeFile(targetFile);
|
||||
try {
|
||||
// Finally, try to move it
|
||||
FileUtils.moveFile(file, renamed);
|
||||
FileUtils.moveFile(file, targetFile);
|
||||
} catch (IOException e) {
|
||||
// We failed (might also be their OS)
|
||||
e.printStackTrace();
|
||||
@@ -268,7 +262,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
});
|
||||
}
|
||||
|
||||
private final GuiImage defaultThumbnail = new GuiImage().setTexture(ResourceHelper.getDefaultThumbnail());
|
||||
private final GuiImage defaultThumbnail = new GuiImage().setTexture(Utils.DEFAULT_THUMBNAIL);
|
||||
public class GuiReplayEntry extends AbstractGuiContainer<GuiReplayEntry> implements Comparable<GuiReplayEntry> {
|
||||
public final File file;
|
||||
public final GuiLabel name = new GuiLabel();
|
||||
@@ -311,7 +305,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
} else {
|
||||
thumbnail = new GuiImage(this).setTexture(thumbImage).setSize(30 * 16 / 9, 30);
|
||||
}
|
||||
duration.setText(DurationUtils.convertSecondsToShortString(metaData.getDuration() / 1000));
|
||||
duration.setText(Utils.convertSecondsToShortString(metaData.getDuration() / 1000));
|
||||
addElements(null, durationPanel);
|
||||
|
||||
setLayout(new CustomLayout<GuiReplayEntry>() {
|
||||
|
||||
Reference in New Issue
Block a user