diff --git a/build.gradle b/build.gradle index 7a4020a..e498b01 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ group= "com.brandon3055.draconicevolution" // http://maven.apache.org/guides/min archivesBaseName = "Draconic-Evolution" minecraft { - version = "1.7.10-10.13.0.1187" + version = "1.7.10-10.13.0.1188" //assetDir = "run/assets" } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/ItemParticleGenRenderer.java b/src/main/java/com/brandon3055/draconicevolution/client/render/ItemParticleGenRenderer.java index e93fd67..e97b74e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/ItemParticleGenRenderer.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/ItemParticleGenRenderer.java @@ -35,6 +35,8 @@ public class ItemParticleGenRenderer implements IItemRenderer @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); if (type == IItemRenderer.ItemRenderType.ENTITY) GL11.glTranslatef(-0.5F, 0.0F, -0.5F); this.dummytile.xCoord = 0; @@ -42,6 +44,8 @@ public class ItemParticleGenRenderer implements IItemRenderer this.dummytile.zCoord = 0; this.dummytile.setWorldObj(Minecraft.getMinecraft().theWorld); this.render.renderTileEntityAt(this.dummytile, 0.0D, 0.0D, 0.0D, 0.0F); + GL11.glPopAttrib(); + GL11.glPopMatrix(); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/Draconium.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/Draconium.java new file mode 100644 index 0000000..d1d365a --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/Draconium.java @@ -0,0 +1,29 @@ +package com.brandon3055.draconicevolution.common.blocks; + +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.lib.References; +import com.brandon3055.draconicevolution.common.lib.Strings; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; + +/** + * Created by Brandon on 25/07/2014. + */ +public class Draconium extends DraconicEvolutionBlock { + public Draconium() { + super(Material.iron); + this.setHardness(10F); + this.setResistance(100F); + this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); + this.setBlockName(Strings.draconiumName); + ModBlocks.register(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconium_block"); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/MobSpawner.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/MobSpawner.java deleted file mode 100644 index a54a924..0000000 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/MobSpawner.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.brandon3055.draconicevolution.common.blocks; - -import net.minecraft.block.material.Material; -import sun.org.mozilla.javascript.internal.ast.Block; - -/** - * Created by Brandon on 21/06/2014. - */ -public class MobSpawner extends Block { - public MobSpawner() - { - - } - -} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ModBlocks.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ModBlocks.java index 54309d9..6e8e7f7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ModBlocks.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ModBlocks.java @@ -1,5 +1,7 @@ package com.brandon3055.draconicevolution.common.blocks; +import com.brandon3055.draconicevolution.common.blocks.multiblock.EnergyStorageCore; +import com.brandon3055.draconicevolution.common.blocks.multiblock.InvisibleMultiblock; import net.minecraft.block.Block; import cpw.mods.fml.common.registry.GameRegistry; import com.brandon3055.draconicevolution.DraconicEvolution; @@ -21,6 +23,9 @@ public class ModBlocks { public static Block customSpawner; public static Block longRangeDislocator; public static Block generator; + public static Block energyStorageCore; + public static Block draconium; + public static Block invisibleMultiblock; public static void init() { @@ -37,6 +42,9 @@ public class ModBlocks { energyInfuser = new EnergyInfuser(); customSpawner = new CustomSpawner(); generator = new Generator(); + energyStorageCore = new EnergyStorageCore(); + draconium = new Draconium(); + invisibleMultiblock = new InvisibleMultiblock(); if(ConfigHandler.disable_LRD < 2) longRangeDislocator = new LongRangeDislocator(); if(DraconicEvolution.debug) testBlock = new TestBlock(); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java index 2ddc81e..87afdfb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java @@ -2,11 +2,15 @@ package com.brandon3055.draconicevolution.common.blocks; import java.util.Random; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; @@ -45,8 +49,10 @@ public class ParticleGenerator extends Block @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + if (meta == 1) return false; if (player.isSneaking()) { + if (activateEnergyStorageCore(world, x, y, z, player)) return true; TileEntity tile = world.getTileEntity(x, y, z); TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null; if (gen != null) @@ -148,4 +154,34 @@ public class ParticleGenerator extends Block return new TileParticleGenerator(); } + private boolean activateEnergyStorageCore(World world, int x, int y, int z, EntityPlayer player){ + for (int x1 = x - 11; x1 <= x + 11; x1++){ + if (world.getBlock(x1, y, z) == ModBlocks.energyStorageCore) { + TileEnergyStorageCore tile = (world.getTileEntity(x1, y, z) != null && world.getTileEntity(x1, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x1, y, z) : null; + if (tile != null && !tile.isOnline()) + { + if (!tile.tryActivate() && world.isRemote) { + player.addChatComponentMessage(new ChatComponentTranslation("msg.energyStorageCoreUTA.txt")); + return false; + } + return true; + } + } + } + + for (int z1 = z - 11; z1 <= z + 11; z1++){ + if (world.getBlock(x, y, z1) == ModBlocks.energyStorageCore) { + TileEnergyStorageCore tile = (world.getTileEntity(x, y, z1) != null && world.getTileEntity(x, y, z1) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z1) : null; + if (tile != null && !tile.isOnline()) + { + if (!tile.tryActivate() && world.isRemote) { + player.addChatComponentMessage(new ChatComponentTranslation("msg.energyStorageCoreUTA.txt")); + return false; + } + return true; + } + } + } + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java index f5736b8..934c043 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java @@ -54,7 +54,7 @@ public class TestBlock extends DraconicEvolutionBlock { @Override public TileEntity createTileEntity(World world, int metadata) { - return null;//new TileTestBlock(); + return new TileTestBlock(); } @Override diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java new file mode 100644 index 0000000..fe52f9f --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java @@ -0,0 +1,67 @@ +package com.brandon3055.draconicevolution.common.blocks.multiblock; + +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.blocks.DraconicEvolutionBlock; +import com.brandon3055.draconicevolution.common.blocks.ModBlocks; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.lib.References; +import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.tileentities.TileGenerator; +import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Created by Brandon on 25/07/2014. + */ +public class EnergyStorageCore extends DraconicEvolutionBlock { + + public EnergyStorageCore() { + super(Material.iron); + this.setHardness(10F); + this.setResistance(100F); + this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); + this.setBlockName(Strings.energyStorageCoreName); + ModBlocks.register(this); + } + + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "energy_storage_core"); + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileEnergyStorageCore(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + TileEnergyStorageCore tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; + if (tile == null) + { + LogHelper.error("Missing Tile Entity (EnergyStorageCore)"); + return false; + } + if (!world.isRemote) + tile.tryActivate(); + //if (world.isRemote) + //player.addChatComponentMessage(new ChatComponentText(""+tile.getEnergyStored(ForgeDirection.UP))); + return true; + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java new file mode 100644 index 0000000..89b8d34 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java @@ -0,0 +1,127 @@ +package com.brandon3055.draconicevolution.common.blocks.multiblock; + +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.blocks.DraconicEvolutionBlock; +import com.brandon3055.draconicevolution.common.blocks.Draconium; +import com.brandon3055.draconicevolution.common.blocks.ModBlocks; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.lib.References; +import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore; +import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileInvisibleMultiblock; +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.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.Random; + +/** + * Created by Brandon on 25/07/2014. + */ +public class InvisibleMultiblock extends DraconicEvolutionBlock { + + public InvisibleMultiblock() { + super(Material.iron); + this.setHardness(10F); + this.setResistance(100F); + //this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); + this.setBlockName(Strings.invisibleMultiblockName); + ModBlocks.register(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconium_block"); + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderType() { + return -1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileInvisibleMultiblock(); + } + + @Override + public Item getItemDropped(int meta, Random p_149650_2_, int var2) { + if (meta == 0) + return Item.getItemFromBlock(ModBlocks.draconium); + else if (meta == 1) + return Item.getItemFromBlock(Blocks.redstone_block); + else + return null; + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; + if (thisTile == null) + { + LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock)"); + return false; + } + TileEnergyStorageCore master= thisTile.getMaster(); + if (master == null) { + onNeighborBlockChange(world, x, y, z, this); + return false; + } + if (world.isRemote) + player.addChatComponentMessage(new ChatComponentText(""+master.getEnergyStored(ForgeDirection.UP))); + return true; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { + TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; + if (thisTile == null) + { + LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock)"); + revert(world, x, y, z); + return; + } + TileEnergyStorageCore master = thisTile.getMaster(); + if (master == null) { + LogHelper.error("Master = null reverting!"); + revert(world, x, y, z); + return; + } + if (!master.isOnline()) revert(world, x, y, z); + } + + private void revert(World world, int x, int y, int z){ + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0) + world.setBlock(x, y, z, ModBlocks.draconium); + else if (meta == 1) + world.setBlock(x, y, z, Blocks.redstone_block); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/MultiblockHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/MultiblockHelper.java new file mode 100644 index 0000000..6e72108 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/MultiblockHelper.java @@ -0,0 +1,65 @@ +package com.brandon3055.draconicevolution.common.blocks.multiblock; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +/** + * Created by Brandon on 25/07/2014. + */ +public class MultiblockHelper { + + + + public static class TileLocation { + protected int xCoord; + protected int yCoord; + protected int zCoord; + + public TileLocation(){ + + } + + public TileLocation(int x, int y, int z){ + this.xCoord = x; + this.yCoord = y; + this.zCoord = z; + } + + public int getXCoord(){ + return xCoord; + } + + public int getYCoord(){ + return yCoord; + } + + public int getZCoord(){ + return zCoord; + } + + public void setXCoord(int x){ + xCoord = x; + } + + public void setYCoord(int y){ + yCoord = y; + } + + public void setZCoord(int z){ + zCoord = z; + } + + public void writeToNBT(NBTTagCompound compound, String key) { + compound.setInteger("X_"+key, xCoord); + compound.setInteger("Y_"+key, yCoord); + compound.setInteger("Z_"+key, zCoord); + } + + public void readFromNBT(NBTTagCompound compound, String key) { + xCoord = compound.getInteger("X_"+key); + yCoord = compound.getInteger("Y_"+key); + zCoord = compound.getInteger("Z_"+key); + } + } + +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java b/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java index 6eaef21..86e29a6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java @@ -5,6 +5,8 @@ import com.brandon3055.draconicevolution.common.core.network.*; import com.brandon3055.draconicevolution.common.entity.EntityCustomDragon; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.tileentities.*; +import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore; +import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileInvisibleMultiblock; import com.brandon3055.draconicevolution.common.world.DraconicWorldGenerator; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @@ -62,6 +64,8 @@ public class CommonProxy { GameRegistry.registerTileEntity(TileEnergyInfuser.class, "TileEnergyInfuser"); GameRegistry.registerTileEntity(TileCustomSpawner.class, "TileCustomSpawner"); GameRegistry.registerTileEntity(TileGenerator.class, "TileGenerator"); + GameRegistry.registerTileEntity(TileEnergyStorageCore.class, "TileEnergyStorageCore"); + GameRegistry.registerTileEntity(TileInvisibleMultiblock.class, "TileInvisibleMultiblock"); if(DraconicEvolution.debug) GameRegistry.registerTileEntity(TileTestBlock.class, "TileTestBlock"); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/utills/Utills.java b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/Utills.java new file mode 100644 index 0000000..85953c4 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/Utills.java @@ -0,0 +1,12 @@ +package com.brandon3055.draconicevolution.common.core.utills; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +/** + * Created by Brandon on 25/07/2014. + */ +public class Utills { + + +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java b/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java index d884d0f..66835e2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java @@ -47,4 +47,7 @@ public class Strings {// public sta public static final String MobSoulName = "mobSoul"; public static final String longRangeDislocatorName = "longRangeDislocator"; public static final String generatorName = "generator"; + public static final String energyStorageCoreName = "energyStorageCore"; + public static final String draconiumName = "draconium"; + public static final String invisibleMultiblockName = "invisibleMultiblock"; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java index 7450ce9..895cf6f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java @@ -111,6 +111,7 @@ public class TileCustomSpawner extends TileEntity isSetToSpawn = tagCompound.getBoolean("Running"); } + @Override public Packet getDescriptionPacket(){ NBTTagCompound nbttagcompound = new NBTTagCompound(); writeToNBT(nbttagcompound); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java index 201d481..1a2958f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java @@ -10,6 +10,7 @@ import cofh.api.energy.EnergyStorage; import cofh.api.energy.IEnergyHandler; import com.brandon3055.draconicevolution.common.core.utills.LogHelper; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; /** @@ -74,4 +75,8 @@ public class TileTestBlock extends TileEntity implements IEnergyHandler { return true; } + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java new file mode 100644 index 0000000..8c76456 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java @@ -0,0 +1,588 @@ +package com.brandon3055.draconicevolution.common.tileentities.multiblocktiles; + +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyHandler; +import com.brandon3055.draconicevolution.common.blocks.ModBlocks; +import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Created by Brandon on 25/07/2014. + */ +public class TileEnergyStorageCore extends TileEntity implements IEnergyHandler { + + protected EnergyStorage storage = new EnergyStorage(1000000, 1000000, 1000000); + protected TileLocation[] stabilizers = new TileLocation[4]; + protected int tier = 6; + protected boolean online = false; + + + @Override + public void updateEntity() { + if (tier != 6) + LogHelper.info(tier); + } + + + /** + * ######################MultiBlock Methods####################### + */ + + public boolean tryActivate() { + if (!findStabalyzers()) return false; + if (!setTier(false)) return false; + if (!testOrActivateStructureIfValid(false, false)) return false; + if (!testOrActivateStructureIfValid(false, true)) return false; + //LogHelper.info(testOrActivateStructureIfValid(false, true)); + + return true; + } + + public boolean isStructureStillValid(){ + return true; + } + + private boolean findStabalyzers() { + for (int x = xCoord; x <= xCoord + 11; x++) { + if (worldObj.getBlock(x, yCoord, zCoord) == ModBlocks.particleGenerator) { + stabilizers[0] = new TileLocation(x, yCoord, zCoord); + break; + } else if (x == xCoord + 11) { + return false; + } + + } + for (int x = xCoord; x >= xCoord - 11; x--) { + if (worldObj.getBlock(x, yCoord, zCoord) == ModBlocks.particleGenerator) { + stabilizers[1] = new TileLocation(x, yCoord, zCoord); + break; + } else if (x == xCoord - 11) { + return false; + } + } + for (int z = zCoord; z <= zCoord + 11; z++) { + if (worldObj.getBlock(xCoord, yCoord, z) == ModBlocks.particleGenerator) { + stabilizers[2] = new TileLocation(xCoord, yCoord, z); + break; + } else if (z == zCoord + 11) { + return false; + } + } + for (int z = zCoord; z >= zCoord - 11; z--) { + if (worldObj.getBlock(xCoord, yCoord, z) == ModBlocks.particleGenerator) { + stabilizers[3] = new TileLocation(xCoord, yCoord, z); + break; + } else if (z == zCoord - 11) { + return false; + } + } + return true; + } + + private boolean setTier(boolean force) { + if (force) return true; + int xPos = 0; + int xNeg = 0; + int yPos = 0; + int yNeg = 0; + int zPos = 0; + int zNeg = 0; + int range = 5; + + for (int x = 0; x <= range; x++) { + if (testForOrActivateDraconium(xCoord + x, yCoord, zCoord, false, false)) { + xPos = x; + break; + } + } + + for (int x = 0; x <= range; x++) { + if (testForOrActivateDraconium(xCoord - x, yCoord, zCoord, false, false)) { + xNeg = x; + if (xNeg != xPos) return false; + break; + } + } + + for (int y = 0; y <= range; y++) { + if (testForOrActivateDraconium(xCoord, yCoord + y, zCoord, false, false)) { + yPos = y; + if (yPos != xNeg) return false; + break; + } + } + + for (int y = 0; y <= range; y++) { + if (testForOrActivateDraconium(xCoord, yCoord - y, zCoord, false, false)) { + yNeg = y; + if (yNeg != yPos) return false; + break; + } + } + + for (int z = 0; z <= range; z++) { + if (testForOrActivateDraconium(xCoord, yCoord, zCoord + z, false, false)) { + zPos = z; + if (zPos != yNeg) return false; + break; + } + } + + for (int z = 0; z <= range; z++) { + if (testForOrActivateDraconium(xCoord, yCoord, zCoord - z, false, false)) { + zNeg = z; + if (zNeg != zPos) return false; + break; + } + } + + tier = xPos; + if (tier > 1) tier++; + if (tier == 1){ + if (testForOrActivateDraconium(xCoord + 1, yCoord + 1, zCoord, false, false)) tier = 2; + } + //LogHelper.info(""+tier); + return true; + } + + private boolean testOrActivateStructureIfValid(boolean setBlocks, boolean activate){ + switch (tier){ + case 0: + if (!testOrActivateRect(1, 1, 1, "air", setBlocks, activate)) return false; + break; + case 1: + if (!testForOrActivateDraconium(xCoord + 1, yCoord, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord - 1, yCoord, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord + 1, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord - 1, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord, zCoord + 1, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord, zCoord - 1, setBlocks, activate)) return false; + if (!isAir(xCoord+1, yCoord+1, zCoord, setBlocks) || !isAir(xCoord, yCoord+1, zCoord+1, setBlocks) || !isAir(xCoord-1, yCoord+1, zCoord, setBlocks) || !isAir(xCoord, yCoord+1, zCoord-1, setBlocks) || !isAir(xCoord+1, yCoord-1, zCoord, setBlocks) || !isAir(xCoord, yCoord-1, zCoord+1, setBlocks) || !isAir(xCoord-1, yCoord-1, zCoord, setBlocks) || !isAir(xCoord, yCoord-1, zCoord-1, setBlocks) || !isAir(xCoord+1, yCoord, zCoord+1, setBlocks) || !isAir(xCoord-1, yCoord, zCoord-1, setBlocks) || !isAir(xCoord+1, yCoord, zCoord-1, setBlocks) || !isAir(xCoord-1, yCoord, zCoord+1, setBlocks)) return false; + if (!isAir(xCoord+1, yCoord+1, zCoord+1, setBlocks) || !isAir(xCoord-1, yCoord+1, zCoord-1, setBlocks) || !isAir(xCoord+1, yCoord+1, zCoord-1, setBlocks) || !isAir(xCoord-1, yCoord+1, zCoord+1, setBlocks) || !isAir(xCoord+1, yCoord-1, zCoord+1, setBlocks) || !isAir(xCoord-1, yCoord-1, zCoord-1, setBlocks) || !isAir(xCoord+1, yCoord-1, zCoord-1, setBlocks) || !isAir(xCoord-1, yCoord-1, zCoord+1, setBlocks)) return false; + break; + case 2: + if (!testOrActivateRect(1, 1, 1, "draconium", setBlocks, activate)) return false; + break; + case 3: + if (!testOrActivateSides(1, "draconium", setBlocks, activate)) return false; + if (!testOrActivateRect(1, 1, 1, "redstone", setBlocks, activate)) return false; + break; + case 4: + if (!testOrActivateSides(2, "draconium", setBlocks, activate)) return false; + if (!testOrActivateRect(2, 1, 1, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(1, 2, 1, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(1, 1, 2, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRings(2, 2, "draconium", setBlocks, activate)) return false; + break; + case 5: + if (!testOrActivateSides(3, "draconium", setBlocks, activate)) return false; + if (!testOrActivateSides(2, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(2, 2, 2, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRings(2, 3, "draconium", setBlocks, activate)) return false; + break; + case 6: + if (!testOrActivateSides(4, "draconium", setBlocks, activate)) return false; + if (!testOrActivateSides(3, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(3, 2, 2, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(2, 3, 2, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRect(2, 2, 3, "redstone", setBlocks, activate)) return false; + if (!testOrActivateRings(2, 4, "draconium", setBlocks, activate)) return false; + if (!testOrActivateRings(3, 3, "draconium", setBlocks, activate)) return false; + break; + } + return true; + } + + private boolean testOrActivateRect(int xDim, int yDim, int zDim, String block, boolean set, boolean activate){ + for (int x = xCoord - xDim; x <= xCoord + xDim; x++){ + for (int y = yCoord - yDim; y <= yCoord + yDim; y++){ + for (int z = zCoord - zDim; z <= zCoord + zDim; z++){ + + if (block.equals("air")){ + if (!(x == xCoord && y == yCoord && z == zCoord) && !isAir(x, y, z, set)) return false; + } + else if (block.equals("redstone")){ + if (!(x == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(x, y, z, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(x == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(x, y, z, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + return true; + } + + private boolean testOrActivateRings(int size, int dist, String block, boolean set, boolean activate){ + for (int y=yCoord-size; y<=yCoord+size;y++){ + for (int z=zCoord-size; z<=zCoord+size;z++){ + + if (y == yCoord-size || y == yCoord+size || z == zCoord-size || z==zCoord+size) { + if (block.equals("air")) { + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !isAir(xCoord + dist, y, z, set)) + return false; + } else if (block.equals("redstone")) { + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord + dist, y, z, set, activate)) + return false; + } else if (block.equals("draconium")) { + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord + dist, y, z, set, activate)) + return false; + } else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + for (int y=yCoord-size; y<=yCoord+size;y++){ + for (int z=zCoord-size; z<=zCoord+size;z++){ + + if (y == yCoord-size || y == yCoord+size || z == zCoord-size || z==zCoord+size) { + if (block.equals("air")) { + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !isAir(xCoord - dist, y, z, set)) + return false; + } else if (block.equals("redstone")) { + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord - dist, y, z, set, activate)) + return false; + } else if (block.equals("draconium")) { + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord - dist, y, z, set, activate)) + return false; + } else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + + for (int x=xCoord-size; x<=xCoord+size;x++){ + for (int z=zCoord-size; z<=zCoord+size;z++){ + + if (x == xCoord-size || x == xCoord+size || z == zCoord-size || z == zCoord+size) { + if (block.equals("air")){ + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !isAir(x, yCoord + dist, z, set)) return false; + } + else if (block.equals("redstone")){ + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord + dist, z, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord + dist, z, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + for (int x=xCoord-size; x<=xCoord+size;x++){ + for (int z=zCoord-size; z<=zCoord+size;z++){ + + if (x == xCoord-size || x == xCoord+size || z == zCoord-size || z==zCoord+size) { + if (block.equals("air")){ + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !isAir(x, yCoord - dist, z, set)) return false; + } + else if (block.equals("redstone")){ + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord - dist, z, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord - dist, z, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + + for (int y=yCoord-size; y<=yCoord+size;y++){ + for (int x=xCoord-size; x<=xCoord+size;x++){ + + if (y == yCoord-size || y == yCoord+size || x == xCoord-size || x == xCoord+size) { + if (block.equals("air")){ + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !isAir(x, y, zCoord + dist, set)) return false; + } + else if (block.equals("redstone")){ + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord + dist, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord + dist, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + for (int y=yCoord-size; y<=yCoord+size;y++){ + for (int x=xCoord-size; x<=xCoord+size;x++){ + + if (y == yCoord-size || y == yCoord+size || x == xCoord-size || x==xCoord+size) { + if (block.equals("air")){ + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !isAir(x, y, zCoord - dist, set)) return false; + } + else if (block.equals("redstone")){ + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord - dist, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord - dist, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + } + return true; + } + + private boolean testOrActivateSides(int dist, String block, boolean set, boolean activate){ + dist++; + for (int y=yCoord-1; y<=yCoord+1;y++){ + for (int z=zCoord-1; z<=zCoord+1;z++){ + + if (block.equals("air")){ + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !isAir(xCoord + dist, y, z, set)) return false; + } + else if (block.equals("redstone")){ + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord + dist, y, z, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord + dist, y, z, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + for (int y=yCoord-1; y<=yCoord+1;y++){ + for (int z=zCoord-1; z<=zCoord+1;z++){ + + if (block.equals("air")){ + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !isAir(xCoord - dist, y, z, set)) return false; + } + else if (block.equals("redstone")){ + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord - dist, y, z, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateDraconium(xCoord - dist, y, z, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + + for (int x=xCoord-1; x<=xCoord+1;x++){ + for (int z=zCoord-1; z<=zCoord+1;z++){ + + if (block.equals("air")){ + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !isAir(x, yCoord + dist, z, set)) return false; + } + else if (block.equals("redstone")){ + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord + dist, z, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord + dist, z, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + for (int x=xCoord-1; x<=xCoord+1;x++){ + for (int z=zCoord-1; z<=zCoord+1;z++){ + + if (block.equals("air")){ + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !isAir(x, yCoord - dist, z, set)) return false; + } + else if (block.equals("redstone")){ + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord - dist, z, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateDraconium(x, yCoord - dist, z, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + + for (int y=yCoord-1; y<=yCoord+1;y++){ + for (int x=xCoord-1; x<=xCoord+1;x++){ + + if (block.equals("air")){ + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !isAir(x, y, zCoord + dist, set)) return false; + } + else if (block.equals("redstone")){ + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord + dist, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord + dist, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + for (int y=yCoord-1; y<=yCoord+1;y++){ + for (int x=xCoord-1; x<=xCoord+1;x++){ + + if (block.equals("air")){ + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !isAir(x, y, zCoord - dist, set)) return false; + } + else if (block.equals("redstone")){ + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord - dist, set, activate)) return false; + } + else if (block.equals("draconium")){ + if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateDraconium(x, y, zCoord - dist, set, activate)) return false; + } + else if (!block.equals("draconium") && !block.equals("redstone") && !block.equals("air")) { + LogHelper.error("Invalid String In Multiblock Structure Code!!!"); + return false; + } + } + } + + return true; + } + + private boolean testForOrActivateDraconium(int x, int y, int z, boolean set, boolean activate){ + if (!activate) { + if (set) { + worldObj.setBlock(x, y, z, ModBlocks.draconium); + return true; + } else return worldObj.getBlock(x, y, z) == ModBlocks.draconium || (worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && worldObj.getBlockMetadata(x, y, z) == 0); + }else{ + return activateDraconium(x, y, z); + } + } + + private boolean testForOrActivateRedstone(int x, int y, int z, boolean set, boolean activate){ + if (!activate) { + if (set) { + worldObj.setBlock(x, y, z, Blocks.redstone_block); + return true; + } else return worldObj.getBlock(x, y, z) == Blocks.redstone_block || (worldObj.getBlock(x, y, z) == ModBlocks.invisibleMultiblock && worldObj.getBlockMetadata(x, y, z) == 1); + }else{ + return activateRedstone(x, y, z); + } + } + + private boolean activateDraconium(int x, int y, int z){ + if (testForOrActivateDraconium(x, y, z, false, false)){ + worldObj.setBlock(x, y, z, ModBlocks.invisibleMultiblock, 0, 2); + TileInvisibleMultiblock tile = (worldObj.getTileEntity(x, y, z) != null && worldObj.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) worldObj.getTileEntity(x, y, z) : null; + if (tile != null) { + tile.master = new TileLocation(xCoord, yCoord, zCoord); + } + return true; + } + LogHelper.error("Failed to activate structure (activateDraconium)"); + return false; + } + + private boolean activateRedstone(int x, int y, int z){ + if (testForOrActivateRedstone(x, y, z, false, false)){ + worldObj.setBlock(x, y, z, ModBlocks.invisibleMultiblock, 1, 2); + TileInvisibleMultiblock tile = (worldObj.getTileEntity(x, y, z) != null && worldObj.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) worldObj.getTileEntity(x, y, z) : null; + if (tile != null) { + tile.master = new TileLocation(xCoord, yCoord, zCoord); + } + return true; + } + LogHelper.error("Failed to activate structure (activateRedstone)"); + return false; + } + + private boolean isAir(int x, int y, int z, boolean set){ + if (set){ + worldObj.setBlock(x, y, z, Blocks.air); + return true; + }else + return worldObj.getBlock(x, y, z) == Blocks.air; + } + + public boolean isOnline(){ + return online; + } + + /** + * ############################################################### + */ + + + @Override + public void writeToNBT(NBTTagCompound compound) { + storage.writeToNBT(compound); + super.writeToNBT(compound); + for (int i = 0; i < stabilizers.length; i++){ + if (stabilizers[i] != null) + stabilizers[i].writeToNBT(compound, String.valueOf(i)); + } + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + storage.readFromNBT(compound); + super.readFromNBT(compound); + for (int i = 0; i < stabilizers.length; i++){ + if (stabilizers[i] != null) + stabilizers[i].readFromNBT(compound, String.valueOf(i)); + } + } + + @Override + public Packet getDescriptionPacket(){ + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } + + /* IEnergyHandler */ + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + + return storage.receiveEnergy(maxReceive, simulate); + } + + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return storage.extractEnergy(maxExtract, simulate); + } + + @Override + public int getEnergyStored(ForgeDirection from) { + return storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return storage.getMaxEnergyStored(); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileInvisibleMultiblock.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileInvisibleMultiblock.java new file mode 100644 index 0000000..8275938 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileInvisibleMultiblock.java @@ -0,0 +1,55 @@ +package com.brandon3055.draconicevolution.common.tileentities.multiblocktiles; + +import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; + +/** + * Created by Brandon on 26/07/2014. + */ +public class TileInvisibleMultiblock extends TileEntity { + public TileLocation master; + + public boolean isMasterOnline() { + TileEnergyStorageCore tile = (worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) != null && worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) : null; + if (tile == null) { + return false; + } + return tile.online; + } + + public TileEnergyStorageCore getMaster(){ + if (master == null) return null; + TileEnergyStorageCore tile = (worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) != null && worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) worldObj.getTileEntity(master.getXCoord(), master.getYCoord(), master.getZCoord()) : null; + return tile; + } + + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + master.writeToNBT(compound, "Key"); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + master.readFromNBT(compound, "Key"); + } + + @Override + public Packet getDescriptionPacket(){ + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } + +} diff --git a/src/main/resources/assets/draconicevolution/lang/en_US.lang b/src/main/resources/assets/draconicevolution/lang/en_US.lang index ad94961..77aed35 100644 --- a/src/main/resources/assets/draconicevolution/lang/en_US.lang +++ b/src/main/resources/assets/draconicevolution/lang/en_US.lang @@ -88,6 +88,7 @@ msg.spawnerInfo10.txt=Tier 3 : ???... msg.dislocatorUnsafe.txt=Destination Unsafe Please Try Again msg.dislocatorNoGround.txt=Error world not found msg.range.txt=Range: +msg.energyStorageCoreUTA.txt=Unable to activate (Invalid Configuration) //###################################Tool Tips###################################// info.teleporterInfUnset1.txt=Unbound diff --git a/src/main/resources/assets/draconicevolution/textures/blocks/draconium_block.png b/src/main/resources/assets/draconicevolution/textures/blocks/draconium_block.png new file mode 100644 index 0000000..8946e7b Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/blocks/draconium_block.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/blocks/energy_storage_core.png b/src/main/resources/assets/draconicevolution/textures/blocks/energy_storage_core.png new file mode 100644 index 0000000..e3347b2 Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/blocks/energy_storage_core.png differ