Converted PartAdvanced to TraitPart

This commit is contained in:
Calclavia 2014-07-14 18:09:56 -04:00
parent 8fb8062ae6
commit 66789c4658
5 changed files with 55 additions and 88 deletions

View file

@ -7,7 +7,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import resonantinduction.core.prefab.part.PartAdvanced; import resonantinduction.core.prefab.part.TraitPart;
import universalelectricity.api.CompatibilityModule; import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.UniversalClass; import universalelectricity.api.UniversalClass;
import universalelectricity.api.energy.EnergyNetworkLoader; import universalelectricity.api.energy.EnergyNetworkLoader;
@ -18,7 +18,7 @@ import universalelectricity.api.vector.VectorHelper;
import codechicken.multipart.TMultiPart; import codechicken.multipart.TMultiPart;
@UniversalClass @UniversalClass
public abstract class PartConductor extends PartAdvanced implements IConductor public abstract class PartConductor extends TraitPart implements IConductor
{ {
private IEnergyNetwork network; private IEnergyNetwork network;

View file

@ -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<ItemStack> getDrops()
{
List<ItemStack> drops = new ArrayList<ItemStack>();
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;
}
}

View file

@ -19,7 +19,7 @@ import codechicken.lib.data.MCDataOutput;
* @author Calclavia * @author Calclavia
* *
*/ */
public abstract class PartColorableMaterial<M extends Enum> extends PartAdvanced public abstract class PartColorableMaterial<M extends Enum> extends TraitPart
{ {
public static final int DEFAULT_COLOR = 15; public static final int DEFAULT_COLOR = 15;
public int color = DEFAULT_COLOR; public int color = DEFAULT_COLOR;

View file

@ -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
}
}

View file

@ -7,7 +7,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import resonantinduction.core.prefab.part.PartAdvanced; import resonantinduction.core.prefab.part.TraitPart;
import universalelectricity.api.CompatibilityModule; import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.UniversalClass; import universalelectricity.api.UniversalClass;
import universalelectricity.api.energy.EnergyNetworkLoader; import universalelectricity.api.energy.EnergyNetworkLoader;
@ -20,7 +20,7 @@ import codechicken.multipart.TMultiPart;
@UniversalClass @UniversalClass
@Deprecated @Deprecated
public abstract class PartConductor extends PartAdvanced implements IConductor public abstract class PartConductor extends TraitPart implements IConductor
{ {
private IEnergyNetwork network; private IEnergyNetwork network;