Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
update 1.1: can use the G key in addition to /ghost
Browse files Browse the repository at this point in the history
  • Loading branch information
gbl committed Jul 31, 2017
1 parent 4938208 commit e831b42
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
25 changes: 22 additions & 3 deletions src/main/java/de/guntram/mcmod/antighost/AntiGhost.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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";
Expand All @@ -59,7 +78,7 @@ public List<String> 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)
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/antighost/lang/en_US.lang
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
key.categories.antighost=AntiGhost
key.reveal=Reveal ghost blocks
msg.request=requesting resend of blocks around you

0 comments on commit e831b42

Please sign in to comment.