mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-29 23:48:00 +01:00
Add fixes for liteloader's outdated mappings.
Remove these when it updates
This commit is contained in:
parent
945996cfa4
commit
cc3c1b77b0
2 changed files with 318 additions and 0 deletions
|
@ -0,0 +1,211 @@
|
||||||
|
/*
|
||||||
|
* This file is part of LiteLoader.
|
||||||
|
* Copyright (C) 2012-16 Adam Mummery-Smith
|
||||||
|
* All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package com.mumfrey.liteloader.client.mixin;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import com.mumfrey.liteloader.PlayerInteractionListener.MouseButton;
|
||||||
|
import com.mumfrey.liteloader.client.ClientProxy;
|
||||||
|
import com.mumfrey.liteloader.client.overlays.IMinecraft;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
|
import net.minecraft.client.resources.IResourcePack;
|
||||||
|
import net.minecraft.client.shader.Framebuffer;
|
||||||
|
import net.minecraft.util.Timer;
|
||||||
|
|
||||||
|
@Mixin(Minecraft.class)
|
||||||
|
public abstract class MixinMinecraft implements IMinecraft
|
||||||
|
{
|
||||||
|
@Shadow @Final private Timer timer;
|
||||||
|
@Shadow volatile boolean running;
|
||||||
|
@Shadow @Final private List<IResourcePack> defaultResourcePacks;
|
||||||
|
@Shadow private String serverName;
|
||||||
|
@Shadow private int serverPort;
|
||||||
|
|
||||||
|
@Shadow abstract void resize(int width, int height);
|
||||||
|
@Shadow private void clickMouse() {}
|
||||||
|
@Shadow private void rightClickMouse() {}
|
||||||
|
@Shadow private void middleClickMouse() {}
|
||||||
|
|
||||||
|
@Inject(method = "init()V", at = @At("RETURN"))
|
||||||
|
private void onStartupComplete(CallbackInfo ci)
|
||||||
|
{
|
||||||
|
ClientProxy.onStartupComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "updateFramebufferSize()V", at = @At("HEAD"))
|
||||||
|
private void onResize(CallbackInfo ci)
|
||||||
|
{
|
||||||
|
ClientProxy.onResize((Minecraft)(Object)this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "runTick()V", at = @At("HEAD"))
|
||||||
|
private void newTick(CallbackInfo ci)
|
||||||
|
{
|
||||||
|
ClientProxy.newTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "runGameLoop()V", at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
shift = Shift.AFTER,
|
||||||
|
target = "Lnet/minecraft/client/renderer/EntityRenderer;updateCameraAndRender(FJ)V"
|
||||||
|
))
|
||||||
|
private void onTick(CallbackInfo ci)
|
||||||
|
{
|
||||||
|
ClientProxy.onTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "runGameLoop()V", at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/shader/Framebuffer;framebufferRender(II)V"
|
||||||
|
))
|
||||||
|
private void renderFBO(Framebuffer framebufferMc, int width, int height)
|
||||||
|
{
|
||||||
|
boolean fboEnabled = OpenGlHelper.isFramebufferEnabled();
|
||||||
|
if (fboEnabled)
|
||||||
|
{
|
||||||
|
ClientProxy.preRenderFBO(framebufferMc);
|
||||||
|
framebufferMc.framebufferRender(width, height);
|
||||||
|
ClientProxy.preRenderFBO(framebufferMc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
framebufferMc.framebufferRender(width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "runGameLoop()V", at = @At(
|
||||||
|
value = "INVOKE_STRING",
|
||||||
|
target = "Lnet/minecraft/profiler/Profiler;startSection(Ljava/lang/String;)V",
|
||||||
|
args = "ldc=tick"
|
||||||
|
))
|
||||||
|
private void onTimerUpdate(CallbackInfo ci)
|
||||||
|
{
|
||||||
|
ClientProxy.onTimerUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "runGameLoop()V", at = @At(
|
||||||
|
value = "INVOKE_STRING",
|
||||||
|
target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V",
|
||||||
|
args = "ldc=gameRenderer"
|
||||||
|
))
|
||||||
|
private void onRender(CallbackInfo ci)
|
||||||
|
{
|
||||||
|
ClientProxy.onRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "processKeyBinds()V", at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/Minecraft;clickMouse()V"
|
||||||
|
))
|
||||||
|
private void onClickMouse(Minecraft self)
|
||||||
|
{
|
||||||
|
if (ClientProxy.onClickMouse(self.player, MouseButton.LEFT))
|
||||||
|
{
|
||||||
|
this.clickMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "sendClickBlockToController(Z)V", at = @At(
|
||||||
|
value = "FIELD",
|
||||||
|
target = "Lnet/minecraft/client/Minecraft;objectMouseOver:Lnet/minecraft/util/math/RayTraceResult;",
|
||||||
|
ordinal = 0
|
||||||
|
),
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
private void onMouseHeld(boolean leftClick, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
if (!ClientProxy.onMouseHeld(((Minecraft)(Object)this).player, MouseButton.LEFT))
|
||||||
|
{
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "processKeyBinds()V", at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/Minecraft;rightClickMouse()V",
|
||||||
|
ordinal = 0
|
||||||
|
))
|
||||||
|
private void onRightClickMouse(Minecraft self)
|
||||||
|
{
|
||||||
|
if (ClientProxy.onClickMouse(self.player, MouseButton.RIGHT))
|
||||||
|
{
|
||||||
|
this.rightClickMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "processKeyBinds()V", at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/Minecraft;rightClickMouse()V",
|
||||||
|
ordinal = 1
|
||||||
|
))
|
||||||
|
private void onRightMouseHeld(Minecraft self)
|
||||||
|
{
|
||||||
|
if (ClientProxy.onMouseHeld(self.player, MouseButton.RIGHT))
|
||||||
|
{
|
||||||
|
this.rightClickMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "processKeyBinds()V", at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/Minecraft;middleClickMouse()V"
|
||||||
|
))
|
||||||
|
private void onMiddleClickMouse(Minecraft self)
|
||||||
|
{
|
||||||
|
if (ClientProxy.onClickMouse(self.player, MouseButton.MIDDLE))
|
||||||
|
{
|
||||||
|
this.middleClickMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Timer getTimer()
|
||||||
|
{
|
||||||
|
return this.timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRunning()
|
||||||
|
{
|
||||||
|
return this.running;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IResourcePack> getDefaultResourcePacks()
|
||||||
|
{
|
||||||
|
return this.defaultResourcePacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServerName()
|
||||||
|
{
|
||||||
|
return this.serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getServerPort()
|
||||||
|
{
|
||||||
|
return this.serverPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResizeWindow(int width, int height)
|
||||||
|
{
|
||||||
|
this.resize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,107 @@
|
||||||
|
/*
|
||||||
|
* This file is part of LiteLoader.
|
||||||
|
* Copyright (C) 2012-16 Adam Mummery-Smith
|
||||||
|
* All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package com.mumfrey.liteloader.common.mixin;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
|
import com.mumfrey.liteloader.common.ducks.ITeleportHandler;
|
||||||
|
import com.mumfrey.liteloader.core.Proxy;
|
||||||
|
|
||||||
|
import net.minecraft.network.NetHandlerPlayServer;
|
||||||
|
import net.minecraft.network.play.client.CPacketAnimation;
|
||||||
|
import net.minecraft.network.play.client.CPacketPlayer;
|
||||||
|
import net.minecraft.network.play.client.CPacketPlayerDigging;
|
||||||
|
import net.minecraft.network.play.client.CPacketPlayerTryUseItem;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
|
||||||
|
@Mixin(NetHandlerPlayServer.class)
|
||||||
|
public abstract class MixinNetHandlerPlayServer implements ITeleportHandler
|
||||||
|
{
|
||||||
|
@Shadow private int teleportId;
|
||||||
|
@Shadow private Vec3d targetPos;
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "processTryUseItem(Lnet/minecraft/network/play/client/CPacketPlayerTryUseItem;)V",
|
||||||
|
cancellable = true,
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
shift = Shift.AFTER,
|
||||||
|
target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue"
|
||||||
|
+ "(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private void onPlaceBlock(CPacketPlayerTryUseItem packetIn, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
Proxy.onPlaceBlock(ci, (NetHandlerPlayServer)(Object)this, packetIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "handleAnimation(Lnet/minecraft/network/play/client/CPacketAnimation;)V",
|
||||||
|
cancellable = true,
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
shift = Shift.AFTER,
|
||||||
|
target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue"
|
||||||
|
+ "(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private void onClickedAir(CPacketAnimation packetIn, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
Proxy.onClickedAir(ci, (NetHandlerPlayServer)(Object)this, packetIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "processPlayerDigging(Lnet/minecraft/network/play/client/CPacketPlayerDigging;)V",
|
||||||
|
cancellable = true,
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
shift = Shift.AFTER,
|
||||||
|
target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue"
|
||||||
|
+ "(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private void onPlayerDigging(CPacketPlayerDigging packetIn, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
Proxy.onPlayerDigging(ci, (NetHandlerPlayServer)(Object)this, packetIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "processPlayer(Lnet/minecraft/network/play/client/CPacketPlayer;)V",
|
||||||
|
cancellable = true,
|
||||||
|
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||||
|
at = @At(
|
||||||
|
value = "FIELD",
|
||||||
|
opcode = Opcodes.GETFIELD,
|
||||||
|
target = "Lnet/minecraft/entity/player/EntityPlayerMP;posY:D",
|
||||||
|
ordinal = 3
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private void onPlayerMoved(CPacketPlayer packetIn, CallbackInfo ci, WorldServer world)
|
||||||
|
{
|
||||||
|
Proxy.onPlayerMoved(ci, (NetHandlerPlayServer)(Object)this, packetIn, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int beginTeleport(Vec3d location)
|
||||||
|
{
|
||||||
|
this.targetPos = location;
|
||||||
|
|
||||||
|
if (++this.teleportId == Integer.MAX_VALUE)
|
||||||
|
{
|
||||||
|
this.teleportId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.teleportId;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue