Get rid of all the ATs in favor of Mixins
This commit is contained in:
@@ -240,7 +240,7 @@ public class ReplayMod implements
|
||||
try {
|
||||
return super.getInputStream(resourceName);
|
||||
//#else
|
||||
//$$ List<IResourcePack> defaultResourcePacks = mc.defaultResourcePacks;
|
||||
//$$ List<IResourcePack> defaultResourcePacks = ((MinecraftAccessor) mc).getDefaultResourcePacks();
|
||||
//$$ FolderResourcePack jGuiResourcePack = new FolderResourcePack(new File("../jGui/src/main/resources")) {
|
||||
//$$ @Override
|
||||
//$$ protected InputStream getInputStreamByName(String resourceName) throws IOException {
|
||||
|
||||
@@ -12,6 +12,11 @@ import java.util.Queue;
|
||||
import java.util.concurrent.FutureTask;
|
||||
//#endif
|
||||
|
||||
//#if MC<11300
|
||||
//$$ import net.minecraft.client.resources.IResourcePack;
|
||||
//$$ import java.util.List;
|
||||
//#endif
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public interface MinecraftAccessor {
|
||||
@Accessor
|
||||
@@ -32,4 +37,9 @@ public interface MinecraftAccessor {
|
||||
|
||||
@Accessor
|
||||
CrashReport getCrashReporter();
|
||||
|
||||
//#if MC<11300
|
||||
//$$ @Accessor
|
||||
//$$ List<IResourcePack> getDefaultResourcePacks();
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
//#if MC>=11300
|
||||
package com.replaymod.core.mixin;
|
||||
|
||||
import com.replaymod.core.events.PostRenderCallback;
|
||||
import com.replaymod.core.events.PreRenderCallback;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.OpenGuiScreenCallback;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
//#if MC>=11300
|
||||
import com.replaymod.core.events.PostRenderCallback;
|
||||
import com.replaymod.core.events.PreRenderCallback;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.OpenGuiScreenCallback;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
//#else
|
||||
//$$ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
//$$ import com.replaymod.replay.InputReplayTimer;
|
||||
//$$ import org.lwjgl.input.Mouse;
|
||||
//#endif
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import net.minecraft.util.NonBlockingThreadExecutor;
|
||||
@@ -28,6 +36,7 @@ public abstract class MixinMinecraft
|
||||
//$$ public MixinMinecraft(String string_1) { super(string_1); }
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
@Shadow protected abstract void processKeyBinds();
|
||||
|
||||
@Override
|
||||
@@ -66,5 +75,41 @@ public abstract class MixinMinecraft
|
||||
private void openGuiScreen(GuiScreen newGuiScreen, CallbackInfo ci) {
|
||||
OpenGuiScreenCallback.EVENT.invoker().openGuiScreen(newGuiScreen);
|
||||
}
|
||||
//#else
|
||||
//#if MC>=10904
|
||||
//$$ @Shadow protected abstract void runTickKeyboard() throws IOException;
|
||||
//$$ @Shadow protected abstract void runTickMouse() throws IOException;
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public void replayModRunTickKeyboard() {
|
||||
//$$ try {
|
||||
//$$ runTickKeyboard();
|
||||
//$$ } catch (IOException e) {
|
||||
//$$ e.printStackTrace();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public void replayModRunTickMouse() {
|
||||
//$$ try {
|
||||
//$$ runTickMouse();
|
||||
//$$ } catch (IOException e) {
|
||||
//$$ e.printStackTrace();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
//$$ @Redirect(
|
||||
//#if MC>=10904
|
||||
//$$ method = "runTickMouse",
|
||||
//#else
|
||||
//$$ method = "runTick",
|
||||
//#endif
|
||||
//$$ at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventDWheel()I", remap = false)
|
||||
//$$ )
|
||||
//$$ private static int scroll() {
|
||||
//$$ int wheel = Mouse.getEventDWheel();
|
||||
//$$ InputReplayTimer.handleScroll(wheel);
|
||||
//$$ return wheel;
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//#if MC<10800
|
||||
//$$ package com.replaymod.core.mixin;
|
||||
//$$
|
||||
//$$ import net.minecraft.client.resources.IResourcePack;
|
||||
//$$ import net.minecraft.client.resources.ResourcePackRepository;
|
||||
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||
//$$ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
//$$
|
||||
//$$ import java.io.File;
|
||||
//$$
|
||||
//$$ @Mixin(ResourcePackRepository.class)
|
||||
//$$ public interface ResourcePackRepositoryAccessor {
|
||||
//$$ @Accessor("field_148533_g")
|
||||
//$$ boolean isActive();
|
||||
//$$ @Accessor("field_148533_g")
|
||||
//$$ void setActive(boolean value);
|
||||
//$$ @Accessor("field_148532_f")
|
||||
//$$ void setPack(IResourcePack value);
|
||||
//$$ @Accessor("field_148534_e")
|
||||
//$$ File getCacheDir();
|
||||
//$$ }
|
||||
//#endif
|
||||
@@ -21,5 +21,25 @@ public interface TimerAccessor {
|
||||
//$$ float getTimerSpeed();
|
||||
//$$ @Accessor
|
||||
//$$ void setTimerSpeed(float value);
|
||||
//$$ @Accessor
|
||||
//$$ float getTicksPerSecond();
|
||||
//$$ @Accessor
|
||||
//$$ void setTicksPerSecond(float value);
|
||||
//$$ @Accessor
|
||||
//$$ double getLastHRTime();
|
||||
//$$ @Accessor
|
||||
//$$ void setLastHRTime(double value);
|
||||
//$$ @Accessor
|
||||
//$$ long getLastSyncHRClock();
|
||||
//$$ @Accessor
|
||||
//$$ void setLastSyncHRClock(long value);
|
||||
//$$ @Accessor
|
||||
//$$ double getTimeSyncAdjustment();
|
||||
//$$ @Accessor
|
||||
//$$ void setTimeSyncAdjustment(double value);
|
||||
//$$ @Accessor
|
||||
//$$ long getCounter();
|
||||
//$$ @Accessor
|
||||
//$$ void setCounter(long value);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -44,16 +44,12 @@ public class WrappedTimer extends Timer {
|
||||
//#if MC>=11200
|
||||
toA.setTickLength(fromA.getTickLength());
|
||||
//#else
|
||||
//$$ to.ticksPerSecond = from.ticksPerSecond;
|
||||
//$$ to.lastHRTime = from.lastHRTime;
|
||||
//$$ toA.setTicksPerSecond(fromA.getTicksPerSecond());
|
||||
//$$ toA.setLastHRTime(fromA.getLastHRTime());
|
||||
//$$ toA.setTimerSpeed(fromA.getTimerSpeed());
|
||||
//$$ to.lastSyncHRClock = from.lastSyncHRClock;
|
||||
//#if MC>=10809
|
||||
//$$ to.counter = from.counter;
|
||||
//#else
|
||||
//$$ to.field_74285_i = from.field_74285_i;
|
||||
//#endif
|
||||
//$$ to.timeSyncAdjustment = from.timeSyncAdjustment;
|
||||
//$$ toA.setLastSyncHRClock(fromA.getLastSyncHRClock());
|
||||
//$$ toA.setCounter(fromA.getCounter());
|
||||
//$$ toA.setTimeSyncAdjustment(fromA.getTimeSyncAdjustment());
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.world.WorldType;
|
||||
//#else
|
||||
//$$ import com.replaymod.core.mixin.ResourcePackRepositoryAccessor;
|
||||
//$$ import com.google.common.util.concurrent.Futures;
|
||||
//$$ import io.netty.handler.codec.DecoderException;
|
||||
//$$ import net.minecraft.client.resources.FileResourcePack;
|
||||
@@ -351,8 +352,9 @@ public class MCVer {
|
||||
//#if MC>=10800
|
||||
//$$ return repo.func_177319_a(file);
|
||||
//#else
|
||||
//$$ repo.field_148533_g = false;
|
||||
//$$ repo.field_148532_f = new FileResourcePack(file);
|
||||
//$$ ResourcePackRepositoryAccessor acc = (ResourcePackRepositoryAccessor) repo;
|
||||
//$$ acc.setActive(false);
|
||||
//$$ acc.setPack(new FileResourcePack(file));
|
||||
//$$ Minecraft.getMinecraft().scheduleResourcesRefresh();
|
||||
//$$ return Futures.immediateFuture(null);
|
||||
//#endif
|
||||
@@ -520,13 +522,19 @@ public class MCVer {
|
||||
public static void processKeyBinds() {
|
||||
((MinecraftMethodAccessor) getMinecraft()).replayModProcessKeyBinds();
|
||||
}
|
||||
//#endif
|
||||
|
||||
public interface MinecraftMethodAccessor {
|
||||
//#if MC>=11300
|
||||
void replayModProcessKeyBinds();
|
||||
//#else
|
||||
//$$ void replayModRunTickMouse();
|
||||
//$$ void replayModRunTickKeyboard();
|
||||
//#endif
|
||||
//#if MC>=11400
|
||||
//$$ void replayModExecuteTaskQueue();
|
||||
//#endif
|
||||
}
|
||||
//#endif
|
||||
|
||||
public static long milliTime() {
|
||||
//#if MC>=11300
|
||||
|
||||
Reference in New Issue
Block a user