Added documentation to almost everything

This commit is contained in:
MachineMuse 2012-12-18 11:00:10 -07:00
parent 9ec7f69873
commit 4fd2db5f4a
21 changed files with 404 additions and 55 deletions

View file

@ -1,5 +1,14 @@
package machinemuse.general.geometry;
/**
* Base class for Points. The main reason for this is to have a
* pass-by-reference coordinate with getter/setter functions so that points with
* more elaborate behaviour can be implemented - such as for open/close
* animations.
*
* @author MachineMuse
*
*/
public class Point2D {
private float x;
private float y;

View file

@ -8,6 +8,12 @@ import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
/**
* Packet handler for the client side.
*
* @author MachineMuse
*
*/
public class ClientPacketHandler implements IPacketHandler {
@Override
public void onPacketData(INetworkManager manager,

View file

@ -10,9 +10,19 @@ import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
/**
* The Client Proxy does all the things that should only be done client-side,
* like registering client-side handlers and renderers.
*
* @author Claire
*
*/
public class ClientProxy extends CommonProxy {
private static EquipmentRenderer eRenderer = new EquipmentRenderer();
/**
* Register all the custom renderers for this mod.
*/
@Override
public void registerRenderers() {
for (Item i : PowersuitsMod.allItems) {
@ -27,6 +37,11 @@ public class ClientProxy extends CommonProxy {
MinecraftForgeClient.preloadTexture("/gui/tinktablegui.png");
}
/**
* Register the tick handler (for on-tick behaviour) and packet handler (for
* network synchronization and permission stuff).
*/
@Override
public void registerHandlers() {
tickHandler = new TickHandler();
TickRegistry.registerTickHandler(tickHandler, Side.CLIENT);

View file

@ -10,6 +10,14 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.storage.MapData;
import net.minecraftforge.client.IItemRenderer;
/**
* Custom renderer for the power armor and tools. Note - this only renders the
* item as held in hand, in an inventory slot, or sitting on the ground. To
* render the player's armor is a different interface (not sure yet).
*
* @author MachineMuse
*
*/
public class EquipmentRenderer implements IItemRenderer {
private static final boolean useRenderHelper = true;
@ -60,6 +68,7 @@ public class EquipmentRenderer implements IItemRenderer {
default:
}
MuseGui muse = new MuseGui();
// Placeholder graphics
switch (item.getItem().getIconIndex(item)) {
case 0: // Head
muse.draw3x3item(

View file

@ -6,6 +6,14 @@ import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
/**
* Server side of the CommonProxy/ClientProxy paradigm. Provides functions which
* the ClientProxy will override if the behaviour is different for client and
* server.
*
* @author MachineMuse
*
*/
public class CommonProxy {
public static String ITEMS_PNG = "/tutorial/generic/items.png";
public static String BLOCK_PNG = "/tutorial/generic/block.png";
@ -13,11 +21,15 @@ public class CommonProxy {
public static ITickHandler tickHandler;
public static IPacketHandler packetHandler;
// Client stuff
/**
* Only the client needs to register renderers.
*/
public void registerRenderers() {
// Nothing here as this is the server side proxy
}
/**
* Register the server-side tickhandler and packethandler.
*/
public void registerHandlers() {
tickHandler = new TickHandler();
TickRegistry.registerTickHandler(tickHandler, Side.SERVER);

View file

@ -1,20 +1,31 @@
package machinemuse.powersuits.common;
import machinemuse.powersuits.common.block.BlockTinkerTable;
import net.minecraft.block.Block;
import net.minecraft.block.StepSound;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration;
import cpw.mods.fml.common.registry.GameRegistry;
/**
* Initial attempt at storing all tweakable/configurable values in one class.
* This got really messy really fast so it's in the process of being reworked.
*
* @author MachineMuse
*
*/
public class Config extends Configuration {
private static final int[] assignedItemIDs = new int[Items.values().length];
private static final int[] assignedBlockIDs = new int[Blocks.values().length];
private static Configuration config;
/**
* Called in the pre-init phase of initialization, informs Forge that we
* want the following blockIDs.
*
* @param config
* The Forge configuration object which will handle such
* requests.
*/
public static void init(Configuration config) {
Config.config = config;
config.load();
@ -33,18 +44,43 @@ public class Config extends Configuration {
config.save();
}
/**
* Default prefix for all NBTtag keys on itemstacks. Needed in case some
* other mod adds NBT data to items.
*
* @return
*/
public static String getModuleNBTTagPrefix() {
return "mmmpsmod";
}
/**
* The packet channel for this mod. We will only listen for and send packets
* on this 'channel'. Max of 16 characters.
*
* @return
*/
public static String getNetworkChannelName() {
return "mmmPowerSuits";
}
/**
* The default creative tab to add all these items to. This behaviour may
* change if more items are added, but I doubt it.
*
* @return
*/
public static CreativeTabs getCreativeTab() {
return CreativeTabs.tabMisc;
}
/**
* Once Forge has assigned IDs for all our items, this function will tell us
* what was actually assigned.
*
* @param item
* @return
*/
public static int getAssignedItemID(Items item) {
if (assignedItemIDs[item.ordinal()] == 0) {
assignedItemIDs[item.ordinal()] = config.getItem(item.englishName,
@ -53,6 +89,13 @@ public class Config extends Configuration {
return assignedItemIDs[item.ordinal()];
}
/**
* Once Forge has assigned IDs for all our blocks, this function will tell
* us what was actually assigned.
*
* @param item
* @return
*/
public static int getAssignedBlockID(Blocks block) {
if (assignedBlockIDs[block.ordinal()] == 0) {
assignedBlockIDs[block.ordinal()] = config.getBlock(
@ -61,15 +104,13 @@ public class Config extends Configuration {
return assignedBlockIDs[block.ordinal()];
}
public static int RegisterRecipes() {
ItemStack iron = new ItemStack(Item.ingotIron);
ItemStack lapis = new ItemStack(Item.dyePowder, 1);
GameRegistry.addRecipe(new ItemStack(new BlockTinkerTable()), " I ",
"ILI",
" I ", 'I', iron, 'L', lapis);
return 0;
}
/**
* An enum listing all the blocks that this mod adds. Used for assigning IDs
* and various other things.
*
* @author MachineMuse
*
*/
public static enum Blocks {
TinkerTable(1002, 0, "tinkerTable", "Tinker Table",
80.0F, Material.iron, Block.soundMetalFootstep,
@ -103,6 +144,13 @@ public class Config extends Configuration {
}
/**
* An enum listing all the items that this mod adds. Used for assigning IDs
* and various other things.
*
* @author MachineMuse
*
*/
public static enum Items {
// Icon index, ID name, English name, Armor Type
PowerArmorHead(0, "powerArmorHead", "Power Armor Head"),
@ -125,4 +173,16 @@ public class Config extends Configuration {
}
}
/**
* An enum to describe the various GUI windows which can appear. IDs are
* less important here since this data isn't saved or synced.
*
* @author Claire
*
*/
public static enum Guis {
GuiTinkerTable,
GuiSuitManager;
}
}

View file

@ -5,6 +5,13 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
/**
* Gui handler for this mod. Mainly just takes an ID according to what was
* passed to player.OpenGUI, and opens the corresponding GUI.
*
* @author MachineMuse
*
*/
public class GuiHandler implements IGuiHandler {
@Override
@ -16,6 +23,11 @@ public class GuiHandler implements IGuiHandler {
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
switch (ID) {
case 0:
return new GuiTinkerTable(player);
default:
return null;
}
}
}

View file

@ -10,6 +10,7 @@ import machinemuse.powersuits.common.item.ItemPowerArmor;
import machinemuse.powersuits.common.item.ItemPowerTool;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
@ -23,8 +24,29 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
/**
* Main mod class. This is what Forge loads to get the mod up and running, both
* server- and client-side.
*
* @author MachineMuse
*
*/
// Informs forge that this is a base mod class, and gives it some info for the
// FML mod list. This is also where it looks to see if your client's version
// matches the server's.
@Mod(modid = "mmmPowersuits", name = "MachineMuse Modular Powersuits", version = "0.0.1")
// Informs forge of the requirements:
//
// clientSideRequired means players can't connect without it. True for things
// that add new blocks/items, false for things like bukkit plugins.
//
// serverSideRequired means clients can't connect to servers that don't have it.
// This isn't a strict restriction currently but it can cause problems if the
// mod does anything potentially incompatible in its preInit function. True for
// things that add new blocks/items, false for things like Rei's Minimap or
// Inventory Tweaks.
@NetworkMod(clientSideRequired = true, serverSideRequired = true,
clientPacketHandlerSpec =
@SidedPacketHandler(channels = { "mmPowersuits" }, packetHandler = ClientPacketHandler.class),
@ -32,14 +54,31 @@ import cpw.mods.fml.common.network.NetworkRegistry;
@SidedPacketHandler(channels = { "mmPowersuits" }, packetHandler = ServerPacketHandler.class))
public class PowersuitsMod {
// The instance of your mod that Forge uses.
/**
* The instance of the mod that Forge will access. Note that it has to be
* set by hand in the preInit step.
*/
@Instance("PowersuitsMod")
public static PowersuitsMod instance;
// Says where the client and server 'proxy' code is loaded.
/**
* Tells Forge what classes to load for the client and server proxies. These
* execute side-specific code like registering renderers (for the client) or
* different tick handlers (for the server).
*/
@SidedProxy(clientSide = "machinemuse.powersuits.client.ClientProxy", serverSide = "machinemuse.powersuits.common.CommonProxy")
public static CommonProxy proxy;
/**
* In the preInit step you only want to load configs, reserve block/item
* IDs, and inform Forge if your mod has to be loaded after any others. No
* heavy loading or registering should occur here, because it happens as
* soon as they start Minecraft and there's no guarantee that your mod will
* be loaded.
*
* @param event
* An event object with useful data
*/
@PreInit
public void preInit(FMLPreInitializationEvent event) {
instance = this;
@ -47,13 +86,25 @@ public class PowersuitsMod {
event.getSuggestedConfigurationFile()));
}
/**
* A static handle for the blocks and items. We only want one instance of
* each of them.
*/
public static List<Block> allBlocks = new ArrayList<Block>();
public static List<Item> allItems = new ArrayList<Item>();
public static GuiHandler guiHandler = new GuiHandler();
/**
* This is where all the heavy loading and registering of handlers goes.
* This occurs when you connect to a server or open a world.
*
* @param event
* An event object with useful data
*/
@Init
public void load(FMLInitializationEvent event) {
allBlocks.add(new BlockTinkerTable());
loadBlocks();
loadItems();
@ -62,6 +113,9 @@ public class PowersuitsMod {
NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
}
/**
* Custom function to collect all the item-loading in one place.
*/
public static void loadItems() {
ItemPowerArmor item = new ItemPowerArmor(Config.Items.PowerArmorHead);
item.setValidAugTypes(AugmentationTypes.validHeadAugmentations());
@ -84,8 +138,29 @@ public class PowersuitsMod {
allItems.add(tool);
}
/**
* Custom function to collect all the block-loading in one place.
*/
public static void loadBlocks() {
Block tinkTable = new BlockTinkerTable();
ItemStack iron = new ItemStack(Item.ingotIron);
ItemStack lapis = new ItemStack(Item.dyePowder, 1);
GameRegistry.addRecipe(new ItemStack(tinkTable),
" I ",
"ILI",
" I ",
'I', iron, 'L', lapis);
allBlocks.add(tinkTable);
}
/**
* Stuff to do after the player connects. This is for things that need to
* wait until the world is completely loaded before initializing.
*
* @param event
* An event object with useful data
*/
@PostInit
public void postInit(FMLPostInitializationEvent event) {
// Stub Method
}
}

View file

@ -9,6 +9,12 @@ import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
/**
* Packet handler for the server side.
*
* @author MachineMuse
*
*/
public class ServerPacketHandler implements IPacketHandler {
@Override

View file

@ -7,20 +7,28 @@ import net.minecraft.world.World;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
/**
* Tick handler for the mod. This is where you put code that should be executed
* once every tick.
*
* @author MachineMuse
*
*/
public class TickHandler implements ITickHandler {
/**
* Called at the "start" phase of a tick
*
* Multiple ticks may fire simultaneously- you will only be called once with
* all the firing ticks
* Multiple tick types may fire simultaneously- you will only be called once
* with all the firing ticks
*/
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
World world;
EntityPlayer player;
if (type.contains(TickType.WORLD)) {
world = (World) tickData[0];
}
// if (type.contains(TickType.WORLD)) {
// world = (World) tickData[0];
// }
// TODO: Find a better way to handle this^
}

View file

@ -8,7 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
/**
* An Augmentation is a module that can be slotted into the power armor or tool.
*
* @author Claire
* @author MachineMuse
*
*/
public abstract class Augmentation {

View file

@ -1,5 +1,12 @@
package machinemuse.powersuits.common.augmentation;
/**
* An enumeration of the different types of augmentations and their IDs. Also
* contains valid-for-slot configuration.
*
* @author MachineMuse
*
*/
public enum AugmentationTypes {
ArmorPlate("armorPlate", "Armor Plate", 1),

View file

@ -3,7 +3,6 @@ package machinemuse.powersuits.common.block;
import machinemuse.powersuits.common.CommonProxy;
import machinemuse.powersuits.common.Config;
import machinemuse.powersuits.common.PowersuitsMod;
import machinemuse.powersuits.common.Config.Blocks;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -12,8 +11,18 @@ import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
/**
* This is the tinkertable block. It doesn't do much except look pretty
* (eventually) and provide a way for the player to access the TinkerTable GUI.
*
* @author MachineMuse
*
*/
public class BlockTinkerTable extends Block {
/**
* Constructor. Reads all the block info from Config.
*/
public BlockTinkerTable() {
super(Config.getAssignedBlockID(Config.Blocks.TinkerTable),
Config.Blocks.TinkerTable.textureIndex,
@ -46,7 +55,9 @@ public class BlockTinkerTable extends Block {
if (player.isSneaking()) {
return false;
}
player.openGui(PowersuitsMod.instance, 0, world, x, y, z);
player.openGui(PowersuitsMod.instance,
Config.Guis.GuiTinkerTable.ordinal(),
world, x, y, z);
return true;
}
}

View file

@ -2,6 +2,11 @@ package machinemuse.powersuits.common.item;
import machinemuse.powersuits.common.augmentation.AugmentationTypes;
/**
* Interface for ItemPowerArmor and ItemPowerTool to share.
*
* @author Claire
*/
public interface IModularItem {
AugmentationTypes[] getValidAugTypes();

View file

@ -12,10 +12,20 @@ import net.minecraft.util.DamageSource;
import net.minecraftforge.common.ISpecialArmor;
import cpw.mods.fml.common.registry.LanguageRegistry;
/**
* Describes the 4 different modular armor pieces - head, torso, legs, feet.
*
* @author MachineMuse
*/
public class ItemPowerArmor extends ItemArmor implements ISpecialArmor,
IModularItem {
AugmentationTypes[] validAugTypes;
/**
* Constructor. Takes information from the Config.Items enum.
*
* @param item
*/
public ItemPowerArmor(Config.Items item) {
super(Config.getAssignedItemID(item), // itemID
EnumArmorMaterial.IRON, // Material
@ -28,46 +38,73 @@ public class ItemPowerArmor extends ItemArmor implements ISpecialArmor,
LanguageRegistry.addName(this, item.englishName);
}
/**
* Returns the texture file for this tool. Probably won't be used since we
* are using a custom renderer.
*/
public String getTextureFile() {
// TODO: Delete this probably
return CommonProxy.ITEMS_PNG;
}
/**
* Inherited from ISpecialArmor, allows significant customization of damage
* calculations.
*/
@Override
public ArmorProperties getProperties(EntityLiving player, ItemStack armor,
DamageSource source, double damage, int slot) {
// Order in which this armor is assessed for damage.
// Order in which this armor is assessed for damage. Higher(?) priority
// items take damage first, and if none spills over, the other items
// take no damage.
int priority = 1;
// How much of incoming damage is absorbed by this armor piece.
// 1.0 = absorbs all damage
// 0.5 = 50% damage to item, 50% damage carried over
double absorbRatio = 0.1;
double absorbRatio = 0.2;
// Maximum damage absorbed by this piece
int absorbMax = 2;
// Maximum damage absorbed by this piece. Actual damage to this item
// will be clamped between (damage * absorbRatio) and (absorbMax). Note
// that a player has 20 hp (1hp = 1 half-heart)
int absorbMax = 4;
ArmorProperties props = new ArmorProperties(priority, absorbRatio,
return new ArmorProperties(priority, absorbRatio,
absorbMax);
return props;
}
/**
* Inherited from ISpecialArmor, allows us to customize the calculations for
* how much armor will display on the player's HUD.
*/
@Override
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
// How many half-shields of armor display on the player's gui from this
// piece
return 4;
}
/**
* Inherited from ISpecialArmor, allows us to customize how the armor
* handles being damaged.
*/
@Override
public void damageArmor(EntityLiving entity, ItemStack stack,
DamageSource source, int damage, int slot) {
// Damage the armor's durability
}
/**
* For IModularItem's aug-list functionality.
*
* @param types
*/
public void setValidAugTypes(AugmentationTypes[] types) {
validAugTypes = types;
}
/**
* Inherited from IModularItem, returns a (potentially sparse) array of
* valid augmentations for this item.
*/
@Override
public AugmentationTypes[] getValidAugTypes() {
return validAugTypes;

View file

@ -5,9 +5,19 @@ import machinemuse.powersuits.common.augmentation.AugmentationTypes;
import net.minecraft.item.Item;
import cpw.mods.fml.common.registry.LanguageRegistry;
/**
* Describes the modular power tool.
*
* @author MachineMuse
*/
public class ItemPowerTool extends Item implements IModularItem {
private AugmentationTypes[] validAugTypes;
/**
* Constructor. Takes information from the Config.Items enum.
*
* @param item
*/
public ItemPowerTool(Config.Items item) {
super(Config.getAssignedItemID(item)); // armor type.
setMaxStackSize(1);
@ -17,10 +27,19 @@ public class ItemPowerTool extends Item implements IModularItem {
LanguageRegistry.addName(this, item.englishName);
}
/**
* For IModularItem's aug-list functionality.
*
* @param types
*/
public void setValidAugTypes(AugmentationTypes[] types) {
validAugTypes = types;
}
/**
* Inherited from IModularItem, returns a (potentially sparse) array of
* valid augmentations for this item.
*/
@Override
public AugmentationTypes[] getValidAugTypes() {
return validAugTypes;

View file

@ -4,6 +4,11 @@ import java.util.List;
import machinemuse.general.geometry.Point2D;
/**
* Defines a generic clickable item for a MuseGui.
*
* @author MachineMuse
*/
public abstract class Clickable {
private Point2D position;

View file

@ -2,6 +2,12 @@ package machinemuse.powersuits.gui;
import java.util.List;
/**
* Extends the Clickable class to make a clickable Augmentation; note that this
* will not be an actual item.
*
* @author MachineMuse
*/
public class ClickableAugmentation extends Clickable {
@Override

View file

@ -5,6 +5,12 @@ import java.util.List;
import machinemuse.general.geometry.Point2D;
import net.minecraft.item.ItemStack;
/**
* Extends the Clickable class to add a clickable ItemStack - note that this
* will be a button that looks like the item, not a container slot.
*
* @author MachineMuse
*/
public class ClickableItem extends Clickable {
public static final Point2D offset = new Point2D(8, 8);
private ItemStack item;

View file

@ -7,10 +7,21 @@ import machinemuse.powersuits.common.item.IModularItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
/**
* The gui class for the TinkerTable block.
*
* @author MachineMuse
*
*/
public class GuiTinkerTable extends MuseGui {
protected EntityPlayer player;
protected ArrayList<ItemStack> modularItems;
/**
* Constructor. Takes a player as an argument.
*
* @param player
*/
public GuiTinkerTable(EntityPlayer player) {
this.player = player;
this.modularItems = new ArrayList<ItemStack>();
@ -19,7 +30,7 @@ public class GuiTinkerTable extends MuseGui {
}
/**
* Adds the buttons (and other controls) to the screen in question.
* Add the buttons (and other controls) to the screen.
*/
public void initGui()
{
@ -32,12 +43,6 @@ public class GuiTinkerTable extends MuseGui {
}
}
public void refresh() {
for (int i = 0; i < 4; i++) {
}
}
// public void drawNthItem(ItemStack stack, int n) {
// // TBI
// // draw item
@ -60,13 +65,21 @@ public class GuiTinkerTable extends MuseGui {
//
// }
//
/**
* Draws the background layer for the GUI.
*/
public void drawBackground() {
this.drawDefaultBackground();
this.drawRectangularBackground();
this.drawDefaultBackground(); // Shading on the world view
this.drawRectangularBackground(); // The window rectangle
}
public void drawScreen(int par1, int par2, float par3) {
super.drawScreen(par1, par2, par3);
/**
* Called every frame, draws the screen!
*/
@Override
public void drawScreen(int x, int y, float z) {
super.drawScreen(x, y, z);
drawBackground();
drawItemList();
Colour colour = Colour.getGreyscale(1.0F, 1.0F);
@ -78,6 +91,9 @@ public class GuiTinkerTable extends MuseGui {
// }
}
/**
* todo: Replace this with clickables...
*/
public void drawItemList() {
this.drawItemsOnVerticalLine(modularItems, -0.9F, 0.0F,
0.9f,

View file

@ -12,18 +12,24 @@ import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
/**
* I got fed up with Minecraft's gui system so I wrote my own (to some extent.
* Still based on GuiScreen). This class contains a variety of helper functions
* to draw geometry and various other prettifications. Note that MuseGui is
* heavily geometry-based as opposed to texture-based.
*
* @author MachineMuse
*
*/
public class MuseGui extends GuiScreen {
protected static RenderItem itemRenderer = new RenderItem();
private final boolean usePretty = true;
private static final int numSegments = 360;
private static final int xcenter = 8;
private static final int ycenter = 8;
private static final Tessellator tesselator = Tessellator.instance;
private long creationTime;
int xSize, ySize;
public static final double theta = (2 * Math.PI) / numSegments;
/**
* Adds the buttons (and other controls) to the screen in question.
*/
@ -34,6 +40,10 @@ public class MuseGui extends GuiScreen {
creationTime = System.currentTimeMillis();
}
/**
* Mostly for placeholder graphics, this function draws a 3x3 grid of swirly
* circles over a 16x16 square.
*/
public void draw3x3item(boolean a, boolean b, boolean c, boolean d,
boolean e, boolean f, boolean g, boolean h, boolean i) {
if (a)
@ -58,6 +68,9 @@ public class MuseGui extends GuiScreen {
drawCircleAround(13, 13, 2);
}
/**
* Draws the gradient-rectangle background you see in the TinkerTable gui.
*/
public void drawRectangularBackground() {
int xpadding = (width - xSize) / 2;
int ypadding = (height - ySize) / 2;
@ -80,6 +93,7 @@ public class MuseGui extends GuiScreen {
// GL11.glEnd();
}
// TODO: Make this draw clickables instead of itemstacks
public void drawItemsOnVerticalLine(ArrayList<ItemStack> items,
float xoffset,
float yoffset,
@ -98,8 +112,8 @@ public class MuseGui extends GuiScreen {
}
/**
* Returns absolute screen coordinates (0 to width) from a relative
* coordinate (-1.0F to +1.0F)
* Returns absolute screen coordinates (int 0 to width) from a relative
* coordinate (float -1.0F to +1.0F)
*
* @param relx
* Relative X coordinate
@ -112,8 +126,8 @@ public class MuseGui extends GuiScreen {
}
/**
* Returns absolute screen coordinates (0 to width) from a relative
* coordinate (-1.0F to +1.0F)
* Returns absolute screen coordinates (int 0 to width) from a relative
* coordinate (float -1.0F to +1.0F)
*
* @param relx
* Relative Y coordinate
@ -149,9 +163,20 @@ public class MuseGui extends GuiScreen {
GL11.glEnable(GL11.GL_LIGHTING);
}
/**
* Draws a swirly green circle at the specified coordinates in the current
* reference frame.
*
* @param xoffset
* @param yoffset
* @param radius
*/
public static void drawCircleAround(float xoffset, float yoffset,
float radius) {
int start = (int) (System.currentTimeMillis() / 4 % 360);
int numSegments = 360;
double theta = (2 * Math.PI) / numSegments;
int start = (int) (System.currentTimeMillis() / 4 % numSegments);
double x = radius * Math.sin(theta * start);
double y = radius * Math.cos(theta * start);
double tf = Math.tan(theta);