-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Advancement Screenshot tweak
Closes #626
- Loading branch information
Showing
5 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...acgaming/universaltweaks/tweaks/misc/advancements/screenshot/UTAdvancementScreenshot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package mod.acgaming.universaltweaks.tweaks.misc.advancements.screenshot; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.entity.player.EntityPlayerMP; | ||
import net.minecraftforge.event.entity.player.AdvancementEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
|
||
import mod.acgaming.universaltweaks.UniversalTweaks; | ||
import mod.acgaming.universaltweaks.config.UTConfigGeneral; | ||
import mod.acgaming.universaltweaks.config.UTConfigTweaks; | ||
import mod.acgaming.universaltweaks.util.UTPacketHandler; | ||
|
||
@Mod.EventBusSubscriber(modid = UniversalTweaks.MODID, value = Side.CLIENT) | ||
public class UTAdvancementScreenshot | ||
{ | ||
private static long lastScreenshotTick = 0; | ||
|
||
@SubscribeEvent | ||
public static void utAdvancementScreenshot(AdvancementEvent event) | ||
{ | ||
if (!UTConfigTweaks.MISC.utAdvancementScreenshotToggle) return; | ||
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTAdvancementScreenshot ::: Advancement event"); | ||
long currentTick = Minecraft.getMinecraft().world.getTotalWorldTime(); | ||
if (currentTick - lastScreenshotTick > 20) | ||
{ | ||
UTPacketHandler.instance.sendTo(new UTAdvancementScreenshotMessage(), (EntityPlayerMP) event.getEntityPlayer()); | ||
lastScreenshotTick = currentTick; | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...g/universaltweaks/tweaks/misc/advancements/screenshot/UTAdvancementScreenshotMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package mod.acgaming.universaltweaks.tweaks.misc.advancements.screenshot; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.util.ScreenShotHelper; | ||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage; | ||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; | ||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
public class UTAdvancementScreenshotMessage implements IMessage | ||
{ | ||
public UTAdvancementScreenshotMessage() {} | ||
|
||
@Override | ||
public void fromBytes(ByteBuf buf) {} | ||
|
||
@Override | ||
public void toBytes(ByteBuf buf) {} | ||
|
||
public static class Handler implements IMessageHandler<UTAdvancementScreenshotMessage, IMessage> | ||
{ | ||
@Override | ||
public IMessage onMessage(UTAdvancementScreenshotMessage message, MessageContext ctx) | ||
{ | ||
Minecraft.getMinecraft().addScheduledTask(() -> { | ||
Minecraft mc = Minecraft.getMinecraft(); | ||
ScreenShotHelper.saveScreenshot(mc.gameDir, mc.displayWidth, mc.displayHeight, mc.getFramebuffer()); | ||
}); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters