diff --git a/archive/java/resonantinduction/electrical/wire/PartConductor.java b/archive/java/resonantinduction/electrical/wire/PartConductor.java index 678ca311d..61425417d 100644 --- a/archive/java/resonantinduction/electrical/wire/PartConductor.java +++ b/archive/java/resonantinduction/electrical/wire/PartConductor.java @@ -7,7 +7,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.MinecraftForge; -import resonantinduction.core.prefab.part.PartAdvanced; +import resonantinduction.core.prefab.part.TraitPart; import universalelectricity.api.CompatibilityModule; import universalelectricity.api.UniversalClass; import universalelectricity.api.energy.EnergyNetworkLoader; @@ -18,7 +18,7 @@ import universalelectricity.api.vector.VectorHelper; import codechicken.multipart.TMultiPart; @UniversalClass -public abstract class PartConductor extends PartAdvanced implements IConductor +public abstract class PartConductor extends TraitPart implements IConductor { private IEnergyNetwork network; diff --git a/src/main/scala/resonantinduction/core/prefab/part/PartAdvanced.java b/src/main/scala/resonantinduction/core/prefab/part/PartAdvanced.java deleted file mode 100644 index 7e2c6f803..000000000 --- a/src/main/scala/resonantinduction/core/prefab/part/PartAdvanced.java +++ /dev/null @@ -1,83 +0,0 @@ -package resonantinduction.core.prefab.part; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.world.World; -import codechicken.multipart.IRedstonePart; -import codechicken.multipart.TMultiPart; - -public abstract class PartAdvanced extends TMultiPart -{ - protected long ticks = 0; - - @Override - public void update() - { - if (ticks == 0) - { - initiate(); - } - - if (ticks >= Long.MAX_VALUE) - { - ticks = 1; - } - - ticks++; - } - - /** - * Called on the TileEntity's first tick. - */ - public void initiate() - { - } - - public World getWorld() - { - return world(); - } - - protected abstract ItemStack getItem(); - - @Override - public Iterable getDrops() - { - List drops = new ArrayList(); - drops.add(getItem()); - return drops; - } - - @Override - public ItemStack pickItem(MovingObjectPosition hit) - { - return getItem(); - } - - protected boolean checkRedstone(int side) - { - if (this.world().isBlockIndirectlyGettingPowered(x(), y(), z())) - { - return true; - } - else - { - for (TMultiPart tp : tile().jPartList()) - { - if (tp instanceof IRedstonePart) - { - IRedstonePart rp = (IRedstonePart) tp; - if ((Math.max(rp.strongPowerLevel(side), rp.weakPowerLevel(side)) << 4) > 0) - { - return true; - } - } - } - } - - return false; - } -} diff --git a/src/main/scala/resonantinduction/core/prefab/part/PartColorableMaterial.java b/src/main/scala/resonantinduction/core/prefab/part/PartColorableMaterial.java index 58de95003..8ca1a6401 100644 --- a/src/main/scala/resonantinduction/core/prefab/part/PartColorableMaterial.java +++ b/src/main/scala/resonantinduction/core/prefab/part/PartColorableMaterial.java @@ -19,7 +19,7 @@ import codechicken.lib.data.MCDataOutput; * @author Calclavia * */ -public abstract class PartColorableMaterial extends PartAdvanced +public abstract class PartColorableMaterial extends TraitPart { public static final int DEFAULT_COLOR = 15; public int color = DEFAULT_COLOR; diff --git a/src/main/scala/resonantinduction/core/prefab/part/TraitPart.scala b/src/main/scala/resonantinduction/core/prefab/part/TraitPart.scala new file mode 100644 index 000000000..94d46f1c2 --- /dev/null +++ b/src/main/scala/resonantinduction/core/prefab/part/TraitPart.scala @@ -0,0 +1,50 @@ +package resonantinduction.core.prefab.part + +import java.util.{ArrayList, List} + +import codechicken.multipart.{IRedstonePart, TMultiPart} +import net.minecraft.item.ItemStack +import net.minecraft.util.MovingObjectPosition +import resonant.content.spatial.block.TraitTicker + +import scala.collection.JavaConversions._ + +trait TraitPart extends TMultiPart with TraitTicker +{ + protected def getItem: ItemStack + + override def getDrops: Iterable[ItemStack] = + { + val drops: List[ItemStack] = new ArrayList[ItemStack] + drops.add(getItem) + return drops + } + + override def pickItem(hit: MovingObjectPosition): ItemStack = + { + return getItem + } + + protected def checkRedstone(side: Int): Boolean = + { + if (this.world.isBlockIndirectlyGettingPowered(x, y, z)) + { + return true + } + else + { + for (tp <- tile.partList) + { + if (tp.isInstanceOf[IRedstonePart]) + { + val rp: IRedstonePart = tp.asInstanceOf[IRedstonePart] + if ((Math.max(rp.strongPowerLevel(side), rp.weakPowerLevel(side)) << 4) > 0) + { + return true + } + } + } + } + return false + } +} \ No newline at end of file diff --git a/src/main/scala/resonantinduction/electrical/wire/PartConductor.java b/src/main/scala/resonantinduction/electrical/wire/PartConductor.java index b4d5d56fa..de3ff117a 100644 --- a/src/main/scala/resonantinduction/electrical/wire/PartConductor.java +++ b/src/main/scala/resonantinduction/electrical/wire/PartConductor.java @@ -7,7 +7,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.MinecraftForge; -import resonantinduction.core.prefab.part.PartAdvanced; +import resonantinduction.core.prefab.part.TraitPart; import universalelectricity.api.CompatibilityModule; import universalelectricity.api.UniversalClass; import universalelectricity.api.energy.EnergyNetworkLoader; @@ -20,7 +20,7 @@ import codechicken.multipart.TMultiPart; @UniversalClass @Deprecated -public abstract class PartConductor extends PartAdvanced implements IConductor +public abstract class PartConductor extends TraitPart implements IConductor { private IEnergyNetwork network;