Skip to content

Commit

Permalink
1.1 - Add a lot of new features (code in a poor state, will be rewrit…
Browse files Browse the repository at this point in the history
…ten)
  • Loading branch information
ShinyDialga committed Nov 11, 2015
1 parent 2dbc78a commit a078a39
Show file tree
Hide file tree
Showing 12 changed files with 666 additions and 106 deletions.
30 changes: 26 additions & 4 deletions src/main/java/com/shinycraft/streamermod/StreamerMod.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.shinycraft.streamermod;

import com.shinycraft.streamermod.keybinds.GameModeKeyBind;
import com.shinycraft.streamermod.keybinds.SpectatorHighlightKeyBind;
import com.shinycraft.streamermod.listeners.RenderListener;
import com.shinycraft.streamermod.renderer.ModRenderer;
import com.shinycraft.streamermod.renderer.ScreenDisplay;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.FMLCommonHandler;
Expand All @@ -22,11 +25,24 @@ public class StreamerMod
public static File team2File;
public static int defaultYLevel = 16;
public static boolean scoreboard = true;
public static boolean playerDisplay = true;
public static boolean coreLeakDistance = true;

This comment has been minimized.

Copy link
@ryanwarsaw

ryanwarsaw Nov 11, 2015

@ShinyDialga Is there any reason in particular why you decided to define all of these things statically?

This comment has been minimized.

Copy link
@ShinyDialga

ShinyDialga Nov 11, 2015

Author Owner

I'm still learning how to use mods, and I used static methods to debug it easier. I also don't have the time to rewrite it currently until after the tournament. This will change though, as I'm going to convert this mod into a more modular format.

public static File timeFile;
public static File mapNameFile;
public static File team1ColorInput;
public static File team1ColorOutput;
public static File team2ColorInput;
public static File team2ColorOutput;

public static boolean seePlayerHighlights = false;
public static ScreenDisplay screenDisplay;

@EventHandler
public void init(FMLInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(RenderListener.instance);
FMLCommonHandler.instance().bus().register(new GameModeKeyBind());
FMLCommonHandler.instance().bus().register(new SpectatorHighlightKeyBind());
screenDisplay = new ScreenDisplay();
}

@EventHandler
Expand All @@ -38,12 +54,18 @@ public void preInit(FMLPreInitializationEvent event) {
config.save();
String team1FileString = config.getString("Team1txtFile", Configuration.CATEGORY_GENERAL, "team1.txt", "This is where the first team's name will export to");
String team2FileString = config.getString("Team2txtFile", Configuration.CATEGORY_GENERAL, "team2.txt", "This is where the second team's name will export to");
int y = config.getInt("defaultGUIyLevel", Configuration.CATEGORY_GENERAL, 16, 0, 1980, "How far down the GUI starts");
boolean sb = config.getBoolean("scoreboardEnabled", Configuration.CATEGORY_GENERAL, true, "Enables the scoreboard");
defaultYLevel = config.getInt("DefaultGUIyLevel", Configuration.CATEGORY_GENERAL, 16, 0, 1980, "How far down the GUI starts");
scoreboard = config.getBoolean("ScoreboardEnabled", Configuration.CATEGORY_GENERAL, true, "Enables the scoreboard");
playerDisplay = config.getBoolean("PlayerDisplayEnabled", Configuration.CATEGORY_GENERAL, true, "Enables the player display");
coreLeakDistance = config.getBoolean("CoreLeakDistanceEnabled", Configuration.CATEGORY_GENERAL, true, "Enables the core leak distance display");
timeFile = new File(config.getString("TimetxtFile", Configuration.CATEGORY_GENERAL, "time.txt", "Displays how much time is left in a match"));
mapNameFile = new File(config.getString("MapNametxtFile", Configuration.CATEGORY_GENERAL, "mapname.txt", "Shows what map is currently being played"));
team1ColorInput = new File(config.getString("Team1OverlayInputFile", Configuration.CATEGORY_GENERAL, "team1overlayinput.png", "Links the template required for team 1's color changing overlay output"));
team1ColorOutput = new File(config.getString("Team1OverlayOutputFile", Configuration.CATEGORY_GENERAL, "team1overlayoutput.png", "An image that is colored based on team 1's color"));
team2ColorInput = new File(config.getString("Team2OverlayInputFile", Configuration.CATEGORY_GENERAL, "team2overlayinput.png", "Links the template required for team 2's color changing overlay output"));
team2ColorOutput = new File(config.getString("Team2OverlayOutputFile", Configuration.CATEGORY_GENERAL, "team2overlayoutput.png", "An image that is colored based on team 2's color"));
team1File = new File(team1FileString);
team2File = new File(team2FileString);
defaultYLevel = y;
scoreboard = sb;
config.load();
config.save();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.shinycraft.streamermod.events;

/**
* Created by ShinyDialga45 on 11/6/2015.
*/
public class XMLUpdateEvent {



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.shinycraft.streamermod.keybinds;

import com.shinycraft.streamermod.StreamerMod;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.WorldSettings;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import org.lwjgl.input.Keyboard;

import java.util.EnumSet;

/**
* Created by ShinyDialga45 on 8/22/2015.
*/
public class GameModeKeyBind {

/** Key index for easy handling */
public static final int CUSTOM_INV = 0;
/** Key descriptions; use a language file to localize the description later */
private static final String[] desc = {"Toggle Creative/Spectator mode"};
/** Default key values */
private static final int[] keyValues = {Keyboard.KEY_P};
private final KeyBinding[] keys;

public GameModeKeyBind() {
keys = new KeyBinding[desc.length];
for (int i = 0; i < desc.length; ++i) {
keys[i] = new KeyBinding(desc[i], keyValues[i], "Streamer Mod");
ClientRegistry.registerKeyBinding(keys[i]);
}
}

/**
* KeyInputEvent is in the FML package, so we must register to the FML event bus
*/
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
if (keys[CUSTOM_INV].isPressed() && FMLClientHandler.instance().getClient().inGameHasFocus) {
if (Minecraft.getMinecraft().playerController.getCurrentGameType().equals(WorldSettings.GameType.CREATIVE)) {
Minecraft.getMinecraft().thePlayer.sendChatMessage("/gamemode 3");
} else if (Minecraft.getMinecraft().playerController.getCurrentGameType().equals(WorldSettings.GameType.SPECTATOR)) {
Minecraft.getMinecraft().thePlayer.sendChatMessage("/gamemode 1");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.shinycraft.streamermod.keybinds;

import com.shinycraft.streamermod.StreamerMod;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.world.WorldSettings;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import org.lwjgl.input.Keyboard;

/**
* Created by ShinyDialga45 on 8/22/2015.
*/
public class SpectatorHighlightKeyBind {

/** Key index for easy handling */
public static final int CUSTOM_INV = 0;
/** Key descriptions; use a language file to localize the description later */
private static final String[] desc = {"See lines through players"};
/** Default key values */
private static final int[] keyValues = {Keyboard.KEY_B};
private final KeyBinding[] keys;

public SpectatorHighlightKeyBind() {
keys = new KeyBinding[desc.length];
for (int i = 0; i < desc.length; ++i) {
keys[i] = new KeyBinding(desc[i], keyValues[i], "Streamer Mod");
ClientRegistry.registerKeyBinding(keys[i]);
}
}

/**
* KeyInputEvent is in the FML package, so we must register to the FML event bus
*/
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
if (keys[CUSTOM_INV].isPressed() && FMLClientHandler.instance().getClient().inGameHasFocus) {
StreamerMod.seePlayerHighlights = !StreamerMod.seePlayerHighlights;
}
}
}
Loading

0 comments on commit a078a39

Please sign in to comment.