Added a command to make taking screenshots of Marx generator discharges easier/possible
This commit is contained in:
parent
afccf9b677
commit
14fde279be
|
@ -45,14 +45,14 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.ScreenShotHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.*;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
@ -64,6 +64,7 @@ import java.util.Map;
|
|||
|
||||
@Mod.EventBusSubscriber(modid = IndustrialWires.MODID, value = Side.CLIENT)
|
||||
public class ClientEventHandler {
|
||||
public static boolean shouldScreenshot = false;
|
||||
@SubscribeEvent
|
||||
public static void renderOverlayPost(RenderGameOverlayEvent.Post e) {
|
||||
if (ClientUtils.mc().player != null && e.getType() == RenderGameOverlayEvent.ElementType.TEXT) {
|
||||
|
@ -171,4 +172,14 @@ public class ClientEventHandler {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public static void renderWorldLastLow(RenderWorldLastEvent ev) {
|
||||
if (shouldScreenshot) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ITextComponent comp = ScreenShotHelper.saveScreenshot(mc.mcDataDir, mc.displayWidth, mc.displayHeight, mc.getFramebuffer());//TODO
|
||||
mc.player.sendMessage(comp);
|
||||
shouldScreenshot = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ import malte0811.industrialWires.hv.MarxOreHandler;
|
|||
import malte0811.industrialWires.hv.MultiblockMarx;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.util.CommandIWClient;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.audio.MovingSound;
|
||||
|
@ -68,6 +69,7 @@ import net.minecraft.util.SoundEvent;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
|
@ -260,6 +262,7 @@ public class ClientProxy extends CommonProxy {
|
|||
m.fontRenderer.setUnicodeFlag(uni);
|
||||
List<ManualPages> marxEntry = splitter.toManualEntry();
|
||||
m.addEntry("industrialwires.marx", IndustrialWires.MODID, marxEntry.toArray(new ManualPages[marxEntry.size()]));
|
||||
ClientCommandHandler.instance.registerCommand(new CommandIWClient());
|
||||
}
|
||||
|
||||
private static final ResourceLocation TINNITUS_LOC = new ResourceLocation(IndustrialWires.MODID, "tinnitus");
|
||||
|
|
|
@ -22,6 +22,7 @@ import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
|||
import malte0811.industrialWires.blocks.IWProperties;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx;
|
||||
import malte0811.industrialWires.blocks.hv.TileEntityMarx.Discharge;
|
||||
import malte0811.industrialWires.client.ClientEventHandler;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
|
@ -37,6 +38,7 @@ import org.lwjgl.opengl.GL11;
|
|||
import static malte0811.industrialWires.blocks.hv.TileEntityMarx.FiringState.FIRE;
|
||||
|
||||
public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
|
||||
public static boolean screenShot = false;
|
||||
@Override
|
||||
public void render(TileEntityMarx te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
|
||||
final boolean debug = false;
|
||||
|
@ -66,6 +68,10 @@ public class TileRenderMarx extends TileEntitySpecialRenderer<TileEntityMarx> {
|
|||
}
|
||||
cleanUp();
|
||||
te.state = TileEntityMarx.FiringState.CHARGING;
|
||||
if (screenShot) {
|
||||
ClientEventHandler.shouldScreenshot = true;
|
||||
screenShot = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialWires.util;
|
||||
|
||||
import malte0811.industrialWires.client.render.TileRenderMarx;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandIWClient extends CommandBase {
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ciw";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUsage(@Nonnull ICommandSender sender) {
|
||||
return "/ciw <triggermarxscreenshot>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException {
|
||||
if (args.length==0)
|
||||
throw new CommandException("1 parameter is required");
|
||||
switch (args[0].toLowerCase()) {
|
||||
//TODO more immersive way of doing this?
|
||||
case "triggermarxscreenshot":
|
||||
TileRenderMarx.screenShot = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) {
|
||||
if (args.length==1) {
|
||||
return getListOfStringsMatchingLastWord(args, "triggermarxscreenshot");
|
||||
}
|
||||
return super.getTabCompletions(server, sender, args, targetPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue