Prepared for alpha release
many small changes
This commit is contained in:
parent
b0b2ba35bd
commit
d57ed3520d
BIN
blankarmor.png
Normal file
BIN
blankarmor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 186 B |
BIN
moduleicons.png
BIN
moduleicons.png
Binary file not shown.
Before Width: | Height: | Size: 7.6 KiB |
|
@ -1,56 +1,66 @@
|
|||
package net.machinemuse.general.gui;
|
||||
|
||||
public class MuseIcon {
|
||||
public static final String ICON_PATH = "/icons.png";
|
||||
public static final MuseIcon ORB_1_GREEN = new MuseIcon(ICON_PATH, 0);
|
||||
public static final MuseIcon ORB_1_RED = new MuseIcon(ICON_PATH, 1);
|
||||
public static final MuseIcon ORB_1_BLUE = new MuseIcon(ICON_PATH, 2);
|
||||
public static final MuseIcon PLATE_1_GREEN = new MuseIcon(ICON_PATH, 3);
|
||||
public static final MuseIcon PLATE_1_RED = new MuseIcon(ICON_PATH, 4);
|
||||
public static final MuseIcon PLATE_1_BLUE = new MuseIcon(ICON_PATH, 5);
|
||||
public static final MuseIcon NEXUS_1_GREEN = new MuseIcon(ICON_PATH, 6);
|
||||
public static final MuseIcon NEXUS_1_RED = new MuseIcon(ICON_PATH, 7);
|
||||
public static final MuseIcon NEXUS_1_BLUE = new MuseIcon(ICON_PATH, 8);
|
||||
public static final MuseIcon TOOL_AXE = new MuseIcon(ICON_PATH, 9);
|
||||
public static final MuseIcon TOOL_PICK = new MuseIcon(ICON_PATH, 10);
|
||||
public static final MuseIcon TOOL_SHOVEL = new MuseIcon(ICON_PATH, 11);
|
||||
public static final MuseIcon TOOL_SHEARS = new MuseIcon(ICON_PATH, 12);
|
||||
public static final MuseIcon TOOL_FIST = new MuseIcon(ICON_PATH, 13);
|
||||
public static final MuseIcon TOOL_PINCH = new MuseIcon(ICON_PATH, 14);
|
||||
public static final MuseIcon ARMOR_HEAD = new MuseIcon(ICON_PATH, 15);
|
||||
public static final MuseIcon PLATE_2_GREEN = new MuseIcon(ICON_PATH, 16);
|
||||
public static final MuseIcon PLATE_2_RED = new MuseIcon(ICON_PATH, 17);
|
||||
public static final MuseIcon PLATE_2_BLUE = new MuseIcon(ICON_PATH, 18);
|
||||
public static final MuseIcon INDICATOR_1_BLUE = new MuseIcon(ICON_PATH, 19);
|
||||
public static final MuseIcon INDICATOR_1_RED = new MuseIcon(ICON_PATH, 20);
|
||||
public static final MuseIcon INDICATOR_1_GREEN = new MuseIcon(ICON_PATH, 21);
|
||||
public static final MuseIcon ARMOR_TORSO = new MuseIcon(ICON_PATH, 31);
|
||||
public static final MuseIcon ARMOR_LEGS = new MuseIcon(ICON_PATH, 47);
|
||||
public static final MuseIcon ARMOR_FEET = new MuseIcon(ICON_PATH, 63);
|
||||
|
||||
public static final String SEBK_ICON_PATH = "/sebkicons.png";
|
||||
public static final MuseIcon ORB_1_GREEN = new MuseIcon(SEBK_ICON_PATH, 0);
|
||||
public static final MuseIcon ORB_1_RED = new MuseIcon(SEBK_ICON_PATH, 1);
|
||||
public static final MuseIcon ORB_1_BLUE = new MuseIcon(SEBK_ICON_PATH, 2);
|
||||
public static final MuseIcon PLATE_1_GREEN = new MuseIcon(SEBK_ICON_PATH, 3);
|
||||
public static final MuseIcon PLATE_1_RED = new MuseIcon(SEBK_ICON_PATH, 4);
|
||||
public static final MuseIcon PLATE_1_BLUE = new MuseIcon(SEBK_ICON_PATH, 5);
|
||||
public static final MuseIcon NEXUS_1_GREEN = new MuseIcon(SEBK_ICON_PATH, 6);
|
||||
public static final MuseIcon NEXUS_1_RED = new MuseIcon(SEBK_ICON_PATH, 7);
|
||||
public static final MuseIcon NEXUS_1_BLUE = new MuseIcon(SEBK_ICON_PATH, 8);
|
||||
public static final MuseIcon TOOL_AXE = new MuseIcon(SEBK_ICON_PATH, 9);
|
||||
public static final MuseIcon TOOL_PICK = new MuseIcon(SEBK_ICON_PATH, 10);
|
||||
public static final MuseIcon TOOL_SHOVEL = new MuseIcon(SEBK_ICON_PATH, 11);
|
||||
public static final MuseIcon TOOL_SHEARS = new MuseIcon(SEBK_ICON_PATH, 12);
|
||||
public static final MuseIcon TOOL_FIST = new MuseIcon(SEBK_ICON_PATH, 13);
|
||||
public static final MuseIcon TOOL_PINCH = new MuseIcon(SEBK_ICON_PATH, 14);
|
||||
public static final MuseIcon ARMOR_HEAD = new MuseIcon(SEBK_ICON_PATH, 15);
|
||||
public static final MuseIcon PLATE_2_GREEN = new MuseIcon(SEBK_ICON_PATH, 16);
|
||||
public static final MuseIcon PLATE_2_RED = new MuseIcon(SEBK_ICON_PATH, 17);
|
||||
public static final MuseIcon PLATE_2_BLUE = new MuseIcon(SEBK_ICON_PATH, 18);
|
||||
public static final MuseIcon INDICATOR_1_BLUE = new MuseIcon(SEBK_ICON_PATH, 19);
|
||||
public static final MuseIcon INDICATOR_1_RED = new MuseIcon(SEBK_ICON_PATH, 20);
|
||||
public static final MuseIcon INDICATOR_1_GREEN = new MuseIcon(SEBK_ICON_PATH, 21);
|
||||
public static final MuseIcon ARMOR_TORSO = new MuseIcon(SEBK_ICON_PATH, 31);
|
||||
public static final MuseIcon ARMOR_LEGS = new MuseIcon(SEBK_ICON_PATH, 47);
|
||||
public static final MuseIcon ARMOR_FEET = new MuseIcon(SEBK_ICON_PATH, 63);
|
||||
public static final String WC_ICON_PATH = "/watericons.png";
|
||||
public static final MuseIcon JETBOOTS = new MuseIcon(WC_ICON_PATH, 0);
|
||||
public static final MuseIcon JETPACK = new MuseIcon(WC_ICON_PATH, 1);
|
||||
public static final MuseIcon GLIDER = new MuseIcon(WC_ICON_PATH, 2);
|
||||
public static final MuseIcon GRAVITY_ENGINE = new MuseIcon(WC_ICON_PATH, 3);
|
||||
public static final MuseIcon SPRINT_ASSIST = new MuseIcon(WC_ICON_PATH, 4);
|
||||
public static final MuseIcon JUMP_ASSIST = new MuseIcon(WC_ICON_PATH, 5);
|
||||
public static final MuseIcon ENERGY_SHIELD = new MuseIcon(WC_ICON_PATH, 6);
|
||||
public static final MuseIcon DIAMOND_PICK_UPGRADE = new MuseIcon(WC_ICON_PATH, 7);
|
||||
public static final MuseIcon BATTERY_UPGRADE = new MuseIcon(WC_ICON_PATH, 8);
|
||||
|
||||
String texturefile;
|
||||
int index;
|
||||
|
||||
|
||||
public MuseIcon(String texturefile, int index) {
|
||||
super();
|
||||
this.texturefile = texturefile;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
||||
public String getTexturefile() {
|
||||
return texturefile;
|
||||
}
|
||||
|
||||
|
||||
public void setTexturefile(String texturefile) {
|
||||
this.texturefile = texturefile;
|
||||
}
|
||||
|
||||
|
||||
public int getIconIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
public void setIconIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -44,6 +44,16 @@ public class ClickableSlider extends Clickable {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public double getValue() {
|
||||
double val = 0;
|
||||
if (moduleTag.hasKey(name)) {
|
||||
val = moduleTag.getDouble(name);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
public void moveSlider(double x, double y) {
|
||||
double xval = position.x() - x;
|
||||
double xratio = 0.5 - (xval / width);
|
||||
|
|
|
@ -1,39 +1,44 @@
|
|||
package net.machinemuse.general.gui.frame;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import net.machinemuse.general.MuseStringUtils;
|
||||
import net.machinemuse.general.geometry.Colour;
|
||||
import net.machinemuse.general.geometry.MuseRenderer;
|
||||
import net.machinemuse.general.geometry.Point2D;
|
||||
import net.machinemuse.general.gui.clickable.ClickableItem;
|
||||
import net.machinemuse.general.gui.clickable.ClickableSlider;
|
||||
import net.machinemuse.powersuits.item.ItemUtils;
|
||||
import net.machinemuse.powersuits.network.MusePacket;
|
||||
import net.machinemuse.powersuits.network.MusePacketTweakRequest;
|
||||
import net.machinemuse.powersuits.powermodule.GenericModule;
|
||||
import net.machinemuse.powersuits.powermodule.IModuleProperty;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class ModuleTweakFrame extends ScrollableFrame {
|
||||
protected static double SCALERATIO = 0.5;
|
||||
protected ItemSelectionFrame itemTarget;
|
||||
protected ModuleSelectionFrame moduleTarget;
|
||||
protected List<ClickableSlider> sliders;
|
||||
protected List<String> propertyStrings;
|
||||
protected Map<String, Double> propertyStrings;
|
||||
protected ClickableSlider selectedSlider;
|
||||
protected EntityClientPlayerMP player;
|
||||
|
||||
public ModuleTweakFrame(
|
||||
EntityPlayer player,
|
||||
EntityClientPlayerMP player,
|
||||
Point2D topleft, Point2D bottomright,
|
||||
Colour borderColour, Colour insideColour,
|
||||
ItemSelectionFrame itemTarget, ModuleSelectionFrame moduleTarget) {
|
||||
super(topleft.times(1 / SCALERATIO), bottomright.times(1 / SCALERATIO), borderColour, insideColour);
|
||||
this.itemTarget = itemTarget;
|
||||
this.moduleTarget = moduleTarget;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override public void update(double mousex, double mousey) {
|
||||
|
@ -66,9 +71,9 @@ public class ModuleTweakFrame extends ScrollableFrame {
|
|||
}
|
||||
int nexty = (int) (sliders.size() * 24 + topleft.y() + 24);
|
||||
GenericModule module = moduleTarget.getSelectedModule().getModule();
|
||||
for (String property : propertyStrings) {
|
||||
for (Map.Entry<String, Double> property : propertyStrings.entrySet()) {
|
||||
nexty += 8;
|
||||
String[] str = property.split("\t");
|
||||
String[] str = { property.getKey() + ":", MuseStringUtils.formatNumberShort(property.getValue()) };
|
||||
MuseRenderer.drawStringsJustified(Arrays.asList(str), topleft.x() + 4, bottomright.x() - 4, nexty);
|
||||
|
||||
}
|
||||
|
@ -79,11 +84,16 @@ public class ModuleTweakFrame extends ScrollableFrame {
|
|||
NBTTagCompound itemTag = ItemUtils.getMuseItemTag(stack);
|
||||
NBTTagCompound moduleTag = itemTag.getCompoundTag(module.getName());
|
||||
|
||||
propertyStrings = new LinkedList<String>();
|
||||
propertyStrings = new HashMap();
|
||||
|
||||
Set<IModuleProperty> propertyCalcs = module.getPropertyComputers();
|
||||
for (IModuleProperty property : propertyCalcs) {
|
||||
propertyStrings.add(property.getString(moduleTag));
|
||||
double currValue = 0;
|
||||
if (propertyStrings.containsKey(property.getName())) {
|
||||
currValue = propertyStrings.get(property.getName());
|
||||
}
|
||||
currValue += property.computeProperty(moduleTag);
|
||||
propertyStrings.put(property.getName(), currValue);
|
||||
}
|
||||
|
||||
Set<String> tweaks = module.getTweaks();
|
||||
|
@ -113,9 +123,15 @@ public class ModuleTweakFrame extends ScrollableFrame {
|
|||
}
|
||||
|
||||
@Override public void onMouseUp(double x, double y, int button) {
|
||||
if (selectedSlider != null && itemTarget.getSelectedItem() != null && moduleTarget.getSelectedModule() != null) {
|
||||
ClickableItem item = itemTarget.getSelectedItem();
|
||||
GenericModule module = moduleTarget.getSelectedModule().getModule();
|
||||
MusePacket tweakRequest = new MusePacketTweakRequest((Player) player, item.inventorySlot, module.getName(), selectedSlider.getName(),
|
||||
selectedSlider.getValue());
|
||||
player.sendQueue.addToSendQueue(tweakRequest.getPacket250());
|
||||
}
|
||||
if (button == 0) {
|
||||
selectedSlider = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class GuiTinkerTable extends MuseGui {
|
|||
public GuiTinkerTable(EntityClientPlayerMP player) {
|
||||
this.player = player;
|
||||
this.xSize = 256;
|
||||
this.ySize = 226;
|
||||
this.ySize = 200;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,6 +39,7 @@ public class GuiTinkerTable extends MuseGui {
|
|||
Colour.DARKBLUE.withAlpha(0.8F),
|
||||
player);
|
||||
frames.add(itemSelectFrame);
|
||||
|
||||
ItemInfoFrame statsFrame = new ItemInfoFrame(player,
|
||||
new Point2D(absX(0f), absY(-0.9f)),
|
||||
new Point2D(absX(0.9f), absY(-0.05f)),
|
||||
|
@ -46,6 +47,7 @@ public class GuiTinkerTable extends MuseGui {
|
|||
Colour.DARKBLUE.withAlpha(0.8),
|
||||
itemSelectFrame);
|
||||
frames.add(statsFrame);
|
||||
|
||||
ModuleSelectionFrame moduleSelectFrame = new ModuleSelectionFrame(
|
||||
new Point2D(absX(-0.75F), absY(-0.95f)),
|
||||
new Point2D(absX(-0.05F), absY(0.55f)),
|
||||
|
@ -53,6 +55,7 @@ public class GuiTinkerTable extends MuseGui {
|
|||
Colour.DARKBLUE.withAlpha(0.8),
|
||||
itemSelectFrame);
|
||||
frames.add(moduleSelectFrame);
|
||||
|
||||
InstallSalvageFrame installFrame = new InstallSalvageFrame(
|
||||
player,
|
||||
new Point2D(absX(-0.75F), absY(0.6f)),
|
||||
|
@ -61,6 +64,7 @@ public class GuiTinkerTable extends MuseGui {
|
|||
Colour.DARKBLUE.withAlpha(0.8),
|
||||
itemSelectFrame, moduleSelectFrame);
|
||||
frames.add(installFrame);
|
||||
|
||||
ModuleTweakFrame tweakFrame = new ModuleTweakFrame(
|
||||
player,
|
||||
new Point2D(absX(0f), absY(0f)),
|
||||
|
|
|
@ -17,29 +17,26 @@ import cpw.mods.fml.relauncher.Side;
|
|||
public class CommonProxy {
|
||||
public static String ITEMS_PNG = "/tutorial/generic/items.png";
|
||||
public static String BLOCK_PNG = "/tutorial/generic/block.png";
|
||||
|
||||
public static ITickHandler tickHandler;
|
||||
public static MusePacketHandler packetHandler;
|
||||
|
||||
|
||||
public static ITickHandler tickHandler = new PlayerTickHandler();
|
||||
public static MusePacketHandler packetHandler = new MusePacketHandler();
|
||||
|
||||
/**
|
||||
* Only the client needs to register renderers.
|
||||
*/
|
||||
public void registerRenderers() {
|
||||
}
|
||||
|
||||
public void registerRenderers() {}
|
||||
|
||||
/**
|
||||
* Register the server-side tickhandler and packethandler.
|
||||
*/
|
||||
public void registerHandlers() {
|
||||
tickHandler = new PlayerTickHandler();
|
||||
TickRegistry.registerTickHandler(tickHandler, Side.SERVER);
|
||||
|
||||
packetHandler = new MusePacketHandler();
|
||||
|
||||
packetHandler.register();
|
||||
}
|
||||
|
||||
|
||||
public void postInit() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Map;
|
|||
import net.machinemuse.general.gui.MuseIcon;
|
||||
import net.machinemuse.powersuits.item.ModularCommon;
|
||||
import net.machinemuse.powersuits.powermodule.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -61,13 +62,13 @@ public class Config extends Configuration {
|
|||
// Request block IDs
|
||||
for (Blocks b : Blocks.values()) {
|
||||
assignedBlockIDs[b.ordinal()] =
|
||||
config.getBlock(b.englishName, 1002).getInt();
|
||||
config.getBlock(b.englishName, b.defaultBlockId).getInt();
|
||||
}
|
||||
|
||||
// Request item IDs
|
||||
for (Items i : Items.values()) {
|
||||
assignedItemIDs[i.ordinal()] =
|
||||
config.getItem(i.englishName, 5000).getInt();
|
||||
config.getItem(i.englishName, i.defaultItemID).getInt();
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
@ -111,8 +112,7 @@ public class Config extends Configuration {
|
|||
*/
|
||||
public static int getAssignedItemID(Items item) {
|
||||
if (assignedItemIDs[item.ordinal()] == 0) {
|
||||
assignedItemIDs[item.ordinal()] = config.getItem(item.englishName,
|
||||
1002).getInt();
|
||||
assignedItemIDs[item.ordinal()] = config.getItem(item.englishName, item.defaultItemID).getInt();
|
||||
}
|
||||
return assignedItemIDs[item.ordinal()];
|
||||
}
|
||||
|
@ -126,8 +126,7 @@ public class Config extends Configuration {
|
|||
*/
|
||||
public static int getAssignedBlockID(Blocks block) {
|
||||
if (assignedBlockIDs[block.ordinal()] == 0) {
|
||||
assignedBlockIDs[block.ordinal()] = config.getBlock(
|
||||
block.englishName, 5000).getInt();
|
||||
assignedBlockIDs[block.ordinal()] = config.getBlock(block.englishName, block.defaultBlockId).getInt();
|
||||
}
|
||||
return assignedBlockIDs[block.ordinal()];
|
||||
}
|
||||
|
@ -142,15 +141,6 @@ public class Config extends Configuration {
|
|||
}
|
||||
}
|
||||
|
||||
public static void loadModularProperties() {
|
||||
loadModularProperty(ModularCommon.MAXIMUM_ENERGY, 0);
|
||||
loadModularProperty(ModularCommon.BATTERY_WEIGHT, 0);
|
||||
loadModularProperty(ModularCommon.SHOVEL_HARVEST_SPEED, 0);
|
||||
loadModularProperty(ModularCommon.SHOVEL_ENERGY_CONSUMPTION, 0);
|
||||
loadModularProperty(ModularCommon.AXE_HARVEST_SPEED, 0);
|
||||
loadModularProperty(ModularCommon.PICKAXE_HARVEST_SPEED, 0);
|
||||
|
||||
}
|
||||
public static double computeModularProperty(ItemStack stack, String propertyName) {
|
||||
ModularProperty propertyComputer = loadModularProperty(propertyName, 0);
|
||||
return propertyComputer.computeProperty(stack);
|
||||
|
@ -179,52 +169,114 @@ public class Config extends Configuration {
|
|||
public static void loadTinkerings() {
|
||||
// loadModularProperties();
|
||||
boolean[] ARMORONLY = { true, true, true, true, false };
|
||||
boolean[] HEADONLY = { true, false, false, false, false };
|
||||
boolean[] TORSOONLY = { false, true, false, false, false };
|
||||
boolean[] LEGSONLY = { false, false, true, false, false };
|
||||
boolean[] FEETONLY = { false, false, false, true, false };
|
||||
boolean[] TOOLONLY = { false, false, false, false, true };
|
||||
boolean[] ALLITEMS = { true, true, true, true, true };
|
||||
GenericModule module;
|
||||
|
||||
module = new GenericModule(ModularCommon.IRON_SHIELDING, ARMORONLY, MuseIcon.PLATE_1_RED, ModularCommon.CATEGORY_ARMOR)
|
||||
module = new GenericModule(ModularCommon.MODULE_IRON_PLATING, ARMORONLY, MuseIcon.ORB_1_GREEN, ModularCommon.CATEGORY_ARMOR)
|
||||
.setDescription("Iron plating is heavy but protective.")
|
||||
.setDefaultDouble(ModularCommon.TRADEOFF_ARMOR_THICKNESS, 3)
|
||||
.addInstallCost(new ItemStack(Item.ingotIron, 3))
|
||||
.addInstallCost(new ItemStack(BasicComponents.itemCircuit, 1, 0));
|
||||
.addInstallCost(new ItemStack(Item.ingotIron, 5));
|
||||
addSimpleTradeoff(
|
||||
module, "Plating Thickness",
|
||||
ModularCommon.ARMOR_VALUE_PHYSICAL, "", 0, 5,
|
||||
ModularCommon.WEIGHT, "g", 0, 10000);
|
||||
addModule(module);
|
||||
|
||||
module = new GenericModule(ModularCommon.DIAMOND_SHIELDING, ARMORONLY, MuseIcon.PLATE_1_BLUE, ModularCommon.CATEGORY_ARMOR)
|
||||
module = new GenericModule(ModularCommon.MODULE_DIAMOND_PLATING, ARMORONLY, MuseIcon.ORB_1_BLUE, ModularCommon.CATEGORY_ARMOR)
|
||||
.setDescription("Diamonds are lighter, harder, and more protective than Iron but much harder to find.")
|
||||
.addInstallCost(new ItemStack(Item.diamond, 3))
|
||||
.addInstallCost(new ItemStack(BasicComponents.itemCircuit, 1, 1));
|
||||
.addInstallCost(new ItemStack(Item.diamond, 5));
|
||||
addSimpleTradeoff(
|
||||
module, "Plating Thickness",
|
||||
ModularCommon.ARMOR_VALUE_PHYSICAL, "", 0, 6,
|
||||
ModularCommon.WEIGHT, "g", 0, 6000);
|
||||
addModule(module);
|
||||
|
||||
module = new GenericModule(ModularCommon.SHOVEL, TOOLONLY, MuseIcon.TOOL_SHOVEL, ModularCommon.CATEGORY_TOOL)
|
||||
module = new GenericModule(ModularCommon.MODULE_ENERGY_SHIELD, ARMORONLY, MuseIcon.ENERGY_SHIELD, ModularCommon.CATEGORY_ARMOR)
|
||||
.setDescription("Energy shields are much lighter than plating, but consume energy.")
|
||||
.addInstallCost(new ItemStack(BasicComponents.itemCircuit, 3, 1));
|
||||
addSimpleTradeoff(
|
||||
module, "Field Strength",
|
||||
ModularCommon.ARMOR_ENERGY_CONSUMPTION, "J", 0, 500,
|
||||
ModularCommon.ARMOR_VALUE_ENERGY, "", 0, 6);
|
||||
addModule(module);
|
||||
|
||||
module = new GenericModule(ModularCommon.MODULE_SHOVEL, TOOLONLY, MuseIcon.TOOL_SHOVEL, ModularCommon.CATEGORY_TOOL)
|
||||
.setDescription("Shovels are good for soft materials like dirt and sand.")
|
||||
.addInstallCost(new ItemStack(Item.ingotIron, 3));
|
||||
addSimpleTradeoff(
|
||||
module,
|
||||
ModularCommon.TRADEOFF_OVERCLOCK,
|
||||
module, "Overclock",
|
||||
ModularCommon.SHOVEL_ENERGY_CONSUMPTION, "J", 10, 990,
|
||||
ModularCommon.SHOVEL_HARVEST_SPEED, "", 2, 18);
|
||||
addModule(module);
|
||||
|
||||
module = new GenericModule(ModularCommon.AXE, TOOLONLY, MuseIcon.TOOL_AXE, ModularCommon.CATEGORY_TOOL)
|
||||
module = new GenericModule(ModularCommon.MODULE_AXE, TOOLONLY, MuseIcon.TOOL_AXE, ModularCommon.CATEGORY_TOOL)
|
||||
.setDescription("Axes are mostly for chopping trees.")
|
||||
.addInstallCost(new ItemStack(Item.ingotIron, 3));
|
||||
addSimpleTradeoff(
|
||||
module, "Overclock",
|
||||
ModularCommon.AXE_ENERGY_CONSUMPTION, "J", 10, 990,
|
||||
ModularCommon.AXE_HARVEST_SPEED, "", 2, 18);
|
||||
addModule(module);
|
||||
|
||||
module = new GenericModule(ModularCommon.PICKAXE, TOOLONLY, MuseIcon.TOOL_PICK, ModularCommon.CATEGORY_TOOL)
|
||||
module = new GenericModule(ModularCommon.MODULE_PICKAXE, TOOLONLY, MuseIcon.TOOL_PICK, ModularCommon.CATEGORY_TOOL)
|
||||
.setDescription("Picks are good for harder materials like stone and ore.")
|
||||
.addInstallCost(new ItemStack(Item.ingotIron, 3));
|
||||
addSimpleTradeoff(
|
||||
module, "Overclock",
|
||||
ModularCommon.PICKAXE_ENERGY_CONSUMPTION, "J", 10, 990,
|
||||
ModularCommon.PICKAXE_HARVEST_SPEED, "", 2, 18);
|
||||
addModule(module);
|
||||
|
||||
module = new GenericModule(ModularCommon.BATTERY_BASIC, ALLITEMS, MuseIcon.ORB_1_GREEN, ModularCommon.CATEGORY_ENERGY)
|
||||
module = new GenericModule(ModularCommon.MODULE_BATTERY_BASIC, ALLITEMS, MuseIcon.BATTERY_UPGRADE, ModularCommon.CATEGORY_ENERGY)
|
||||
.setDescription("Integrate a battery to allow the item to store energy.")
|
||||
.addInstallCost(new ItemStack(BasicComponents.itemBattery, 1));
|
||||
addSimpleTradeoff(
|
||||
module,
|
||||
ModularCommon.TRADEOFF_BATTERY_SIZE,
|
||||
ModularCommon.MAXIMUM_ENERGY, "J", 20000, 480000,
|
||||
module, "Battery Size",
|
||||
ModularCommon.MAXIMUM_ENERGY, "J", 20000, 80000,
|
||||
ModularCommon.WEIGHT, "g", 2000, 8000);
|
||||
addModule(module);
|
||||
|
||||
module = new GenericModule(ModularCommon.MODULE_DIAMOND_PICK_UPGRADE, TOOLONLY, MuseIcon.DIAMOND_PICK_UPGRADE, ModularCommon.CATEGORY_TOOL)
|
||||
.setDescription("Add diamonds to allow your pickaxe module to mine Obsidian.")
|
||||
.addInstallCost(new ItemStack(Item.diamond, 3));
|
||||
addModule(module);
|
||||
|
||||
module = new GenericModule(ModularCommon.MODULE_SPRINT_ASSIST, LEGSONLY, MuseIcon.SPRINT_ASSIST, ModularCommon.CATEGORY_MOVEMENT)
|
||||
.setDescription("A set of servo motors to help you sprint (double-tap forward) faster.")
|
||||
.addInstallCost(new ItemStack(BasicComponents.itemMotor, 4));
|
||||
addSimpleTradeoff(
|
||||
module, "Power",
|
||||
ModularCommon.SPRINT_ENERGY_CONSUMPTION, "J", 0, 100,
|
||||
ModularCommon.SPRINT_SPEED_MULTIPLIER, "x", 1, 2);
|
||||
addSimpleTradeoff(
|
||||
module, "Compensation",
|
||||
ModularCommon.SPRINT_ENERGY_CONSUMPTION, "J", 0, 10,
|
||||
ModularCommon.SPRINT_FOOD_COMPENSATION, "x", 0, 1);
|
||||
addModule(module);
|
||||
|
||||
module = new GenericModule(ModularCommon.MODULE_JUMP_ASSIST, LEGSONLY, MuseIcon.JUMP_ASSIST, ModularCommon.CATEGORY_MOVEMENT)
|
||||
.setDescription("Another set of servo motors to help you jump higher.")
|
||||
.addInstallCost(new ItemStack(BasicComponents.itemMotor, 4));
|
||||
addSimpleTradeoff(
|
||||
module, "Power",
|
||||
ModularCommon.JUMP_ENERGY_CONSUMPTION, "J", 0, 100,
|
||||
ModularCommon.JUMP_MULTIPLIER, "x", 1, 2);
|
||||
addModule(module);
|
||||
|
||||
module = new GenericModule(ModularCommon.MODULE_SHOCK_ABSORBER, FEETONLY, MuseIcon.PLATE_1_RED, ModularCommon.CATEGORY_MOVEMENT)
|
||||
.setDescription("With some servos, springs, and padding, you should be able to negate a portion of fall damage.")
|
||||
.addInstallCost(new ItemStack(BasicComponents.itemMotor, 2))
|
||||
.addInstallCost(new ItemStack(Block.cloth, 2));
|
||||
addSimpleTradeoff(
|
||||
module, "Power",
|
||||
ModularCommon.SHOCK_ABSORB_ENERGY_CONSUMPTION, "J", 0, 10,
|
||||
ModularCommon.SHOCK_ABSORB_MULTIPLIER, "x", 0, 1);
|
||||
|
||||
addModule(module);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,7 +287,7 @@ public class Config extends Configuration {
|
|||
*
|
||||
*/
|
||||
public static enum Blocks {
|
||||
TinkerTable(1002, 0, "tinkerTable", "Tinker Table");
|
||||
TinkerTable(2477, 0, "tinkerTable", "Tinker Table");
|
||||
|
||||
public final int defaultBlockId;
|
||||
public final int textureIndex;
|
||||
|
@ -262,20 +314,22 @@ public class Config extends Configuration {
|
|||
*/
|
||||
public static enum Items {
|
||||
// Icon index, ID name, English name, Armor Type
|
||||
PowerArmorHead(0, "powerArmorHead", "Power Armor Head"),
|
||||
PowerArmorTorso(1, "powerArmorTorso", "Power Armor Torso"),
|
||||
PowerArmorLegs(2, "powerArmorLegs", "Power Armor Legs"),
|
||||
PowerArmorFeet(3, "powerArmorFeet", "Power Armor Feet"),
|
||||
PowerTool(4, "powerTool", "Power Tool"),
|
||||
PowerArmorHead(24770, 0, "powerArmorHead", "Power Armor Head"),
|
||||
PowerArmorTorso(24771, 1, "powerArmorTorso", "Power Armor Torso"),
|
||||
PowerArmorLegs(24772, 2, "powerArmorLegs", "Power Armor Legs"),
|
||||
PowerArmorFeet(24773, 3, "powerArmorFeet", "Power Armor Feet"),
|
||||
PowerTool(24774, 4, "powerTool", "Power Tool"),
|
||||
|
||||
;
|
||||
|
||||
public final int defaultItemID;
|
||||
public final int iconIndex;
|
||||
public final String idName;
|
||||
public final String englishName;
|
||||
|
||||
Items(int iconIndex,
|
||||
Items(int defaultItemID, int iconIndex,
|
||||
String idName, String englishName) {
|
||||
this.defaultItemID = defaultItemID;
|
||||
this.iconIndex = iconIndex;
|
||||
this.idName = idName;
|
||||
this.englishName = englishName;
|
||||
|
|
|
@ -4,11 +4,15 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.machinemuse.powersuits.block.BlockTinkerTable;
|
||||
import net.machinemuse.powersuits.event.EventHandler;
|
||||
import net.machinemuse.powersuits.item.*;
|
||||
import net.machinemuse.powersuits.network.MusePacketHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import basiccomponents.common.BasicComponents;
|
||||
import cpw.mods.fml.common.*;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
|
@ -20,6 +24,7 @@ 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
|
||||
|
@ -48,22 +53,20 @@ import cpw.mods.fml.common.network.NetworkRegistry;
|
|||
serverPacketHandlerSpec =
|
||||
@SidedPacketHandler(channels = { "mmmPowersuits" }, packetHandler = MusePacketHandler.class))
|
||||
public class PowersuitsMod {
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@Instance("PowersuitsMod") public static PowersuitsMod instance;
|
||||
|
||||
/**
|
||||
* 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 = "net.machinemuse.powersuits.client.ClientProxy", serverSide = "net.machinemuse.powersuits.common.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@SidedProxy(clientSide = "net.machinemuse.powersuits.client.ClientProxy", serverSide = "net.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
|
||||
|
@ -74,13 +77,13 @@ public class PowersuitsMod {
|
|||
* @param event
|
||||
* An event object with useful data
|
||||
*/
|
||||
@PreInit
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
@PreInit public void preInit(FMLPreInitializationEvent event) {
|
||||
instance = this;
|
||||
Config.init(new Configuration(
|
||||
event.getSuggestedConfigurationFile()));
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
}
|
||||
|
||||
|
||||
public static Config config;
|
||||
/**
|
||||
* A static handle for the blocks and items. We only want one instance of
|
||||
|
@ -89,7 +92,7 @@ public class PowersuitsMod {
|
|||
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.
|
||||
|
@ -97,49 +100,75 @@ public class PowersuitsMod {
|
|||
* @param event
|
||||
* An event object with useful data
|
||||
*/
|
||||
@Init
|
||||
public void load(FMLInitializationEvent event) {
|
||||
@Init public void load(FMLInitializationEvent event) {
|
||||
loadBlocks();
|
||||
|
||||
|
||||
loadItems();
|
||||
|
||||
|
||||
proxy.registerHandlers();
|
||||
proxy.registerRenderers();
|
||||
NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom function to collect all the item-loading in one place.
|
||||
*/
|
||||
public static void loadItems() {
|
||||
// Recipe
|
||||
ItemStack iron = new ItemStack(Item.ingotIron);
|
||||
ItemStack circuit = new ItemStack(BasicComponents.itemCircuit, 1, 0);
|
||||
|
||||
ItemPowerArmor item = new ItemPowerArmorHead();
|
||||
allItems.add(item);
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(item),
|
||||
"III",
|
||||
"C C",
|
||||
'I', iron, 'C', circuit);
|
||||
|
||||
item = new ItemPowerArmorTorso();
|
||||
allItems.add(item);
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(item),
|
||||
"I I",
|
||||
"CIC",
|
||||
"III",
|
||||
'I', iron, 'C', circuit);
|
||||
|
||||
item = new ItemPowerArmorLegs();
|
||||
allItems.add(item);
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(item),
|
||||
"III",
|
||||
"C C",
|
||||
"I I",
|
||||
'I', iron, 'C', circuit);
|
||||
|
||||
item = new ItemPowerArmorFeet();
|
||||
allItems.add(item);
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(item),
|
||||
"C C",
|
||||
"I I",
|
||||
'I', iron, 'C', circuit);
|
||||
|
||||
ItemPowerTool tool = new ItemPowerTool();
|
||||
allItems.add(tool);
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(tool),
|
||||
" C ",
|
||||
"CI ",
|
||||
" IC",
|
||||
'I', iron, 'C', circuit);
|
||||
|
||||
Config.loadTinkerings();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom function to collect all the block-loading in one place.
|
||||
*/
|
||||
public static void loadBlocks() {
|
||||
Block tinkTable = BlockTinkerTable.instance();
|
||||
|
||||
|
||||
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.
|
||||
|
@ -147,8 +176,7 @@ public class PowersuitsMod {
|
|||
* @param event
|
||||
* An event object with useful data
|
||||
*/
|
||||
@PostInit
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
@PostInit public void postInit(FMLPostInitializationEvent event) {
|
||||
proxy.postInit();
|
||||
}
|
||||
}
|
62
net/machinemuse/powersuits/event/EventHandler.java
Normal file
62
net/machinemuse/powersuits/event/EventHandler.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package net.machinemuse.powersuits.event;
|
||||
|
||||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.machinemuse.powersuits.item.ItemPowerArmor;
|
||||
import net.machinemuse.powersuits.item.ItemPowerTool;
|
||||
import net.machinemuse.powersuits.item.ItemUtils;
|
||||
import net.machinemuse.powersuits.item.ModularCommon;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
||||
public class EventHandler {
|
||||
@ForgeSubscribe public void handleHarvestCheck(PlayerEvent.HarvestCheck event) {
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
Block block = event.block;
|
||||
ItemStack stack = player.inventory.getCurrentItem();
|
||||
if (stack.getItem() instanceof ItemPowerTool && ItemPowerTool.canHarvestBlock(stack, block, 0)) {
|
||||
event.success = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe public void handleLivingJumpEvent(LivingJumpEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
ItemStack stack = player.getCurrentArmor(1);
|
||||
if (stack != null && stack.getItem() instanceof ItemPowerArmor && ItemUtils.itemHasModule(stack, ModularCommon.MODULE_JUMP_ASSIST)) {
|
||||
double jumpAssist = Config.computeModularProperty(stack, ModularCommon.JUMP_MULTIPLIER);
|
||||
double drain = Config.computeModularProperty(stack, ModularCommon.JUMP_ENERGY_CONSUMPTION);
|
||||
double avail = ItemUtils.getPlayerEnergy(player);
|
||||
if (drain < avail) {
|
||||
ItemUtils.drainPlayerEnergy(player, drain);
|
||||
player.motionY *= jumpAssist;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ForgeSubscribe public void handleFallEvent(LivingFallEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
ItemStack boots = player.getCurrentArmor(0);
|
||||
if (boots != null) {
|
||||
if (ItemUtils.itemHasModule(boots, ModularCommon.MODULE_SHOCK_ABSORBER)) {
|
||||
double distanceAbsorb = event.distance * Config.computeModularProperty(boots, ModularCommon.SHOCK_ABSORB_MULTIPLIER);
|
||||
|
||||
double drain = distanceAbsorb * distanceAbsorb * 0.05
|
||||
* Config.computeModularProperty(boots, ModularCommon.SHOCK_ABSORB_ENERGY_CONSUMPTION);
|
||||
double avail = ItemUtils.getPlayerEnergy(player);
|
||||
if (drain < avail) {
|
||||
ItemUtils.drainPlayerEnergy(player, drain);
|
||||
event.distance -= distanceAbsorb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.machinemuse.general.MuseStringUtils;
|
||||
import net.machinemuse.general.gui.MuseIcon;
|
||||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.machinemuse.powersuits.common.Config.Items;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
|
@ -13,6 +14,7 @@ import net.minecraft.item.ItemArmor;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraftforge.common.IArmorTextureProvider;
|
||||
import net.minecraftforge.common.ISpecialArmor;
|
||||
|
||||
/**
|
||||
|
@ -23,7 +25,8 @@ import net.minecraftforge.common.ISpecialArmor;
|
|||
public abstract class ItemPowerArmor extends ItemArmor
|
||||
implements
|
||||
ISpecialArmor,
|
||||
IModularItem {
|
||||
IModularItem,
|
||||
IArmorTextureProvider {
|
||||
Config.Items itemType;
|
||||
|
||||
/**
|
||||
|
@ -36,11 +39,15 @@ public abstract class ItemPowerArmor extends ItemArmor
|
|||
public ItemPowerArmor(int id, EnumArmorMaterial material,
|
||||
int renderIndex, int armorType) {
|
||||
super(id, material, renderIndex, armorType);
|
||||
setTextureFile("/icons.png");
|
||||
setTextureFile(MuseIcon.SEBK_ICON_PATH);
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(Config.getCreativeTab());
|
||||
}
|
||||
|
||||
@Override public String getArmorTextureFile(ItemStack itemstack) {
|
||||
return "/blankarmor.png";
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherited from ISpecialArmor, allows significant customization of damage
|
||||
* calculations.
|
||||
|
@ -80,24 +87,23 @@ public abstract class ItemPowerArmor extends ItemArmor
|
|||
}
|
||||
|
||||
public double getArmorDouble(EntityPlayer player, ItemStack stack) {
|
||||
double totalarmor = 0;
|
||||
double totalArmor = 0;
|
||||
NBTTagCompound props = ItemUtils.getMuseItemTag(stack);
|
||||
|
||||
double energy = ItemUtils.getAvailableEnergy(player);
|
||||
double energy = ItemUtils.getPlayerEnergy(player);
|
||||
double physArmor = Config.computeModularProperty(stack, ModularCommon.ARMOR_VALUE_PHYSICAL);
|
||||
double enerArmor = Config.computeModularProperty(stack, ModularCommon.ARMOR_VALUE_ENERGY);
|
||||
double enerConsum = Config.computeModularProperty(stack, ModularCommon.ARMOR_ENERGY_CONSUMPTION);
|
||||
|
||||
if (ItemUtils.itemHasModule(stack, ModularCommon.IRON_SHIELDING)
|
||||
&& energy > 0) {
|
||||
totalarmor = 3;
|
||||
}
|
||||
if (ItemUtils.itemHasModule(stack, ModularCommon.DIAMOND_SHIELDING)
|
||||
&& energy > 0) {
|
||||
totalarmor = 5;
|
||||
}
|
||||
totalArmor += physArmor;
|
||||
|
||||
// Make it so each armor piece can only contribute 1/4 of the armor
|
||||
if (energy > enerConsum) {
|
||||
totalArmor += enerArmor;
|
||||
}
|
||||
// Make it so each armor piece can only contribute 2/5 of the armor
|
||||
// value
|
||||
totalarmor = Math.min(6.25, totalarmor);
|
||||
return totalarmor;
|
||||
totalArmor = Math.min(10, totalArmor);
|
||||
return totalArmor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,10 +112,14 @@ public abstract class ItemPowerArmor extends ItemArmor
|
|||
*/
|
||||
@Override public void damageArmor(EntityLiving entity, ItemStack stack,
|
||||
DamageSource source, int damage, int slot) {
|
||||
NBTTagCompound itemProperties = ItemUtils
|
||||
.getMuseItemTag(stack);
|
||||
float drain = damage * itemProperties.getFloat("Energy per damage");
|
||||
onUse(drain, stack);
|
||||
NBTTagCompound itemProperties = ItemUtils.getMuseItemTag(stack);
|
||||
double enerConsum = Config.computeModularProperty(stack, ModularCommon.ARMOR_ENERGY_CONSUMPTION);
|
||||
double drain = enerConsum * damage;
|
||||
if (entity instanceof EntityPlayer) {
|
||||
ItemUtils.drainPlayerEnergy((EntityPlayer) entity, drain);
|
||||
} else {
|
||||
onUse(drain, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public Items getItemType() {
|
||||
|
|
|
@ -15,5 +15,5 @@ public class ItemPowerArmorHead extends ItemPowerArmor {
|
|||
setIconIndex(15);
|
||||
LanguageRegistry.addName(this, itemType.englishName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.machinemuse.general.MuseStringUtils;
|
||||
import net.machinemuse.general.gui.MuseIcon;
|
||||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.machinemuse.powersuits.common.Config.Items;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -11,11 +12,12 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumToolMaterial;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -28,6 +30,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
public class ItemPowerTool extends ItemTool
|
||||
implements
|
||||
IModularItem {
|
||||
private static final ItemStack ironPickaxe = new ItemStack(Item.pickaxeSteel);
|
||||
private static final ItemStack ironAxe = new ItemStack(Item.axeSteel);
|
||||
private static final ItemStack ironShovel = new ItemStack(Item.shovelSteel);
|
||||
private static final ItemStack diamondPick = new ItemStack(Item.pickaxeDiamond);
|
||||
|
||||
/**
|
||||
* Constructor. Takes information from the Config.Items enum.
|
||||
|
@ -48,7 +54,7 @@ public class ItemPowerTool extends ItemTool
|
|||
this.damageVsEntity = 1;
|
||||
setCreativeTab(Config.getCreativeTab());
|
||||
setIconIndex(10);
|
||||
setTextureFile("/icons.png");
|
||||
setTextureFile(MuseIcon.SEBK_ICON_PATH);
|
||||
setItemName(Config.Items.PowerTool.idName);
|
||||
LanguageRegistry.addName(this, Config.Items.PowerTool.englishName);
|
||||
}
|
||||
|
@ -66,6 +72,38 @@ public class ItemPowerTool extends ItemTool
|
|||
return getStrVsBlock(stack, block, 0);
|
||||
}
|
||||
|
||||
public static boolean canHarvestBlock(ItemStack stack, Block block, int meta) {
|
||||
if (ForgeHooks.canToolHarvestBlock(block, meta, ironPickaxe) && ItemUtils.itemHasModule(stack, ModularCommon.MODULE_PICKAXE)) {
|
||||
return true;
|
||||
} else if (ForgeHooks.canToolHarvestBlock(block, meta, ironShovel) && ItemUtils.itemHasModule(stack, ModularCommon.MODULE_SHOVEL)) {
|
||||
return true;
|
||||
} else if (ForgeHooks.canToolHarvestBlock(block, meta, ironAxe) && ItemUtils.itemHasModule(stack, ModularCommon.MODULE_AXE)) {
|
||||
return true;
|
||||
} else if (ForgeHooks.canToolHarvestBlock(block, meta, diamondPick)
|
||||
&& ItemUtils.itemHasModule(stack, ModularCommon.MODULE_DIAMOND_PICK_UPGRADE)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** FORGE: Overridden to allow custom tool effectiveness */
|
||||
@Override public float getStrVsBlock(ItemStack stack, Block block, int meta) {
|
||||
double harvestSpeed = 1;
|
||||
if (ForgeHooks.isToolEffective(ironPickaxe, block, meta) && ItemUtils.itemHasModule(stack, ModularCommon.MODULE_PICKAXE)) {
|
||||
harvestSpeed = Config.computeModularProperty(stack, ModularCommon.PICKAXE_HARVEST_SPEED);
|
||||
} else if (ForgeHooks.isToolEffective(ironShovel, block, meta) && ItemUtils.itemHasModule(stack, ModularCommon.MODULE_SHOVEL)) {
|
||||
harvestSpeed = Config.computeModularProperty(stack, ModularCommon.SHOVEL_HARVEST_SPEED);
|
||||
} else if (ForgeHooks.isToolEffective(ironAxe, block, meta) && ItemUtils.itemHasModule(stack, ModularCommon.MODULE_AXE)) {
|
||||
harvestSpeed = Config.computeModularProperty(stack, ModularCommon.AXE_HARVEST_SPEED);
|
||||
} else if (ForgeHooks.isToolEffective(diamondPick, block, meta) && ItemUtils.itemHasModule(stack, ModularCommon.MODULE_DIAMOND_PICK_UPGRADE)) {
|
||||
harvestSpeed = Config.computeModularProperty(stack, ModularCommon.PICKAXE_HARVEST_SPEED);
|
||||
} else {
|
||||
harvestSpeed = 1;
|
||||
}
|
||||
return (float) harvestSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current implementations of this method in child classes do not use the
|
||||
* entry argument beside stack. They just raise the damage on the stack.
|
||||
|
@ -81,12 +119,24 @@ public class ItemPowerTool extends ItemTool
|
|||
*/
|
||||
@Override public boolean onBlockDestroyed(ItemStack stack, World world,
|
||||
int blockID, int x, int y, int z,
|
||||
EntityLiving par7EntityLiving) {
|
||||
if (Block.blocksList[blockID]
|
||||
.getBlockHardness(world, x, y, z) != 0.0D) {
|
||||
stack.damageItem(1, par7EntityLiving);
|
||||
EntityLiving entity) {
|
||||
double drain = 1;
|
||||
Block block = Block.blocksList[blockID];
|
||||
int meta = 0;
|
||||
if (ForgeHooks.isToolEffective(diamondPick, block, meta)) {
|
||||
drain = Config.computeModularProperty(stack, ModularCommon.PICKAXE_ENERGY_CONSUMPTION);
|
||||
} else if (ForgeHooks.isToolEffective(ironShovel, block, meta)) {
|
||||
drain = Config.computeModularProperty(stack, ModularCommon.SHOVEL_ENERGY_CONSUMPTION);
|
||||
} else if (ForgeHooks.isToolEffective(ironAxe, block, meta)) {
|
||||
drain = Config.computeModularProperty(stack, ModularCommon.AXE_ENERGY_CONSUMPTION);
|
||||
} else {
|
||||
drain = 1;
|
||||
}
|
||||
if (entity instanceof EntityPlayer) {
|
||||
ItemUtils.drainPlayerEnergy((EntityPlayer) entity, drain);
|
||||
} else {
|
||||
onUse(drain, stack);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -124,32 +174,7 @@ public class ItemPowerTool extends ItemTool
|
|||
*/
|
||||
@Override public boolean getIsRepairable(ItemStack par1ItemStack,
|
||||
ItemStack par2ItemStack) {
|
||||
return this.toolMaterial.getToolCraftingMaterial() == par2ItemStack.itemID ? true
|
||||
: super.getIsRepairable(par1ItemStack, par2ItemStack);
|
||||
}
|
||||
|
||||
/** FORGE: Overridden to allow custom tool effectiveness */
|
||||
@Override public float getStrVsBlock(ItemStack stack, Block block, int meta) {
|
||||
|
||||
int shovelLevel = MinecraftForge.getBlockHarvestLevel(block, meta,
|
||||
"shovel");
|
||||
int axeLevel = MinecraftForge.getBlockHarvestLevel(block, meta, "axe");
|
||||
int pickaxeLevel = MinecraftForge.getBlockHarvestLevel(block, meta,
|
||||
"pickaxe");
|
||||
// TODO: Iron this out
|
||||
boolean shovelActive = shovelLevel > axeLevel
|
||||
&& shovelLevel > pickaxeLevel;
|
||||
boolean axeActive = axeLevel > pickaxeLevel;
|
||||
boolean pickaxeActive = pickaxeLevel > 1.0f;
|
||||
if (shovelActive) {
|
||||
return shovelLevel;
|
||||
} else if (axeActive) {
|
||||
return axeLevel;
|
||||
} else if (pickaxeActive) {
|
||||
return pickaxeLevel;
|
||||
} else {
|
||||
return 1.0F;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String formatInfo(String string, double value) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
|
||||
public class ItemUtils {
|
||||
public static final String NBTPREFIX = "mmmpsmod";
|
||||
|
||||
|
||||
public static List<GenericModule> getValidModulesForItem(
|
||||
EntityPlayer player, ItemStack stack) {
|
||||
List<GenericModule> validModules = new ArrayList();
|
||||
|
@ -28,7 +28,7 @@ public class ItemUtils {
|
|||
}
|
||||
return validModules;
|
||||
}
|
||||
|
||||
|
||||
public static boolean tagHasModule(NBTTagCompound tag, String moduleName) {
|
||||
if (tag.hasKey(moduleName)) {
|
||||
return true;
|
||||
|
@ -36,19 +36,19 @@ public class ItemUtils {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean itemHasModule(ItemStack stack, String moduleName) {
|
||||
return tagHasModule(getMuseItemTag(stack), moduleName);
|
||||
}
|
||||
|
||||
|
||||
public static void tagAddModule(NBTTagCompound tag, GenericModule module) {
|
||||
tag.setCompoundTag(module.getName(), module.getNewTag());
|
||||
}
|
||||
|
||||
|
||||
public static void itemAddModule(ItemStack stack, GenericModule module) {
|
||||
tagAddModule(getMuseItemTag(stack), module);
|
||||
}
|
||||
|
||||
|
||||
public static boolean removeModule(NBTTagCompound tag, String moduleName) {
|
||||
if (tag.hasKey(moduleName)) {
|
||||
tag.removeTag(moduleName);
|
||||
|
@ -57,11 +57,11 @@ public class ItemUtils {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean removeModule(ItemStack stack, String moduleName) {
|
||||
return removeModule(getMuseItemTag(stack), moduleName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets or creates stack.getTagCompound().getTag(NBTPREFIX)
|
||||
*
|
||||
|
@ -80,7 +80,7 @@ public class ItemUtils {
|
|||
stackTag = new NBTTagCompound();
|
||||
stack.setTagCompound(stackTag);
|
||||
}
|
||||
|
||||
|
||||
NBTTagCompound properties;
|
||||
if (stackTag.hasKey(NBTPREFIX)) {
|
||||
properties = stackTag
|
||||
|
@ -92,7 +92,7 @@ public class ItemUtils {
|
|||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scans a specified inventory for modular items.
|
||||
*
|
||||
|
@ -103,7 +103,7 @@ public class ItemUtils {
|
|||
*/
|
||||
public static List<ItemStack> getModularItemsInInventory(IInventory inv) {
|
||||
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack != null && stack.getItem() instanceof IModularItem) {
|
||||
|
@ -112,11 +112,11 @@ public class ItemUtils {
|
|||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
|
||||
public static List<ItemStack> getModularItemsInInventory(EntityPlayer player) {
|
||||
return getModularItemsInInventory(player.inventory);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scans a specified inventory for modular items.
|
||||
*
|
||||
|
@ -126,7 +126,7 @@ public class ItemUtils {
|
|||
*/
|
||||
public static List<Integer> getModularItemSlotsInInventory(IInventory inv) {
|
||||
ArrayList<Integer> slots = new ArrayList<Integer>();
|
||||
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack != null && stack.getItem() instanceof IModularItem) {
|
||||
|
@ -135,7 +135,7 @@ public class ItemUtils {
|
|||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempts to cast an item to IModularItem, returns null if fails
|
||||
*/
|
||||
|
@ -146,7 +146,7 @@ public class ItemUtils {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the player has a copy of all of the items in
|
||||
* workingUpgradeCost.
|
||||
|
@ -171,7 +171,7 @@ public class ItemUtils {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param workingUpgradeCost
|
||||
* @param inventory
|
||||
|
@ -197,7 +197,7 @@ public class ItemUtils {
|
|||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks the given NBTTag and returns the value if it exists, otherwise 0.
|
||||
*/
|
||||
|
@ -211,7 +211,7 @@ public class ItemUtils {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bouncer for succinctness. Checks the item's modular properties and
|
||||
* returns the value if it exists, otherwise 0.
|
||||
|
@ -219,7 +219,7 @@ public class ItemUtils {
|
|||
public static double getDoubleOrZero(ItemStack stack, String string) {
|
||||
return getDoubleOrZero(getMuseItemTag(stack), string);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the value of the given nbt tag, or removes it if the value would be
|
||||
* zero.
|
||||
|
@ -235,7 +235,7 @@ public class ItemUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the given itemstack's modular property, or removes it if the value
|
||||
* would be zero.
|
||||
|
@ -244,7 +244,7 @@ public class ItemUtils {
|
|||
double value) {
|
||||
setDoubleOrRemove(getMuseItemTag(stack), string, value);
|
||||
}
|
||||
|
||||
|
||||
public static String getStringOrNull(NBTTagCompound itemProperties,
|
||||
String key) {
|
||||
String value = null;
|
||||
|
@ -255,11 +255,11 @@ public class ItemUtils {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public static String getStringOrNull(ItemStack stack, String key) {
|
||||
return getStringOrNull(getMuseItemTag(stack), key);
|
||||
}
|
||||
|
||||
|
||||
public static void setStringOrNull(NBTTagCompound itemProperties,
|
||||
String key, String value) {
|
||||
if (itemProperties != null) {
|
||||
|
@ -270,20 +270,34 @@ public class ItemUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void setStringOrNull(ItemStack stack, String key, String value) {
|
||||
setStringOrNull(getMuseItemTag(stack),
|
||||
key, value);
|
||||
}
|
||||
|
||||
public static double getAvailableEnergy(EntityPlayer player) {
|
||||
|
||||
public static double getPlayerEnergy(EntityPlayer player) {
|
||||
double avail = 0;
|
||||
for (ItemStack stack : getModularItemsInInventory(player.inventory)) {
|
||||
avail += ((IModularItem) stack.getItem()).getJoules(stack);
|
||||
}
|
||||
return avail;
|
||||
}
|
||||
|
||||
|
||||
public static void drainPlayerEnergy(EntityPlayer player, double drainAmount) {
|
||||
for (ItemStack stack : getModularItemsInInventory(player.inventory)) {
|
||||
IModularItem item = getAsModular(stack.getItem());
|
||||
double joules = item.getJoules(stack);
|
||||
if (joules > drainAmount) {
|
||||
item.onUse(drainAmount, stack);
|
||||
break;
|
||||
} else {
|
||||
drainAmount -= joules;
|
||||
item.onUse(joules, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static double getMaxEnergy(EntityClientPlayerMP player) {
|
||||
double max = 0;
|
||||
for (ItemStack stack : getModularItemsInInventory(player.inventory)) {
|
||||
|
@ -291,7 +305,7 @@ public class ItemUtils {
|
|||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
public static boolean canStackTogether(ItemStack stack1, ItemStack stack2) {
|
||||
if (!isSameItem(stack1, stack2)) {
|
||||
return false;
|
||||
|
@ -303,7 +317,7 @@ public class ItemUtils {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean isSameItem(ItemStack stack1, ItemStack stack2) {
|
||||
if (stack1 == null || stack2 == null) {
|
||||
return false;
|
||||
|
@ -316,7 +330,7 @@ public class ItemUtils {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void transferStackWithChance(ItemStack itemsToGive,
|
||||
ItemStack destinationStack, double chanceOfSuccess) {
|
||||
int maxSize = destinationStack.getMaxStackSize();
|
||||
|
@ -328,16 +342,16 @@ public class ItemUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Set<Integer> giveOrDropItems(ItemStack itemsToGive,
|
||||
EntityPlayerMP player) {
|
||||
return giveOrDropItemWithChance(itemsToGive, player, 1.0);
|
||||
}
|
||||
|
||||
|
||||
public static Set<Integer> giveOrDropItemWithChance(ItemStack itemsToGive,
|
||||
EntityPlayerMP player, double chanceOfSuccess) {
|
||||
Set<Integer> slots = new HashSet<Integer>();
|
||||
|
||||
|
||||
// First try to add the items to existing stacks
|
||||
for (int i = 0; i < player.inventory.getSizeInventory()
|
||||
&& itemsToGive.stackSize > 0; i++) {
|
||||
|
@ -373,7 +387,7 @@ public class ItemUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return slots;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,31 +15,39 @@ public abstract class ModularCommon {
|
|||
*/
|
||||
public static final String MAXIMUM_ENERGY = "Maximum Energy";
|
||||
public static final String CURRENT_ENERGY = "Current Energy";
|
||||
public static final String ARMOR_WEIGHT = "Armor Weight";
|
||||
public static final String ARMOR_VALUE_PHYSICAL = "Armor (Physical)";
|
||||
public static final String ARMOR_VALUE_ENERGY = "Armor (Energy)";
|
||||
public static final String ARMOR_ENERGY_CONSUMPTION = "Energy Per Damage";
|
||||
public static final String WEIGHT = "Weight";
|
||||
public static final String ARMOR_DURABILITY = "Armor Durability";
|
||||
public static final String ARMOR_VALUE = "Armor Value";
|
||||
public static final String SHOVEL_HARVEST_SPEED = "Shovel Harvest Speed";
|
||||
public static final String SHOVEL_ENERGY_CONSUMPTION = "Shovel Energy Consumption";
|
||||
public static final String AXE_HARVEST_SPEED = "Axe Harvest Speed";
|
||||
public static final String PICKAXE_HARVEST_SPEED = "Pickaxe Harvest Speed";
|
||||
public static final String SHOVEL_ENERGY_CONSUMPTION = "Shovel Energy Consumption";
|
||||
public static final String AXE_ENERGY_CONSUMPTION = "Axe Energy Consumption";
|
||||
public static final String PICKAXE_ENERGY_CONSUMPTION = "Pickaxe Energy Consumption";
|
||||
public static final String BATTERY_WEIGHT = "Battery Weight";
|
||||
public static final String SPRINT_ENERGY_CONSUMPTION = "Sprint Energy Consumption";
|
||||
public static final String SPRINT_SPEED_MULTIPLIER = "Sprint Speed Multiplier";
|
||||
public static final String SPRINT_FOOD_COMPENSATION = "Exhaustion Compensation";
|
||||
public static final String JUMP_ENERGY_CONSUMPTION = "Jump Energy Consumption";
|
||||
public static final String JUMP_MULTIPLIER = "Jump Multiplier";
|
||||
public static final String SHOCK_ABSORB_MULTIPLIER = "Distance Reduction";
|
||||
public static final String SHOCK_ABSORB_ENERGY_CONSUMPTION = "Energy consumption";
|
||||
|
||||
/**
|
||||
* Tradeoffs for module properties
|
||||
*/
|
||||
public static final String TRADEOFF_ARMOR_THICKNESS = "Armor Thickness";
|
||||
public static final String TRADEOFF_BATTERY_SIZE = "Battery Size";
|
||||
public static final String TRADEOFF_OVERCLOCK = "Overclock";
|
||||
/**
|
||||
* Module names
|
||||
*/
|
||||
public static final String SHOVEL = "Shovel";
|
||||
public static final String AXE = "Axe";
|
||||
public static final String PICKAXE = "Pickaxe";
|
||||
public static final String BATTERY_BASIC = "Basic Battery";
|
||||
public static final String IRON_SHIELDING = "Iron Shielding";
|
||||
public static final String DIAMOND_SHIELDING = "Diamond Shielding";
|
||||
public static final String MODULE_SHOVEL = "Shovel";
|
||||
public static final String MODULE_AXE = "Axe";
|
||||
public static final String MODULE_PICKAXE = "Pickaxe";
|
||||
public static final String MODULE_BATTERY_BASIC = "Basic Battery";
|
||||
public static final String MODULE_IRON_PLATING = "Iron Plating";
|
||||
public static final String MODULE_DIAMOND_PLATING = "Diamond Plating";
|
||||
public static final String MODULE_ENERGY_SHIELD = "Energy Shield";
|
||||
public static final String MODULE_DIAMOND_PICK_UPGRADE = "Diamond Drill Upgrade";
|
||||
public static final String MODULE_SPRINT_ASSIST = "Sprint Assist";
|
||||
public static final String MODULE_JUMP_ASSIST = "Jump Assist";
|
||||
public static final String MODULE_SHOCK_ABSORBER = "Shock Absorber";
|
||||
|
||||
/**
|
||||
* Categories for modules
|
||||
|
@ -48,6 +56,7 @@ public abstract class ModularCommon {
|
|||
public static final String CATEGORY_ENERGY = "Energy";
|
||||
public static final String CATEGORY_TOOL = "Tool";
|
||||
public static final String CATEGORY_WEAPON = "Weapon";
|
||||
public static final String CATEGORY_MOVEMENT = "Movement";
|
||||
|
||||
/**
|
||||
* Adds information to the item's tooltip when 'getting' it.
|
||||
|
@ -133,24 +142,4 @@ public abstract class ModularCommon {
|
|||
public static double getTotalWeight(ItemStack stack) {
|
||||
return Config.computeModularProperty(stack, ModularCommon.WEIGHT);
|
||||
}
|
||||
|
||||
public static double getShovelPowerConsumption(ItemStack stack) {
|
||||
NBTTagCompound itemTag = ItemUtils.getMuseItemTag(stack);
|
||||
double energyConsumption = 10;
|
||||
if (ItemUtils.tagHasModule(itemTag, SHOVEL)) {
|
||||
NBTTagCompound moduleTag = itemTag.getCompoundTag(SHOVEL);
|
||||
energyConsumption += 990 * getOrSetModuleProperty(moduleTag, TRADEOFF_OVERCLOCK, 0.1);
|
||||
}
|
||||
return energyConsumption;
|
||||
}
|
||||
|
||||
public static double getShovelHarvestSpeed(ItemStack stack) {
|
||||
NBTTagCompound itemTag = ItemUtils.getMuseItemTag(stack);
|
||||
double harvestSpeed = 2;
|
||||
if (ItemUtils.tagHasModule(itemTag, SHOVEL)) {
|
||||
NBTTagCompound moduleTag = itemTag.getCompoundTag(SHOVEL);
|
||||
harvestSpeed += 18 * getOrSetModuleProperty(moduleTag, TRADEOFF_OVERCLOCK, 0.1);
|
||||
}
|
||||
return harvestSpeed;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,18 +23,18 @@ import cpw.mods.fml.common.network.Player;
|
|||
*
|
||||
*/
|
||||
public abstract class MusePacket {
|
||||
|
||||
|
||||
protected static final int READ_ERROR = -150;
|
||||
|
||||
|
||||
protected Player player;
|
||||
|
||||
|
||||
protected ByteArrayOutputStream bytes;
|
||||
|
||||
|
||||
protected Packet250CustomPayload packet;
|
||||
protected DataOutputStream dataout;
|
||||
protected DataInputStream datain;
|
||||
protected int id;
|
||||
|
||||
|
||||
protected MusePacket(Player player) {
|
||||
this.player = player;
|
||||
this.bytes = new ByteArrayOutputStream();
|
||||
|
@ -42,12 +42,12 @@ public abstract class MusePacket {
|
|||
int id = MusePacketHandler.getTypeID(this);
|
||||
writeInt(id);
|
||||
}
|
||||
|
||||
|
||||
protected MusePacket(Player player, DataInputStream data) {
|
||||
this.player = player;
|
||||
this.datain = data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the MC packet associated with this MusePacket
|
||||
*
|
||||
|
@ -58,36 +58,55 @@ public abstract class MusePacket {
|
|||
return new Packet250CustomPayload(Config.getNetworkChannelName(),
|
||||
bytes.toByteArray());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by the network manager since it does all the packet mapping
|
||||
*
|
||||
* @param player2
|
||||
*/
|
||||
public abstract void handleClient(EntityClientPlayerMP player);
|
||||
|
||||
|
||||
public abstract void handleServer(EntityPlayerMP player);
|
||||
|
||||
|
||||
public int readInt() {
|
||||
try {
|
||||
int read = datain.readInt();
|
||||
return read;
|
||||
} catch (IOException e) {
|
||||
MuseLogger.logError("PROBLEM WRITING INT TO PACKET D:");
|
||||
MuseLogger.logError("PROBLEM READING INT FROM PACKET D:");
|
||||
e.printStackTrace();
|
||||
return READ_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void writeInt(int i) {
|
||||
try {
|
||||
dataout.writeInt(i);
|
||||
} catch (IOException e) {
|
||||
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public double readDouble() {
|
||||
try {
|
||||
double read = datain.readDouble();
|
||||
return read;
|
||||
} catch (IOException e) {
|
||||
MuseLogger.logError("PROBLEM READING DOUBLE FROM PACKET D:");
|
||||
e.printStackTrace();
|
||||
return READ_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
public void writeDouble(double i) {
|
||||
try {
|
||||
dataout.writeDouble(i);
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a ItemStack from the InputStream
|
||||
*/
|
||||
|
@ -96,7 +115,7 @@ public abstract class MusePacket {
|
|||
ItemStack stack = null;
|
||||
try {
|
||||
short itemID = datain.readShort();
|
||||
|
||||
|
||||
if (itemID >= 0)
|
||||
{
|
||||
byte stackSize = datain.readByte();
|
||||
|
@ -104,14 +123,14 @@ public abstract class MusePacket {
|
|||
stack = new ItemStack(itemID, stackSize, damageAmount);
|
||||
stack.stackTagCompound = readNBTTagCompound();
|
||||
}
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
MuseLogger.logError("Problem reading itemstack D:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes the ItemStack's ID (short), then size (byte), then damage. (short)
|
||||
*/
|
||||
|
@ -128,13 +147,13 @@ public abstract class MusePacket {
|
|||
dataout.writeByte(stack.stackSize);
|
||||
dataout.writeShort(stack.getItemDamage());
|
||||
NBTTagCompound nbt = null;
|
||||
|
||||
|
||||
if (stack.getItem().isDamageable()
|
||||
|| stack.getItem().getShareTag())
|
||||
{
|
||||
nbt = stack.stackTagCompound;
|
||||
}
|
||||
|
||||
|
||||
writeNBTTagCompound(nbt);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -142,14 +161,14 @@ public abstract class MusePacket {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads a compressed NBTTagCompound from the InputStream
|
||||
*/
|
||||
public NBTTagCompound readNBTTagCompound() throws IOException
|
||||
{
|
||||
short length = datain.readShort();
|
||||
|
||||
|
||||
if (length < 0)
|
||||
{
|
||||
return null;
|
||||
|
@ -161,7 +180,7 @@ public abstract class MusePacket {
|
|||
return CompressedStreamTools.decompress(fullData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes a compressed NBTTagCompound to the OutputStream
|
||||
*/
|
||||
|
@ -179,7 +198,7 @@ public abstract class MusePacket {
|
|||
dataout.write(compressednbt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes a String to the DataOutputStream
|
||||
*/
|
||||
|
@ -193,7 +212,7 @@ public abstract class MusePacket {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads a string from a packet
|
||||
*/
|
||||
|
@ -202,7 +221,7 @@ public abstract class MusePacket {
|
|||
String read = null;
|
||||
try {
|
||||
short length = datain.readShort();
|
||||
|
||||
|
||||
if (length > maxlength)
|
||||
{
|
||||
throw new IOException(
|
||||
|
@ -217,12 +236,12 @@ public abstract class MusePacket {
|
|||
else
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
builder.append(datain.readChar());
|
||||
}
|
||||
|
||||
|
||||
read = builder.toString();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -230,5 +249,5 @@ public abstract class MusePacket {
|
|||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -35,37 +35,37 @@ public class MusePacketHandler implements IPacketHandler {
|
|||
addPacketType(1, MusePacketInventoryRefresh.class);
|
||||
addPacketType(2, MusePacketInstallModuleRequest.class);
|
||||
addPacketType(3, MusePacketSalvageModuleRequest.class);
|
||||
|
||||
addPacketType(4, MusePacketTweakRequest.class);
|
||||
|
||||
NetworkRegistry.instance().registerChannel(this,
|
||||
Config.getNetworkChannelName());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public static BiMap<Integer, Constructor<? extends MusePacket>> packetConstructors = HashBiMap
|
||||
.create();
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkManager manager,
|
||||
|
||||
@Override public void onPacketData(INetworkManager manager,
|
||||
Packet250CustomPayload payload, Player player) {
|
||||
|
||||
|
||||
if (payload.channel.equals(Config.getNetworkChannelName())) {
|
||||
|
||||
|
||||
MusePacket repackaged = repackage(payload, player);
|
||||
|
||||
|
||||
if (repackaged != null) {
|
||||
|
||||
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
|
||||
if (side == Side.CLIENT) {
|
||||
repackaged.handleClient((EntityClientPlayerMP) player);
|
||||
} else if (side == Side.SERVER) {
|
||||
repackaged.handleServer((EntityPlayerMP) player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static MusePacket repackage(Packet250CustomPayload payload,
|
||||
Player player) {
|
||||
MusePacket repackaged = null;
|
||||
|
@ -74,20 +74,20 @@ public class MusePacketHandler implements IPacketHandler {
|
|||
EntityPlayer target = (EntityPlayer) player;
|
||||
int packetType;
|
||||
try {
|
||||
|
||||
|
||||
packetType = data.readInt();
|
||||
repackaged = useConstructor(packetConstructors.get(packetType),
|
||||
data, player);
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
MuseLogger.logError("PROBLEM READING PACKET TYPE D:");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return repackaged;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @return
|
||||
|
@ -105,7 +105,7 @@ public class MusePacketHandler implements IPacketHandler {
|
|||
}
|
||||
return -150;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the constructor of the given object. Keep in sync with
|
||||
* useConstructor.
|
||||
|
@ -120,7 +120,7 @@ public class MusePacketHandler implements IPacketHandler {
|
|||
throws NoSuchMethodException, SecurityException {
|
||||
return packetType.getConstructor(DataInputStream.class, Player.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new instance of the object, created via the constructor in
|
||||
* question. Keep in sync with getConstructor.
|
||||
|
@ -148,7 +148,7 @@ public class MusePacketHandler implements IPacketHandler {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean addPacketType(int id,
|
||||
Class<? extends MusePacket> packetType) {
|
||||
try {
|
||||
|
@ -166,5 +166,5 @@ public class MusePacketHandler implements IPacketHandler {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
public class MusePacketInstallModuleRequest extends MusePacket {
|
||||
protected ItemStack stack;
|
||||
protected int itemSlot;
|
||||
protected String tinkerName;
|
||||
protected String moduleName;
|
||||
|
||||
/**
|
||||
* Constructor for sending this packet.
|
||||
|
@ -39,13 +39,13 @@ public class MusePacketInstallModuleRequest extends MusePacket {
|
|||
* Player making the request
|
||||
* @param itemSlot
|
||||
* Slot containing the item for which the upgrade is requested
|
||||
* @param tinkerName
|
||||
* @param moduleName
|
||||
*/
|
||||
public MusePacketInstallModuleRequest(Player player, int itemSlot,
|
||||
String tinkerName) {
|
||||
String moduleName) {
|
||||
super(player);
|
||||
writeInt(itemSlot);
|
||||
writeString(tinkerName);
|
||||
writeString(moduleName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ public class MusePacketInstallModuleRequest extends MusePacket {
|
|||
public MusePacketInstallModuleRequest(DataInputStream data, Player player) {
|
||||
super(player, data);
|
||||
itemSlot = readInt();
|
||||
tinkerName = readString(64);
|
||||
moduleName = readString(64);
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.SERVER) {
|
||||
EntityPlayerMP srvplayer = (EntityPlayerMP) player;
|
||||
|
@ -69,10 +69,10 @@ public class MusePacketInstallModuleRequest extends MusePacket {
|
|||
|
||||
@Override
|
||||
public void handleServer(EntityPlayerMP playerEntity) {
|
||||
if (tinkerName != null) {
|
||||
if (moduleName != null) {
|
||||
InventoryPlayer inventory = playerEntity.inventory;
|
||||
int entityId = playerEntity.entityId;
|
||||
GenericModule moduleType = Config.getModule(tinkerName);
|
||||
GenericModule moduleType = Config.getModule(moduleName);
|
||||
List<ItemStack> cost = moduleType.getInstallCost();
|
||||
|
||||
if (ItemUtils.hasInInventory(cost, playerEntity.inventory)) {
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package net.machinemuse.powersuits.network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.machinemuse.powersuits.item.ItemUtils;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
/**
|
||||
* Packet for requesting to purchase an upgrade. Player-to-server. Server
|
||||
* decides whether it is a valid upgrade or not and replies with an associated
|
||||
* inventoryrefresh packet.
|
||||
*
|
||||
* @author MachineMuse
|
||||
*
|
||||
*/
|
||||
public class MusePacketTweakRequest extends MusePacket {
|
||||
protected ItemStack stack;
|
||||
protected int itemSlot;
|
||||
protected String moduleName;
|
||||
protected String tweakName;
|
||||
protected double tweakValue;
|
||||
|
||||
/**
|
||||
* Constructor for sending this packet.
|
||||
*
|
||||
* @param player
|
||||
* Player making the request
|
||||
* @param itemSlot
|
||||
* Slot containing the item for which the upgrade is requested
|
||||
* @param tinkerName
|
||||
*/
|
||||
public MusePacketTweakRequest(Player player, int itemSlot,
|
||||
String moduleName, String tweakName, double tweakValue) {
|
||||
super(player);
|
||||
writeInt(itemSlot);
|
||||
writeString(moduleName);
|
||||
writeString(tweakName);
|
||||
writeDouble(tweakValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for receiving this packet.
|
||||
*
|
||||
* @param player
|
||||
* @param data
|
||||
* @throws IOException
|
||||
*
|
||||
*/
|
||||
public MusePacketTweakRequest(DataInputStream data, Player player) {
|
||||
super(player, data);
|
||||
itemSlot = readInt();
|
||||
moduleName = readString(64);
|
||||
tweakName = readString(64);
|
||||
tweakValue = readDouble();
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
if (side == Side.SERVER) {
|
||||
EntityPlayerMP srvplayer = (EntityPlayerMP) player;
|
||||
stack = srvplayer.inventory.getStackInSlot(itemSlot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void handleServer(EntityPlayerMP playerEntity) {
|
||||
if (moduleName != null && tweakName != null) {
|
||||
InventoryPlayer inventory = playerEntity.inventory;
|
||||
int entityId = playerEntity.entityId;
|
||||
NBTTagCompound itemTag = ItemUtils.getMuseItemTag(stack);
|
||||
if (ItemUtils.tagHasModule(itemTag, moduleName)) {
|
||||
NBTTagCompound moduleTag = itemTag.getCompoundTag(moduleName);
|
||||
tweakValue = Math.min(1, Math.max(0, tweakValue));
|
||||
moduleTag.setDouble(tweakName, tweakValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void handleClient(EntityClientPlayerMP player) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -5,5 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
public interface IModuleProperty {
|
||||
public double computeProperty(NBTTagCompound moduleTag);
|
||||
|
||||
public String getString(NBTTagCompound moduleTag);
|
||||
public String getName();
|
||||
public String getUnits();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.machinemuse.powersuits.powermodule;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.machinemuse.powersuits.item.ItemUtils;
|
||||
|
@ -9,7 +8,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ModularProperty implements IModularProperty {
|
||||
protected Map<String, IModuleProperty> modulesWithProperty;
|
||||
protected Map<String, List<IModuleProperty>> modulesWithProperty;
|
||||
protected String name;
|
||||
protected double baseValue;
|
||||
|
||||
|
@ -22,27 +21,24 @@ public class ModularProperty implements IModularProperty {
|
|||
@Override public double computeProperty(ItemStack stack) {
|
||||
double value = baseValue;
|
||||
NBTTagCompound itemTag = ItemUtils.getMuseItemTag(stack);
|
||||
for (Entry<String, IModuleProperty> entry : modulesWithProperty.entrySet()) {
|
||||
for (Entry<String, List<IModuleProperty>> entry : modulesWithProperty.entrySet()) {
|
||||
if (itemTag.hasKey(entry.getKey())) {
|
||||
NBTTagCompound moduleTag = itemTag.getCompoundTag(entry.getKey());
|
||||
value += entry.getValue().computeProperty(moduleTag);
|
||||
for (IModuleProperty property : entry.getValue()) {
|
||||
NBTTagCompound moduleTag = itemTag.getCompoundTag(entry.getKey());
|
||||
value += property.computeProperty(moduleTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void addModuleWithProperty(String moduleName, IModuleProperty property) {
|
||||
modulesWithProperty.put(moduleName, property);
|
||||
if (!modulesWithProperty.containsKey(moduleName)) {
|
||||
modulesWithProperty.put(moduleName, new LinkedList());
|
||||
}
|
||||
List<IModuleProperty> moduleProperties = modulesWithProperty.get(moduleName);
|
||||
moduleProperties.add(property);
|
||||
}
|
||||
|
||||
public Map<String, IModuleProperty> getModulesWithProperty() {
|
||||
return modulesWithProperty;
|
||||
}
|
||||
|
||||
public void setModulesWithProperty(Map<String, IModuleProperty> modulesWithProperty) {
|
||||
this.modulesWithProperty = modulesWithProperty;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.machinemuse.powersuits.powermodule;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import net.machinemuse.general.MuseStringUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ModulePropertyComplex implements IModuleProperty {
|
||||
|
@ -36,10 +35,11 @@ public class ModulePropertyComplex implements IModuleProperty {
|
|||
return property;
|
||||
}
|
||||
|
||||
@Override public String getString(NBTTagCompound moduleTag) {
|
||||
return name
|
||||
+ ":\t"
|
||||
+ MuseStringUtils.formatNumberShort(computeProperty(moduleTag))
|
||||
+ units;
|
||||
@Override public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override public String getUnits() {
|
||||
return units;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.machinemuse.powersuits.powermodule;
|
||||
|
||||
import net.machinemuse.general.MuseStringUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ModulePropertySimple implements IModuleProperty {
|
||||
|
@ -30,10 +29,11 @@ public class ModulePropertySimple implements IModuleProperty {
|
|||
return property;
|
||||
}
|
||||
|
||||
@Override public String getString(NBTTagCompound moduleTag) {
|
||||
return name
|
||||
+ ":\t"
|
||||
+ MuseStringUtils.formatNumberShort(computeProperty(moduleTag))
|
||||
+ units;
|
||||
@Override public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override public String getUnits() {
|
||||
return units;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,18 @@ package net.machinemuse.powersuits.tick;
|
|||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.machinemuse.powersuits.common.MuseLogger;
|
||||
import net.machinemuse.powersuits.item.IModularItem;
|
||||
import net.machinemuse.powersuits.item.ItemUtils;
|
||||
import net.machinemuse.powersuits.item.ModularCommon;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
/**
|
||||
* Tick handler for Player update step. tickStart() is queued before the entity
|
||||
|
@ -28,19 +32,36 @@ import cpw.mods.fml.common.TickType;
|
|||
public class PlayerTickHandler implements ITickHandler {
|
||||
@Override public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
EntityPlayer player = toPlayer(tickData[0]);
|
||||
double totalEnergy = 0;
|
||||
double totalEnergy = ItemUtils.getPlayerEnergy(player);
|
||||
double totalWeight = 0;
|
||||
double weightCapacity = 25000;
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
for (ItemStack item : ItemUtils.getModularItemsInInventory(player)) {
|
||||
totalWeight += ModularCommon.getTotalWeight(item);
|
||||
for (ItemStack stack : ItemUtils.getModularItemsInInventory(player)) {
|
||||
totalWeight += ModularCommon.getTotalWeight(stack);
|
||||
}
|
||||
if (player.isSprinting()) {
|
||||
// idk why this is the pants slot
|
||||
ItemStack pants = player.getCurrentArmor(1);
|
||||
if (pants != null && pants.getItem() instanceof IModularItem && ItemUtils.itemHasModule(pants, ModularCommon.MODULE_SPRINT_ASSIST)) {
|
||||
double sprintCost = Config.computeModularProperty(pants, ModularCommon.SPRINT_ENERGY_CONSUMPTION);
|
||||
if (sprintCost < totalEnergy) {
|
||||
totalEnergy -= sprintCost;
|
||||
ItemUtils.drainPlayerEnergy(player, sprintCost);
|
||||
double sprintBoost = Config.computeModularProperty(pants, ModularCommon.SPRINT_SPEED_MULTIPLIER);
|
||||
player.landMovementFactor *= sprintBoost;
|
||||
player.jumpMovementFactor *= sprintBoost;
|
||||
double movement = Math.round(Math.sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ) * 100.0F);
|
||||
double exhaustionComp = Config.computeModularProperty(pants, ModularCommon.SPRINT_FOOD_COMPENSATION);
|
||||
player.addExhaustion((float) (-0.0001 * movement * exhaustionComp));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (totalWeight > weightCapacity) {
|
||||
player.motionX *= weightCapacity / totalWeight;
|
||||
player.motionZ *= weightCapacity / totalWeight;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
EntityPlayer player = toPlayer(tickData[0]);
|
||||
List<ItemStack> stacks = ItemUtils
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RenderTickHandler implements ITickHandler {
|
|||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player != null) {
|
||||
double currEnergy = ItemUtils.getAvailableEnergy(player);
|
||||
double currEnergy = ItemUtils.getPlayerEnergy(player);
|
||||
double maxEnergy = ItemUtils.getMaxEnergy(player);
|
||||
if (maxEnergy > 0) {
|
||||
String currStr = MuseStringUtils.formatNumberShort(currEnergy);
|
||||
|
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
BIN
watericons.png
Normal file
BIN
watericons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Loading…
Reference in a new issue