diff --git a/electrical/src/main/java/resonantinduction/electrical/MultipartElectrical.java b/electrical/src/main/java/resonantinduction/electrical/MultipartElectrical.java index e401bee41..398df4720 100644 --- a/electrical/src/main/java/resonantinduction/electrical/MultipartElectrical.java +++ b/electrical/src/main/java/resonantinduction/electrical/MultipartElectrical.java @@ -24,6 +24,7 @@ public class MultipartElectrical implements IPartFactory { MultiPartRegistry.registerParts(this, PART_TYPES); MultipartGenerator.registerPassThroughInterface("universalelectricity.api.electricity.IVoltageOutput"); + MultipartGenerator.registerTrait("icbm.api.IBlockFrequency", "resonantinduction.quantum.gate.TraitFrequency"); MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.electrical.wire.trait.TraitConductor"); MultipartGenerator.registerTrait("cofh.api.energy.IEnergyHandler", "resonantinduction.electrical.wire.trait.TraitEnergyHandler"); MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.electrical.wire.trait.TraitEnergySink"); diff --git a/electrical/src/main/java/resonantinduction/quantum/gate/BlockQuantumGate.java b/electrical/src/main/java/resonantinduction/quantum/gate/BlockQuantumGate.java index 60adc798a..edcb25647 100644 --- a/electrical/src/main/java/resonantinduction/quantum/gate/BlockQuantumGate.java +++ b/electrical/src/main/java/resonantinduction/quantum/gate/BlockQuantumGate.java @@ -74,7 +74,7 @@ public class BlockQuantumGate extends BlockTile @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f1, float f2, float f3) { - if (player != null && player.getHeldItem() == null || player.getHeldItem().itemID != (Electrical.blockGlyph.blockID)) + if (player != null && player.getHeldItem() == null) { TileEntity tile = world.getBlockTileEntity(x, y, z); diff --git a/electrical/src/main/java/resonantinduction/quantum/gate/ItemQuantumGlyph.java b/electrical/src/main/java/resonantinduction/quantum/gate/ItemQuantumGlyph.java index 40b6e563a..47872f447 100644 --- a/electrical/src/main/java/resonantinduction/quantum/gate/ItemQuantumGlyph.java +++ b/electrical/src/main/java/resonantinduction/quantum/gate/ItemQuantumGlyph.java @@ -81,7 +81,7 @@ public class ItemQuantumGlyph extends JItemMultiPart implements IHighlight @Override public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo) { - for (int i = 0; i < 4; i++) + for (int i = 0; i < PartQuantumGlyph.MAX_GLYPH; i++) { listToAddTo.add(new ItemStack(itemID, 1, i)); } diff --git a/electrical/src/main/java/resonantinduction/quantum/gate/PartQuantumGlyph.java b/electrical/src/main/java/resonantinduction/quantum/gate/PartQuantumGlyph.java index 6104447bb..3dbf10638 100644 --- a/electrical/src/main/java/resonantinduction/quantum/gate/PartQuantumGlyph.java +++ b/electrical/src/main/java/resonantinduction/quantum/gate/PartQuantumGlyph.java @@ -1,16 +1,17 @@ package resonantinduction.quantum.gate; +import icbm.api.IBlockFrequency; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MovingObjectPosition; -import resonantinduction.core.Reference; +import resonantinduction.core.ResonantInduction; import resonantinduction.electrical.Electrical; -import calclavia.lib.render.RenderUtility; import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataOutput; import codechicken.lib.vec.Cuboid6; @@ -20,8 +21,9 @@ import codechicken.multipart.JNormalOcclusion; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class PartQuantumGlyph extends JCuboidPart implements JNormalOcclusion +public class PartQuantumGlyph extends JCuboidPart implements JNormalOcclusion, IBlockFrequency { + public static final int MAX_GLYPH = 4; static final Cuboid6[] bounds = new Cuboid6[8]; static @@ -46,6 +48,42 @@ public class PartQuantumGlyph extends JCuboidPart implements JNormalOcclusion this.number = (byte) itemDamage; } + @Override + public void update() + { + if (world().isRemote) + { + int frequency = ((IBlockFrequency) tile()).getFrequency(); + + if (frequency > 0) + { + // Spawn particle effects. + universalelectricity.api.vector.Vector3 center = new universalelectricity.api.vector.Vector3(x() + 0.5, y() + 0.5, z() + 0.5); + Electrical.proxy.renderElectricShock(world(), center, center.clone().translate(Math.random() * 1 - 0.5, Math.random() * 1 - 0.5, Math.random() * 1 - 0.5)); + } + } + } + + @Override + public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack itemStack) + { + if (!world().isRemote) + { + int frequency = ((IBlockFrequency) tile()).getFrequency(); + + if (frequency > -1) + { + player.addChatMessage("Quantum Gate Frequency: " + frequency); + } + else + { + player.addChatMessage("Quantum Gate not set up."); + } + } + + return true; + } + @Override public String getType() { @@ -77,7 +115,7 @@ public class PartQuantumGlyph extends JCuboidPart implements JNormalOcclusion protected ItemStack getItem() { - return new ItemStack(Electrical.itemQuantumGlyph); + return new ItemStack(Electrical.itemQuantumGlyph, 1, number); } @Override @@ -124,4 +162,16 @@ public class PartQuantumGlyph extends JCuboidPart implements JNormalOcclusion nbt.setByte("number", number); } + @Override + public int getFrequency() + { + return number; + } + + @Override + public void setFrequency(int frequency) + { + + } + } diff --git a/electrical/src/main/java/resonantinduction/quantum/gate/TraitFrequency.java b/electrical/src/main/java/resonantinduction/quantum/gate/TraitFrequency.java new file mode 100644 index 000000000..da270f24f --- /dev/null +++ b/electrical/src/main/java/resonantinduction/quantum/gate/TraitFrequency.java @@ -0,0 +1,42 @@ +package resonantinduction.quantum.gate; + +import icbm.api.IBlockFrequency; + +import java.util.Iterator; + +import net.minecraft.block.Block; +import scala.collection.Seq; +import universalelectricity.api.vector.Vector3; +import codechicken.multipart.TMultiPart; +import codechicken.multipart.TileMultipart; + +public class TraitFrequency extends TileMultipart implements IBlockFrequency +{ + @Override + public int getFrequency() + { + int frequency = 0; + + int i = 0; + + for (TMultiPart part : jPartList()) + { + if (part instanceof IBlockFrequency) + { + frequency += Math.pow(PartQuantumGlyph.MAX_GLYPH, i) * ((IBlockFrequency) part).getFrequency(); + i++; + } + } + if (i >= 8) + return frequency; + + return -1; + } + + @Override + public void setFrequency(int frequency) + { + + } + +} diff --git a/src/main/resources/assets/resonantinduction/textures/blocks/glyph_0.png b/src/main/resources/assets/resonantinduction/textures/blocks/glyph_0.png index 6f69cd5e1..84ca11cb0 100644 Binary files a/src/main/resources/assets/resonantinduction/textures/blocks/glyph_0.png and b/src/main/resources/assets/resonantinduction/textures/blocks/glyph_0.png differ diff --git a/src/main/resources/assets/resonantinduction/textures/blocks/glyph_1.png b/src/main/resources/assets/resonantinduction/textures/blocks/glyph_1.png index b7387d6f7..9bfd32dc6 100644 Binary files a/src/main/resources/assets/resonantinduction/textures/blocks/glyph_1.png and b/src/main/resources/assets/resonantinduction/textures/blocks/glyph_1.png differ diff --git a/src/main/resources/assets/resonantinduction/textures/blocks/glyph_2.png b/src/main/resources/assets/resonantinduction/textures/blocks/glyph_2.png index 5b34119f5..cd5fac5eb 100644 Binary files a/src/main/resources/assets/resonantinduction/textures/blocks/glyph_2.png and b/src/main/resources/assets/resonantinduction/textures/blocks/glyph_2.png differ diff --git a/src/main/resources/assets/resonantinduction/textures/blocks/glyph_3.png b/src/main/resources/assets/resonantinduction/textures/blocks/glyph_3.png index 5b34119f5..146dbac6f 100644 Binary files a/src/main/resources/assets/resonantinduction/textures/blocks/glyph_3.png and b/src/main/resources/assets/resonantinduction/textures/blocks/glyph_3.png differ