From 1718862a6a5c8df422c8e313cbfa447905e896de Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 11 Jul 2015 05:24:04 +0200 Subject: [PATCH] Added Scuba Armor, made the Helmet work. Rest to come. --- .../actuallyadditions/ActuallyAdditions.java | 6 +- .../config/ConfigCategories.java | 3 +- .../config/values/ConfigIntValues.java | 7 ++ .../actuallyadditions/items/InitItems.java | 37 ++++++---- .../actuallyadditions/items/ItemArmorAA.java | 69 +++++++++++++++++++ .../items/ItemScubaArmor.java | 42 +++++++++++ .../items/ItemTeleStaff.java | 2 + .../material/InitArmorMaterials.java | 19 +++++ ...mMaterials.java => InitToolMaterials.java} | 4 +- 9 files changed, 171 insertions(+), 18 deletions(-) create mode 100644 src/main/java/ellpeck/actuallyadditions/items/ItemArmorAA.java create mode 100644 src/main/java/ellpeck/actuallyadditions/items/ItemScubaArmor.java create mode 100644 src/main/java/ellpeck/actuallyadditions/material/InitArmorMaterials.java rename src/main/java/ellpeck/actuallyadditions/material/{InitItemMaterials.java => InitToolMaterials.java} (92%) diff --git a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java index 71afff3dc..167c39f82 100644 --- a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java +++ b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java @@ -18,7 +18,8 @@ import ellpeck.actuallyadditions.gen.OreGen; import ellpeck.actuallyadditions.inventory.GuiHandler; import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.ItemCoffee; -import ellpeck.actuallyadditions.material.InitItemMaterials; +import ellpeck.actuallyadditions.material.InitArmorMaterials; +import ellpeck.actuallyadditions.material.InitToolMaterials; import ellpeck.actuallyadditions.misc.DispenserHandlerEmptyBucket; import ellpeck.actuallyadditions.misc.DispenserHandlerFertilize; import ellpeck.actuallyadditions.network.PacketHandler; @@ -46,7 +47,8 @@ public class ActuallyAdditions{ ConfigurationHandler.init(event.getSuggestedConfigurationFile()); PacketHandler.init(); - InitItemMaterials.init(); + InitToolMaterials.init(); + InitArmorMaterials.init(); InitBlocks.init(); InitItems.init(); InitVillager.init(); diff --git a/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java b/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java index d0e2f7c99..542310060 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java +++ b/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java @@ -14,7 +14,8 @@ public enum ConfigCategories{ OTHER("other"), FLUIDS("fluids"), DRILL_VALUES("drill values"), - CRUSHER_RECIPES("crusher recipes"); + CRUSHER_RECIPES("crusher recipes"), + ARMOR_VALUES("armor values"); public final String name; diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java index 23fec019d..a450f0f48 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java @@ -35,6 +35,13 @@ public enum ConfigIntValues{ OBSIDIAN_USES("Obsidian: Max Uses", ConfigCategories.TOOL_VALUES, 8000, 50, 20000, "How often Obsidian Tools can be used"), OBSIDIAN_ENCHANTABILITY("Obsidian: Enchantability", ConfigCategories.TOOL_VALUES, 15, 1, 30, "How enchantable an Obsidian Tool is"), + SCUBA_DURABILITY("Scuba Armor: Durability", ConfigCategories.ARMOR_VALUES, 450, 10, 2000, "The Durability of Scuba Armor"), + SCUBA_HEAD_DAMAGE("Scuba Helmets: Damage Reduction", ConfigCategories.ARMOR_VALUES, 2, 0, 10, "The Damage Reduction of Scuba Helmets"), + SCUBA_CHEST_DAMAGE("Scuba Chests: Damage Reduction", ConfigCategories.ARMOR_VALUES, 5, 0, 10, "The Damage Reduction of Scuba Chests"), + SCUBA_LEGS_DAMAGE("Scuba Legs: Damage Reduction", ConfigCategories.ARMOR_VALUES, 4, 0, 10, "The Damage Reduction of Scuba Legs"), + SCUBA_BOOTS_DAMAGE("Scuba Boots: Damage Reduction", ConfigCategories.ARMOR_VALUES, 1, 0, 10, "The Damage Reduction of Scuba Boots"), + SCUBA_ENCHANTABILITY("Scuba Armor: Enchantability", ConfigCategories.ARMOR_VALUES, 15, 1, 100, "The Enchantability of Scuba Armor"), + GRINDER_CRUSH_TIME("Crusher: Time", ConfigCategories.MACHINE_VALUES, 100, 10, 1000, "How long the Crusher takes to crush an item"), GRINDER_DOUBLE_CRUSH_TIME("Double Crusher: Time", ConfigCategories.MACHINE_VALUES, 150, 10, 1000, "How long the Double Crusher takes to crush an item"), FURNACE_DOUBLE_SMELT_TIME("Double Furnace: Time", ConfigCategories.MACHINE_VALUES, 80, 10, 1000, "How long the Double Furnace takes to crush an item"), diff --git a/src/main/java/ellpeck/actuallyadditions/items/InitItems.java b/src/main/java/ellpeck/actuallyadditions/items/InitItems.java index ff97eca55..47feefb3e 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/InitItems.java +++ b/src/main/java/ellpeck/actuallyadditions/items/InitItems.java @@ -4,7 +4,7 @@ import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.items.metalists.TheFoods; import ellpeck.actuallyadditions.items.metalists.TheMiscItems; import ellpeck.actuallyadditions.items.tools.*; -import ellpeck.actuallyadditions.material.InitItemMaterials; +import ellpeck.actuallyadditions.material.InitToolMaterials; import ellpeck.actuallyadditions.util.CompatUtil; import ellpeck.actuallyadditions.util.ItemUtil; import ellpeck.actuallyadditions.util.ModUtil; @@ -82,9 +82,20 @@ public class InitItems{ public static Item itemTeleStaff; + public static Item itemScubaHelm; + public static Item itemScubaChest; + public static Item itemScubaPants; + public static Item itemScubaBoots; + public static void init(){ ModUtil.LOGGER.info("Initializing Items..."); + itemScubaHelm = new ItemScubaArmor("itemScubaHelm", 0); + itemScubaChest = new ItemScubaArmor("itemScubaChest", 1); + itemScubaPants = new ItemScubaArmor("itemScubaPants", 2); + itemScubaBoots = new ItemScubaArmor("itemScubaBoots", 3); + ItemUtil.registerItems(new Item[]{itemScubaHelm, itemScubaChest, itemScubaPants, itemScubaBoots}); + itemTeleStaff = new ItemTeleStaff(); ItemUtil.register(itemTeleStaff); @@ -180,18 +191,18 @@ public class InitItems{ ItemUtil.register(itemCoffeeSeed); CompatUtil.registerMFRSeed(itemCoffeeSeed); - itemPickaxeEmerald = new ItemPickaxeAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemPickaxeEmerald", EnumRarity.rare); - itemAxeEmerald = new ItemAxeAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemAxeEmerald", EnumRarity.rare); - itemShovelEmerald = new ItemShovelAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemShovelEmerald", EnumRarity.rare); - itemSwordEmerald = new ItemSwordAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemSwordEmerald", EnumRarity.rare); - itemHoeEmerald = new ItemHoeAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemHoeEmerald", EnumRarity.rare); + itemPickaxeEmerald = new ItemPickaxeAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemPickaxeEmerald", EnumRarity.rare); + itemAxeEmerald = new ItemAxeAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemAxeEmerald", EnumRarity.rare); + itemShovelEmerald = new ItemShovelAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemShovelEmerald", EnumRarity.rare); + itemSwordEmerald = new ItemSwordAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemSwordEmerald", EnumRarity.rare); + itemHoeEmerald = new ItemHoeAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemHoeEmerald", EnumRarity.rare); ItemUtil.registerItems(new Item[]{itemPickaxeEmerald, itemAxeEmerald, itemShovelEmerald, itemSwordEmerald, itemHoeEmerald}); - itemPickaxeObsidian = new ItemPickaxeAA(InitItemMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemPickaxeObsidian", EnumRarity.uncommon); - itemAxeObsidian = new ItemAxeAA(InitItemMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemAxeObsidian", EnumRarity.uncommon); - itemShovelObsidian = new ItemShovelAA(InitItemMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemShovelObsidian", EnumRarity.uncommon); - itemSwordObsidian = new ItemSwordAA(InitItemMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemSwordObsidian", EnumRarity.uncommon); - itemHoeObsidian = new ItemHoeAA(InitItemMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemHoeObsidian", EnumRarity.uncommon); + itemPickaxeObsidian = new ItemPickaxeAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemPickaxeObsidian", EnumRarity.uncommon); + itemAxeObsidian = new ItemAxeAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemAxeObsidian", EnumRarity.uncommon); + itemShovelObsidian = new ItemShovelAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemShovelObsidian", EnumRarity.uncommon); + itemSwordObsidian = new ItemSwordAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemSwordObsidian", EnumRarity.uncommon); + itemHoeObsidian = new ItemHoeAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemHoeObsidian", EnumRarity.uncommon); ItemUtil.registerItems(new Item[]{itemPickaxeObsidian, itemAxeObsidian, itemShovelObsidian, itemSwordObsidian, itemHoeObsidian}); woodenPaxel = new ItemAllToolAA(Item.ToolMaterial.WOOD, new ItemStack(Blocks.planks), "woodenPaxel", EnumRarity.uncommon); @@ -199,8 +210,8 @@ public class InitItems{ ironPaxel = new ItemAllToolAA(Item.ToolMaterial.IRON, new ItemStack(Items.iron_ingot), "ironPaxel", EnumRarity.rare); goldPaxel = new ItemAllToolAA(Item.ToolMaterial.GOLD, new ItemStack(Items.gold_ingot), "goldPaxel", EnumRarity.rare); diamondPaxel = new ItemAllToolAA(Item.ToolMaterial.EMERALD, new ItemStack(Items.diamond), "diamondPaxel", EnumRarity.epic); - emeraldPaxel = new ItemAllToolAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "emeraldPaxel", EnumRarity.epic); - obsidianPaxel = new ItemAllToolAA(InitItemMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "obsidianPaxel", EnumRarity.epic); + emeraldPaxel = new ItemAllToolAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "emeraldPaxel", EnumRarity.epic); + obsidianPaxel = new ItemAllToolAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "obsidianPaxel", EnumRarity.epic); ItemUtil.registerItems(new Item[]{woodenPaxel, stonePaxel, ironPaxel, goldPaxel, diamondPaxel, emeraldPaxel, obsidianPaxel}); } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemArmorAA.java b/src/main/java/ellpeck/actuallyadditions/items/ItemArmorAA.java new file mode 100644 index 000000000..b01db223f --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemArmorAA.java @@ -0,0 +1,69 @@ +package ellpeck.actuallyadditions.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import java.util.List; + +public class ItemArmorAA extends ItemArmor implements INameableItem{ + + private ItemStack repairItem; + private String name; + private String[] textures; + + public ItemArmorAA(String name, ArmorMaterial material, int type, ItemStack repairItem, String textureBase){ + super(material, 0, type); + this.repairItem = repairItem; + this.name = name; + String texture = ModUtil.MOD_ID_LOWER+":textures/armor/"+textureBase; + textures = new String[]{texture+"1.png", texture+"2.png"}; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass){ + return this.itemIcon; + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.rare; + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + ItemUtil.addInformation(this, list, 1, ""); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public String getName(){ + return this.name; + } + + @Override + public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ + return this.repairItem != null && stack.getItem() == this.repairItem.getItem(); + } + + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type){ + return this.textures[slot == 2 ? 1 : 0]; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemScubaArmor.java b/src/main/java/ellpeck/actuallyadditions/items/ItemScubaArmor.java new file mode 100644 index 000000000..ae44d07bc --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemScubaArmor.java @@ -0,0 +1,42 @@ +package ellpeck.actuallyadditions.items; + +import ellpeck.actuallyadditions.material.InitArmorMaterials; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class ItemScubaArmor extends ItemArmorAA{ + + private static final int helmetTime = 500; + private static final int helmetTimeDecreaseInAir = 3; + + public ItemScubaArmor(String name, int type){ + super(name, InitArmorMaterials.armorMaterialScuba, type, null, "armorScuba"); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack armor){ + if(!world.isRemote){ + if(armor.getItem() == InitItems.itemScubaHelm){ + NBTTagCompound compound = armor.getTagCompound(); + if(compound == null) compound = new NBTTagCompound(); + + int time = compound.getInteger("waitTime"); + if(player.isInsideOfMaterial(Material.water)){ + if(time < helmetTime){ + compound.setInteger("waitTime", time+1); + player.setAir(300); + } + } + else{ + if(time > 0){ + compound.setInteger("waitTime", time < helmetTimeDecreaseInAir ? 0 : time-helmetTimeDecreaseInAir); + } + } + armor.setTagCompound(compound); + } + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemTeleStaff.java b/src/main/java/ellpeck/actuallyadditions/items/ItemTeleStaff.java index 88a956858..56498fc3c 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemTeleStaff.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemTeleStaff.java @@ -63,6 +63,8 @@ public class ItemTeleStaff extends ItemEnergy implements INameableItem{ if(compound == null) compound = new NBTTagCompound(); compound.setInteger("waitTime", time); + + stack.setTagCompound(compound); } private int getWaitTime(ItemStack stack){ diff --git a/src/main/java/ellpeck/actuallyadditions/material/InitArmorMaterials.java b/src/main/java/ellpeck/actuallyadditions/material/InitArmorMaterials.java new file mode 100644 index 000000000..cf764f754 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/material/InitArmorMaterials.java @@ -0,0 +1,19 @@ +package ellpeck.actuallyadditions.material; + +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.item.ItemArmor; +import net.minecraftforge.common.util.EnumHelper; + +public class InitArmorMaterials{ + + public static ItemArmor.ArmorMaterial armorMaterialScuba; + public static ItemArmor.ArmorMaterial armorMaterialEmerald; + public static ItemArmor.ArmorMaterial armorMaterialObsidian; + + public static void init(){ + ModUtil.LOGGER.info("Initializing Armor Materials..."); + + armorMaterialScuba = EnumHelper.addArmorMaterial("armorMaterialScuba", ConfigIntValues.SCUBA_DURABILITY.getValue(), new int[]{ConfigIntValues.SCUBA_HEAD_DAMAGE.getValue(), ConfigIntValues.SCUBA_CHEST_DAMAGE.getValue(), ConfigIntValues.SCUBA_LEGS_DAMAGE.getValue(), ConfigIntValues.SCUBA_BOOTS_DAMAGE.getValue()}, ConfigIntValues.SCUBA_ENCHANTABILITY.getValue()); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/material/InitItemMaterials.java b/src/main/java/ellpeck/actuallyadditions/material/InitToolMaterials.java similarity index 92% rename from src/main/java/ellpeck/actuallyadditions/material/InitItemMaterials.java rename to src/main/java/ellpeck/actuallyadditions/material/InitToolMaterials.java index 2d08c2cd7..98dea6f4d 100644 --- a/src/main/java/ellpeck/actuallyadditions/material/InitItemMaterials.java +++ b/src/main/java/ellpeck/actuallyadditions/material/InitToolMaterials.java @@ -6,13 +6,13 @@ import ellpeck.actuallyadditions.util.ModUtil; import net.minecraft.item.Item.ToolMaterial; import net.minecraftforge.common.util.EnumHelper; -public class InitItemMaterials{ +public class InitToolMaterials{ public static ToolMaterial toolMaterialEmerald; public static ToolMaterial toolMaterialObsidian; public static void init(){ - ModUtil.LOGGER.info("Initializing Materials..."); + ModUtil.LOGGER.info("Initializing Tool Materials..."); toolMaterialEmerald = EnumHelper.addToolMaterial("toolMaterialEmerald", ConfigIntValues.EMERALD_HARVEST_LEVEL.getValue(), ConfigIntValues.EMERALD_USES.getValue(), ConfigFloatValues.EMERALD_SPEED.getValue(), ConfigFloatValues.EMERALD_MAX_DAMAGE.getValue(), ConfigIntValues.EMERALD_ENCHANTABILITY.getValue()); toolMaterialObsidian = EnumHelper.addToolMaterial("toolMaterialObsidian", ConfigIntValues.OBSIDIAN_HARVEST_LEVEL.getValue(), ConfigIntValues.OBSIDIAN_USES.getValue(), ConfigFloatValues.OBSIDIAN_SPEED.getValue(), ConfigFloatValues.OBSIDIAN_MAX_DAMAGE.getValue(), ConfigIntValues.OBSIDIAN_ENCHANTABILITY.getValue());