Added Solar Generator Module.
This commit is contained in:
parent
1adced8817
commit
79b7c21e13
5 changed files with 39 additions and 0 deletions
|
@ -59,6 +59,7 @@ public abstract class ModularCommon {
|
|||
public static final String WALKING_ENERGY_CONSUMPTION = "Walking Energy Consumption";
|
||||
public static final String WALKING_SPEED_MULTIPLIER = "Walking Speed Multiplier";
|
||||
public static final String EATING_ENERGY_CONSUMPTION = "Eating Energy Consumption";
|
||||
public static final String SOLAR_ENERGY_GENERATION = "Solar Energy Generation";
|
||||
|
||||
/**
|
||||
* Module names
|
||||
|
@ -94,6 +95,7 @@ public abstract class ModularCommon {
|
|||
public static final String MODULE_ACTIVE_CAMOUFLAGE = "Active Camouflage";
|
||||
public static final String MODULE_FLIGHT_CONTROL = "Flight Control";
|
||||
public static final String MODULE_AUTO_FEEDER = "Auto-Feeder";
|
||||
public static final String MODULE_SOLAR_GENERATOR = "Solar Generator";
|
||||
public static final String CITIZEN_JOE_STYLE = "Citizen Joe Style";
|
||||
/**
|
||||
* Categories for modules
|
||||
|
|
|
@ -245,6 +245,13 @@ public class Config {
|
|||
// .addInstallCost(copyAndResize(ItemComponent.fieldEmitter, 2));
|
||||
// addModule(module);
|
||||
|
||||
module = new PowerModule(ModularCommon.MODULE_SOLAR_GENERATOR, HEADONLY, MuseIcon.NEXUS_1_GREEN, ModularCommon.CATEGORY_ENERGY)
|
||||
.setDescription("Let the sun power your adventures.")
|
||||
.addBaseProperty(ModularCommon.SOLAR_ENERGY_GENERATION, 1)
|
||||
.addInstallCost(copyAndResize(ItemComponent.solarPanel, 1))
|
||||
.addInstallCost(copyAndResize(ItemComponent.controlCircuit, 2));
|
||||
addModule(module);
|
||||
|
||||
module = new PowerModule(ModularCommon.MODULE_AUTO_FEEDER, HEADONLY, MuseIcon.NEXUS_1_BLUE, ModularCommon.CATEGORY_ENVIRONMENTAL)
|
||||
.setDescription("Why eat when your armor can do it for you.")
|
||||
.setToggleable(true)
|
||||
|
|
|
@ -35,6 +35,7 @@ public class RecipeManager {
|
|||
ItemStack rosered = new ItemStack(Item.dyePowder, 1, 1);
|
||||
ItemStack cactusgreen = new ItemStack(Item.dyePowder, 1, 2);
|
||||
ItemStack enderPearl = new ItemStack(Item.enderPearl);
|
||||
ItemStack stone = new ItemStack(Block.stone);
|
||||
|
||||
if (ModCompatability.vanillaRecipesEnabled()) {
|
||||
GameRegistry.addRecipe(ItemComponent.basicPlating,
|
||||
|
@ -172,6 +173,13 @@ public class RecipeManager {
|
|||
'E', ItemComponent.solenoid,
|
||||
'G', glowstone,
|
||||
'F', ItemComponent.fieldEmitter);
|
||||
GameRegistry.addRecipe(ItemComponent.solarPanel,
|
||||
"GGG",
|
||||
"BBB",
|
||||
"SSS",
|
||||
'G', glass,
|
||||
'B', lapis,
|
||||
'S', stone);
|
||||
|
||||
}
|
||||
if (ModCompatability.UERecipesEnabled() && ModCompatability.isBasicComponentsLoaded()) {
|
||||
|
|
|
@ -36,6 +36,7 @@ public class ItemComponent extends Item {
|
|||
public static ItemStack controlCircuit;
|
||||
public static ItemStack myofiberGel;
|
||||
public static ItemStack artificialMuscle;
|
||||
public static ItemStack solarPanel;
|
||||
|
||||
public ItemComponent() {
|
||||
super(Config.getAssignedItemID(Config.Items.PowerArmorComponent));
|
||||
|
@ -113,6 +114,8 @@ public class ItemComponent extends Item {
|
|||
artificialMuscle = addComponent("componentArtificialMuscle", "Artificial Muscle",
|
||||
"An electrical, artificial muscle, with less range of movement than human muscle but orders of magnitude more strength.",
|
||||
MuseIcon.ARTIFICIAL_MUSCLE);
|
||||
solarPanel = addComponent("componentSolarPanel", "Solar Panel",
|
||||
"A light sensitive device that will generate electricity from the sun.", MuseIcon.INDICATOR_1_BLUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.FoodStats;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
|
@ -84,11 +85,13 @@ public class PlayerTickHandler implements ITickHandler {
|
|||
boolean hasInvis = false;
|
||||
boolean hasFlightControl = false;
|
||||
boolean hasFeeder = false;
|
||||
boolean hasSolarGeneration = false;
|
||||
|
||||
if (helmet != null && helmet.getItem() instanceof IModularItem) {
|
||||
hasNightVision = MuseItemUtils.itemHasActiveModule(helmet, ModularCommon.MODULE_NIGHT_VISION);
|
||||
hasFlightControl = MuseItemUtils.itemHasActiveModule(helmet, ModularCommon.MODULE_FLIGHT_CONTROL);
|
||||
hasFeeder = MuseItemUtils.itemHasActiveModule(helmet, ModularCommon.MODULE_AUTO_FEEDER);
|
||||
hasSolarGeneration = MuseItemUtils.itemHasActiveModule(helmet, ModularCommon.MODULE_SOLAR_GENERATOR);
|
||||
if (helmet.getTagCompound().hasKey("ench")) {
|
||||
helmet.getTagCompound().removeTag("ench");
|
||||
}
|
||||
|
@ -378,6 +381,22 @@ public class PlayerTickHandler implements ITickHandler {
|
|||
totalEnergyDrain += eatingEnergyConsumption*foodNeeded;
|
||||
}
|
||||
}
|
||||
//Solar Generator
|
||||
if (hasSolarGeneration) {
|
||||
World world = player.worldObj;
|
||||
int xCoord = MathHelper.floor_double(player.posX);
|
||||
int zCoord = MathHelper.floor_double(player.posZ);
|
||||
boolean isRaining = false, canRain = true;
|
||||
if (world.getTotalWorldTime() % 20 == 0) {
|
||||
canRain = world.getWorldChunkManager().getBiomeGenAt(xCoord, zCoord).getIntRainfall() > 0;
|
||||
}
|
||||
isRaining = canRain && (world.isRaining() || world.isThundering()); //Make sure you're not in desert - Thanks cpw :P
|
||||
boolean sunVisible = world.isDaytime() && !isRaining && world.canBlockSeeTheSky(xCoord, MathHelper.floor_double(player.posY) + 1, zCoord);
|
||||
if (!world.isRemote && !world.provider.hasNoSky && sunVisible && (world.getTotalWorldTime() % 100) == 0) {
|
||||
MuseItemUtils.givePlayerEnergy(player, ModuleManager.computeModularProperty(helmet, ModularCommon.SOLAR_ENERGY_GENERATION));
|
||||
player.sendChatToPlayer("Charging 1 J");
|
||||
}
|
||||
}
|
||||
|
||||
// Update fall distance for damage, energy drain, and
|
||||
// exhaustion this tick
|
||||
|
|
Loading…
Reference in a new issue