Improved tick handler and gui
This commit is contained in:
parent
eaa79d8b5c
commit
7ead7c3854
22 changed files with 424 additions and 155 deletions
|
@ -49,9 +49,9 @@ public class Colour {
|
|||
public int getInt() {
|
||||
int val = 0;
|
||||
val = val | ((int) (a * 255) << 24);
|
||||
val = val | ((int) (b * 255) << 16);
|
||||
val = val | ((int) (r * 255) << 16);
|
||||
val = val | ((int) (g * 255) << 8);
|
||||
val = val | ((int) (r * 255));
|
||||
val = val | ((int) (b * 255));
|
||||
|
||||
return val;
|
||||
}
|
||||
|
|
|
@ -259,6 +259,8 @@ public abstract class Doodler {
|
|||
gui.getRenderItem().zLevel = 100.0F;
|
||||
gui.getRenderItem().renderItemAndEffectIntoGUI(
|
||||
gui.getFontRenderer(), gui.getRenderEngine(), item, x, y);
|
||||
gui.getRenderItem().renderItemOverlayIntoGUI(gui.getFontRenderer(),
|
||||
gui.getRenderEngine(), item, x, y);
|
||||
gui.getRenderItem().zLevel = 0.0F;
|
||||
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
|
|
@ -12,6 +12,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
*
|
||||
*/
|
||||
public abstract class Augmentation {
|
||||
protected NBTTagCompound nbtTag;
|
||||
|
||||
/**
|
||||
* Default compound for all NBTtag keys on itemstacks. Needed in case some
|
||||
* other mod adds NBT data to these items.
|
||||
|
@ -20,17 +22,31 @@ public abstract class Augmentation {
|
|||
*/
|
||||
public static String nbtPrefix = "mmmpsmod";
|
||||
|
||||
public static Augmentation fromNBTTag(NBTTagCompound tag) {
|
||||
int id = tag.getInteger("AugID");
|
||||
protected int level;
|
||||
|
||||
switch (id) {
|
||||
case 1:
|
||||
return new AugmentationArmorPlating(tag);
|
||||
default:
|
||||
return null;
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void upgrade() {
|
||||
level += 1;
|
||||
if (nbtTag != null) {
|
||||
nbtTag.setInteger("level", level);
|
||||
}
|
||||
}
|
||||
|
||||
public void downgrade() {
|
||||
level -= 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the items to create Augmentation instances.
|
||||
*
|
||||
* @param tag
|
||||
* @return
|
||||
*/
|
||||
public abstract Augmentation fromNBTTag(NBTTagCompound tag);
|
||||
|
||||
/**
|
||||
* Returns the name of this Augmentation.
|
||||
*
|
||||
|
@ -54,7 +70,7 @@ public abstract class Augmentation {
|
|||
* the level you would be upgrading to
|
||||
* @return a list of ItemStacks describing the cost.
|
||||
*/
|
||||
public abstract List<ItemStack> getUpgradeCost(int level);
|
||||
public abstract List<ItemStack> getUpgradeCost();
|
||||
|
||||
/**
|
||||
* Returns a list of materials that would be refunded from downgrading or
|
||||
|
@ -64,9 +80,11 @@ public abstract class Augmentation {
|
|||
* the level you would be downgrading to
|
||||
* @return a list of ItemStacks describing the cost.
|
||||
*/
|
||||
public abstract List<ItemStack> getDowngradeRefund(int level);
|
||||
public abstract List<ItemStack> getDowngradeRefund();
|
||||
|
||||
public abstract NBTTagCompound getNBTTag();
|
||||
public NBTTagCompound getNBTTag() {
|
||||
return nbtTag;
|
||||
}
|
||||
|
||||
public abstract Augmentation newAug();
|
||||
}
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
package machinemuse.powersuits.augmentation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class AugmentationArmorPlating extends Augmentation {
|
||||
protected int durability;
|
||||
|
||||
public AugmentationArmorPlating() {
|
||||
|
||||
level = 0;
|
||||
}
|
||||
|
||||
public AugmentationArmorPlating(NBTTagCompound tag) {
|
||||
// TODO Auto-generated constructor stub
|
||||
this.nbtTag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,21 +29,17 @@ public class AugmentationArmorPlating extends Augmentation {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getUpgradeCost(int level) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public List<ItemStack> getUpgradeCost() {
|
||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
||||
list.add(new ItemStack(Item.redstone, 4));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDowngradeRefund(int level) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTTag() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public List<ItemStack> getDowngradeRefund() {
|
||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
||||
list.add(new ItemStack(Item.redstone, 3));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,4 +48,19 @@ public class AugmentationArmorPlating extends Augmentation {
|
|||
return new AugmentationArmorPlating();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Augmentation fromNBTTag(NBTTagCompound tag) {
|
||||
AugmentationArmorPlating aug = new AugmentationArmorPlating();
|
||||
if (tag.hasKey("level")) {
|
||||
aug.level = tag.getInteger("Level");
|
||||
} else {
|
||||
aug.level = new Integer(0);
|
||||
}
|
||||
if (tag.hasKey("durability")) {
|
||||
aug.durability = tag.getInteger("Durability");
|
||||
} else {
|
||||
aug.durability = new Integer(0);
|
||||
}
|
||||
return aug;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,67 +3,67 @@
|
|||
*/
|
||||
package machinemuse.powersuits.augmentation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* @author MachineMuse
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class AugmentationBattery extends Augmentation {
|
||||
float energy;
|
||||
|
||||
public AugmentationBattery() {
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see machinemuse.powersuits.augmentation.Augmentation#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return "Electric Battery";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see machinemuse.powersuits.augmentation.Augmentation#getWeight()
|
||||
*/
|
||||
@Override
|
||||
public float getWeight() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public float getAvailableEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
public float getMaxEnergy() {
|
||||
return 5000 * 12 ^ level;
|
||||
}
|
||||
|
||||
public float setAvailableEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see machinemuse.powersuits.augmentation.Augmentation#getUpgradeCost(int)
|
||||
*/
|
||||
@Override
|
||||
public List<ItemStack> getUpgradeCost(int level) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public List<ItemStack> getUpgradeCost() {
|
||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
||||
list.add(new ItemStack(Item.redstone, 4));
|
||||
return list;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see machinemuse.powersuits.augmentation.Augmentation#getDowngradeRefund(int)
|
||||
*/
|
||||
@Override
|
||||
public List<ItemStack> getDowngradeRefund(int level) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public List<ItemStack> getDowngradeRefund() {
|
||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
||||
list.add(new ItemStack(Item.redstone, 3));
|
||||
return list;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see machinemuse.powersuits.augmentation.Augmentation#getNBTTag()
|
||||
*/
|
||||
@Override
|
||||
public NBTTagCompound getNBTTag() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see machinemuse.powersuits.augmentation.Augmentation#newAug()
|
||||
*/
|
||||
@Override
|
||||
public Augmentation newAug() {
|
||||
return new AugmentationBattery();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Augmentation fromNBTTag(NBTTagCompound tag) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package machinemuse.powersuits.augmentation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import machinemuse.powersuits.item.IModularItem;
|
||||
import machinemuse.powersuits.item.ItemUtil;
|
||||
import machinemuse.powersuits.item.ItemUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
|
@ -27,20 +29,21 @@ public class AugmentationList {
|
|||
* @param itemStack
|
||||
*/
|
||||
public AugmentationList(ItemStack itemStack) {
|
||||
IModularItem item = ItemUtil.getAsModular(itemStack.getItem());
|
||||
|
||||
IModularItem item = ItemUtils.getAsModular(itemStack.getItem());
|
||||
CraftingManager.getInstance().getRecipeList();
|
||||
if (item != null) {
|
||||
augCache = new HashMap<Augmentation, Augmentation>();
|
||||
if (itemStack.hasTagCompound()) {
|
||||
|
||||
this.tag = itemStack.getTagCompound().getCompoundTag(
|
||||
Augmentation.nbtPrefix);
|
||||
validAugs = item.getValidAugs();
|
||||
augCache = new HashMap<Augmentation, Augmentation>();
|
||||
} else {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setCompoundTag(Augmentation.nbtPrefix,
|
||||
new NBTTagCompound());
|
||||
itemStack.setTagCompound(nbt);
|
||||
this.tag = nbt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,4 +76,16 @@ public class AugmentationList {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public List<Augmentation> getAllAugData() {
|
||||
List<Augmentation> augData = new ArrayList<Augmentation>();
|
||||
Iterator<Augmentation> iter = validAugs.iterator();
|
||||
while (iter.hasNext()) {
|
||||
augData.add(getAugData(iter.next()));
|
||||
}
|
||||
return augData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package machinemuse.powersuits.client;
|
|||
import machinemuse.powersuits.common.CommonProxy;
|
||||
import machinemuse.powersuits.common.Config;
|
||||
import machinemuse.powersuits.common.PowersuitsMod;
|
||||
import machinemuse.powersuits.common.TickHandler;
|
||||
import machinemuse.powersuits.common.WorldTickHandler;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import cpw.mods.fml.common.Side;
|
||||
|
@ -43,7 +43,7 @@ public class ClientProxy extends CommonProxy {
|
|||
*/
|
||||
@Override
|
||||
public void registerHandlers() {
|
||||
tickHandler = new TickHandler();
|
||||
tickHandler = new WorldTickHandler();
|
||||
TickRegistry.registerTickHandler(tickHandler, Side.CLIENT);
|
||||
|
||||
packetHandler = new ClientPacketHandler();
|
||||
|
|
|
@ -31,7 +31,7 @@ public class CommonProxy {
|
|||
* Register the server-side tickhandler and packethandler.
|
||||
*/
|
||||
public void registerHandlers() {
|
||||
tickHandler = new TickHandler();
|
||||
tickHandler = new WorldTickHandler();
|
||||
TickRegistry.registerTickHandler(tickHandler, Side.SERVER);
|
||||
|
||||
packetHandler = new ServerPacketHandler();
|
||||
|
|
100
machinemuse/powersuits/common/PlayerTickHandler.java
Normal file
100
machinemuse/powersuits/common/PlayerTickHandler.java
Normal file
|
@ -0,0 +1,100 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package machinemuse.powersuits.common;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import machinemuse.powersuits.augmentation.Augmentation;
|
||||
import machinemuse.powersuits.augmentation.AugmentationBattery;
|
||||
import machinemuse.powersuits.item.ItemUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
/**
|
||||
* Tick handler for Player ticks. This is where we compute all the updates that
|
||||
* should go every tick.
|
||||
*
|
||||
* @author MachineMuse
|
||||
*/
|
||||
public class PlayerTickHandler implements ITickHandler {
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
World world = toWorld(tickData[0]);
|
||||
EntityPlayer player = toPlayer(tickData[1]);
|
||||
List<Augmentation> playerAugs = ItemUtils
|
||||
.getPlayerAugs(player);
|
||||
float totalEnergy = 0;
|
||||
float totalWeight = 0;
|
||||
|
||||
Iterator<Augmentation> iter = playerAugs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Augmentation aug = iter.next();
|
||||
if (aug instanceof AugmentationBattery) {
|
||||
totalEnergy += ((AugmentationBattery) aug).getAvailableEnergy();
|
||||
}
|
||||
totalWeight += aug.getWeight();
|
||||
}
|
||||
if (totalWeight > 25) {
|
||||
player.motionX *= 25 / totalWeight;
|
||||
player.motionZ *= 25 / totalWeight;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
World world = toWorld(tickData[0]);
|
||||
EntityPlayer player = toPlayer(tickData[1]);
|
||||
List<ItemStack> stacks = ItemUtils
|
||||
.getModularItemsInInventory(player.inventory);
|
||||
|
||||
}
|
||||
|
||||
public static World toWorld(Object data) {
|
||||
World world = null;
|
||||
try {
|
||||
world = (World) data;
|
||||
} catch (ClassCastException e) {
|
||||
MuseLogger.logDebug(
|
||||
"MMMPS: Player tick handler received invalid World object");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
public static EntityPlayer toPlayer(Object data) {
|
||||
EntityPlayer player = null;
|
||||
try {
|
||||
player = (EntityPlayer) data;
|
||||
} catch (ClassCastException e) {
|
||||
MuseLogger
|
||||
.logDebug(
|
||||
"MMMPS: Player tick handler received invalid Player object");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of tick handled by this handler
|
||||
*/
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
return EnumSet.of(TickType.PLAYER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Profiling label for this handler
|
||||
*/
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "MMMPS PlayerTickHandler";
|
||||
}
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ import cpw.mods.fml.common.TickType;
|
|||
* @author MachineMuse
|
||||
*
|
||||
*/
|
||||
public class TickHandler implements ITickHandler {
|
||||
public class WorldTickHandler implements ITickHandler {
|
||||
/**
|
||||
* Called at the "start" phase of a tick
|
||||
*
|
||||
|
@ -41,7 +41,6 @@ public class TickHandler implements ITickHandler {
|
|||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
|
@ -4,13 +4,14 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import machinemuse.general.geometry.Colour;
|
||||
import machinemuse.general.geometry.Doodler;
|
||||
import machinemuse.general.geometry.FlyFromMiddlePoint2D;
|
||||
import machinemuse.general.geometry.Point2D;
|
||||
import machinemuse.powersuits.augmentation.Augmentation;
|
||||
import machinemuse.powersuits.augmentation.AugmentationList;
|
||||
import machinemuse.powersuits.common.MuseLogger;
|
||||
import machinemuse.powersuits.item.ItemUtil;
|
||||
import machinemuse.powersuits.item.ItemUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
@ -25,8 +26,11 @@ public class GuiTinkerTable extends MuseGui {
|
|||
protected List<ClickableItem> itemButtons;
|
||||
protected ClickableItem selectedItemStack;
|
||||
protected List<ClickableAugmentation> augButtons;
|
||||
protected ClickableAugmentation selectedAugmentation;
|
||||
protected ClickableAugmentation selectedAugClickable;
|
||||
protected AugmentationList augData;
|
||||
protected Augmentation workingAugmentation;
|
||||
protected List<ItemStack> workingUpgradeCost;
|
||||
protected List<ItemStack> workingDowngradeRefund;
|
||||
|
||||
/**
|
||||
* Constructor. Takes a player as an argument.
|
||||
|
@ -56,7 +60,7 @@ public class GuiTinkerTable extends MuseGui {
|
|||
*
|
||||
*/
|
||||
public void loadItems() {
|
||||
List<ItemStack> stacks = ItemUtil
|
||||
List<ItemStack> stacks = ItemUtils
|
||||
.getModularItemsInInventory(player.inventory);
|
||||
|
||||
List<Point2D> points = this.pointsInLine(stacks.size(),
|
||||
|
@ -79,7 +83,7 @@ public class GuiTinkerTable extends MuseGui {
|
|||
protected void loadAugList(ClickableItem itemClicked) {
|
||||
augButtons = new ArrayList<ClickableAugmentation>();
|
||||
augData = new AugmentationList(itemClicked.getItem());
|
||||
List<Augmentation> validAugs = ItemUtil.getAsModular(itemClicked
|
||||
List<Augmentation> validAugs = ItemUtils.getAsModular(itemClicked
|
||||
.getItem().getItem()).getValidAugs();
|
||||
List<Point2D> points = this.pointsInLine(validAugs.size(),
|
||||
new Point2D(-0.7F, -0.9F),
|
||||
|
@ -106,17 +110,13 @@ public class GuiTinkerTable extends MuseGui {
|
|||
10);
|
||||
}
|
||||
|
||||
if (selectedAugmentation != null) {
|
||||
if (selectedAugClickable != null) {
|
||||
Doodler.drawCircleAround(
|
||||
absX(selectedAugmentation.getPosition().x()),
|
||||
absY(selectedAugmentation.getPosition().y()),
|
||||
absX(selectedAugClickable.getPosition().x()),
|
||||
absY(selectedAugClickable.getPosition().y()),
|
||||
10);
|
||||
|
||||
}
|
||||
// for (Augmentation a : Augmentation.getAllAugs()) {
|
||||
// if (a.canGoInSlot(selectedSlot.getType())) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -143,13 +143,53 @@ public class GuiTinkerTable extends MuseGui {
|
|||
drawClickables(this.itemButtons);
|
||||
drawSelection();
|
||||
drawClickables(this.augButtons);
|
||||
// Colour colour = Colour.getGreyscale(1.0F, 1.0F);
|
||||
// if (editingItem != null && editingLayout != null) {
|
||||
// drawLayout(editingLayout);
|
||||
// if (selectedSlot != null) {
|
||||
// drawSelection();
|
||||
// }
|
||||
// }
|
||||
drawUpgradeDowngrade();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the upgrade/downgrade cost, buttons, and labels.
|
||||
*/
|
||||
public void drawUpgradeDowngrade() {
|
||||
if (workingUpgradeCost != null) {
|
||||
this.drawString(fontRenderer, "Cost:", absX(0.4F),
|
||||
absY(-0.7F),
|
||||
new Colour(0.5F, 1.0F, 0.5F, 1.0F).getInt());
|
||||
List<Point2D> points = this.pointsInLine(workingUpgradeCost.size(),
|
||||
new Point2D(0.4F, -0.5F),
|
||||
new Point2D(0.9F, -0.5F));
|
||||
Iterator<Point2D> pointiter = points.iterator();
|
||||
for (ItemStack item : workingUpgradeCost) {
|
||||
Point2D next = pointiter.next();
|
||||
Doodler.drawItemAt(absX(next.x()), absY(next.y()), this, item);
|
||||
}
|
||||
}
|
||||
if (workingDowngradeRefund != null) {
|
||||
Doodler.on2D();
|
||||
this.drawString(fontRenderer, "Refund:", absX(0.4F),
|
||||
absY(0.3F),
|
||||
new Colour(1.0F, 0.6F, 0.2F, 1.0F).getInt());
|
||||
Doodler.off2D();
|
||||
List<Point2D> points = this.pointsInLine(
|
||||
workingDowngradeRefund.size(),
|
||||
new Point2D(0.4F, 0.5F),
|
||||
new Point2D(0.9F, 0.5F));
|
||||
Iterator<Point2D> pointiter = points.iterator();
|
||||
for (ItemStack item : workingDowngradeRefund) {
|
||||
Point2D next = pointiter.next();
|
||||
Doodler.drawItemAt(absX(next.x()), absY(next.y()), this, item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all the UI stuff that's there.
|
||||
*/
|
||||
protected void clearSelections() {
|
||||
this.selectedAugClickable = null;
|
||||
this.workingAugmentation = null;
|
||||
this.workingUpgradeCost = null;
|
||||
this.workingDowngradeRefund = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,13 +205,16 @@ public class GuiTinkerTable extends MuseGui {
|
|||
(ClickableAugmentation) hitboxClickables(x, y,
|
||||
this.augButtons);
|
||||
if (itemClicked != null) {
|
||||
clearSelections();
|
||||
this.selectedItemStack = itemClicked;
|
||||
loadAugList(itemClicked);
|
||||
} else if (augClicked != null) {
|
||||
this.selectedAugmentation = augClicked;
|
||||
// TODO: add ui on the right for stuff
|
||||
this.selectedAugClickable = augClicked;
|
||||
this.workingAugmentation = augData.getAugData(augClicked.aug);
|
||||
this.workingUpgradeCost = workingAugmentation.getUpgradeCost();
|
||||
this.workingDowngradeRefund = workingAugmentation
|
||||
.getDowngradeRefund();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,8 +61,9 @@ public class MuseGui extends GuiScreen {
|
|||
Doodler.drawGradientRect(
|
||||
absX(ul.x()), absY(ul.y()),
|
||||
absX(br.x()), absY(br.y()),
|
||||
Colour.getGreyscale(0.8f, 0.8f),
|
||||
Colour.getGreyscale(0.3f, 0.8f), (double) this.zLevel);
|
||||
new Colour(0.1F, 0.9F, 0.1F, 0.8F),
|
||||
new Colour(0.0F, 0.2F, 0.0F, 0.8F),
|
||||
(double) this.zLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,8 +112,8 @@ public class MuseGui extends GuiScreen {
|
|||
} else if (num < 2) {
|
||||
points.add(b.minus(a).times(0.5F).plus(a));
|
||||
} else {
|
||||
Point2D step = b.minus(a).times(1.0F / (num - 1));
|
||||
for (int i = 0; i < num; i++) {
|
||||
Point2D step = b.minus(a).times(1.0F / (num + 1));
|
||||
for (int i = 1; i < num + 2; i++) {
|
||||
points.add(a.plus(step.times(i)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import machinemuse.powersuits.common.Config;
|
|||
/**
|
||||
* Interface for ItemPowerArmor and ItemPowerTool to share.
|
||||
*
|
||||
* @author Claire
|
||||
* @author MachineMuse
|
||||
*/
|
||||
public interface IModularItem {
|
||||
public List<Augmentation> getValidAugs();
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package machinemuse.powersuits.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import machinemuse.powersuits.augmentation.Augmentation;
|
||||
import machinemuse.powersuits.common.Config;
|
||||
import machinemuse.powersuits.common.Config.Items;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
|
@ -15,9 +18,12 @@ import net.minecraftforge.common.ISpecialArmor;
|
|||
*
|
||||
* @author MachineMuse
|
||||
*/
|
||||
public abstract class ItemPowerArmor extends ItemArmor implements
|
||||
ISpecialArmor,
|
||||
IModularItem {
|
||||
public abstract class ItemPowerArmor extends ItemArmor
|
||||
implements ISpecialArmor, IModularItem {
|
||||
protected List<Augmentation> validAugTypes;
|
||||
|
||||
Config.Items itemType;
|
||||
|
||||
/**
|
||||
* @param par1
|
||||
* @param par2EnumArmorMaterial
|
||||
|
@ -31,8 +37,6 @@ public abstract class ItemPowerArmor extends ItemArmor implements
|
|||
setCreativeTab(Config.getCreativeTab());
|
||||
}
|
||||
|
||||
Config.Items itemType;
|
||||
|
||||
/**
|
||||
* Inherited from ISpecialArmor, allows significant customization of damage
|
||||
* calculations.
|
||||
|
@ -75,7 +79,7 @@ public abstract class ItemPowerArmor extends ItemArmor implements
|
|||
@Override
|
||||
public void damageArmor(EntityLiving entity, ItemStack stack,
|
||||
DamageSource source, int damage, int slot) {
|
||||
// Damage the armor's durability
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,4 +87,20 @@ public abstract class ItemPowerArmor extends ItemArmor implements
|
|||
return itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
* For IModularItem's aug-list functionality.
|
||||
*/
|
||||
public void addValidAugType(Augmentation template) {
|
||||
validAugTypes.add(template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherited from IModularItem, returns an array of valid augmentations for
|
||||
* this item.
|
||||
*/
|
||||
@Override
|
||||
public List<Augmentation> getValidAugs() {
|
||||
return validAugTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
package machinemuse.powersuits.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import machinemuse.powersuits.augmentation.Augmentation;
|
||||
import machinemuse.powersuits.augmentation.AugmentationArmorPlating;
|
||||
|
@ -18,8 +17,6 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
|
|||
*
|
||||
*/
|
||||
public class ItemPowerArmorFeet extends ItemPowerArmor {
|
||||
protected static List<Augmentation> validAugTypes;
|
||||
|
||||
/**
|
||||
* @param item
|
||||
*/
|
||||
|
@ -46,13 +43,4 @@ public class ItemPowerArmorFeet extends ItemPowerArmor {
|
|||
validAugTypes.add(new AugmentationArmorPlating());
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherited from IModularItem, returns a (potentially sparse) array of
|
||||
* valid augmentations for this item.
|
||||
*/
|
||||
@Override
|
||||
public List<Augmentation> getValidAugs() {
|
||||
return validAugTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package machinemuse.powersuits.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import machinemuse.powersuits.augmentation.Augmentation;
|
||||
import machinemuse.powersuits.augmentation.AugmentationArmorPlating;
|
||||
|
@ -11,8 +10,6 @@ import net.minecraft.item.EnumArmorMaterial;
|
|||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class ItemPowerArmorHead extends ItemPowerArmor {
|
||||
protected static List<Augmentation> validAugTypes;
|
||||
|
||||
public ItemPowerArmorHead() {
|
||||
super(Config.getAssignedItemID(Config.Items.PowerArmorHead), // itemID
|
||||
EnumArmorMaterial.IRON, // Material
|
||||
|
@ -36,12 +33,4 @@ public class ItemPowerArmorHead extends ItemPowerArmor {
|
|||
validAugTypes.add(new AugmentationArmorPlating());
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherited from IModularItem, returns a (potentially sparse) array of
|
||||
* valid augmentations for this item.
|
||||
*/
|
||||
@Override
|
||||
public List<Augmentation> getValidAugs() {
|
||||
return validAugTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package machinemuse.powersuits.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import machinemuse.powersuits.augmentation.Augmentation;
|
||||
import machinemuse.powersuits.augmentation.AugmentationArmorPlating;
|
||||
|
@ -11,8 +10,6 @@ import net.minecraft.item.EnumArmorMaterial;
|
|||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class ItemPowerArmorLegs extends ItemPowerArmor {
|
||||
protected static List<Augmentation> validAugTypes;
|
||||
|
||||
public ItemPowerArmorLegs() {
|
||||
super(Config.getAssignedItemID(Config.Items.PowerArmorLegs), // itemID
|
||||
EnumArmorMaterial.IRON, // Material
|
||||
|
@ -36,13 +33,4 @@ public class ItemPowerArmorLegs extends ItemPowerArmor {
|
|||
validAugTypes.add(new AugmentationArmorPlating());
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherited from IModularItem, returns a (potentially sparse) array of
|
||||
* valid augmentations for this item.
|
||||
*/
|
||||
@Override
|
||||
public List<Augmentation> getValidAugs() {
|
||||
return validAugTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package machinemuse.powersuits.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import machinemuse.powersuits.augmentation.Augmentation;
|
||||
import machinemuse.powersuits.augmentation.AugmentationArmorPlating;
|
||||
|
@ -11,8 +10,6 @@ import net.minecraft.item.EnumArmorMaterial;
|
|||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class ItemPowerArmorTorso extends ItemPowerArmor {
|
||||
protected static List<Augmentation> validAugTypes;
|
||||
|
||||
public ItemPowerArmorTorso() {
|
||||
super(Config.getAssignedItemID(Config.Items.PowerArmorTorso), // itemID
|
||||
EnumArmorMaterial.IRON, // Material
|
||||
|
@ -35,14 +32,4 @@ public class ItemPowerArmorTorso extends ItemPowerArmor {
|
|||
validAugTypes.add(new AugmentationBattery());
|
||||
validAugTypes.add(new AugmentationArmorPlating());
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherited from IModularItem, returns a (potentially sparse) array of
|
||||
* valid augmentations for this item.
|
||||
*/
|
||||
@Override
|
||||
public List<Augmentation> getValidAugs() {
|
||||
return validAugTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
|
|||
* @author MachineMuse
|
||||
*/
|
||||
public class ItemPowerTool extends Item implements IModularItem {
|
||||
private List<Augmentation> validAugTypes;
|
||||
protected List<Augmentation> validAugTypes;
|
||||
|
||||
/**
|
||||
* Constructor. Takes information from the Config.Items enum.
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
package machinemuse.powersuits.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import machinemuse.powersuits.augmentation.Augmentation;
|
||||
import machinemuse.powersuits.augmentation.AugmentationList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class ItemUtil {
|
||||
|
||||
public class ItemUtils {
|
||||
/**
|
||||
* Scans a specified inventory for modular items.
|
||||
*
|
||||
|
@ -29,6 +32,9 @@ public abstract class ItemUtil {
|
|||
return stacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to cast an item to IModularItem, returns null if fails
|
||||
*/
|
||||
public static IModularItem getAsModular(Item item) {
|
||||
if (item instanceof IModularItem) {
|
||||
return (IModularItem) item;
|
||||
|
@ -36,4 +42,20 @@ public abstract class ItemUtil {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static List<Augmentation> getPlayerAugs(EntityPlayer player) {
|
||||
List<Augmentation> augs = new ArrayList<Augmentation>();
|
||||
List<ItemStack> items = getModularItemsInInventory(player.inventory);
|
||||
Iterator<ItemStack> iter = items.iterator();
|
||||
while (iter.hasNext()) {
|
||||
AugmentationList itemAugs = new AugmentationList(iter.next());
|
||||
augs.addAll(itemAugs.getAllAugData());
|
||||
}
|
||||
|
||||
return augs;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package machinemuse.powersuits.augmentation;
|
||||
package machinemuse.powersuits.trash;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,12 +1,18 @@
|
|||
package machinemuse.powersuits.trash;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import machinemuse.powersuits.item.ItemPowerArmor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ContainerTinkerTable extends Container {
|
||||
|
@ -172,4 +178,81 @@ public class ContainerTinkerTable extends Container {
|
|||
return var3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a recipe. See spreadsheet on first page for details.
|
||||
*/
|
||||
public void addRecipe(ItemStack outputStack, Object... recipeParameters)
|
||||
{
|
||||
String reshapedString = "";
|
||||
int currentArg = 0;
|
||||
int var5 = 0;
|
||||
int var6 = 0;
|
||||
|
||||
if (recipeParameters[currentArg] instanceof String[])
|
||||
{
|
||||
String[] nextRecipeString = (String[]) ((String[]) recipeParameters[currentArg++]);
|
||||
|
||||
for (int i = 0; i < nextRecipeString.length; ++i)
|
||||
{
|
||||
String nextChar = nextRecipeString[i];
|
||||
++var6;
|
||||
var5 = nextChar.length();
|
||||
reshapedString = reshapedString + nextChar;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (recipeParameters[currentArg] instanceof String)
|
||||
{
|
||||
String var11 = (String) recipeParameters[currentArg++];
|
||||
++var6;
|
||||
var5 = var11.length();
|
||||
reshapedString = reshapedString + var11;
|
||||
}
|
||||
}
|
||||
|
||||
HashMap var12;
|
||||
|
||||
for (var12 = new HashMap(); currentArg < recipeParameters.length; currentArg += 2)
|
||||
{
|
||||
Character var13 = (Character) recipeParameters[currentArg];
|
||||
ItemStack var14 = null;
|
||||
|
||||
if (recipeParameters[currentArg + 1] instanceof Item)
|
||||
{
|
||||
var14 = new ItemStack((Item) recipeParameters[currentArg + 1]);
|
||||
}
|
||||
else if (recipeParameters[currentArg + 1] instanceof Block)
|
||||
{
|
||||
var14 = new ItemStack((Block) recipeParameters[currentArg + 1], 1, -1);
|
||||
}
|
||||
else if (recipeParameters[currentArg + 1] instanceof ItemStack)
|
||||
{
|
||||
var14 = (ItemStack) recipeParameters[currentArg + 1];
|
||||
}
|
||||
|
||||
var12.put(var13, var14);
|
||||
}
|
||||
|
||||
ItemStack[] var15 = new ItemStack[var5 * var6];
|
||||
|
||||
for (int var16 = 0; var16 < var5 * var6; ++var16)
|
||||
{
|
||||
char var10 = reshapedString.charAt(var16);
|
||||
|
||||
if (var12.containsKey(Character.valueOf(var10)))
|
||||
{
|
||||
var15[var16] = ((ItemStack) var12.get(Character.valueOf(var10)))
|
||||
.copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
var15[var16] = null;
|
||||
}
|
||||
}
|
||||
|
||||
List<IRecipe> recipes = new ArrayList<IRecipe>();
|
||||
recipes.add(new ShapedRecipes(var5, var6, var15,
|
||||
outputStack));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue