From e831b4268912966e843a4b07c77b308e6297753e Mon Sep 17 00:00:00 2001 From: Guntram Blohm Date: Mon, 31 Jul 2017 14:14:12 +0200 Subject: [PATCH] update 1.1: can use the G key in addition to /ghost --- build.gradle | 2 +- .../de/guntram/mcmod/antighost/AntiGhost.java | 25 ++++++++++++++++--- .../assets/antighost/lang/en_US.lang | 2 ++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 950a950..f16f5ed 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -version = "1.12-forge14.21.1.2387-1.0" +version = "1.12-forge14.21.1.2387-1.1" group = "de.guntram.mcmod.antighost" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "antighost" diff --git a/src/main/java/de/guntram/mcmod/antighost/AntiGhost.java b/src/main/java/de/guntram/mcmod/antighost/AntiGhost.java index 99456ad..e5b8ad3 100644 --- a/src/main/java/de/guntram/mcmod/antighost/AntiGhost.java +++ b/src/main/java/de/guntram/mcmod/antighost/AntiGhost.java @@ -3,20 +3,27 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.command.CommandException; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.network.play.client.CPacketPlayerDigging; import net.minecraft.server.MinecraftServer; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentString; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent; +import org.lwjgl.input.Keyboard; @Mod(modid = AntiGhost.MODID, version = AntiGhost.VERSION, @@ -28,12 +35,15 @@ public class AntiGhost implements ICommand { static final String MODID="antighost"; - static final String VERSION="1.0"; + static final String VERSION="1.1"; + static KeyBinding showGui; + @EventHandler public void init(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(this); ClientCommandHandler.instance.registerCommand(this); + ClientRegistry.registerKeyBinding(showGui = new KeyBinding("key.reveal", Keyboard.KEY_G, "key.categories.antighost")); } @EventHandler @@ -43,6 +53,15 @@ public void preInit(final FMLPreInitializationEvent event) { MinecraftForge.EVENT_BUS.register(confHandler); } + @SubscribeEvent + public void keyPressed(final InputEvent.KeyInputEvent e) { + EntityPlayerSP player = Minecraft.getMinecraft().player; + if (showGui.isPressed()) { + this.execute(null, player, null); + player.sendMessage(new TextComponentString(I18n.format("msg.request", (Object[]) null))); + } + } + @Override public String getName() { return "ghost"; @@ -59,7 +78,7 @@ public List getAliases() { } @Override - public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { + public void execute(MinecraftServer server, ICommandSender sender, String[] args) { Minecraft mc=Minecraft.getMinecraft(); NetHandlerPlayClient conn = mc.getConnection(); if (conn==null) diff --git a/src/main/resources/assets/antighost/lang/en_US.lang b/src/main/resources/assets/antighost/lang/en_US.lang index 4ebd72c..7cd5a70 100644 --- a/src/main/resources/assets/antighost/lang/en_US.lang +++ b/src/main/resources/assets/antighost/lang/en_US.lang @@ -1 +1,3 @@ key.categories.antighost=AntiGhost +key.reveal=Reveal ghost blocks +msg.request=requesting resend of blocks around you \ No newline at end of file