Update to MC 1.14 / Fabric
This commit is contained in:
@@ -13,19 +13,10 @@ import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||
import com.replaymod.replaystudio.pathing.path.Path;
|
||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Timer;
|
||||
|
||||
//#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 javax.annotation.Nullable;
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -34,7 +25,7 @@ import static com.replaymod.core.versions.MCVer.*;
|
||||
/**
|
||||
* Plays a timeline.
|
||||
*/
|
||||
public abstract class AbstractTimelinePlayer {
|
||||
public abstract class AbstractTimelinePlayer extends EventRegistrations {
|
||||
private final Minecraft mc = getMinecraft();
|
||||
private final ReplayHandler replayHandler;
|
||||
private Timeline timeline;
|
||||
@@ -79,7 +70,7 @@ public abstract class AbstractTimelinePlayer {
|
||||
}
|
||||
|
||||
replayHandler.getReplaySender().setSyncModeAndWait();
|
||||
FML_BUS.register(this);
|
||||
register();
|
||||
lastTime = 0;
|
||||
|
||||
MinecraftAccessor mcA = (MinecraftAccessor) mc;
|
||||
@@ -106,14 +97,14 @@ public abstract class AbstractTimelinePlayer {
|
||||
return future != null && !future.isDone();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(ReplayTimer.UpdatedEvent event) {
|
||||
{ on(ReplayTimer.UpdatedCallback.EVENT, this::onTick); }
|
||||
public void onTick() {
|
||||
if (future.isDone()) {
|
||||
MinecraftAccessor mcA = (MinecraftAccessor) mc;
|
||||
mcA.setTimer(((ReplayTimer) mcA.getTimer()).getWrapped());
|
||||
replayHandler.getReplaySender().setReplaySpeed(0);
|
||||
replayHandler.getReplaySender().setAsyncMode(true);
|
||||
FML_BUS.unregister(this);
|
||||
unregister();
|
||||
return;
|
||||
}
|
||||
long time = getTimePassed();
|
||||
|
||||
@@ -4,10 +4,6 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||
|
||||
//#if MC<=10710
|
||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
|
||||
/**
|
||||
* Timeline player using the system time.
|
||||
*/
|
||||
@@ -36,15 +32,12 @@ public class RealtimeTimelinePlayer extends AbstractTimelinePlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
//#if MC<=10710
|
||||
//$$ @SubscribeEvent
|
||||
//#endif
|
||||
public void onTick(ReplayTimer.UpdatedEvent event) {
|
||||
public void onTick() {
|
||||
if (secondFrame) {
|
||||
secondFrame = false;
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
super.onTick(event);
|
||||
super.onTick();
|
||||
if (firstFrame) {
|
||||
firstFrame = false;
|
||||
secondFrame = true;
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
package com.replaymod.pathing.player;
|
||||
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.util.Timer;
|
||||
|
||||
//#if MC>=10800
|
||||
//#if MC>=11300
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
//#endif
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.Event;
|
||||
//#endif
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
/**
|
||||
* Wrapper around the current timer that prevents the timer from advancing by itself.
|
||||
*/
|
||||
@@ -30,7 +20,12 @@ public class ReplayTimer extends WrappedTimer {
|
||||
}
|
||||
|
||||
@Override
|
||||
// This should be handled by Remap but it isn't (was handled before a9724e3).
|
||||
//#if MC>=11400
|
||||
//$$ public void beginRenderTick(
|
||||
//#else
|
||||
public void updateTimer(
|
||||
//#endif
|
||||
//#if MC>=11300
|
||||
long sysClock
|
||||
//#endif
|
||||
@@ -42,13 +37,20 @@ public class ReplayTimer extends WrappedTimer {
|
||||
//#endif
|
||||
); // Update current state
|
||||
copy(state, this); // Restore our old state
|
||||
FML_BUS.post(new UpdatedEvent());
|
||||
UpdatedCallback.EVENT.invoker().onUpdate();
|
||||
}
|
||||
|
||||
public Timer getWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
public static class UpdatedEvent extends Event {
|
||||
public interface UpdatedCallback {
|
||||
Event<UpdatedCallback> EVENT = EventFactory.createArrayBacked(UpdatedCallback.class,
|
||||
(listeners) -> () -> {
|
||||
for (UpdatedCallback listener : listeners) {
|
||||
listener.onUpdate();
|
||||
}
|
||||
});
|
||||
void onUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.property.AbstractProperty;
|
||||
import com.replaymod.replaystudio.pathing.property.PropertyPart;
|
||||
import com.replaymod.replaystudio.pathing.property.PropertyParts;
|
||||
import lombok.NonNull;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.World;
|
||||
@@ -31,7 +30,7 @@ public class SpectatorProperty extends AbstractProperty<Integer> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToGame(Integer value, @NonNull Object replayHandler) {
|
||||
public void applyToGame(Integer value, Object replayHandler) {
|
||||
ReplayHandler handler = ((ReplayHandler) replayHandler);
|
||||
World world = handler.getCameraEntity().getEntityWorld();
|
||||
// Lookup entity by id, returns null if an entity with the id does not exists
|
||||
|
||||
Reference in New Issue
Block a user