CameraEntity now registers itself. It doesn't need external code doing its job!
This commit is contained in:
@@ -12,6 +12,7 @@ import net.minecraft.util.MathHelper;
|
|||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
@@ -53,6 +54,7 @@ public class CameraEntity extends EntityPlayer {
|
|||||||
|
|
||||||
public CameraEntity(World worldIn) {
|
public CameraEntity(World worldIn) {
|
||||||
super(worldIn, Minecraft.getMinecraft().getSession().getProfile());
|
super(worldIn, Minecraft.getMinecraft().getSession().getProfile());
|
||||||
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -204,16 +204,13 @@ public class ReplayHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CameraEntity getCameraEntity() {
|
public static CameraEntity getCameraEntity() {
|
||||||
|
if(cameraEntity == null && mc.theWorld != null) cameraEntity = new CameraEntity(mc.theWorld);
|
||||||
return cameraEntity;
|
return cameraEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCameraEntity(CameraEntity entity) {
|
public static void setCameraEntity(CameraEntity entity) {
|
||||||
if(entity == null) return;
|
if(entity == null) return;
|
||||||
if (cameraEntity != null) {
|
|
||||||
FMLCommonHandler.instance().bus().unregister(cameraEntity);
|
|
||||||
}
|
|
||||||
cameraEntity = entity;
|
cameraEntity = entity;
|
||||||
FMLCommonHandler.instance().bus().register(cameraEntity);
|
|
||||||
spectateCamera();
|
spectateCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user