From adf68761440503604d0caa19ceb64c3d1d524579 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Fri, 24 Jan 2014 10:21:10 -0500 Subject: [PATCH] Some work on spells, etc. --- .../AlchemicalWizardry.java | 10 +- .../BloodMagicConfiguration.java | 3 +- .../alchemicalWizardry/ModBlocks.java | 4 +- .../common/block/BlockConduit.java | 27 +- .../common/block/BlockOrientable.java | 247 ++++++++++++++++++ .../common/block/BlockSpellEffect.java | 12 + .../spell/complex/effect/SpellEffectFire.java | 2 +- .../common/tileEntity/TEConduit.java | 6 +- .../common/tileEntity/TEOrientable.java | 8 + 9 files changed, 298 insertions(+), 21 deletions(-) create mode 100644 BM_src/WayofTime/alchemicalWizardry/common/block/BlockOrientable.java create mode 100644 BM_src/WayofTime/alchemicalWizardry/common/block/BlockSpellEffect.java diff --git a/BM_src/WayofTime/alchemicalWizardry/AlchemicalWizardry.java b/BM_src/WayofTime/alchemicalWizardry/AlchemicalWizardry.java index 3112ef8b..d387cf35 100644 --- a/BM_src/WayofTime/alchemicalWizardry/AlchemicalWizardry.java +++ b/BM_src/WayofTime/alchemicalWizardry/AlchemicalWizardry.java @@ -76,6 +76,7 @@ import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar; import WayofTime.alchemicalWizardry.common.tileEntity.TEConduit; import WayofTime.alchemicalWizardry.common.tileEntity.TEHomHeart; import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone; +import WayofTime.alchemicalWizardry.common.tileEntity.TEOrientable; import WayofTime.alchemicalWizardry.common.tileEntity.TEPedestal; import WayofTime.alchemicalWizardry.common.tileEntity.TEPlinth; import WayofTime.alchemicalWizardry.common.tileEntity.TESocket; @@ -284,6 +285,7 @@ public class AlchemicalWizardry public static int spectralBlockBlockID; public static int blockConduitBlockID; public static int blockBloodLightBlockID; + public static int blockSpellEffectBlockID; public static void registerRenderInformation() { @@ -364,7 +366,7 @@ public class AlchemicalWizardry //blocks - //blockConduit = new BlockConduit(blockConduitBlockID); + proxy.registerRenderers(); proxy.registerEntities(); //ItemStacks used for crafting go here @@ -652,6 +654,7 @@ public class AlchemicalWizardry GameRegistry.registerTileEntity(TEPlinth.class, "containerPlinth"); GameRegistry.registerTileEntity(TETeleposer.class, "containerTeleposer"); GameRegistry.registerTileEntity(TEConduit.class, "containerConduit"); + GameRegistry.registerTileEntity(TEOrientable.class, "containerOrientable"); // GameRegistry.registerBlock(ModBlocks.bloodRune, ItemBloodRuneBlock.class, "AlchemicalWizardry" + (ModBlocks.bloodRune.getUnlocalizedName().substring(5))); LanguageRegistry.addName(new ItemStack(ModBlocks.bloodRune, 1, 0), "Blood Rune"); @@ -689,6 +692,8 @@ public class AlchemicalWizardry LanguageRegistry.addName(ModBlocks.blockTeleposer, "Teleposer"); LanguageRegistry.addName(ModBlocks.spectralBlock, "Spectral Block"); LanguageRegistry.addName(ModBlocks.blockBloodLight, "Blood Light"); + LanguageRegistry.addName(ModBlocks.blockConduit, "Spell Conduit"); + //TODO GameRegistry.registerBlock(ModBlocks.armourForge, "armourForge"); GameRegistry.registerBlock(ModBlocks.emptySocket, "emptySocket"); GameRegistry.registerBlock(ModBlocks.bloodStoneBrick, "bloodStoneBrick"); @@ -700,7 +705,8 @@ public class AlchemicalWizardry GameRegistry.registerBlock(ModBlocks.blockTeleposer, "blockTeleposer"); GameRegistry.registerBlock(ModBlocks.spectralBlock, "spectralBlock"); GameRegistry.registerBlock(ModBlocks.blockBloodLight, "bloodLight"); - //GameRegistry.registerBlock(blockConduit,"blockConduit"); + GameRegistry.registerBlock(ModBlocks.blockConduit,"blockConduit"); + GameRegistry.registerBlock(ModBlocks.blockSpellEffect,"blockSpellEffect"); MinecraftForge.setBlockHarvestLevel(ModBlocks.bloodRune, "pickaxe", 2); MinecraftForge.setBlockHarvestLevel(ModBlocks.speedRune, "pickaxe", 2); MinecraftForge.setBlockHarvestLevel(ModBlocks.efficiencyRune, "pickaxe", 2); diff --git a/BM_src/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java b/BM_src/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java index 132721ea..e6c63b88 100644 --- a/BM_src/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java +++ b/BM_src/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java @@ -82,7 +82,8 @@ public class BloodMagicConfiguration AlchemicalWizardry.blockTeleposerBlockID = config.getBlock("BlockTeleposer", 1422).getInt(); AlchemicalWizardry.spectralBlockBlockID = config.getBlock("SpectralBlock", 1423).getInt(); AlchemicalWizardry.blockBloodLightBlockID = config.getBlock("BloodLight", 1424).getInt(); - //blockConduitBlockID = config.getBlock("BlockConduit", 1424).getInt(); + AlchemicalWizardry.blockConduitBlockID = config.getBlock("BlockConduit", 1425).getInt(); + AlchemicalWizardry.blockSpellEffectBlockID = config.getBlock("BlockSpellEffect", 1426).getInt(); //Items AlchemicalWizardry.weakBloodOrbItemID = config.getItem("WeakBloodOrb", 17000).getInt(); AlchemicalWizardry.energyBlasterItemID = config.getItem("EnergyBlaster", 17001).getInt(); diff --git a/BM_src/WayofTime/alchemicalWizardry/ModBlocks.java b/BM_src/WayofTime/alchemicalWizardry/ModBlocks.java index 0be56f76..7a0bb761 100644 --- a/BM_src/WayofTime/alchemicalWizardry/ModBlocks.java +++ b/BM_src/WayofTime/alchemicalWizardry/ModBlocks.java @@ -41,6 +41,7 @@ public class ModBlocks public static Block spectralBlock; public static Block blockConduit; public static Block blockBloodLight; + public static Block blockSpellEffect; public static void init() { @@ -69,7 +70,8 @@ public class ModBlocks blockHomHeart = new BlockHomHeart(AlchemicalWizardry.blockHomHeartBlockID); blockPedestal = new BlockPedestal(AlchemicalWizardry.blockPedestalBlockID); blockPlinth = new BlockPlinth(AlchemicalWizardry.blockPlinthBlockID); + blockConduit = new BlockConduit(AlchemicalWizardry.blockConduitBlockID); blockBloodLight = new BlockBloodLightSource(AlchemicalWizardry.blockBloodLightBlockID); - + blockSpellEffect = new BlockSpellEffect(AlchemicalWizardry.blockSpellEffectBlockID); } } diff --git a/BM_src/WayofTime/alchemicalWizardry/common/block/BlockConduit.java b/BM_src/WayofTime/alchemicalWizardry/common/block/BlockConduit.java index ad9e502d..18fe8099 100644 --- a/BM_src/WayofTime/alchemicalWizardry/common/block/BlockConduit.java +++ b/BM_src/WayofTime/alchemicalWizardry/common/block/BlockConduit.java @@ -1,9 +1,5 @@ package WayofTime.alchemicalWizardry.common.block; -import WayofTime.alchemicalWizardry.AlchemicalWizardry; -import WayofTime.alchemicalWizardry.common.tileEntity.TEConduit; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; @@ -12,6 +8,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; +import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.tileEntity.TEConduit; +import WayofTime.alchemicalWizardry.common.tileEntity.TEOrientable; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockConduit extends BlockContainer { @@ -76,25 +77,25 @@ public class BlockConduit extends BlockContainer ForgeDirection sideClicked = ForgeDirection.getOrientation(side); TileEntity tile = world.getBlockTileEntity(x, y, z); - if (tile instanceof TEConduit) + if (tile instanceof TEOrientable) { //TODO NEEDS WORK - if (((TEConduit) tile).getInputDirection().equals(sideClicked)) + if (((TEOrientable) tile).getInputDirection().equals(sideClicked)) { - ((TEConduit) tile).setInputDirection(((TEConduit) tile).getOutputDirection()); - ((TEConduit) tile).setOutputDirection(sideClicked); - } else if (((TEConduit) tile).getOutputDirection().equals(sideClicked)) + ((TEOrientable) tile).setInputDirection(((TEConduit) tile).getOutputDirection()); + ((TEOrientable) tile).setOutputDirection(sideClicked); + } else if (((TEOrientable) tile).getOutputDirection().equals(sideClicked)) { - ((TEConduit) tile).setOutputDirection(((TEConduit) tile).getInputDirection()); - ((TEConduit) tile).setInputDirection(sideClicked); + ((TEOrientable) tile).setOutputDirection(((TEConduit) tile).getInputDirection()); + ((TEOrientable) tile).setInputDirection(sideClicked); } else { if (!player.isSneaking()) { - ((TEConduit) tile).setOutputDirection(sideClicked); + ((TEOrientable) tile).setOutputDirection(sideClicked); } else { - ((TEConduit) tile).setOutputDirection(sideClicked.getOpposite()); + ((TEOrientable) tile).setOutputDirection(sideClicked.getOpposite()); } } } diff --git a/BM_src/WayofTime/alchemicalWizardry/common/block/BlockOrientable.java b/BM_src/WayofTime/alchemicalWizardry/common/block/BlockOrientable.java new file mode 100644 index 00000000..c9dee139 --- /dev/null +++ b/BM_src/WayofTime/alchemicalWizardry/common/block/BlockOrientable.java @@ -0,0 +1,247 @@ +package WayofTime.alchemicalWizardry.common.block; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import WayofTime.alchemicalWizardry.AlchemicalWizardry; +import WayofTime.alchemicalWizardry.common.tileEntity.TEOrientable; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockOrientable extends BlockContainer +{ + @SideOnly(Side.CLIENT) + private static Icon topIcon; + @SideOnly(Side.CLIENT) + private static Icon sideIcon1; + @SideOnly(Side.CLIENT) + private static Icon sideIcon2; + @SideOnly(Side.CLIENT) + private static Icon bottomIcon; + + @SideOnly(Side.CLIENT) + private static Icon[] fireIcons; + + public BlockOrientable(int id) + { + super(id, Material.rock); + setHardness(2.0F); + setResistance(5.0F); + setCreativeTab(AlchemicalWizardry.tabBloodMagic); + setUnlocalizedName("bloodSocket"); + //func_111022_d("AlchemicalWizardry:blocks"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister iconRegister) + { + this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket"); + this.sideIcon1 = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket"); + this.sideIcon2 = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket"); + this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodSocket"); + + this.fireIcons = this.registerIconsWithString(iconRegister, "fireEffectBlock"); + } + + @SideOnly(Side.CLIENT) + public Icon[] registerIconsWithString(IconRegister iconRegister, String blockString) + { + Icon[] icons = new Icon[7]; + + icons[0] = iconRegister.registerIcon("AlchemicalWizardry:" + blockString + "_input"); + icons[1] = iconRegister.registerIcon("AlchemicalWizardry:" + blockString + "_output"); + icons[2] = iconRegister.registerIcon("AlchemicalWizardry:" + blockString + "_upArrow"); + icons[3] = iconRegister.registerIcon("AlchemicalWizardry:" + blockString + "_downArrow"); + icons[4] = iconRegister.registerIcon("AlchemicalWizardry:" + blockString + "_leftArrow"); + icons[5] = iconRegister.registerIcon("AlchemicalWizardry:" + blockString + "_rightArrow"); + icons[6] = iconRegister.registerIcon("AlchemicalWizardry:" + blockString + "_blank"); + + return icons; + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon(int side, int meta) + { + switch (side) + { + case 0: + return bottomIcon; + + case 1: + return topIcon; + + //case 2: return sideIcon1; + //case 3: return sideIcon1; + //case 4: return sideIcon2; + //case 5: return sideIcon2; + default: + return sideIcon2; + } + } + +// @Override +// public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are) +// { +// return false; +// } + + @SideOnly(Side.CLIENT) + + /** + * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side + */ + public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int x, int y, int z, int side) + { + TileEntity tile = par1IBlockAccess.getBlockTileEntity(x, y, z); + int meta = par1IBlockAccess.getBlockMetadata(x, y, z); + + if(tile instanceof TEOrientable) + { + ForgeDirection input = ((TEOrientable)tile).getInputDirection(); + ForgeDirection output = ((TEOrientable)tile).getOutputDirection(); + + return this.getIconsForMeta(meta)[this.getTextureIndexForSideAndOrientation(side, input, output)]; + } + + return this.getIcon(side, meta); + } + + @Override + public TileEntity createNewTileEntity(World world) + { + return new TEOrientable(); + } + + public Icon[] getIconsForMeta(int metadata) + { + return this.fireIcons; + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float what, float these, float are) + { + if (world.isRemote) + { + return false; + } + + ForgeDirection sideClicked = ForgeDirection.getOrientation(side); + TileEntity tile = world.getBlockTileEntity(x, y, z); + + if (tile instanceof TEOrientable) + { + //TODO NEEDS WORK + if (((TEOrientable) tile).getInputDirection().equals(sideClicked)) + { + ((TEOrientable) tile).setInputDirection(((TEOrientable) tile).getOutputDirection()); + ((TEOrientable) tile).setOutputDirection(sideClicked); + } else if (((TEOrientable) tile).getOutputDirection().equals(sideClicked)) + { + ((TEOrientable) tile).setOutputDirection(((TEOrientable) tile).getInputDirection()); + ((TEOrientable) tile).setInputDirection(sideClicked); + } else + { + if (!player.isSneaking()) + { + ((TEOrientable) tile).setOutputDirection(sideClicked); + } else + { + ((TEOrientable) tile).setOutputDirection(sideClicked.getOpposite()); + } + } + } + + world.markBlockForUpdate(x, y, z); + return true; + } + + public int getTextureIndexForSideAndOrientation(int side, ForgeDirection input, ForgeDirection output) + { + if(ForgeDirection.getOrientation(side) == input) + { + return 0; + } + if(ForgeDirection.getOrientation(side) == output) + { + return 1; + } + if(ForgeDirection.getOrientation(side) == output.getOpposite()) + { + return 6; + } + + switch(side) + { + case 0: //BOTTOM + switch(output) + { + case NORTH: return 2; //UP + case SOUTH: return 3; //DOWN + case EAST: return 4; //LEFT + case WEST: return 5; //RIGHT + default: break; + } + break; + case 1: //TOP + switch(output) + { + case NORTH: return 2; //UP + case SOUTH: return 3; //DOWN + case EAST: return 5; + case WEST: return 4; + default: break; + } + break; + case 2: //NORTH + switch(output) + { + case DOWN: return 3; + case UP: return 2; + case EAST: return 4; + case WEST: return 5; + default: break; + } + break; + case 3: //SOUTH + switch(output) + { + case DOWN: return 3; + case UP: return 2; + case EAST: return 5; + case WEST: return 4; + default: break; + } + break; + case 4: //WEST + switch(output) + { + case DOWN: return 3; + case UP: return 2; + case NORTH: return 5; + case SOUTH: return 4; + default: break; + } + break; + case 5: //EAST + switch(output) + { + case DOWN: return 3; + case UP: return 2; + case NORTH: return 4; + case SOUTH: return 5; + default: break; + } + break; + } + + return 0; + } +} diff --git a/BM_src/WayofTime/alchemicalWizardry/common/block/BlockSpellEffect.java b/BM_src/WayofTime/alchemicalWizardry/common/block/BlockSpellEffect.java new file mode 100644 index 00000000..f2b38a82 --- /dev/null +++ b/BM_src/WayofTime/alchemicalWizardry/common/block/BlockSpellEffect.java @@ -0,0 +1,12 @@ +package WayofTime.alchemicalWizardry.common.block; + + +public class BlockSpellEffect extends BlockOrientable +{ + + public BlockSpellEffect(int id) + { + super(id); + setUnlocalizedName("blockSpellEffect"); + } +} diff --git a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellEffectFire.java b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellEffectFire.java index 49bd8ac1..4683aeb0 100644 --- a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellEffectFire.java +++ b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellEffectFire.java @@ -126,7 +126,7 @@ public class SpellEffectFire extends SpellEffect @Override protected int getCostForOffenseSelf() { - return 100*(int)((this.powerEnhancement+1)*Math.pow(2, potencyEnhancement)); + return 500*(int)((this.powerEnhancement+1)*Math.pow(2, potencyEnhancement)); } @Override diff --git a/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEConduit.java b/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEConduit.java index 1f5f5924..d8b4a426 100644 --- a/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEConduit.java +++ b/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEConduit.java @@ -23,9 +23,9 @@ public class TEConduit extends TEOrientable public void updateEntity() { //this.capacity=(int) (10000*this.capacityMultiplier); - if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) - { - } +// if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) +// { +// } } @Override diff --git a/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEOrientable.java b/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEOrientable.java index dcad8303..1933a411 100644 --- a/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEOrientable.java +++ b/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEOrientable.java @@ -1,7 +1,9 @@ package WayofTime.alchemicalWizardry.common.tileEntity; +import WayofTime.alchemicalWizardry.common.PacketHandler; import WayofTime.alchemicalWizardry.common.block.IOrientable; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.packet.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -82,4 +84,10 @@ public class TEOrientable extends TileEntity implements IOrientable return 0; } } + + @Override + public Packet getDescriptionPacket() + { + return PacketHandler.getBlockOrientationPacket(this); + } }