2013-06-02 13:38:59 +10:00
|
|
|
package codechicken.multipart.minecraft;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
|
|
|
|
import codechicken.core.vec.BlockCoord;
|
|
|
|
|
import codechicken.core.vec.Vector3;
|
|
|
|
|
import codechicken.multipart.TileMultipartObj;
|
|
|
|
|
|
|
|
|
|
public abstract class McSidedMetaPart extends McMetaPart
|
|
|
|
|
{
|
|
|
|
|
public McSidedMetaPart()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public McSidedMetaPart(int meta)
|
|
|
|
|
{
|
|
|
|
|
super(meta);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract int sideForMeta(int meta);
|
|
|
|
|
|
|
|
|
|
public void onNeighbourChanged()
|
|
|
|
|
{
|
2013-06-06 17:25:24 +10:00
|
|
|
if(!world().isRemote)
|
2013-06-04 01:47:51 +10:00
|
|
|
dropIfCantStay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean dropIfCantStay()
|
|
|
|
|
{
|
|
|
|
|
BlockCoord pos = new BlockCoord(getTile()).offset(sideForMeta(meta));
|
2013-06-06 17:25:24 +10:00
|
|
|
if(!world().isBlockSolidOnSide(pos.x, pos.y, pos.z, ForgeDirection.getOrientation(sideForMeta(meta)^1)))
|
2013-06-02 13:38:59 +10:00
|
|
|
{
|
2013-06-04 01:47:51 +10:00
|
|
|
drop();
|
|
|
|
|
return true;
|
2013-06-02 13:38:59 +10:00
|
|
|
}
|
2013-06-04 01:47:51 +10:00
|
|
|
return false;
|
2013-06-02 13:38:59 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void drop()
|
|
|
|
|
{
|
|
|
|
|
tile().remPart(this);
|
2013-06-06 17:25:24 +10:00
|
|
|
TileMultipartObj.dropItem(new ItemStack(getBlock()), world(), Vector3.fromTileEntityCenter(getTile()));
|
2013-06-02 13:38:59 +10:00
|
|
|
}
|
|
|
|
|
}
|