Finished Cloaking Device
This commit is contained in:
parent
0ac12866e2
commit
199bbf28b6
4 changed files with 122 additions and 9 deletions
|
@ -1,5 +1,9 @@
|
|||
package techreborn;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
|
||||
import cpw.mods.fml.client.event.ConfigChangedEvent;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
|
@ -9,14 +13,15 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
|||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import erogenousbeef.coreTR.multiblock.MultiblockEventHandler;
|
||||
import erogenousbeef.coreTR.multiblock.MultiblockServerTickHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
import techreborn.achievement.TRAchievements;
|
||||
import techreborn.api.TechRebornItems;
|
||||
import techreborn.api.recipe.RecipeHandler;
|
||||
import techreborn.api.recipe.recipeConfig.RecipeConfigManager;
|
||||
import techreborn.client.GuiHandler;
|
||||
|
@ -24,7 +29,12 @@ import techreborn.command.TechRebornDevCommand;
|
|||
import techreborn.compat.CompatManager;
|
||||
import techreborn.compat.ICompatModule;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.*;
|
||||
import techreborn.events.TRTickHandler;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModFluids;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.init.ModParts;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.packets.PacketHandler;
|
||||
import techreborn.packets.PacketPipeline;
|
||||
|
@ -34,8 +44,6 @@ import techreborn.util.LogHelper;
|
|||
import techreborn.util.VersionChecker;
|
||||
import techreborn.world.TROreGen;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = ModInfo.MOD_DEPENDENCUIES, guiFactory = ModInfo.GUI_FACTORY_CLASS)
|
||||
public class Core {
|
||||
public static ConfigTechReborn config;
|
||||
|
@ -106,6 +114,7 @@ public class Core {
|
|||
IDSUManager.INSTANCE = new IDSUManager();
|
||||
MinecraftForge.EVENT_BUS.register(IDSUManager.INSTANCE);
|
||||
FMLCommonHandler.instance().bus().register(new MultiblockServerTickHandler());
|
||||
FMLCommonHandler.instance().bus().register(new TRTickHandler(TickEvent.Type.PLAYER, Side.SERVER, Phase.START));
|
||||
packetPipeline.initalise();
|
||||
LogHelper.info("Initialization Complete");
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ public class ConfigTechReborn {
|
|||
public static int LapotronicOrbMaxCharge;
|
||||
public static int OmniToolCharge;
|
||||
public static int RockCutterCharge;
|
||||
public static int CloakingDeviceCharge;
|
||||
public static int GravityCharge;
|
||||
public static int CentrifugeCharge;
|
||||
public static int ThermalGeneratorCharge;
|
||||
|
@ -94,9 +95,12 @@ public class ConfigTechReborn {
|
|||
public static int LithiumBatpackTier;
|
||||
public static int OmniToolTier;
|
||||
public static int RockCutterTier;
|
||||
public static int CloakingDeviceTier;
|
||||
public static int GravityTier;
|
||||
public static int CentrifugeTier;
|
||||
public static int ThermalGeneratorTier;
|
||||
// EU/T
|
||||
public static int CloakingDeviceEUTick;
|
||||
// Crafting
|
||||
public static boolean ExpensiveMacerator;
|
||||
public static boolean ExpensiveDrill;
|
||||
|
@ -357,6 +361,10 @@ public class ConfigTechReborn {
|
|||
.get(CATEGORY_POWER, StatCollector.translateToLocal("config.techreborn.rockCutterMaxCharge"), 10000,
|
||||
StatCollector.translateToLocal("config.techreborn.rockCutterMaxCharge.tooltip"))
|
||||
.getInt();
|
||||
CloakingDeviceCharge = config
|
||||
.get(CATEGORY_POWER, StatCollector.translateToLocal("config.techreborn.cloakingDeviceMaxCharge"), 10000000,
|
||||
StatCollector.translateToLocal("config.techreborn.cloakingDeviceMaxCharge.tooltip"))
|
||||
.getInt();
|
||||
GravityCharge = config
|
||||
.get(CATEGORY_POWER, StatCollector.translateToLocal("config.techreborn.gravityChestplateMaxCharge"),
|
||||
100000, StatCollector.translateToLocal("config.techreborn.gravityChestplateMaxCharge.tooltip"))
|
||||
|
@ -409,6 +417,10 @@ public class ConfigTechReborn {
|
|||
StatCollector.translateToLocal("config.techreborn.omniToolTier.tooltip")).getInt();
|
||||
RockCutterTier = config.get(CATEGORY_POWER, StatCollector.translateToLocal("config.techreborn.rockCutterTier"),
|
||||
3, StatCollector.translateToLocal("config.techreborn.rockCutterTier.tooltip")).getInt();
|
||||
CloakingDeviceTier = config.get(CATEGORY_POWER, StatCollector.translateToLocal("config.techreborn.cloakingDeviceTier"),
|
||||
3, StatCollector.translateToLocal("config.techreborn.cloakingDeviceTier.tooltip")).getInt();
|
||||
CloakingDeviceEUTick = config.get(CATEGORY_POWER, StatCollector.translateToLocal("config.techreborn.cloakingDeviceEUTick"),
|
||||
10000, StatCollector.translateToLocal("config.techreborn.cloakingDeviceEUTick.tooltip")).getInt();
|
||||
GravityTier = config
|
||||
.get(CATEGORY_POWER, StatCollector.translateToLocal("config.techreborn.gravityChestplateTier"), 3,
|
||||
StatCollector.translateToLocal("config.techreborn.gravityChestplateTier.tooltip"))
|
||||
|
|
36
src/main/java/techreborn/events/TRTickHandler.java
Normal file
36
src/main/java/techreborn/events/TRTickHandler.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package techreborn.events;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import techreborn.api.TechRebornItems;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.items.tools.ItemCloakingDevice;
|
||||
|
||||
public class TRTickHandler extends TickEvent {
|
||||
public TRTickHandler(Type type, Side side, Phase phase) {
|
||||
super(type, side, phase);
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
|
||||
public void onPlayerTick(TickEvent.PlayerTickEvent e) {
|
||||
EntityPlayer player = e.player;
|
||||
|
||||
if(player.getEquipmentInSlot(3)== null) {
|
||||
player.setInvisible(false);
|
||||
|
||||
}
|
||||
else if(player.getEquipmentInSlot(3).getItem() != ModItems.cloakingDevice) {
|
||||
player.setInvisible(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,25 +1,81 @@
|
|||
package techreborn.items.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ic2.api.item.ElectricItem;
|
||||
import ic2.api.item.IElectricItem;
|
||||
import ic2.core.item.ElectricItemManager;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.Core;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.items.ItemTR;
|
||||
|
||||
public class ItemCloakingDevice extends ItemTR implements IElectricItem {
|
||||
public static int Teir = 3;
|
||||
public static int MaxCharge = 100000;
|
||||
public static int Teir = ConfigTechReborn.CloakingDeviceTier;
|
||||
public static int MaxCharge = ConfigTechReborn.CloakingDeviceCharge;
|
||||
public static int Limit = 100;
|
||||
public static boolean isActive;
|
||||
|
||||
private int armorType = 1;
|
||||
public ItemCloakingDevice() {
|
||||
setUnlocalizedName("techreborn.cloakingdevice");
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
|
||||
if(ElectricItem.manager != null) {
|
||||
if(ElectricItem.manager.use(itemStack, ConfigTechReborn.CloakingDeviceEUTick, player))
|
||||
player.setInvisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) {
|
||||
return armorType == this.armorType;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(ItemStack itemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
ItemStack itemStack = new ItemStack(this, 1);
|
||||
if (getChargedItem(itemStack) == this && ElectricItem.manager != null) {
|
||||
ItemStack charged = new ItemStack(this, 1);
|
||||
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,
|
||||
false);
|
||||
itemList.add(charged);
|
||||
}
|
||||
if (getEmptyItem(itemStack) == this) {
|
||||
itemList.add(new ItemStack(this, 1, getMaxDamage()));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
if(ElectricItem.manager != null) {
|
||||
double charge = (ElectricItem.manager.getCharge(stack)/getMaxCharge(stack));
|
||||
return 1-charge;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public int getDisplayDamage(ItemStack stack) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Item getChargedItem(ItemStack itemStack) {
|
||||
return this;
|
||||
|
|
Loading…
Reference in a new issue