From 47f67ca96cb8d34ab8859ea600ac149ef4d88cf2 Mon Sep 17 00:00:00 2001 From: TehNut Date: Thu, 2 Oct 2014 23:04:17 -0700 Subject: [PATCH] Begin rewriting of module layout Currently doesn't touch any of the current EMT files except the config and a single line in the base class to uncomment when testing. --- .../tombenpotter/emt/ElectroMagicTools.java | 2 + .../emt/common/modules/ModuleRegistry.java | 34 ++ .../modules/base/BaseRecipeRegistry.java | 17 + .../base/blocks/BaseBlockRegistry.java | 8 + .../common/modules/base/blocks/BlockBase.java | 28 ++ .../base/entities/BaseEntityRegistry.java | 5 + .../modules/base/entities/EntityArcher.java | 117 ++++++ .../modules/base/items/BaseItemRegistry.java | 36 ++ .../common/modules/base/items/ItemBase.java | 23 ++ .../modules/base/items/ItemBaseBaubles.java | 156 ++++++++ .../modules/base/items/ItemBaseChainsaw.java | 120 +++++++ .../modules/base/items/ItemBaseDrill.java | 82 +++++ .../modules/base/items/ItemBaseOmnitool.java | 115 ++++++ .../modules/base/items/ItemMaterials.java | 202 +++++++++++ .../modules/base/items/ItemToolMaterials.java | 143 ++++++++ .../base/items/foci/ItemBaseFocus.java | 134 +++++++ .../base/items/foci/ItemChristmasFocus.java | 54 +++ .../base/items/tools/ItemThorHammer.java | 85 +++++ .../items/tools/ItemThorHammerBroken.java | 58 +++ .../common/modules/ic2/IC2RecipeRegistry.java | 17 + .../common/modules/ic2/blocks/BlockIC2.java | 28 ++ .../modules/ic2/blocks/IC2BlockRegistry.java | 8 + .../modules/ic2/entities/EntityLaser.java | 338 ++++++++++++++++++ .../ic2/entities/IC2EntityRegistry.java | 5 + .../modules/ic2/items/IC2ItemRegistry.java | 14 + .../emt/common/modules/ic2/items/ItemIC2.java | 23 ++ .../modules/ic2/items/ItemIC2Baubles.java | 136 +++++++ .../common/modules/te/TERecipeRegistry.java | 17 + .../emt/common/modules/te/blocks/BlockTE.java | 28 ++ .../modules/te/blocks/TEBlockRegistry.java | 8 + .../emt/common/modules/te/items/ItemTE.java | 23 ++ .../modules/te/items/TEItemRegistry.java | 8 + .../emt/common/util/ConfigHandler.java | 7 + 33 files changed, 2079 insertions(+) create mode 100644 src/main/java/tombenpotter/emt/common/modules/ModuleRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/BaseRecipeRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/blocks/BaseBlockRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/blocks/BlockBase.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/entities/BaseEntityRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/entities/EntityArcher.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/BaseItemRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/ItemBase.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseBaubles.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseChainsaw.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseDrill.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseOmnitool.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/ItemMaterials.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/ItemToolMaterials.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/foci/ItemBaseFocus.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/foci/ItemChristmasFocus.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/tools/ItemThorHammer.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/base/items/tools/ItemThorHammerBroken.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/ic2/IC2RecipeRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/ic2/blocks/BlockIC2.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/ic2/blocks/IC2BlockRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/ic2/entities/EntityLaser.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/ic2/entities/IC2EntityRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/ic2/items/IC2ItemRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/ic2/items/ItemIC2.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/ic2/items/ItemIC2Baubles.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/te/TERecipeRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/te/blocks/BlockTE.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/te/blocks/TEBlockRegistry.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/te/items/ItemTE.java create mode 100644 src/main/java/tombenpotter/emt/common/modules/te/items/TEItemRegistry.java diff --git a/src/main/java/tombenpotter/emt/ElectroMagicTools.java b/src/main/java/tombenpotter/emt/ElectroMagicTools.java index 7315527..d42f70a 100644 --- a/src/main/java/tombenpotter/emt/ElectroMagicTools.java +++ b/src/main/java/tombenpotter/emt/ElectroMagicTools.java @@ -60,6 +60,8 @@ public class ElectroMagicTools { EssentiasOutputs.addPrimalOutputs(); EssentiasOutputs.addOutputs(); +// ModuleRegistry.RegisterModules(); + ElectroMagicTools.logger.info(localize("console.EMT.preInit.end")); } diff --git a/src/main/java/tombenpotter/emt/common/modules/ModuleRegistry.java b/src/main/java/tombenpotter/emt/common/modules/ModuleRegistry.java new file mode 100644 index 0000000..a657d08 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/ModuleRegistry.java @@ -0,0 +1,34 @@ +package tombenpotter.emt.common.modules; + +import tombenpotter.emt.common.modules.base.blocks.BaseBlockRegistry; +import tombenpotter.emt.common.modules.base.BaseRecipeRegistry; +import tombenpotter.emt.common.modules.base.items.BaseItemRegistry; +import tombenpotter.emt.common.modules.ic2.IC2RecipeRegistry; +import tombenpotter.emt.common.modules.ic2.blocks.IC2BlockRegistry; +import tombenpotter.emt.common.modules.ic2.items.IC2ItemRegistry; +import tombenpotter.emt.common.modules.te.TERecipeRegistry; +import tombenpotter.emt.common.modules.te.blocks.TEBlockRegistry; +import tombenpotter.emt.common.modules.te.items.TEItemRegistry; +import tombenpotter.emt.common.util.ConfigHandler; + +public class ModuleRegistry { + + public static void RegisterModules() { + + BaseBlockRegistry.registerBaseBlocks(); + BaseItemRegistry.registerBaseItems(); + BaseRecipeRegistry.registerBaseRecipes(); + + if (ConfigHandler.enableIC2Module) { + IC2BlockRegistry.registerIC2Blocks(); + IC2ItemRegistry.registerIC2Items(); + IC2RecipeRegistry.registerIC2Recipes(); + } + + if (ConfigHandler.enableTEModule) { + TEBlockRegistry.registerTEBlocks(); + TEItemRegistry.registerTEItems(); + TERecipeRegistry.registerTERecipes(); + } + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/BaseRecipeRegistry.java b/src/main/java/tombenpotter/emt/common/modules/base/BaseRecipeRegistry.java new file mode 100644 index 0000000..6d17720 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/BaseRecipeRegistry.java @@ -0,0 +1,17 @@ +package tombenpotter.emt.common.modules.base; + +public class BaseRecipeRegistry { + + private static void registerShapedRecipes() { + + } + + private static void registerShapelessRecipes() { + + } + + public static void registerBaseRecipes() { + registerShapedRecipes(); + registerShapelessRecipes(); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/blocks/BaseBlockRegistry.java b/src/main/java/tombenpotter/emt/common/modules/base/blocks/BaseBlockRegistry.java new file mode 100644 index 0000000..895c797 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/blocks/BaseBlockRegistry.java @@ -0,0 +1,8 @@ +package tombenpotter.emt.common.modules.base.blocks; + +public class BaseBlockRegistry { + + public static void registerBaseBlocks() { + + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/blocks/BlockBase.java b/src/main/java/tombenpotter/emt/common/modules/base/blocks/BlockBase.java new file mode 100644 index 0000000..050b3a1 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/blocks/BlockBase.java @@ -0,0 +1,28 @@ +package tombenpotter.emt.common.modules.base.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; + +public class BlockBase extends Block { + + public BlockBase(String unlocName, Material material, String textureName, SoundType soundType, float hardness) { + super(material); + + setBlockName(ModInformation.modid + ".module.base." + unlocName); + setBlockTextureName(ModInformation.texturePath + ":" + textureName); + setCreativeTab(ElectroMagicTools.tabEMT); + setStepSound(soundType); + setHardness(hardness); + } + + public BlockBase(String unlocName, Material material, SoundType soundType, float hardness) { + super(material); + + setBlockName(ModInformation.modid + ".module.base." + unlocName); + setCreativeTab(ElectroMagicTools.tabEMT); + setStepSound(soundType); + setHardness(hardness); + } +} \ No newline at end of file diff --git a/src/main/java/tombenpotter/emt/common/modules/base/entities/BaseEntityRegistry.java b/src/main/java/tombenpotter/emt/common/modules/base/entities/BaseEntityRegistry.java new file mode 100644 index 0000000..7cf0600 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/entities/BaseEntityRegistry.java @@ -0,0 +1,5 @@ +package tombenpotter.emt.common.modules.base.entities; + +public class BaseEntityRegistry { + +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/entities/EntityArcher.java b/src/main/java/tombenpotter/emt/common/modules/base/entities/EntityArcher.java new file mode 100644 index 0000000..e1f1845 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/entities/EntityArcher.java @@ -0,0 +1,117 @@ +package tombenpotter.emt.common.modules.base.entities; + +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.monster.EntitySnowman; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; +import net.minecraftforge.common.IExtendedEntityProperties; + +public class EntityArcher extends EntitySnowman implements IExtendedEntityProperties { + + public EntityArcher(World par1World) { + super(par1World); + this.isImmuneToFire = true; + this.tasks.addTask(1, new EntityAISwimming(this)); + this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true, false, IMob.mobSelector)); + this.tasks.addTask(4, new EntityAIWander(this, 0.30D)); + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30D); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D); + } + + @Override + public void onDeath(DamageSource par1DamageSource) { + super.onDeath(par1DamageSource); + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 1, true); + this.setDead(); + } + + @Override + protected Item getDropItem() { + return Items.arrow; + } + + @Override + protected void dropFewItems(boolean par1, int par2) { + int j; + int k; + + j = this.rand.nextInt(3 + par2); + + for (k = 0; k < j; ++k) { + this.dropItem(Items.arrow, 1); + } + j = this.rand.nextInt(3 + par2); + + for (k = 0; k < j; ++k) { + this.dropItem(Items.bone, 1); + } + } + + @Override + protected void dropRareDrop(int par1) { + this.entityDropItem(new ItemStack(Blocks.web, 1, 1), 0.0F); + } + + protected void addRandomArmor() { + super.addRandomArmor(); + this.setCurrentItemOrArmor(0, new ItemStack(Items.bow)); + } + + @Override + public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { + EntityArrow entityarrow = new EntityArrow(this.worldObj, this, par1EntityLivingBase, 1.6F, (float) (14 - this.worldObj.difficultySetting.getDifficultyId() * 4)); + int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem()); + int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem()); + entityarrow.setDamage((double) (par2 * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.difficultySetting.getDifficultyId() * 0.11F)); + + if (i > 0) { + entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); + } + + if (j > 0) { + entityarrow.setKnockbackStrength(j); + } + + if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0) { + entityarrow.setFire(100); + } + + this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.worldObj.spawnEntityInWorld(entityarrow); + } + + @Override + public void saveNBTData(NBTTagCompound compound) { + } + + @Override + public void loadNBTData(NBTTagCompound compound) { + } + + @Override + public void init(Entity entity, World world) { + } +} \ No newline at end of file diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/BaseItemRegistry.java b/src/main/java/tombenpotter/emt/common/modules/base/items/BaseItemRegistry.java new file mode 100644 index 0000000..6b7eab8 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/BaseItemRegistry.java @@ -0,0 +1,36 @@ +package tombenpotter.emt.common.modules.base.items; + +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.item.Item; +import tombenpotter.emt.common.modules.base.items.foci.ItemChristmasFocus; +import tombenpotter.emt.common.modules.base.items.tools.ItemThorHammer; +import tombenpotter.emt.common.modules.base.items.tools.ItemThorHammerBroken; + +public class BaseItemRegistry { + + public static Item baseBaubles; + public static Item materials; + public static Item toolMaterials; + + public static Item thorHammer; + public static Item thorHammerBroken; + + public static Item focusChristmas; + + public static void registerBaseItems() { + baseBaubles = new ItemBaseBaubles(); + GameRegistry.registerItem(baseBaubles, "BaseBaubles"); + materials = new ItemMaterials(); + GameRegistry.registerItem(materials, "Materials"); + toolMaterials = new ItemToolMaterials(); + GameRegistry.registerItem(toolMaterials, "ToolMaterials"); + + thorHammer = new ItemThorHammer(); + GameRegistry.registerItem(thorHammer, "ThorHammer"); + thorHammerBroken = new ItemThorHammerBroken(); + GameRegistry.registerItem(thorHammerBroken, "ThorHammerBroken"); + + focusChristmas = new ItemChristmasFocus(); + GameRegistry.registerItem(focusChristmas, "FocusChristmas"); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBase.java b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBase.java new file mode 100644 index 0000000..e4f02bf --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBase.java @@ -0,0 +1,23 @@ +package tombenpotter.emt.common.modules.base.items; + +import net.minecraft.item.Item; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; + +public class ItemBase extends Item { + + public ItemBase(String unlocName, String textureName) { + super(); + + setUnlocalizedName(ModInformation.modid + ".module.base." + unlocName); + setTextureName(ModInformation.texturePath + ":" + textureName); + setCreativeTab(ElectroMagicTools.tabEMT); + } + + public ItemBase(String unlocName) { + super(); + + setUnlocalizedName(ModInformation.modid + ".module.base." + unlocName); + setCreativeTab(ElectroMagicTools.tabEMT); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseBaubles.java b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseBaubles.java new file mode 100644 index 0000000..6a1fdf1 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseBaubles.java @@ -0,0 +1,156 @@ +package tombenpotter.emt.common.modules.base.items; + +import baubles.api.BaubleType; +import baubles.api.IBauble; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IIcon; +import tombenpotter.emt.ModInformation; +import tombenpotter.emt.common.util.TextHelper; + +import java.util.List; +import java.util.Random; + +public class ItemBaseBaubles extends ItemBase implements IBauble { + + public IIcon[] icon = new IIcon[16]; + public static int wornTick; + public Random random = new Random(); + + public ItemBaseBaubles() { + super("bauble"); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setMaxStackSize(1); + + wornTick = 0; + } + + @Override + public String getUnlocalizedName(ItemStack itemstack) { + String name = ""; + switch (itemstack.getItemDamage()) { + case 0: { + name = "oneRing"; + break; + } + default: + name = "nothing"; + break; + } + return getUnlocalizedName() + "." + name; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ri) { + this.icon[0] = ri.registerIcon(ModInformation.texturePath + ":onering"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int meta) { + return this.icon[meta]; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List list) { + list.add(new ItemStack(this, 1, 0)); + } + + @Override + public BaubleType getBaubleType(ItemStack stack) { + if (stack.getItemDamage() <= 0) { + return BaubleType.RING; + } else { + return null; + } + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if (!player.worldObj.isRemote) { + if (stack != null && stack.getItemDamage() == 0) { + if (player instanceof EntityPlayer) { + ((EntityPlayer) player).capabilities.disableDamage = true; + + wornTick++; + + NBTTagCompound tag = new NBTTagCompound(); + tag.setInteger("MindCorruption", wornTick); + ((EntityPlayer) player).writeToNBT(tag); + int corruption = tag.getInteger("MindCorruption"); + if (tag != null && corruption != wornTick) { + wornTick = corruption; + } + + if (corruption <= 0) + ((EntityPlayer) player).addChatMessage(new ChatComponentText(TextHelper.PURPLE + "You have worn the Ring. Your soul has now been forever " + TextHelper.PURPLE + "tainted. " + TextHelper.RED + TextHelper.ITALIC + "Beware of wearing the ring. The tainting will only " + TextHelper.RED + TextHelper.ITALIC + "increase, and strange things will start happening.")); + + if (corruption > 6000 && corruption < 24000 && random.nextInt(2000) == 0) + player.addPotionEffect(new PotionEffect(Potion.blindness.id, 500, 2, false)); + + if (corruption >= 6000 && corruption < 24000 && random.nextInt(2000) == 0) + player.addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2, false)); + + if (corruption >= 24000 && corruption < 72000 && random.nextInt(2000) == 0) { + for (int i = 0; i <= 5; i++) + ((EntityPlayer) player).capabilities.disableDamage = false; + + player.attackEntityFrom(DamageSource.magic, 5); + } + + if (corruption >= 72000 && corruption < 120000 && random.nextInt(4000) == 0) { + for (int i = 0; i <= 100; i++) + ((EntityPlayer) player).capabilities.disableDamage = false; + + player.motionY = 2; + } + + if (corruption >= 120000 && random.nextInt(10000) == 0) { + for (int i = 0; i <= 510; i++) + ((EntityPlayer) player).capabilities.disableDamage = false; + + player.addPotionEffect(new PotionEffect(Potion.wither.id, 5000, 4, false)); + } + } + } + } + } + + @Override + public void onEquipped(ItemStack stack, EntityLivingBase player) { + if (stack != null && stack.getItemDamage() == 0) { + player.setInvisible(true); + } + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + if (stack != null && stack.getItemDamage() == 0) { + player.setInvisible(false); + if (player instanceof EntityPlayer && !((EntityPlayer) player).capabilities.isCreativeMode) + ((EntityPlayer) player).capabilities.disableDamage = false; + } + } + + @Override + public boolean canEquip(ItemStack stack, EntityLivingBase player) { + return true; + } + + @Override + public boolean canUnequip(ItemStack stack, EntityLivingBase player) { + return true; + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseChainsaw.java b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseChainsaw.java new file mode 100644 index 0000000..43f2423 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseChainsaw.java @@ -0,0 +1,120 @@ +package tombenpotter.emt.common.modules.base.items; + +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; +import tombenpotter.emt.common.util.ConfigHandler; +import tombenpotter.emt.common.util.RandomHelper; + +import java.util.ArrayList; +import java.util.Random; + +public class ItemBaseChainsaw extends ItemAxe { + + public String textureName; + + public ItemBaseChainsaw(ToolMaterial material, int maxDamage, String unlocName, String textureName) { + super(material); + this.setCreativeTab(ElectroMagicTools.tabEMT); + this.setMaxDamage(maxDamage); + this.setTextureName(ModInformation.texturePath + ":" + textureName); + this.efficiencyOnProperMaterial = this.toolMaterial.getEfficiencyOnProperMaterial(); + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entityLiving) { + if ((double) block.getBlockHardness(world, x, y, z) != 0.0D) stack.damageItem(1, entityLiving); + return true; + } + + @Override + public boolean canHarvestBlock(Block block, ItemStack stack) { + return false; + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + if (block.getHarvestTool(meta) == null) { + return efficiencyOnProperMaterial; + } else { + if ((canHarvestBlock(block, stack) && (block.getHarvestTool(meta).equals("axe")) || Items.shears.canHarvestBlock(block, stack))) { + return efficiencyOnProperMaterial; + } + } + return super.getDigSpeed(stack, block, meta); + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { + return RandomHelper.placeTorch(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset); + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public boolean getIsRepairable(ItemStack stack1, ItemStack stack2) { + return false; + } + + @Override + public int getItemEnchantability() { + if (!ConfigHandler.enchanting) { + return 0; + } else { + return toolMaterial.getEnchantability(); + } + } + + @Override + public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2) { + return ConfigHandler.enchanting; + } + + @Override + public boolean hitEntity(ItemStack stack, EntityLivingBase entityliving, EntityLivingBase attacker) { + stack.damageItem(1, attacker); + return true; + } + + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + if (player.worldObj.isRemote) { + return false; + } + Block block = player.worldObj.getBlock(x, y, z); + if (block instanceof IShearable) { + IShearable target = (IShearable) block; + if (target.isShearable(stack, player.worldObj, x, y, z)) { + ArrayList drops = target.onSheared(stack, player.worldObj, x, y, z, + EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack)); + Random rand = new Random(); + for (ItemStack drop : drops) { + float f = 0.7F; + double d = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + double d1 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + double d2 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + EntityItem entityitem = new EntityItem(player.worldObj, (double) x + d, (double) y + d1, (double) z + d2, drop); + entityitem.delayBeforeCanPickup = 10; + player.worldObj.spawnEntityInWorld(entityitem); + } + stack.damageItem(1, player); + player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1); + } + } + return false; + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseDrill.java b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseDrill.java new file mode 100644 index 0000000..b85a470 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseDrill.java @@ -0,0 +1,82 @@ +package tombenpotter.emt.common.modules.base.items; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; +import tombenpotter.emt.common.util.ConfigHandler; +import tombenpotter.emt.common.util.RandomHelper; + +public class ItemBaseDrill extends ItemPickaxe { + + public String textureName; + + public ItemBaseDrill(ToolMaterial material, int maxDamage, String unlocName, String textureName) { + super(material); + this.setCreativeTab(ElectroMagicTools.tabEMT); + this.setMaxDamage(maxDamage); + this.setTextureName(ModInformation.texturePath + ":" + textureName); + this.efficiencyOnProperMaterial = this.toolMaterial.getEfficiencyOnProperMaterial(); + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entityLiving) { + if ((double) block.getBlockHardness(world, x, y, z) != 0.0D) stack.damageItem(1, entityLiving); + return true; + } + + @Override + public boolean canHarvestBlock(Block block, ItemStack stack) { + return false; + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + if (block.getHarvestTool(meta) == null) { + return efficiencyOnProperMaterial; + } else { + if (canHarvestBlock(block, stack) && (block.getHarvestTool(meta).equals("pickaxe") || block.getHarvestTool(meta).equals("shovel"))) { + return efficiencyOnProperMaterial; + } + } + return super.getDigSpeed(stack, block, meta); + } + + @Override + public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) { + return true; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { + return RandomHelper.placeTorch(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset); + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public boolean getIsRepairable(ItemStack stack1, ItemStack stack2) { + return false; + } + + @Override + public int getItemEnchantability() { + if (!ConfigHandler.enchanting) { + return 0; + } else { + return toolMaterial.getEnchantability(); + } + } + + @Override + public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2) { + return ConfigHandler.enchanting; + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseOmnitool.java b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseOmnitool.java new file mode 100644 index 0000000..eb74b12 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemBaseOmnitool.java @@ -0,0 +1,115 @@ +package tombenpotter.emt.common.modules.base.items; + +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; +import tombenpotter.emt.common.util.ConfigHandler; +import tombenpotter.emt.common.util.RandomHelper; + +import java.util.ArrayList; +import java.util.Random; + +public class ItemBaseOmnitool extends ItemPickaxe { + + public String textureName; + + public ItemBaseOmnitool(ToolMaterial material, int maxDamage, String unlocName, String textureName) { + super(material); + this.setCreativeTab(ElectroMagicTools.tabEMT); + this.setMaxDamage(maxDamage); + this.setTextureName(ModInformation.texturePath + ":" + textureName); + this.efficiencyOnProperMaterial = this.toolMaterial.getEfficiencyOnProperMaterial(); + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entityLiving) { + if ((double) block.getBlockHardness(world, x, y, z) != 0.0D) stack.damageItem(1, entityLiving); + return true; + } + + @Override + public boolean canHarvestBlock(Block block, ItemStack stack) { + return false; + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + if (block.getHarvestTool(meta) == null) { + return efficiencyOnProperMaterial; + } else { + if (canHarvestBlock(block, stack) && (block.getHarvestTool(meta).equals("pickaxe") || block.getHarvestTool(meta).equals("shovel")) || block.getHarvestTool(meta).equals("axe") || Items.shears.canHarvestBlock(block, stack)) { + return efficiencyOnProperMaterial; + } + } + return super.getDigSpeed(stack, block, meta); + } + + @Override + public boolean hitEntity(ItemStack stack, EntityLivingBase entityliving, EntityLivingBase attacker) { + stack.damageItem(1, attacker); + return true; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { + return RandomHelper.placeTorch(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset); + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public int getItemEnchantability() { + if (!ConfigHandler.enchanting) { + return 0; + } else { + return toolMaterial.getEnchantability(); + } + } + + @Override + public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2) { + return ConfigHandler.enchanting; + } + + @Override + public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { + if (player.worldObj.isRemote) { + return false; + } + Block block = player.worldObj.getBlock(x, y, z); + if (block instanceof IShearable) { + IShearable target = (IShearable) block; + if (target.isShearable(stack, player.worldObj, x, y, z)) { + ArrayList drops = target.onSheared(stack, player.worldObj, x, y, z, + EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack)); + Random rand = new Random(); + for (ItemStack drop : drops) { + float f = 0.7F; + double d = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + double d1 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + double d2 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + EntityItem entityitem = new EntityItem(player.worldObj, (double) x + d, (double) y + d1, (double) z + d2, drop); + entityitem.delayBeforeCanPickup = 10; + player.worldObj.spawnEntityInWorld(entityitem); + } + stack.damageItem(1, player); + player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1); + } + } + return false; + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/ItemMaterials.java b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemMaterials.java new file mode 100644 index 0000000..3f4b543 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemMaterials.java @@ -0,0 +1,202 @@ +package tombenpotter.emt.common.modules.base.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import thaumcraft.common.config.Config; +import thaumcraft.common.lib.InventoryHelper; +import tombenpotter.emt.ModInformation; + +import java.util.List; + +public class ItemMaterials extends ItemBase { + + public IIcon[] icon = new IIcon[32]; + + public ItemMaterials() { + super("materials"); + setHasSubtypes(true); + } + + @Override + public String getUnlocalizedName(ItemStack itemstack) { + String name = ""; + switch (itemstack.getItemDamage()) { + case 0: { + name = "oreClusterUranium"; + break; + } + case 1: { + name = "crushedOreAmber"; + break; + } + case 2: { + name = "purifiedOreAmber"; + break; + } + case 3: { + name = "crushedOreCinnabar"; + break; + } + case 4: { + name = "purifiedOreCinnabar"; + break; + } + case 5: { + name = "thaumiumPlate"; + break; + } + case 6: { + name = "lightningSummoner"; + break; + } + case 7: { + name = "featherMesh"; + break; + } + case 8: { + name = "glue"; + break; + } + case 9: { + name = "ductTape"; + break; + } + case 10: { + name = "rubberBall"; + break; + } + case 11: { + name = "cardboard"; + break; + } + case 12: { + name = "featherGluedCardboardWing"; + break; + } + case 13: { + name = "denseIronSheet"; + break; + } + case 14: { + name = "taintedFeather"; + break; + } + case 15: { + name = "thaumiumWing"; + break; + } + case 16: { + name = "uumatterDrop"; + break; + } + default: + name = "nothing"; + break; + } + return getUnlocalizedName() + "." + name; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ri) { + this.icon[0] = ri.registerIcon(ModInformation.texturePath + ":materials/clusteruranium"); + this.icon[1] = ri.registerIcon(ModInformation.texturePath + ":materials/crushedamber"); + this.icon[2] = ri.registerIcon(ModInformation.texturePath + ":materials/purifiedamber"); + this.icon[3] = ri.registerIcon(ModInformation.texturePath + ":materials/crushedcinnabar"); + this.icon[4] = ri.registerIcon(ModInformation.texturePath + ":materials/purifiedcinnabar"); + this.icon[5] = ri.registerIcon(ModInformation.texturePath + ":materials/thaumiumplate"); + this.icon[6] = ri.registerIcon(ModInformation.texturePath + ":materials/lightningsummoner"); + this.icon[7] = ri.registerIcon(ModInformation.texturePath + ":materials/feathermesh"); + this.icon[8] = ri.registerIcon(ModInformation.texturePath + ":materials/glue"); + this.icon[9] = ri.registerIcon(ModInformation.texturePath + ":materials/ducttape"); + this.icon[10] = ri.registerIcon(ModInformation.texturePath + ":materials/rubberball"); + this.icon[11] = ri.registerIcon(ModInformation.texturePath + ":materials/cardboard"); + this.icon[12] = ri.registerIcon(ModInformation.texturePath + ":materials/cardboardsheet"); + this.icon[13] = ri.registerIcon(ModInformation.texturePath + ":materials/denseironsheet"); + this.icon[14] = ri.registerIcon(ModInformation.texturePath + ":materials/taintedfeather"); + this.icon[15] = ri.registerIcon(ModInformation.texturePath + ":materials/thaumiumWing"); + this.icon[16] = ri.registerIcon(ModInformation.texturePath + ":materials/uumatterdrop"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int meta) { + return this.icon[meta]; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List list) { + for (int i = 1; i <= 16; i++) { + list.add(new ItemStack(this, 1, i)); + } + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (stack != null && stack.getItemDamage() == 6) { + player.swingItem(); + float f = 1.0F; + float f1 = player.prevRotationPitch + ((player.rotationPitch - player.prevRotationPitch) * f); + float f2 = player.prevRotationYaw + ((player.rotationYaw - player.prevRotationYaw) * f); + double d = player.prevPosX + ((player.posX - player.prevPosX) * f); + double d1 = (player.prevPosY + ((player.posY - player.prevPosY) * f) + 1.6200000000000001D) - player.yOffset; + double d2 = player.prevPosZ + ((player.posZ - player.prevPosZ) * f); + Vec3 vec3d = Vec3.createVectorHelper(d, d1, d2); + float f3 = MathHelper.cos((-f2 * 0.01745329F) - 3.141593F); + float f4 = MathHelper.sin((-f2 * 0.01745329F) - 3.141593F); + float f5 = -MathHelper.cos(-f1 * 0.01745329F); + float f6 = MathHelper.sin(-f1 * 0.01745329F); + float f7 = f4 * f5; + float f8 = f6; + float f9 = f3 * f5; + double d3 = 5000D; + Vec3 vec3d1 = vec3d.addVector(f7 * d3, f8 * d3, f9 * d3); + MovingObjectPosition movingobjectposition = player.worldObj.rayTraceBlocks(vec3d, vec3d1, true); + if (movingobjectposition == null) { + return stack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + world.spawnEntityInWorld(new EntityLightningBolt(world, i, j, k)); + } else if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) { + Entity entityhit = movingobjectposition.entityHit; + double x = entityhit.posX; + double y = entityhit.posY; + double z = entityhit.posZ; + world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z)); + } + if (player.capabilities.isCreativeMode) { + return stack; + } else { + player.inventory.consumeInventoryItem(this); + return stack; + } + } + return stack; + } + + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { + super.onUpdate(stack, world, entity, par4, par5); + if ((!entity.worldObj.isRemote) && ((stack.getItemDamage() == 14)) && ((entity instanceof EntityLivingBase)) && (!((EntityLivingBase) entity).isEntityUndead()) && (!((EntityLivingBase) entity).isPotionActive(Config.potionTaintPoisonID)) && (world.rand.nextInt(4321) <= stack.stackSize)) { + ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Config.potionTaintPoisonID, 120, 0, false)); + if ((entity instanceof EntityPlayer)) { + InventoryHelper.consumeInventoryItem((EntityPlayer) entity, stack.getItem(), stack.getItemDamage()); + } + } + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/ItemToolMaterials.java b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemToolMaterials.java new file mode 100644 index 0000000..4927a10 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/ItemToolMaterials.java @@ -0,0 +1,143 @@ +package tombenpotter.emt.common.modules.base.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import tombenpotter.emt.ModInformation; + +import java.util.List; + +public class ItemToolMaterials extends ItemBase { + + public IIcon[] icon = new IIcon[32]; + public final String drillTop = "drillTop"; + public final String chainsawTop = "chainsawTop"; + + public ItemToolMaterials() { + super("materials.tools"); + this.setHasSubtypes(true); + } + + @Override + public String getUnlocalizedName(ItemStack itemstack) { + String name = ""; + switch (itemstack.getItemDamage()) { + default: + name = "nothing"; + break; + case 0: { + name = drillTop + ".wood"; + break; + } + case 1: { + name = drillTop + ".stone"; + break; + } + case 2: { + name = drillTop + ".iron"; + break; + } + case 3: { + name = drillTop + ".gold"; + break; + } + case 4: { + name = drillTop + ".diamond"; + break; + } + case 5: { + name = drillTop + ".copper"; + break; + } + case 6: { + name = drillTop + ".tin"; + break; + } + case 7: { + name = drillTop + ".lead"; + break; + } + case 8: { + name = drillTop + ".bronze"; + break; + } + case 9: { + name = chainsawTop + ".wood"; + break; + } + case 10: { + name = chainsawTop + ".stone"; + break; + } + case 11: { + name = chainsawTop + ".iron"; + break; + } + case 12: { + name = chainsawTop + ".gold"; + break; + } + case 13: { + name = chainsawTop + ".diamond"; + break; + } + case 14: { + name = chainsawTop + ".copper"; + break; + } + case 15: { + name = chainsawTop + ".tin"; + break; + } + case 16: { + name = chainsawTop + ".lead"; + break; + } + case 17: { + name = chainsawTop + ".bronze"; + break; + } + } + return getUnlocalizedName() + "." + name; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ri) { + this.icon[0] = ri.registerIcon(ModInformation.texturePath + ":materials/" + drillTop + "_" + "wood"); + this.icon[1] = ri.registerIcon(ModInformation.texturePath + ":materials/" + drillTop + "_" + "stone"); + this.icon[2] = ri.registerIcon(ModInformation.texturePath + ":materials/" + drillTop + "_" + "iron"); + this.icon[3] = ri.registerIcon(ModInformation.texturePath + ":materials/" + drillTop + "_" + "gold"); + this.icon[4] = ri.registerIcon(ModInformation.texturePath + ":materials/" + drillTop + "_" + "diamond"); + this.icon[5] = ri.registerIcon(ModInformation.texturePath + ":materials/" + drillTop + "_" + "copper"); + this.icon[6] = ri.registerIcon(ModInformation.texturePath + ":materials/" + drillTop + "_" + "tin"); + this.icon[7] = ri.registerIcon(ModInformation.texturePath + ":materials/" + drillTop + "_" + "lead"); + this.icon[8] = ri.registerIcon(ModInformation.texturePath + ":materials/" + drillTop + "_" + "bronze"); + + this.icon[9] = ri.registerIcon(ModInformation.texturePath + ":materials/" + chainsawTop + "_" + "wood"); + this.icon[10] = ri.registerIcon(ModInformation.texturePath + ":materials/" + chainsawTop + "_" + "stone"); + this.icon[11] = ri.registerIcon(ModInformation.texturePath + ":materials/" + chainsawTop + "_" + "iron"); + this.icon[12] = ri.registerIcon(ModInformation.texturePath + ":materials/" + chainsawTop + "_" + "gold"); + this.icon[13] = ri.registerIcon(ModInformation.texturePath + ":materials/" + chainsawTop + "_" + "diamond"); + this.icon[14] = ri.registerIcon(ModInformation.texturePath + ":materials/" + chainsawTop + "_" + "copper"); + this.icon[15] = ri.registerIcon(ModInformation.texturePath + ":materials/" + chainsawTop + "_" + "tin"); + this.icon[16] = ri.registerIcon(ModInformation.texturePath + ":materials/" + chainsawTop + "_" + "lead"); + this.icon[17] = ri.registerIcon(ModInformation.texturePath + ":materials/" + chainsawTop + "_" + "bronze"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int meta) { + return this.icon[meta]; + } + + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List list) { + for (int i = 0; i <= 17; i++) { + list.add(new ItemStack(this, 1, i)); + } + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/foci/ItemBaseFocus.java b/src/main/java/tombenpotter/emt/common/modules/base/items/foci/ItemBaseFocus.java new file mode 100644 index 0000000..f56abf1 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/foci/ItemBaseFocus.java @@ -0,0 +1,134 @@ +package tombenpotter.emt.common.modules.base.items.foci; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.wands.IWandFocus; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; + +import java.util.List; + +public abstract class ItemBaseFocus extends Item implements IWandFocus { + + private IIcon ornament, depth; + + public ItemBaseFocus(String unlocName, String textureName) { + super(); + + setUnlocalizedName(ModInformation.modid + ".module.base.focus." + unlocName); + setTextureName(ModInformation.texturePath + ":" + textureName); + setCreativeTab(ElectroMagicTools.tabEMT); + setMaxDamage(1); + setNoRepair(); + setMaxStackSize(1); + } + + boolean hasOrnament() { + return false; + } + + boolean hasDepth() { + return false; + } + + @Override + public int getFocusColor() { + return 0; + } + + @Override + public boolean isItemTool(ItemStack par1ItemStack) { + return true; + } + + @Override + public EnumRarity getRarity(ItemStack itemstack) { + return EnumRarity.rare; + } + + @Override + public IIcon getFocusDepthLayerIcon() { + return depth; + } + + @Override + public IIcon getOrnament() { + return ornament; + } + + @Override + public WandFocusAnimation getAnimation() { + return WandFocusAnimation.WAVE; + } + + @Override + public AspectList getVisCost() { + return null; + } + + public boolean isUseItem() { + return isVisCostPerTick(); + } + + @Override + public boolean isVisCostPerTick() { + return false; + } + + @Override + public ItemStack onFocusRightClick(ItemStack paramItemStack, World paramWorld, EntityPlayer paramEntityPlayer, MovingObjectPosition paramMovingObjectPosition) { + if (isUseItem()) + paramEntityPlayer.setItemInUse(paramItemStack, Integer.MAX_VALUE); + return paramItemStack; + } + + @Override + public void onUsingFocusTick(ItemStack itemstack, EntityPlayer player, int count) { + + } + + @Override + public void onPlayerStoppedUsingFocus(ItemStack itemstack, World world, EntityPlayer player, int count) { + } + + @Override + public String getSortingHelper(ItemStack itemstack) { + return "00"; + } + + @Override + public boolean onFocusBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { + return false; + } + + @Override + public boolean acceptsEnchant(int id) { + return false; + } + + @Override + public int getItemEnchantability() { + return 5; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { + AspectList cost = getVisCost(); + if (cost != null && cost.size() > 0) { + list.add(StatCollector.translateToLocal(isVisCostPerTick() ? "item.Focus.cost2" : "item.Focus.cost1")); + for (Aspect aspect : cost.getAspectsSorted()) { + float amount = cost.getAmount(aspect) / 100.0F; + list.add(" " + '\u00a7' + aspect.getChatcolor() + aspect.getName() + '\u00a7' + "r x " + amount); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/foci/ItemChristmasFocus.java b/src/main/java/tombenpotter/emt/common/modules/base/items/foci/ItemChristmasFocus.java new file mode 100644 index 0000000..11839ef --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/foci/ItemChristmasFocus.java @@ -0,0 +1,54 @@ +package tombenpotter.emt.common.modules.base.items.foci; + +import net.minecraft.entity.monster.EntitySnowman; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.items.wands.ItemWandCasting; + +public class ItemChristmasFocus extends ItemBaseFocus { + + private static final AspectList visCost = new AspectList().add(Aspect.ORDER, 500).add(Aspect.AIR, 500); + + public ItemChristmasFocus() { + super("christmas", "focus_christmas"); + } + + @Override + public int getFocusColor() { + return 99999999; + } + + @Override + public AspectList getVisCost() { + return visCost; + } + + @Override + public String getSortingHelper(ItemStack itemstack) { + return "CHRISTMAS"; + } + + @Override + public ItemStack onFocusRightClick(ItemStack itemstack, World world, EntityPlayer player, MovingObjectPosition mop) { + ItemWandCasting wand = (ItemWandCasting) itemstack.getItem(); + if ((mop != null) && (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)) { + int x = mop.blockX; + int y = mop.blockY + 1; + int z = mop.blockZ; + if (wand.consumeAllVis(itemstack, player, getVisCost(), true, true)) { + if (!world.isRemote) { + EntitySnowman snowman; + snowman = new EntitySnowman(world); + snowman.setPosition(x, y, z); + world.spawnEntityInWorld(snowman); + } + } + player.swingItem(); + } + return itemstack; + } +} \ No newline at end of file diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/tools/ItemThorHammer.java b/src/main/java/tombenpotter/emt/common/modules/base/items/tools/ItemThorHammer.java new file mode 100644 index 0000000..468067e --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/tools/ItemThorHammer.java @@ -0,0 +1,85 @@ +package tombenpotter.emt.common.modules.base.items.tools; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; +import tombenpotter.emt.common.util.TextHelper; + +import java.util.List; + +public class ItemThorHammer extends ItemSword { + + public ItemThorHammer() { + super(ToolMaterial.EMERALD); + this.setMaxDamage(2000); + this.setCreativeTab(ElectroMagicTools.tabEMT); + this.setUnlocalizedName(ModInformation.modid + ".module.base.hammer"); + this.setTextureName(ModInformation.texturePath + ":hammer/thorhammer"); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { + player.swingItem(); + float f = 1.0F; + float f1 = player.prevRotationPitch + ((player.rotationPitch - player.prevRotationPitch) * f); + float f2 = player.prevRotationYaw + ((player.rotationYaw - player.prevRotationYaw) * f); + double d = player.prevPosX + ((player.posX - player.prevPosX) * f); + double d1 = (player.prevPosY + ((player.posY - player.prevPosY) * f) + 1.6200000000000001D) - player.yOffset; + double d2 = player.prevPosZ + ((player.posZ - player.prevPosZ) * f); + Vec3 vec3d = Vec3.createVectorHelper(d, d1, d2); + float f3 = MathHelper.cos((-f2 * 0.01745329F) - 3.141593F); + float f4 = MathHelper.sin((-f2 * 0.01745329F) - 3.141593F); + float f5 = -MathHelper.cos(-f1 * 0.01745329F); + float f6 = MathHelper.sin(-f1 * 0.01745329F); + float f7 = f4 * f5; + float f8 = f6; + float f9 = f3 * f5; + double d3 = 5000D; + Vec3 vec3d1 = vec3d.addVector(f7 * d3, f8 * d3, f9 * d3); + MovingObjectPosition movingobjectposition = player.worldObj.rayTraceBlocks(vec3d, vec3d1, true); + if (movingobjectposition == null) { + return itemstack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + world.spawnEntityInWorld(new EntityLightningBolt(world, i, j, k)); + } else if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) { + Entity entityhit = movingobjectposition.entityHit; + double x = entityhit.posX; + double y = entityhit.posY; + double z = entityhit.posZ; + world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z)); + } + if (player.capabilities.isCreativeMode) { + return itemstack; + } else { + itemstack.damageItem(20, player); + return itemstack; + } + } + + @Override + public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker) { + entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 12F); + itemstack.damageItem(1, attacker); + return true; + } + + @Override + @SuppressWarnings("unchecked") + public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { + list.add(TextHelper.localize("tooltip.EMT.hammer.thor")); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/base/items/tools/ItemThorHammerBroken.java b/src/main/java/tombenpotter/emt/common/modules/base/items/tools/ItemThorHammerBroken.java new file mode 100644 index 0000000..ab10340 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/base/items/tools/ItemThorHammerBroken.java @@ -0,0 +1,58 @@ +package tombenpotter.emt.common.modules.base.items.tools; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; +import org.lwjgl.input.Keyboard; +import thaumcraft.common.entities.projectile.EntityAlumentum; +import tombenpotter.emt.ModInformation; +import tombenpotter.emt.common.util.TextHelper; + +import java.util.List; + +public class ItemThorHammerBroken extends ItemThorHammer { + + public ItemThorHammerBroken() { + this.setUnlocalizedName(getUnlocalizedName() + ".broken"); + this.setTextureName(ModInformation.texturePath + ":hammer/taintedthorhammer"); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { + player.swingItem(); + world.spawnEntityInWorld(new EntityAlumentum(world, player.posX + 8, player.posY, player.posZ - 8)); + world.spawnEntityInWorld(new EntityAlumentum(world, player.posX - 8, player.posY, player.posZ + 8)); + world.spawnEntityInWorld(new EntityAlumentum(world, player.posX - 8, player.posY, player.posZ - 8)); + world.spawnEntityInWorld(new EntityAlumentum(world, player.posX + 8, player.posY, player.posZ + 8)); + world.spawnEntityInWorld(new EntityAlumentum(world, player.posX, player.posY + 4, player.posZ)); + world.spawnEntityInWorld(new EntityAlumentum(world, player.posX, player.posY + 8, player.posZ)); + + if (player.capabilities.isCreativeMode) { + return itemstack; + } else { + itemstack.damageItem(20, player); + return itemstack; + } + } + + @Override + public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker) { + entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 2F); + itemstack.damageItem(1, attacker); + return true; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer entityPlayer, List list, boolean par4) { + list.add(TextHelper.localize("tooltip.EMT.hammer.broken.thor")); + list.add(TextHelper.localize("tooltip.EMT.hammer.broken.danger")); + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + list.add(TextHelper.localize("tooltip.EMT.hammer.broken.plsNoRightClick")); + } else { + list.add(TextHelper.localize("tooltip.EMT.hammer.broken.plsRightClick")); + } + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/ic2/IC2RecipeRegistry.java b/src/main/java/tombenpotter/emt/common/modules/ic2/IC2RecipeRegistry.java new file mode 100644 index 0000000..db1980b --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/ic2/IC2RecipeRegistry.java @@ -0,0 +1,17 @@ +package tombenpotter.emt.common.modules.ic2; + +public class IC2RecipeRegistry { + + private static void registerShapedRecipes() { + + } + + private static void registerShapelessRecipes() { + + } + + public static void registerIC2Recipes() { + registerShapedRecipes(); + registerShapelessRecipes(); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/ic2/blocks/BlockIC2.java b/src/main/java/tombenpotter/emt/common/modules/ic2/blocks/BlockIC2.java new file mode 100644 index 0000000..e12f2ab --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/ic2/blocks/BlockIC2.java @@ -0,0 +1,28 @@ +package tombenpotter.emt.common.modules.ic2.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; + +public class BlockIC2 extends Block { + + public BlockIC2(String unlocName, Material material, String textureName, SoundType soundType, float hardness) { + super(material); + + setBlockName(ModInformation.modid + ".module.ic2." + unlocName); + setBlockTextureName(ModInformation.texturePath + ":" + textureName); + setCreativeTab(ElectroMagicTools.tabEMT); + setStepSound(soundType); + setHardness(hardness); + } + + public BlockIC2(String unlocName, Material material, SoundType soundType, float hardness) { + super(material); + + setBlockName(ModInformation.modid + ".module.ic2." + unlocName); + setCreativeTab(ElectroMagicTools.tabEMT); + setStepSound(soundType); + setHardness(hardness); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/ic2/blocks/IC2BlockRegistry.java b/src/main/java/tombenpotter/emt/common/modules/ic2/blocks/IC2BlockRegistry.java new file mode 100644 index 0000000..c5345a2 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/ic2/blocks/IC2BlockRegistry.java @@ -0,0 +1,8 @@ +package tombenpotter.emt.common.modules.ic2.blocks; + +public class IC2BlockRegistry { + + public static void registerIC2Blocks() { + + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/ic2/entities/EntityLaser.java b/src/main/java/tombenpotter/emt/common/modules/ic2/entities/EntityLaser.java new file mode 100644 index 0000000..ad2d1f6 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/ic2/entities/EntityLaser.java @@ -0,0 +1,338 @@ +package tombenpotter.emt.common.modules.ic2.entities; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IProjectile; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +import java.util.List; + +public class EntityLaser extends Entity implements IProjectile { + + private int xTile = -1; + private int yTile = -1; + private int zTile = -1; + private Block inTile; + private int inData; + private boolean inGround; + + public Entity shootingEntity; + private int ticksInGround; + private int ticksInAir; + + public EntityLaser(World par1World) { + super(par1World); + this.renderDistanceWeight = 10.0D; + this.setSize(0.5F, 0.5F); + } + + public EntityLaser(World par1World, double par2, double par4, double par6) { + super(par1World); + this.renderDistanceWeight = 10.0D; + this.setSize(0.5F, 0.5F); + this.setPosition(par2, par4, par6); + this.yOffset = 0.0F; + } + + public EntityLaser(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5) { + super(par1World); + this.renderDistanceWeight = 10.0D; + this.shootingEntity = par2EntityLivingBase; + + this.posY = par2EntityLivingBase.posY + (double) par2EntityLivingBase.getEyeHeight() - 0.10000000149011612D; + double d0 = par3EntityLivingBase.posX - par2EntityLivingBase.posX; + double d1 = par3EntityLivingBase.boundingBox.minY + (double) (par3EntityLivingBase.height / 3.0F) - this.posY; + double d2 = par3EntityLivingBase.posZ - par2EntityLivingBase.posZ; + double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2); + + if (d3 >= 1.0E-7D) { + float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; + float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / Math.PI)); + double d4 = d0 / d3; + double d5 = d2 / d3; + this.setLocationAndAngles(par2EntityLivingBase.posX + d4, this.posY, par2EntityLivingBase.posZ + d5, f2, f3); + this.yOffset = 0.0F; + float f4 = (float) d3 * 0.2F; + this.setThrowableHeading(d0, d1 + (double) f4, d2, par4, par5); + } + } + + public EntityLaser(World par1World, EntityLivingBase par2EntityLivingBase, float par3) { + super(par1World); + this.renderDistanceWeight = 10.0D; + this.shootingEntity = par2EntityLivingBase; + + this.setSize(0.5F, 0.5F); + this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double) par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch); + this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F); + this.posY -= 0.10000000149011612D; + this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F); + this.setPosition(this.posX, this.posY, this.posZ); + this.yOffset = 0.0F; + this.motionX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); + this.motionZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); + this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI)); + this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F); + } + + protected void entityInit() { + this.dataWatcher.addObject(16, Byte.valueOf((byte) 0)); + } + + public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) { + float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); + par1 /= (double) f2; + par3 /= (double) f2; + par5 /= (double) f2; + par1 += this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) par8; + par3 += this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) par8; + par5 += this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) par8; + par1 *= (double) par7; + par3 *= (double) par7; + par5 *= (double) par7; + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, (double) f3) * 180.0D / Math.PI); + this.ticksInGround = 0; + } + + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) { + this.setPosition(par1, par3, par5); + this.setRotation(par7, par8); + } + + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) { + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { + float f = MathHelper.sqrt_double(par1 + par5); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, (double) f) / Math.PI); + this.prevRotationPitch = this.rotationPitch; + this.prevRotationYaw = this.rotationYaw; + this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + this.ticksInGround = 0; + } + } + + @SuppressWarnings("rawtypes") + public void onUpdate() { + super.onUpdate(); + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI); + } + + Block block = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); + if (block.getMaterial() != Material.air) { + block.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile); + AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile); + + if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { + this.inGround = true; + } + } + Block i = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); + + i.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile); + AxisAlignedBB axisalignedbb = i.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile); + + if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { + this.inGround = true; + } + + if (this.inGround) { + Block j = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); + int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 3, true); + this.setDead(); + if (j == this.inTile && k == this.inData) { + ++this.ticksInGround; + + if (this.ticksInGround == 1200) { + this.setDead(); + } + } else { + this.inGround = false; + this.motionX *= (double) (this.rand.nextFloat() * 0.2F); + this.motionY *= (double) (this.rand.nextFloat() * 0.2F); + this.motionZ *= (double) (this.rand.nextFloat() * 0.2F); + this.ticksInGround = 0; + this.ticksInAir = 0; + } + } else { + ++this.ticksInAir; + Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); + vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + + if (movingobjectposition != null) { + vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + } + + Entity entity = null; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + int l; + float f1; + + for (l = 0; l < list.size(); ++l) { + Entity entity1 = (Entity) list.get(l); + + if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { + f1 = 0.3F; + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) f1, (double) f1, (double) f1); + MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit; + + if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) { + movingobjectposition = null; + } + } + + float f2; + float f3; + + if (movingobjectposition != null) { + if (movingobjectposition.entityHit != null) { + f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + + { + this.motionX *= -0.10000000149011612D; + this.motionY *= -0.10000000149011612D; + this.motionZ *= -0.10000000149011612D; + this.rotationYaw += 180.0F; + this.prevRotationYaw += 180.0F; + this.ticksInAir = 0; + } + } else { + this.xTile = movingobjectposition.blockX; + this.yTile = movingobjectposition.blockY; + this.zTile = movingobjectposition.blockZ; + this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile); + this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); + this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX)); + this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY)); + this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ)); + f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.posX -= this.motionX / (double) f2 * 0.05000000074505806D; + this.posY -= this.motionY / (double) f2 * 0.05000000074505806D; + this.posZ -= this.motionZ / (double) f2 * 0.05000000074505806D; + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.inGround = true; + } + } + + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + + for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float f4 = 0.99F; + f1 = 0.05F; + + if (this.isInWater()) { + for (int j1 = 0; j1 < 4; ++j1) { + f3 = 0.25F; + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double) f3, this.posY - this.motionY * (double) f3, this.posZ - this.motionZ * (double) f3, this.motionX, this.motionY, this.motionZ); + } + + f4 = 0.8F; + } + + this.motionX *= (double) f4; + this.motionY *= (double) f4; + this.motionZ *= (double) f4; + this.motionY -= (double) f1; + this.setPosition(this.posX, this.posY, this.posZ); + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { + par1NBTTagCompound.setShort("xTile", (short) this.xTile); + par1NBTTagCompound.setShort("yTile", (short) this.yTile); + par1NBTTagCompound.setShort("zTile", (short) this.zTile); + par1NBTTagCompound.setByte("inTile", (byte) Block.getIdFromBlock(this.inTile)); + par1NBTTagCompound.setByte("inData", (byte) this.inData); + par1NBTTagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0)); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { + this.xTile = par1NBTTagCompound.getShort("xTile"); + this.yTile = par1NBTTagCompound.getShort("yTile"); + this.zTile = par1NBTTagCompound.getShort("zTile"); + this.inTile = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255); + this.inData = par1NBTTagCompound.getByte("inData") & 255; + this.inGround = par1NBTTagCompound.getByte("inGround") == 1; + } + + public void onCollide(Entity par1Entity) { + if (!this.worldObj.isRemote) + ; + { + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 3, true); + } + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() { + return 0.0F; + } +} \ No newline at end of file diff --git a/src/main/java/tombenpotter/emt/common/modules/ic2/entities/IC2EntityRegistry.java b/src/main/java/tombenpotter/emt/common/modules/ic2/entities/IC2EntityRegistry.java new file mode 100644 index 0000000..97ed6dc --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/ic2/entities/IC2EntityRegistry.java @@ -0,0 +1,5 @@ +package tombenpotter.emt.common.modules.ic2.entities; + +public class IC2EntityRegistry { + +} diff --git a/src/main/java/tombenpotter/emt/common/modules/ic2/items/IC2ItemRegistry.java b/src/main/java/tombenpotter/emt/common/modules/ic2/items/IC2ItemRegistry.java new file mode 100644 index 0000000..12b2c89 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/ic2/items/IC2ItemRegistry.java @@ -0,0 +1,14 @@ +package tombenpotter.emt.common.modules.ic2.items; + +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.item.Item; + +public class IC2ItemRegistry { + + public static Item ic2Baubles; + + public static void registerIC2Items() { + ic2Baubles = new ItemIC2Baubles(); + GameRegistry.registerItem(ic2Baubles, "IC2Baubles"); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/ic2/items/ItemIC2.java b/src/main/java/tombenpotter/emt/common/modules/ic2/items/ItemIC2.java new file mode 100644 index 0000000..b74ab0e --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/ic2/items/ItemIC2.java @@ -0,0 +1,23 @@ +package tombenpotter.emt.common.modules.ic2.items; + +import net.minecraft.item.Item; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; + +public class ItemIC2 extends Item { + + public ItemIC2(String unlocName, String textureName) { + super(); + + setUnlocalizedName(ModInformation.modid + ".module.ic2." + unlocName); + setTextureName(ModInformation.texturePath + ":" + textureName); + setCreativeTab(ElectroMagicTools.tabEMT); + } + + public ItemIC2(String unlocName) { + super(); + + setUnlocalizedName(ModInformation.modid + ".module.ic2." + unlocName); + setCreativeTab(ElectroMagicTools.tabEMT); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/ic2/items/ItemIC2Baubles.java b/src/main/java/tombenpotter/emt/common/modules/ic2/items/ItemIC2Baubles.java new file mode 100644 index 0000000..2598ffd --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/ic2/items/ItemIC2Baubles.java @@ -0,0 +1,136 @@ +package tombenpotter.emt.common.modules.ic2.items; + +import baubles.api.BaubleType; +import baubles.api.IBauble; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import tombenpotter.emt.ModInformation; +import tombenpotter.emt.common.util.ConfigHandler; + +import java.util.List; +import java.util.Random; + +public class ItemIC2Baubles extends ItemIC2 implements IBauble { + + public IIcon[] icon = new IIcon[16]; + public static int wornTick; + public Random random = new Random(); + + public ItemIC2Baubles() { + super("bauble"); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setMaxStackSize(1); + + wornTick = 0; + } + + @Override + public String getUnlocalizedName(ItemStack itemstack) { + String name = ""; + switch (itemstack.getItemDamage()) { + case 0: { + name = "euMaker.armor"; + break; + } + case 1: { + name = "euMaker.inventory"; + break; + } + default: + name = "nothing"; + break; + } + return getUnlocalizedName() + "." + name; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ri) { + this.icon[0] = ri.registerIcon(ModInformation.texturePath + ":armoreumaker"); + this.icon[1] = ri.registerIcon(ModInformation.texturePath + ":inventoryeumaker"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int meta) { + return this.icon[meta]; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List list) { + list.add(new ItemStack(this, 1, 0)); + list.add(new ItemStack(this, 1, 1)); + } + + @Override + public BaubleType getBaubleType(ItemStack stack) { + if (stack.getItemDamage() <= 1) { + return BaubleType.RING; + } else { + return null; + } + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if (!player.worldObj.isRemote) { + if (stack != null) { + if (stack.getItemDamage() == 0) { + if (player instanceof EntityPlayer) { + int energyLeft = ConfigHandler.armorBaubleProduction; + for (int i = 0; i < ((EntityPlayer) player).inventory.armorInventory.length; i++) { + if (energyLeft > 0) { + if ((((EntityPlayer) player).inventory.armorInventory[i] != null) && (((EntityPlayer) player).inventory.armorInventory[i].getItem() instanceof IElectricItem)) { + double sentPacket = ElectricItem.manager.charge(((EntityPlayer) player).inventory.armorInventory[i], energyLeft, 4, false, false); + energyLeft -= sentPacket; + } + } + } + } + } + } + if (stack != null) { + if (stack.getItemDamage() == 1) { + if (player instanceof EntityPlayer) { + int energyLeft = ConfigHandler.inventoryBaubleProdution; + for (int i = 0; i < ((EntityPlayer) player).inventory.mainInventory.length; i++) { + if (energyLeft > 0) { + if ((((EntityPlayer) player).inventory.mainInventory[i] != null) && (((EntityPlayer) player).inventory.mainInventory[i].getItem() instanceof IElectricItem)) { + double sentPacket = ElectricItem.manager.charge(((EntityPlayer) player).inventory.mainInventory[i], energyLeft, 4, false, false); + energyLeft -= sentPacket; + } + } + } + } + } + } + } + } + + @Override + public void onEquipped(ItemStack stack, EntityLivingBase player) { + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + } + + @Override + public boolean canEquip(ItemStack stack, EntityLivingBase player) { + return true; + } + + @Override + public boolean canUnequip(ItemStack stack, EntityLivingBase player) { + return true; + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/te/TERecipeRegistry.java b/src/main/java/tombenpotter/emt/common/modules/te/TERecipeRegistry.java new file mode 100644 index 0000000..e4f0b95 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/te/TERecipeRegistry.java @@ -0,0 +1,17 @@ +package tombenpotter.emt.common.modules.te; + +public class TERecipeRegistry { + + private static void registerShapedRecipes() { + + } + + private static void registerShapelessRecipes() { + + } + + public static void registerTERecipes() { + registerShapedRecipes(); + registerShapelessRecipes(); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/te/blocks/BlockTE.java b/src/main/java/tombenpotter/emt/common/modules/te/blocks/BlockTE.java new file mode 100644 index 0000000..6c09459 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/te/blocks/BlockTE.java @@ -0,0 +1,28 @@ +package tombenpotter.emt.common.modules.te.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; + +public class BlockTE extends Block { + + public BlockTE(String unlocName, Material material, String textureName, SoundType soundType, float hardness) { + super(material); + + setBlockName(ModInformation.modid + ".module.te." + unlocName); + setBlockTextureName(ModInformation.texturePath + ":" + textureName); + setCreativeTab(ElectroMagicTools.tabEMT); + setStepSound(soundType); + setHardness(hardness); + } + + public BlockTE(String unlocName, Material material, SoundType soundType, float hardness) { + super(material); + + setBlockName(ModInformation.modid + ".module.te." + unlocName); + setCreativeTab(ElectroMagicTools.tabEMT); + setStepSound(soundType); + setHardness(hardness); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/te/blocks/TEBlockRegistry.java b/src/main/java/tombenpotter/emt/common/modules/te/blocks/TEBlockRegistry.java new file mode 100644 index 0000000..a6a90cd --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/te/blocks/TEBlockRegistry.java @@ -0,0 +1,8 @@ +package tombenpotter.emt.common.modules.te.blocks; + +public class TEBlockRegistry { + + public static void registerTEBlocks() { + + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/te/items/ItemTE.java b/src/main/java/tombenpotter/emt/common/modules/te/items/ItemTE.java new file mode 100644 index 0000000..303f619 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/te/items/ItemTE.java @@ -0,0 +1,23 @@ +package tombenpotter.emt.common.modules.te.items; + +import net.minecraft.item.Item; +import tombenpotter.emt.ElectroMagicTools; +import tombenpotter.emt.ModInformation; + +public class ItemTE extends Item { + + public ItemTE(String unlocName, String textureName) { + super(); + + setUnlocalizedName(ModInformation.modid + ".module.te." + unlocName); + setTextureName(ModInformation.texturePath + ":" + textureName); + setCreativeTab(ElectroMagicTools.tabEMT); + } + + public ItemTE(String unlocName) { + super(); + + setUnlocalizedName(ModInformation.modid + ".module.te." + unlocName); + setCreativeTab(ElectroMagicTools.tabEMT); + } +} diff --git a/src/main/java/tombenpotter/emt/common/modules/te/items/TEItemRegistry.java b/src/main/java/tombenpotter/emt/common/modules/te/items/TEItemRegistry.java new file mode 100644 index 0000000..2f83ec1 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/modules/te/items/TEItemRegistry.java @@ -0,0 +1,8 @@ +package tombenpotter.emt.common.modules.te.items; + +public class TEItemRegistry { + + public static void registerTEItems() { + + } +} diff --git a/src/main/java/tombenpotter/emt/common/util/ConfigHandler.java b/src/main/java/tombenpotter/emt/common/util/ConfigHandler.java index e30acf9..2f30c50 100644 --- a/src/main/java/tombenpotter/emt/common/util/ConfigHandler.java +++ b/src/main/java/tombenpotter/emt/common/util/ConfigHandler.java @@ -13,6 +13,7 @@ public class ConfigHandler { public static String CATEGORY_RESEARCH = "Research"; public static String CATEGORY_VALUES = "Numeric Values"; public static String CATEGORY_OUTPUTS = "Essentia Generator Outputs"; + public static String CATEGORY_MODULES = "Modules"; public static int essentiaGeneratorsDelay; public static int etherealProcessorBaseSpeed; @@ -103,6 +104,9 @@ public class ConfigHandler { public static boolean quantumWingsResearch; public static boolean aerGeneratorResearch; + public static boolean enableIC2Module; + public static boolean enableTEModule; + public static void init(File file) { config = new Configuration(file); syncConfig(); @@ -197,6 +201,9 @@ public class ConfigHandler { quantumWingsResearch = config.get(CATEGORY_RESEARCH, "Quantum Wings", false).getBoolean(quantumWingsResearch); aerGeneratorResearch = config.get(CATEGORY_RESEARCH, "Aer Generator", false).getBoolean(aerGeneratorResearch); + enableIC2Module = config.get(CATEGORY_MODULES, "IC2 Module", true).getBoolean(enableIC2Module); + enableTEModule = config.get(CATEGORY_MODULES, "TE Module", true).getBoolean(enableTEModule); + if (config.hasChanged()) { config.save(); }